Java Code Examples for android.content.ServiceConnection#onServiceDisconnected()

The following examples show how to use android.content.ServiceConnection#onServiceDisconnected() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServiceConnectionManager.java    From IPCInvoker with Apache License 2.0 6 votes vote down vote up
static void dispatchOnServiceDisconnected(String processName, ComponentName name) {
    Log.i(TAG, "dispatchOnServiceDisconnected(pn : %s)", processName);
    List<ServiceConnection> list;
    synchronized (sMap) {
        list = sMap.get(processName);
        if (list == null || list.isEmpty()) {
            return;
        }
    }
    List<ServiceConnection> tempList;
    synchronized (list) {
        tempList = new LinkedList<>(list);
    }
    for (ServiceConnection sc : tempList) {
        sc.onServiceDisconnected(name);
    }
}
 
Example 2
Source File: ScalarSensorServiceFinderTest.java    From science-journal with Apache License 2.0 6 votes vote down vote up
@Test
public void testDontGarbageCollectSecondServiceInSamePackage() {
  RecordingCallbacks callbacks = new RecordingCallbacks();
  HashMap<String, ServiceConnection> connections = new HashMap<>();

  ComponentName name1 = new ComponentName("packageName", "packageName.Class1");
  ServiceConnection connection1 =
      ScalarSensorServiceFinder.makeServiceConnection(connections, name1, callbacks, null);
  assertEquals(1, connections.size());

  ComponentName name2 = new ComponentName("packageName", "packageName.Class2");
  ServiceConnection connection2 =
      ScalarSensorServiceFinder.makeServiceConnection(connections, name2, callbacks, null);
  assertEquals(2, connections.size());

  connection1.onServiceDisconnected(name1);
  assertEquals(1, connections.size());

  connection2.onServiceDisconnected(name2);
  assertEquals(0, connections.size());
}
 
Example 3
Source File: PluginManager.java    From DroidPlugin with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void onServiceDisconnected(ComponentName componentName) {
    Log.i(TAG, "onServiceDisconnected disconnected!");
    mPluginManager = null;

    Iterator<WeakReference<ServiceConnection>> iterator = sServiceConnection.iterator();
    while (iterator.hasNext()) {
        WeakReference<ServiceConnection> wsc = iterator.next();
        ServiceConnection sc = wsc != null ? wsc.get() : null;
        if (sc != null) {
            sc.onServiceDisconnected(componentName);
        } else {
            iterator.remove();
        }
    }
    //服务连接断开,需要重新连接。
    connectToService();
}
 
Example 4
Source File: MultiConnectionKeeper.java    From android_external_GmsLib with Apache License 2.0 5 votes vote down vote up
@Override
public void onServiceDisconnected(ComponentName componentName) {
    Log.d(TAG, "Connection(" + actionString + ") : ServiceConnection : " +
            "onServiceDisconnected(" + componentName + ")");
    binder = null;
    component = componentName;
    for (ServiceConnection connection : connectionForwards) {
        connection.onServiceDisconnected(componentName);
    }
    connected = false;
    bound = false;
}
 
Example 5
Source File: MultiConnectionKeeper.java    From android_external_GmsLib with Apache License 2.0 4 votes vote down vote up
public void removeConnectionForward(ServiceConnection connection) {
    connectionForwards.remove(connection);
    if (connected) {
        connection.onServiceDisconnected(component);
    }
}