コード例 #1
0
 public ManagedServiceInfo checkServiceTokenLocked(IInterface service) {
   checkNotNull(service);
   final IBinder token = service.asBinder();
   final int N = mServices.size();
   for (int i = 0; i < N; i++) {
     final ManagedServiceInfo info = mServices.get(i);
     if (info.service.asBinder() == token) return info;
   }
   throw new SecurityException("Disallowed call from unknown " + getCaption() + ": " + service);
 }
コード例 #2
0
 /**
  * Removes a service from the list but does not unbind
  *
  * @return the removed service.
  */
 private ManagedServiceInfo removeServiceImpl(IInterface service, final int userid) {
   if (DEBUG) Slog.d(TAG, "removeServiceImpl service=" + service + " u=" + userid);
   ManagedServiceInfo serviceInfo = null;
   synchronized (mMutex) {
     final int N = mServices.size();
     for (int i = N - 1; i >= 0; i--) {
       final ManagedServiceInfo info = mServices.get(i);
       if (info.service.asBinder() == service.asBinder() && info.userid == userid) {
         if (DEBUG) Slog.d(TAG, "Removing active service " + info.component);
         serviceInfo = removeServiceLocked(i);
       }
     }
   }
   return serviceInfo;
 }
コード例 #3
0
 private ManagedServiceInfo registerServiceImpl(
     final IInterface service, final ComponentName component, final int userid) {
   synchronized (mMutex) {
     try {
       ManagedServiceInfo info =
           newServiceInfo(
               service, component, userid, true /*isSystem*/, null, Build.VERSION_CODES.LOLLIPOP);
       service.asBinder().linkToDeath(info, 0);
       mServices.add(info);
       return info;
     } catch (RemoteException e) {
       // already dead
     }
   }
   return null;
 }
コード例 #4
0
 @Override
 public Object onHook(Object who, Method method, Object... args) throws Throwable {
   HookUtils.replaceFirstAppPkg(args);
   args[IDX_RequiredPermission] = null;
   IntentFilter filter = (IntentFilter) args[IDX_IntentFilter];
   modifyIntentFilter(filter);
   if (args.length > IDX_IIntentReceiver
       && IIntentReceiver.class.isInstance(args[IDX_IIntentReceiver])) {
     final IInterface old = (IInterface) args[IDX_IIntentReceiver];
     if (!ProxyIIntentReceiver.class.isInstance(old)) {
       final IBinder token = old.asBinder();
       if (token != null) {
         token.linkToDeath(
             new IBinder.DeathRecipient() {
               @Override
               public void binderDied() {
                 token.unlinkToDeath(this, 0);
                 mProxyIIntentReceiver.remove(token);
               }
             },
             0);
         IIntentReceiver proxyIIntentReceiver = mProxyIIntentReceiver.get(token);
         if (proxyIIntentReceiver == null) {
           proxyIIntentReceiver = new ProxyIIntentReceiver(old);
           mProxyIIntentReceiver.put(token, proxyIIntentReceiver);
         }
         WeakReference mDispatcher =
             LoadedApk.ReceiverDispatcher.InnerReceiver.mDispatcher.get(old);
         LoadedApk.ReceiverDispatcher.mIIntentReceiver.set(
             mDispatcher.get(), proxyIIntentReceiver);
         args[IDX_IIntentReceiver] = proxyIIntentReceiver;
       }
     }
   }
   return method.invoke(who, args);
 }