Search in sources :

Example 1 with PackageSetting

use of com.lody.virtual.server.pm.PackageSetting in project VirtualApp by asLody.

the class BroadcastSystem method startApp.

public void startApp(VPackage p) {
    PackageSetting setting = (PackageSetting) p.mExtras;
    for (VPackage.ActivityComponent receiver : p.receivers) {
        ActivityInfo info = receiver.info;
        List<BroadcastReceiver> receivers = mReceivers.get(p.packageName);
        if (receivers == null) {
            receivers = new ArrayList<>();
            mReceivers.put(p.packageName, receivers);
        }
        String componentAction = String.format("_VA_%s_%s", info.packageName, info.name);
        IntentFilter componentFilter = new IntentFilter(componentAction);
        BroadcastReceiver r = new StaticBroadcastReceiver(setting.appId, info, componentFilter);
        mContext.registerReceiver(r, componentFilter, null, mScheduler);
        receivers.add(r);
        for (VPackage.ActivityIntentInfo ci : receiver.intents) {
            IntentFilter cloneFilter = new IntentFilter(ci.filter);
            redirectFilterActions(cloneFilter);
            r = new StaticBroadcastReceiver(setting.appId, info, cloneFilter);
            mContext.registerReceiver(r, cloneFilter, null, mScheduler);
            receivers.add(r);
        }
    }
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) IntentFilter(android.content.IntentFilter) VPackage(com.lody.virtual.server.pm.parser.VPackage) PackageSetting(com.lody.virtual.server.pm.PackageSetting) BroadcastReceiver(android.content.BroadcastReceiver)

Example 2 with PackageSetting

use of com.lody.virtual.server.pm.PackageSetting in project VirtualApp by asLody.

the class VActivityManagerService method startProcessIfNeedLocked.

ProcessRecord startProcessIfNeedLocked(String processName, int userId, String packageName) {
    if (VActivityManagerService.get().getFreeStubCount() < 3) {
        // run GC
        killAllApps();
    }
    PackageSetting ps = PackageCacheManager.getSetting(packageName);
    ApplicationInfo info = VPackageManagerService.get().getApplicationInfo(packageName, 0, userId);
    if (ps == null || info == null) {
        return null;
    }
    if (!ps.isLaunched(userId)) {
        sendFirstLaunchBroadcast(ps, userId);
        ps.setLaunched(userId, true);
        VAppManagerService.get().savePersistenceData();
    }
    int uid = VUserHandle.getUid(userId, ps.appId);
    ProcessRecord app = mProcessNames.get(processName, uid);
    if (app != null && app.client.asBinder().isBinderAlive()) {
        return app;
    }
    int vpid = queryFreeStubProcessLocked();
    if (vpid == -1) {
        return null;
    }
    app = performStartProcessLocked(uid, vpid, info, processName);
    if (app != null) {
        app.pkgList.add(info.packageName);
    }
    return app;
}
Also used : PackageSetting(com.lody.virtual.server.pm.PackageSetting) ApplicationInfo(android.content.pm.ApplicationInfo)

Aggregations

PackageSetting (com.lody.virtual.server.pm.PackageSetting)2 BroadcastReceiver (android.content.BroadcastReceiver)1 IntentFilter (android.content.IntentFilter)1 ActivityInfo (android.content.pm.ActivityInfo)1 ApplicationInfo (android.content.pm.ApplicationInfo)1 VPackage (com.lody.virtual.server.pm.parser.VPackage)1