예제 #1
0
 public void doConnected(android.content.ComponentName name, android.os.IBinder service
                         )
 {
     android.app.LoadedApk.ServiceDispatcher.ConnectionInfo old;
     android.app.LoadedApk.ServiceDispatcher.ConnectionInfo info;
     lock (this)
     {
         old = mActiveConnections.get(name);
         if (old != null && old.binder == service)
         {
             // Huh, already have this one.  Oh well!
             return;
         }
         if (service != null)
         {
             // A new service is being connected... set it all up.
             mDied             = false;
             info              = new android.app.LoadedApk.ServiceDispatcher.ConnectionInfo();
             info.binder       = service;
             info.deathMonitor = new android.app.LoadedApk.ServiceDispatcher.DeathMonitor(this
                                                                                          , name, service);
             try
             {
                 service.linkToDeath(info.deathMonitor, 0);
                 mActiveConnections.put(name, info);
             }
             catch (android.os.RemoteException)
             {
                 // This service was dead before we got it...  just
                 // don't do anything with it.
                 mActiveConnections.remove(name);
                 return;
             }
         }
         else
         {
             // The named service is being disconnected... clean up.
             mActiveConnections.remove(name);
         }
         if (old != null)
         {
             old.binder.unlinkToDeath(old.deathMonitor, 0);
         }
     }
     // If there was an old service, it is not disconnected.
     if (old != null)
     {
         mConnection.onServiceDisconnected(name);
     }
     // If there is a new service, it is now connected.
     if (service != null)
     {
         mConnection.onServiceConnected(name, service);
     }
 }
예제 #2
0
 internal void doForget()
 {
     lock (this)
     {
         java.util.Iterator <android.app.LoadedApk.ServiceDispatcher.ConnectionInfo> it = mActiveConnections
                                                                                          .values().iterator();
         while (it.hasNext())
         {
             android.app.LoadedApk.ServiceDispatcher.ConnectionInfo ci = it.next();
             ci.binder.unlinkToDeath(ci.deathMonitor, 0);
         }
         mActiveConnections.clear();
     }
 }
예제 #3
0
			public void doConnected(android.content.ComponentName name, android.os.IBinder service
				)
			{
				android.app.LoadedApk.ServiceDispatcher.ConnectionInfo old;
				android.app.LoadedApk.ServiceDispatcher.ConnectionInfo info;
				lock (this)
				{
					old = mActiveConnections.get(name);
					if (old != null && old.binder == service)
					{
						// Huh, already have this one.  Oh well!
						return;
					}
					if (service != null)
					{
						// A new service is being connected... set it all up.
						mDied = false;
						info = new android.app.LoadedApk.ServiceDispatcher.ConnectionInfo();
						info.binder = service;
						info.deathMonitor = new android.app.LoadedApk.ServiceDispatcher.DeathMonitor(this
							, name, service);
						try
						{
							service.linkToDeath(info.deathMonitor, 0);
							mActiveConnections.put(name, info);
						}
						catch (android.os.RemoteException)
						{
							// This service was dead before we got it...  just
							// don't do anything with it.
							mActiveConnections.remove(name);
							return;
						}
					}
					else
					{
						// The named service is being disconnected... clean up.
						mActiveConnections.remove(name);
					}
					if (old != null)
					{
						old.binder.unlinkToDeath(old.deathMonitor, 0);
					}
				}
				// If there was an old service, it is not disconnected.
				if (old != null)
				{
					mConnection.onServiceDisconnected(name);
				}
				// If there is a new service, it is now connected.
				if (service != null)
				{
					mConnection.onServiceConnected(name, service);
				}
			}