Search in sources :

Example 1 with IServiceConnection

use of android.app.IServiceConnection in project VirtualApp by asLody.

the class VActivityManagerService method publishService.

@Override
public void publishService(IBinder token, Intent intent, IBinder service, int userId) {
    synchronized (this) {
        ServiceRecord r = (ServiceRecord) token;
        if (r != null) {
            ServiceRecord.IntentBindRecord boundRecord = r.peekBinding(intent);
            if (boundRecord != null) {
                boundRecord.binder = service;
                for (IServiceConnection conn : boundRecord.connections) {
                    ComponentName component = ComponentUtils.toComponentName(r.serviceInfo);
                    connectService(conn, component, boundRecord);
                }
            }
        }
    }
}
Also used : IServiceConnection(android.app.IServiceConnection) ComponentName(android.content.ComponentName)

Example 2 with IServiceConnection

use of android.app.IServiceConnection in project VirtualApp by asLody.

the class BindService method call.

@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);
}
Also used : IServiceConnection(android.app.IServiceConnection) ServiceInfo(android.content.pm.ServiceInfo) IBinder(android.os.IBinder) IInterface(android.os.IInterface) Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Example 3 with IServiceConnection

use of android.app.IServiceConnection in project VirtualApp by asLody.

the class UnbindService method call.

@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);
}
Also used : IServiceConnection(android.app.IServiceConnection) ServiceConnectionDelegate(com.lody.virtual.client.hook.secondary.ServiceConnectionDelegate)

Aggregations

IServiceConnection (android.app.IServiceConnection)3 ComponentName (android.content.ComponentName)2 Intent (android.content.Intent)1 ServiceInfo (android.content.pm.ServiceInfo)1 IBinder (android.os.IBinder)1 IInterface (android.os.IInterface)1 ServiceConnectionDelegate (com.lody.virtual.client.hook.secondary.ServiceConnectionDelegate)1