private void sendInstalledBroadcast(String packageName) { Intent intent = new Intent(Intent.ACTION_PACKAGE_ADDED); intent.setData(Uri.parse("package:" + packageName)); VActivityManagerService.get().sendBroadcastAsUser(intent, VUserHandle.ALL); }
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; }
private void sendUninstalledBroadcast(String packageName) { Intent intent = new Intent(Intent.ACTION_PACKAGE_REMOVED); intent.setData(Uri.parse("package:" + packageName)); VActivityManagerService.get().sendBroadcastAsUser(intent, VUserHandle.ALL); }
private void sendUserInfoChangedBroadcast(int userId) { Intent changedIntent = new Intent(Constants.ACTION_USER_INFO_CHANGED); changedIntent.putExtra(Constants.EXTRA_USER_HANDLE, userId); changedIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); VActivityManagerService.get().sendBroadcastAsUser(changedIntent, new VUserHandle(userId)); }
private void broadcastCheckInNowIfNeed(int userId) { long time = System.currentTimeMillis(); if (Math.abs(time - lastAccountChangeTime) > CHECK_IN_TIME) { lastAccountChangeTime = time; saveAllAccounts(); Intent intent = new Intent("android.server.checkin.CHECKIN_NOW"); VActivityManagerService.get().sendBroadcastAsUser(intent, new VUserHandle(userId)); } }
public boolean performOptimize(String packageName, int userId) { VActivityManagerService.get().sendBroadcastAsUser( specifyApp(new Intent(Intent.ACTION_BOOT_COMPLETED), packageName, userId) , new VUserHandle(userId)); return true; }
private void sendAccountsChangedBroadcast(int userId) { Intent intent = new Intent(AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION); VActivityManagerService.get().sendBroadcastAsUser(intent, new VUserHandle(userId)); broadcastCheckInNowIfNeed(userId); }
Intent addedIntent = new Intent(Constants.ACTION_USER_REMOVED); addedIntent.putExtra(Constants.EXTRA_USER_HANDLE, userHandle); VActivityManagerService.get().sendOrderedBroadcastAsUser(addedIntent, VUserHandle.ALL, null, new BroadcastReceiver() {
int res = VActivityManagerService.get().stopUser(userHandle, new IStopUserCallback.Stub() { @Override
VActivityManagerService.get().sendBroadcastAsUser(addedIntent, VUserHandle.ALL, null); } finally {
private void uninstallPackageFully(PackageSetting ps) { String packageName = ps.packageName; try { BroadcastSystem.get().stopApp(packageName); VActivityManagerService.get().killAppByPkg(packageName, VUserHandle.USER_ALL); VEnvironment.getPackageResourcePath(packageName).delete(); FileUtils.deleteDir(VEnvironment.getDataAppPackageDirectory(packageName)); VEnvironment.getOdexFile(packageName).delete(); for (int id : VUserManagerService.get().getUserIds()) { FileUtils.deleteDir(VEnvironment.getDataUserPackageDirectory(id, packageName)); FileUtils.deleteDir(VEnvironment.getVirtualPrivateStorageDir(id, packageName)); } PackageCacheManager.remove(packageName); } catch (Exception e) { e.printStackTrace(); } finally { notifyAppUninstalled(ps, -1); } }
FileUtils.deleteDir(libDir); VEnvironment.getOdexFile(pkg.packageName).delete(); VActivityManagerService.get().killAppByPkg(pkg.packageName, VUserHandle.USER_ALL);
@Override public boolean clearPackage(String packageName) throws RemoteException { try { BroadcastSystem.get().stopApp(packageName); VActivityManagerService.get().killAppByPkg(packageName, VUserHandle.USER_ALL); for (int id : VUserManagerService.get().getUserIds()) { FileUtils.deleteDir(VEnvironment.getDataUserPackageDirectory(id, packageName)); FileUtils.deleteDir(VEnvironment.getVirtualPrivateStorageDir(id, packageName)); } return true; } catch (Exception e) { return false; } }
@Override public boolean clearPackageAsUser(int userId, String packageName) throws RemoteException { if (!VUserManagerService.get().exists(userId)) { return false; } PackageSetting ps = PackageCacheManager.getSetting(packageName); if (ps != null) { int[] userIds = getPackageInstalledUsers(packageName); if (!ArrayUtils.contains(userIds, userId)) { return false; } if (userIds.length == 1) { clearPackage(packageName); } else { // Just hidden it VActivityManagerService.get().killAppByPkg(packageName, userId); ps.setInstalled(userId, false); mPersistenceLayer.save(); FileUtils.deleteDir(VEnvironment.getDataUserPackageDirectory(userId, packageName)); FileUtils.deleteDir(VEnvironment.getVirtualPrivateStorageDir(userId, packageName)); } return true; } return false; }
@Override public synchronized boolean uninstallPackageAsUser(String packageName, int userId) { if (!VUserManagerService.get().exists(userId)) { return false; } PackageSetting ps = PackageCacheManager.getSetting(packageName); if (ps != null) { int[] userIds = getPackageInstalledUsers(packageName); if (!ArrayUtils.contains(userIds, userId)) { return false; } if (userIds.length == 1) { uninstallPackageFully(ps); } else { // Just hidden it VActivityManagerService.get().killAppByPkg(packageName, userId); ps.setInstalled(userId, false); notifyAppUninstalled(ps, userId); mPersistenceLayer.save(); FileUtils.deleteDir(VEnvironment.getDataUserPackageDirectory(userId, packageName)); FileUtils.deleteDir(VEnvironment.getVirtualPrivateStorageDir(userId, packageName)); } return true; } return false; }
@Override public boolean onCreate() { Context context = getContext(); DaemonService.startup(context); if (!VirtualCore.get().isStartup()) { return true; } VPackageManagerService.systemReady(); addService(ServiceManagerNative.PACKAGE, VPackageManagerService.get()); VActivityManagerService.systemReady(context); addService(ServiceManagerNative.ACTIVITY, VActivityManagerService.get()); addService(ServiceManagerNative.USER, VUserManagerService.get()); VAppManagerService.systemReady(); addService(ServiceManagerNative.APP, VAppManagerService.get()); BroadcastSystem.attach(VActivityManagerService.get(), VAppManagerService.get()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { addService(ServiceManagerNative.JOB, VJobSchedulerService.get()); } VNotificationManagerService.systemReady(context); addService(ServiceManagerNative.NOTIFICATION, VNotificationManagerService.get()); VAppManagerService.get().scanApps(); VAccountManagerService.systemReady(); addService(ServiceManagerNative.ACCOUNT, VAccountManagerService.get()); addService(ServiceManagerNative.VS, VirtualStorageService.get()); addService(ServiceManagerNative.DEVICE, VDeviceManagerService.get()); addService(ServiceManagerNative.VIRTUAL_LOC, VirtualLocationService.get()); return true; }
private void sendInstalledBroadcast(String packageName) { Intent intent = new Intent(Intent.ACTION_PACKAGE_ADDED); intent.setData(Uri.parse("package:" + packageName)); VActivityManagerService.get().sendBroadcastAsUser(intent, VUserHandle.ALL); }
private void sendUninstalledBroadcast(String packageName) { Intent intent = new Intent(Intent.ACTION_PACKAGE_REMOVED); intent.setData(Uri.parse("package:" + packageName)); VActivityManagerService.get().sendBroadcastAsUser(intent, VUserHandle.ALL); }
private void sendUserInfoChangedBroadcast(int userId) { Intent changedIntent = new Intent(Constants.ACTION_USER_INFO_CHANGED); changedIntent.putExtra(Constants.EXTRA_USER_HANDLE, userId); changedIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); VActivityManagerService.get().sendBroadcastAsUser(changedIntent, new VUserHandle(userId)); }
private void broadcastCheckInNowIfNeed(int userId) { long time = System.currentTimeMillis(); if (Math.abs(time - lastAccountChangeTime) > CHECK_IN_TIME) { lastAccountChangeTime = time; saveAllAccounts(); Intent intent = new Intent("android.server.checkin.CHECKIN_NOW"); VActivityManagerService.get().sendBroadcastAsUser(intent, new VUserHandle(userId)); } }