Search in sources :

Example 6 with IInterface

use of android.os.IInterface in project VirtualApp by asLody.

the class GetContentProvider method call.

@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
    int nameIdx = getProviderNameIndex();
    String name = (String) args[nameIdx];
    int userId = VUserHandle.myUserId();
    ProviderInfo info = VPackageManager.get().resolveContentProvider(name, 0, userId);
    if (info != null && info.enabled && isAppPkg(info.packageName)) {
        int targetVPid = VActivityManager.get().initProcess(info.packageName, info.processName, userId);
        if (targetVPid == -1) {
            return null;
        }
        args[nameIdx] = StubManifest.getStubAuthority(targetVPid);
        Object holder = method.invoke(who, args);
        if (holder == null) {
            return null;
        }
        IInterface provider = IActivityManager.ContentProviderHolder.provider.get(holder);
        if (provider != null) {
            provider = VActivityManager.get().acquireProviderClient(userId, info);
        }
        IActivityManager.ContentProviderHolder.provider.set(holder, provider);
        IActivityManager.ContentProviderHolder.info.set(holder, info);
        return holder;
    }
    Object holder = method.invoke(who, args);
    if (holder != null) {
        IInterface provider = IActivityManager.ContentProviderHolder.provider.get(holder);
        info = IActivityManager.ContentProviderHolder.info.get(holder);
        if (provider != null) {
            provider = ProviderHook.createProxy(true, info.authority, provider);
        }
        IActivityManager.ContentProviderHolder.provider.set(holder, provider);
        return holder;
    }
    return null;
}
Also used : ProviderInfo(android.content.pm.ProviderInfo) IInterface(android.os.IInterface)

Example 7 with IInterface

use of android.os.IInterface in project VirtualApp by asLody.

the class GetIntentSender method call.

@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
    String creator = (String) args[1];
    String[] resolvedTypes = (String[]) args[6];
    int type = (int) args[0];
    int flags = (int) args[7];
    if ((PendingIntent.FLAG_UPDATE_CURRENT & flags) != 0) {
        flags = (flags & ~(PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_NO_CREATE)) | PendingIntent.FLAG_CANCEL_CURRENT;
    }
    if (args[5] instanceof Intent[]) {
        Intent[] intents = (Intent[]) args[5];
        if (intents.length > 0) {
            Intent intent = intents[intents.length - 1];
            if (resolvedTypes != null && resolvedTypes.length > 0) {
                intent.setDataAndType(intent.getData(), resolvedTypes[resolvedTypes.length - 1]);
            }
            Intent targetIntent = redirectIntentSender(type, creator, intent);
            if (targetIntent != null) {
                args[5] = new Intent[] { targetIntent };
            }
        }
    }
    args[7] = flags;
    args[1] = getHostPkg();
    IInterface sender = (IInterface) method.invoke(who, args);
    if (sender != null && creator != null) {
        VActivityManager.get().addPendingIntent(sender.asBinder(), creator);
    }
    return sender;
}
Also used : IInterface(android.os.IInterface) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Example 8 with IInterface

use of android.os.IInterface in project VirtualApp by asLody.

the class VClientImpl method acquireProviderClient.

@Override
public IBinder acquireProviderClient(ProviderInfo info) {
    if (mTempLock != null) {
        mTempLock.block();
    }
    if (!VClientImpl.get().isBound()) {
        VClientImpl.get().bindApplication(info.packageName, info.processName);
    }
    IInterface provider = null;
    String[] authorities = info.authority.split(";");
    String authority = authorities.length == 0 ? info.authority : authorities[0];
    ContentResolver resolver = VirtualCore.get().getContext().getContentResolver();
    ContentProviderClient client = null;
    try {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            client = resolver.acquireUnstableContentProviderClient(authority);
        } else {
            client = resolver.acquireContentProviderClient(authority);
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
    if (client != null) {
        provider = mirror.android.content.ContentProviderClient.mContentProvider.get(client);
        client.release();
    }
    return provider != null ? provider.asBinder() : null;
}
Also used : IInterface(android.os.IInterface) ContentProviderClient(android.content.ContentProviderClient) ContentResolver(android.content.ContentResolver)

Example 9 with IInterface

use of android.os.IInterface in project VirtualApp by asLody.

the class VClientImpl method fixInstalledProviders.

private void fixInstalledProviders() {
    clearSettingProvider();
    Map clientMap = ActivityThread.mProviderMap.get(VirtualCore.mainThread());
    boolean highApi = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
    for (Object clientRecord : clientMap.values()) {
        if (highApi) {
            IInterface provider = ActivityThread.ProviderClientRecordJB.mProvider.get(clientRecord);
            Object holder = ActivityThread.ProviderClientRecordJB.mHolder.get(clientRecord);
            ProviderInfo info = IActivityManager.ContentProviderHolder.info.get(holder);
            if (holder != null && !info.authority.startsWith(StubManifest.STUB_CP_AUTHORITY)) {
                provider = ProviderHook.createProxy(true, info.authority, provider);
                ActivityThread.ProviderClientRecordJB.mProvider.set(clientRecord, provider);
                IActivityManager.ContentProviderHolder.provider.set(holder, provider);
            }
        } else {
            String authority = ActivityThread.ProviderClientRecord.mName.get(clientRecord);
            IInterface provider = ActivityThread.ProviderClientRecord.mProvider.get(clientRecord);
            if (provider != null && !authority.startsWith(StubManifest.STUB_CP_AUTHORITY)) {
                provider = ProviderHook.createProxy(true, authority, provider);
                ActivityThread.ProviderClientRecord.mProvider.set(clientRecord, provider);
            }
        }
    }
}
Also used : ProviderInfo(android.content.pm.ProviderInfo) IInterface(android.os.IInterface) Map(java.util.Map)

Example 10 with IInterface

use of android.os.IInterface in project VirtualApp by asLody.

the class VActivityManagerService method startServiceCommon.

private ComponentName startServiceCommon(Intent service, boolean scheduleServiceArgs, int userId) {
    ServiceInfo serviceInfo = resolveServiceInfo(service, userId);
    if (serviceInfo == null) {
        return null;
    }
    ProcessRecord targetApp = startProcessIfNeedLocked(ComponentUtils.getProcessName(serviceInfo), userId, serviceInfo.packageName);
    if (targetApp == null) {
        VLog.e(TAG, "Unable to start new Process for : " + ComponentUtils.toComponentName(serviceInfo));
        return null;
    }
    IInterface appThread = targetApp.appThread;
    ServiceRecord r = findRecordLocked(userId, serviceInfo);
    if (r == null) {
        r = new ServiceRecord();
        r.startId = 0;
        r.activeSince = SystemClock.elapsedRealtime();
        r.process = targetApp;
        r.serviceInfo = serviceInfo;
        try {
            IApplicationThreadCompat.scheduleCreateService(appThread, r, r.serviceInfo, 0);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
        addRecord(r);
    }
    r.lastActivityTime = SystemClock.uptimeMillis();
    if (scheduleServiceArgs) {
        r.startId++;
        boolean taskRemoved = serviceInfo.applicationInfo != null && serviceInfo.applicationInfo.targetSdkVersion < Build.VERSION_CODES.ECLAIR;
        try {
            IApplicationThreadCompat.scheduleServiceArgs(appThread, r, taskRemoved, r.startId, 0, service);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
    return ComponentUtils.toComponentName(serviceInfo);
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) IInterface(android.os.IInterface) RemoteException(android.os.RemoteException)

Aggregations

IInterface (android.os.IInterface)28 RemoteException (android.os.RemoteException)16 ComponentName (android.content.ComponentName)15 Intent (android.content.Intent)14 IBinder (android.os.IBinder)12 PendingIntent (android.app.PendingIntent)11 ServiceConnection (android.content.ServiceConnection)9 UserHandle (android.os.UserHandle)9 ApplicationInfo (android.content.pm.ApplicationInfo)5 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)5 IVrListener (android.service.vr.IVrListener)4 PendingEvent (com.android.server.utils.ManagedApplicationService.PendingEvent)4 ServiceInfo (android.content.pm.ServiceInfo)3 ProviderInfo (android.content.pm.ProviderInfo)2 InvocationHandler (java.lang.reflect.InvocationHandler)2 IServiceConnection (android.app.IServiceConnection)1 ContentProviderClient (android.content.ContentProviderClient)1 ContentResolver (android.content.ContentResolver)1 IIntentReceiver (android.content.IIntentReceiver)1 IntentFilter (android.content.IntentFilter)1