public static ServiceConnectionDelegate getDelegate(IServiceConnection conn) { if(conn instanceof ServiceConnectionDelegate){ return (ServiceConnectionDelegate)conn; } IBinder binder = conn.asBinder(); ServiceConnectionDelegate delegate = DELEGATE_MAP.get(binder); if (delegate == null) { delegate = new ServiceConnectionDelegate(conn); DELEGATE_MAP.put(binder, delegate); } return delegate; }
@Override public void connected(ComponentName name, IBinder service) throws RemoteException { connected(name, service, false); }
public int bindService(Context context, Intent service, ServiceConnection connection, int flags) { try { IServiceConnection conn = ServiceConnectionDelegate.getDelegate(context, connection, flags); return getService().bindService(null, null, service, null, conn, flags, 0); } catch (RemoteException e) { return VirtualRuntime.crash(e); } }
@Override public Object call(Object who, Method method, Object... args) throws Throwable { IServiceConnection conn = (IServiceConnection) args[0]; ServiceConnectionDelegate delegate = ServiceConnectionDelegate.removeDelegate(conn); if (delegate == null) { return method.invoke(who, args); } return VActivityManager.get().unbindService(delegate); }
public static IServiceConnection removeDelegate(Context context, ServiceConnection conn) { IServiceConnection connection = null; try{ Object loadApk = ContextImpl.mPackageInfo.get(VirtualCore.get().getContext()); connection = LoadedApk.forgetServiceDispatcher.call(loadApk, context, conn); }catch (Exception e){ Log.e("ConnectionDelegate", "forgetServiceDispatcher", e); } if(connection == null){ return null; } return ServiceConnectionDelegate.removeDelegate(connection); }
public static IServiceConnection getDelegate(Context context, ServiceConnection connection,int flags) { IServiceConnection sd = null; if (connection == null) { throw new IllegalArgumentException("connection is null"); } try { Object activityThread = ActivityThread.currentActivityThread.call(); Object loadApk = ContextImpl.mPackageInfo.get(VirtualCore.get().getContext()); Handler handler = ActivityThread.getHandler.call(activityThread); sd = LoadedApk.getServiceDispatcher.call(loadApk, connection, context, handler, flags); } catch (Exception e) { Log.e("ConnectionDelegate", "getServiceDispatcher", e); } if (sd == null) { throw new RuntimeException("Not supported in system context"); } return getDelegate(sd); }
public boolean unbindService(Context context, ServiceConnection connection) { try { IServiceConnection conn = ServiceConnectionDelegate.removeDelegate(context, connection); return getService().unbindService(conn, VUserHandle.myUserId()); } catch (RemoteException e) { return VirtualRuntime.crash(e); } }
public static ServiceConnectionDelegate getDelegate(IServiceConnection conn) { if(conn instanceof ServiceConnectionDelegate){ return (ServiceConnectionDelegate)conn; } IBinder binder = conn.asBinder(); ServiceConnectionDelegate delegate = DELEGATE_MAP.get(binder); if (delegate == null) { delegate = new ServiceConnectionDelegate(conn); DELEGATE_MAP.put(binder, delegate); } return delegate; }
@Override public void connected(ComponentName name, IBinder service) throws RemoteException { connected(name, service, false); }
@Override public Object call(Object who, Method method, Object... args) throws Throwable { IInterface caller = (IInterface) args[0]; IBinder token = (IBinder) args[1]; Intent service = (Intent) args[2]; String resolvedType = (String) args[3]; IServiceConnection conn = (IServiceConnection) args[4]; int flags = (int) args[5]; int userId = VUserHandle.myUserId(); if (isServerProcess()) { userId = service.getIntExtra("_VA_|_user_id_", VUserHandle.USER_NULL); } if (userId == VUserHandle.USER_NULL) { return method.invoke(who, args); } ServiceInfo serviceInfo = VirtualCore.get().resolveServiceInfo(service, userId); if (serviceInfo != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { service.setComponent(new ComponentName(serviceInfo.packageName, serviceInfo.name)); } conn = ServiceConnectionDelegate.getDelegate(conn); return VActivityManager.get().bindService(caller.asBinder(), token, service, resolvedType, conn, flags, userId); } return method.invoke(who, args); }
@Override public Object call(Object who, Method method, Object... args) throws Throwable { IServiceConnection conn = (IServiceConnection) args[0]; ServiceConnectionDelegate delegate = ServiceConnectionDelegate.removeDelegate(conn); if (delegate == null) { return method.invoke(who, args); } return VActivityManager.get().unbindService(delegate); }
public static ServiceConnectionDelegate getDelegate(IServiceConnection conn) { if(conn instanceof ServiceConnectionDelegate){ return (ServiceConnectionDelegate)conn; } IBinder binder = conn.asBinder(); ServiceConnectionDelegate delegate = DELEGATE_MAP.get(binder); if (delegate == null) { delegate = new ServiceConnectionDelegate(conn); DELEGATE_MAP.put(binder, delegate); } return delegate; }
@Override public void connected(ComponentName name, IBinder service) throws RemoteException { connected(name, service, false); }
public int bindService(Context context, Intent service, ServiceConnection connection, int flags) { try { IServiceConnection conn = ServiceConnectionDelegate.getDelegate(context, connection, flags); return getService().bindService(null, null, service, null, conn, flags, 0); } catch (RemoteException e) { return VirtualRuntime.crash(e); } }
@Override public Object call(Object who, Method method, Object... args) throws Throwable { IServiceConnection conn = (IServiceConnection) args[0]; ServiceConnectionDelegate delegate = ServiceConnectionDelegate.removeDelegate(conn); if (delegate == null) { return method.invoke(who, args); } return VActivityManager.get().unbindService(delegate); }
public int bindService(Context context, Intent service, ServiceConnection connection, int flags) { try { IServiceConnection conn = ServiceConnectionDelegate.getDelegate(context, connection, flags); return getService().bindService(null, null, service, null, conn, flags, 0); } catch (RemoteException e) { return VirtualRuntime.crash(e); } }
public static IServiceConnection removeDelegate(Context context, ServiceConnection conn) { IServiceConnection connection = null; try{ Object loadApk = ContextImpl.mPackageInfo.get(VirtualCore.get().getContext()); connection = LoadedApk.forgetServiceDispatcher.call(loadApk, context, conn); }catch (Exception e){ Log.e("ConnectionDelegate", "forgetServiceDispatcher", e); } if(connection == null){ return null; } return ServiceConnectionDelegate.removeDelegate(connection); }
public static IServiceConnection getDelegate(Context context, ServiceConnection connection,int flags) { IServiceConnection sd = null; if (connection == null) { throw new IllegalArgumentException("connection is null"); } try { Object activityThread = ActivityThread.currentActivityThread.call(); Object loadApk = ContextImpl.mPackageInfo.get(VirtualCore.get().getContext()); Handler handler = ActivityThread.getHandler.call(activityThread); sd = LoadedApk.getServiceDispatcher.call(loadApk, connection, context, handler, flags); } catch (Exception e) { Log.e("ConnectionDelegate", "getServiceDispatcher", e); } if (sd == null) { throw new RuntimeException("Not supported in system context"); } return getDelegate(sd); }
public static IServiceConnection removeDelegate(Context context, ServiceConnection conn) { IServiceConnection connection = null; try{ Object loadApk = ContextImpl.mPackageInfo.get(VirtualCore.get().getContext()); connection = LoadedApk.forgetServiceDispatcher.call(loadApk, context, conn); }catch (Exception e){ Log.e("ConnectionDelegate", "forgetServiceDispatcher", e); } if(connection == null){ return null; } return ServiceConnectionDelegate.removeDelegate(connection); }
public static IServiceConnection getDelegate(Context context, ServiceConnection connection,int flags) { IServiceConnection sd = null; if (connection == null) { throw new IllegalArgumentException("connection is null"); } try { Object activityThread = ActivityThread.currentActivityThread.call(); Object loadApk = ContextImpl.mPackageInfo.get(VirtualCore.get().getContext()); Handler handler = ActivityThread.getHandler.call(activityThread); sd = LoadedApk.getServiceDispatcher.call(loadApk, connection, context, handler, flags); } catch (Exception e) { Log.e("ConnectionDelegate", "getServiceDispatcher", e); } if (sd == null) { throw new RuntimeException("Not supported in system context"); } return getDelegate(sd); }