@Override public int getPackageUid(String packageName, int userId) { checkUserId(userId); synchronized (mPackages) { VPackage p = mPackages.get(packageName); if (p != null) { PackageSetting ps = (PackageSetting) p.mExtras; return VUserHandle.getUid(userId, ps.appId); } return -1; } }
private void sendFirstLaunchBroadcast(PackageSetting ps, int userId) { Intent intent = new Intent(Intent.ACTION_PACKAGE_FIRST_LAUNCH, Uri.fromParts("package", ps.packageName, null)); intent.setPackage(ps.packageName); intent.putExtra(Intent.EXTRA_UID, VUserHandle.getUid(ps.appId, userId)); intent.putExtra("android.intent.extra.user_handle", userId); sendBroadcastAsUser(intent, null); }
@Override public String[] getPackagesForUid(int uid) { int userId = VUserHandle.getUserId(uid); checkUserId(userId); synchronized (this) { List<String> pkgList = new ArrayList<>(2); for (VPackage p : mPackages.values()) { PackageSetting settings = (PackageSetting) p.mExtras; if (VUserHandle.getUid(userId, settings.appId) == uid) { pkgList.add(p.packageName); } } return pkgList.toArray(new String[pkgList.size()]); } }
boolean handleStaticBroadcast(int appId, ActivityInfo info, Intent intent, PendingResultData result) { Intent realIntent = intent.getParcelableExtra("_VA_|_intent_"); ComponentName component = intent.getParcelableExtra("_VA_|_component_"); int userId = intent.getIntExtra("_VA_|_user_id_", VUserHandle.USER_NULL); if (realIntent == null) { return false; } if (userId < 0) { VLog.w(TAG, "Sent a broadcast without userId " + realIntent); return false; } int vuid = VUserHandle.getUid(userId, appId); return handleUserBroadcast(vuid, info, component, realIntent, result); }
@Override public void processRestarted(String packageName, String processName, int userId) { int callingPid = getCallingPid(); int appId = VAppManagerService.get().getAppId(packageName); int uid = VUserHandle.getUid(userId, appId); synchronized (this) { ProcessRecord app = findProcessLocked(callingPid); if (app == null) { ApplicationInfo appInfo = VPackageManagerService.get().getApplicationInfo(packageName, 0, userId); appInfo.flags |= ApplicationInfo.FLAG_HAS_CODE; String stubProcessName = getProcessName(callingPid); int vpid = parseVPid(stubProcessName); if (vpid != -1) { performStartProcessLocked(uid, vpid, appInfo, processName); } } } }
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().pingBinder()) { 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; }
@Override public int getPackageUid(String packageName, int userId) { checkUserId(userId); synchronized (mPackages) { VPackage p = mPackages.get(packageName); if (p != null) { PackageSetting ps = (PackageSetting) p.mExtras; return VUserHandle.getUid(userId, ps.appId); } return -1; } }
@Override public int getPackageUid(String packageName, int userId) { checkUserId(userId); synchronized (mPackages) { VPackage p = mPackages.get(packageName); if (p != null) { PackageSetting ps = (PackageSetting) p.mExtras; return VUserHandle.getUid(userId, ps.appId); } return -1; } }
private void sendFirstLaunchBroadcast(PackageSetting ps, int userId) { Intent intent = new Intent(Intent.ACTION_PACKAGE_FIRST_LAUNCH, Uri.fromParts("package", ps.packageName, null)); intent.setPackage(ps.packageName); intent.putExtra(Intent.EXTRA_UID, VUserHandle.getUid(ps.appId, userId)); intent.putExtra("android.intent.extra.user_handle", userId); sendBroadcastAsUser(intent, null); }
private void sendFirstLaunchBroadcast(PackageSetting ps, int userId) { Intent intent = new Intent(Intent.ACTION_PACKAGE_FIRST_LAUNCH, Uri.fromParts("package", ps.packageName, null)); intent.setPackage(ps.packageName); intent.putExtra(Intent.EXTRA_UID, VUserHandle.getUid(ps.appId, userId)); intent.putExtra("android.intent.extra.user_handle", userId); sendBroadcastAsUser(intent, null); }
@Override public String[] getPackagesForUid(int uid) { int userId = VUserHandle.getUserId(uid); checkUserId(userId); synchronized (this) { List<String> pkgList = new ArrayList<>(2); for (VPackage p : mPackages.values()) { PackageSetting settings = (PackageSetting) p.mExtras; if (VUserHandle.getUid(userId, settings.appId) == uid) { pkgList.add(p.packageName); } } return pkgList.toArray(new String[pkgList.size()]); } }
@Override public String[] getPackagesForUid(int uid) { int userId = VUserHandle.getUserId(uid); checkUserId(userId); synchronized (this) { List<String> pkgList = new ArrayList<>(2); for (VPackage p : mPackages.values()) { PackageSetting settings = (PackageSetting) p.mExtras; if (VUserHandle.getUid(userId, settings.appId) == uid) { pkgList.add(p.packageName); } } return pkgList.toArray(new String[pkgList.size()]); } }
boolean handleStaticBroadcast(int appId, ActivityInfo info, Intent intent, PendingResultData result) { Intent realIntent = intent.getParcelableExtra("_VA_|_intent_"); ComponentName component = intent.getParcelableExtra("_VA_|_component_"); int userId = intent.getIntExtra("_VA_|_user_id_", VUserHandle.USER_NULL); if (realIntent == null) { return false; } if (userId < 0) { VLog.w(TAG, "Sent a broadcast without userId " + realIntent); return false; } int vuid = VUserHandle.getUid(userId, appId); return handleUserBroadcast(vuid, info, component, realIntent, result); }
boolean handleStaticBroadcast(int appId, ActivityInfo info, Intent intent, PendingResultData result) { Intent realIntent = intent.getParcelableExtra("_VA_|_intent_"); ComponentName component = intent.getParcelableExtra("_VA_|_component_"); int userId = intent.getIntExtra("_VA_|_user_id_", VUserHandle.USER_NULL); if (realIntent == null) { return false; } if (userId < 0) { VLog.w(TAG, "Sent a broadcast without userId " + realIntent); return false; } int vuid = VUserHandle.getUid(userId, appId); return handleUserBroadcast(vuid, info, component, realIntent, result); }
@Override public void processRestarted(String packageName, String processName, int userId) { int callingPid = getCallingPid(); int appId = VAppManagerService.get().getAppId(packageName); int uid = VUserHandle.getUid(userId, appId); synchronized (this) { ProcessRecord app = findProcessLocked(callingPid); if (app == null) { ApplicationInfo appInfo = VPackageManagerService.get().getApplicationInfo(packageName, 0, userId); appInfo.flags |= ApplicationInfo.FLAG_HAS_CODE; String stubProcessName = getProcessName(callingPid); int vpid = parseVPid(stubProcessName); if (vpid != -1) { performStartProcessLocked(uid, vpid, appInfo, processName); } } } }
@Override public void processRestarted(String packageName, String processName, int userId) { int callingPid = getCallingPid(); int appId = VAppManagerService.get().getAppId(packageName); int uid = VUserHandle.getUid(userId, appId); synchronized (this) { ProcessRecord app = findProcessLocked(callingPid); if (app == null) { ApplicationInfo appInfo = VPackageManagerService.get().getApplicationInfo(packageName, 0, userId); appInfo.flags |= ApplicationInfo.FLAG_HAS_CODE; String stubProcessName = getProcessName(callingPid); int vpid = parseVPid(stubProcessName); if (vpid != -1) { performStartProcessLocked(uid, vpid, appInfo, processName); } } } }
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().pingBinder()) { 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; }
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; }