@Test public void testGetRegisteredTransportNames() throws Exception { setUpPackage(PACKAGE_A, ApplicationInfo.PRIVATE_FLAG_PRIVILEGED); setUpPackage(PACKAGE_B, ApplicationInfo.PRIVATE_FLAG_PRIVILEGED); TransportData[] transportsData = {mTransportA1, mTransportA2, mTransportB1}; setUpTransports(transportsData); TransportManager transportManager = createTransportManager(mTransportA1, mTransportA2, mTransportB1); transportManager.registerTransports(); String[] transportNames = transportManager.getRegisteredTransportNames(); assertThat(transportNames) .asList() .containsExactlyElementsIn( Stream.of(transportsData) .map(transportData -> transportData.transportName) .collect(toList())); }
String[] getRegisteredTransportNames() { synchronized (mTransportLock) { String[] transportNames = new String[mRegisteredTransportsDescriptionMap.size()]; int i = 0; for (TransportDescription description : mRegisteredTransportsDescriptionMap.values()) { transportNames[i] = description.name; i++; } return transportNames; } }
TransportManager { String[] getRegisteredTransportNames() { synchronized (mTransportLock) { String[] transportNames = new String[mRegisteredTransportsDescriptionMap.size()]; int i = 0; for (TransportDescription description : mRegisteredTransportsDescriptionMap.values()) { transportNames[i] = description.name; i++; } return transportNames; } } }
TransportManager { String[] getRegisteredTransportNames() { synchronized (mTransportLock) { String[] transportNames = new String[mRegisteredTransportsDescriptionMap.size()]; int i = 0; for (TransportDescription description : mRegisteredTransportsDescriptionMap.values()) { transportNames[i] = description.name; i++; } return transportNames; } } TransportManager(Context context, Set<ComponentName> whitelist, String selectedTransport); @VisibleForTesting  TransportManager(
            Context context,
            Set<ComponentName> whitelist,
            String selectedTransport,
            TransportClientManager transportClientManager); }
TransportManager { String[] getRegisteredTransportNames() { synchronized (mTransportLock) { String[] transportNames = new String[mRegisteredTransportsDescriptionMap.size()]; int i = 0; for (TransportDescription description : mRegisteredTransportsDescriptionMap.values()) { transportNames[i] = description.name; i++; } return transportNames; } } TransportManager(Context context, Set<ComponentName> whitelist, String selectedTransport); @VisibleForTesting  TransportManager(
            Context context,
            Set<ComponentName> whitelist,
            String selectedTransport,
            TransportClientManager transportClientManager); void setOnTransportRegisteredListener(OnTransportRegisteredListener listener); String getTransportName(ComponentName transportComponent); String getTransportDirName(ComponentName transportComponent); String getTransportDirName(String transportName); @Nullable Intent getTransportConfigurationIntent(String transportName); String getTransportCurrentDestinationString(String transportName); @Nullable Intent getTransportDataManagementIntent(String transportName); @Nullable String getTransportDataManagementLabel(String transportName); boolean isTransportRegistered(String transportName); void forEachRegisteredTransport(Consumer<String> transportConsumer); void updateTransportAttributes(
            ComponentName transportComponent,
            String name,
            @Nullable Intent configurationIntent,
            String currentDestinationString,
            @Nullable Intent dataManagementIntent,
            @Nullable String dataManagementLabel); @Nullable TransportClient getTransportClient(String transportName, String caller); TransportClient getTransportClientOrThrow(String transportName, String caller); @Nullable TransportClient getCurrentTransportClient(String caller); TransportClient getCurrentTransportClientOrThrow(String caller); void disposeOfTransportClient(TransportClient transportClient, String caller); @WorkerThread int registerAndSelectTransport(ComponentName transportComponent); @WorkerThread void registerTransports(); void dumpTransportClients(PrintWriter pw); void dumpTransportStats(PrintWriter pw); }
TransportManager { String[] getRegisteredTransportNames() { synchronized (mTransportLock) { String[] transportNames = new String[mRegisteredTransportsDescriptionMap.size()]; int i = 0; for (TransportDescription description : mRegisteredTransportsDescriptionMap.values()) { transportNames[i] = description.name; i++; } return transportNames; } } TransportManager(Context context, Set<ComponentName> whitelist, String selectedTransport); @VisibleForTesting  TransportManager(
            Context context,
            Set<ComponentName> whitelist,
            String selectedTransport,
            TransportClientManager transportClientManager); void setOnTransportRegisteredListener(OnTransportRegisteredListener listener); String getTransportName(ComponentName transportComponent); String getTransportDirName(ComponentName transportComponent); String getTransportDirName(String transportName); @Nullable Intent getTransportConfigurationIntent(String transportName); String getTransportCurrentDestinationString(String transportName); @Nullable Intent getTransportDataManagementIntent(String transportName); @Nullable String getTransportDataManagementLabel(String transportName); boolean isTransportRegistered(String transportName); void forEachRegisteredTransport(Consumer<String> transportConsumer); void updateTransportAttributes(
            ComponentName transportComponent,
            String name,
            @Nullable Intent configurationIntent,
            String currentDestinationString,
            @Nullable Intent dataManagementIntent,
            @Nullable String dataManagementLabel); @Nullable TransportClient getTransportClient(String transportName, String caller); TransportClient getTransportClientOrThrow(String transportName, String caller); @Nullable TransportClient getCurrentTransportClient(String caller); TransportClient getCurrentTransportClientOrThrow(String caller); void disposeOfTransportClient(TransportClient transportClient, String caller); @WorkerThread int registerAndSelectTransport(ComponentName transportComponent); @WorkerThread void registerTransports(); void dumpTransportClients(PrintWriter pw); void dumpTransportStats(PrintWriter pw); @VisibleForTesting
    static final String SERVICE_ACTION_TRANSPORT_HOST; }