Loading services/core/java/com/android/server/pm/DeletePackageHelper.java +11 −1 Original line number Original line Diff line number Diff line Loading @@ -108,7 +108,7 @@ final class DeletePackageHelper { } } /** /** * This method is an internal method that could be get invoked either * This method is an internal method that could be invoked either * to delete an installed package or to clean up a failed installation. * to delete an installed package or to clean up a failed installation. * After deleting an installed package, a broadcast is sent to notify any * After deleting an installed package, a broadcast is sent to notify any * listeners that the package has been removed. For cleaning up a failed * listeners that the package has been removed. For cleaning up a failed Loading Loading @@ -146,6 +146,8 @@ final class DeletePackageHelper { int[] allUsers; int[] allUsers; final int freezeUser; final int freezeUser; final SparseArray<TempUserState> priorUserStates; final SparseArray<TempUserState> priorUserStates; final boolean isInstallerPackage; /** enabled state of the uninstalled application */ /** enabled state of the uninstalled application */ synchronized (mPm.mLock) { synchronized (mPm.mLock) { final Computer computer = mPm.snapshotComputer(); final Computer computer = mPm.snapshotComputer(); Loading Loading @@ -226,6 +228,8 @@ final class DeletePackageHelper { freezeUser = removeUser; freezeUser = removeUser; priorUserStates = null; priorUserStates = null; } } isInstallerPackage = mPm.mSettings.isInstallerPackage(packageName); } } synchronized (mPm.mInstallLock) { synchronized (mPm.mInstallLock) { Loading Loading @@ -324,6 +328,12 @@ final class DeletePackageHelper { } } } } if (res && isInstallerPackage) { final PackageInstallerService packageInstallerService = mPm.mInjector.getPackageInstallerService(); packageInstallerService.onInstallerPackageDeleted(uninstalledPs.getAppId(), removeUser); } return res ? PackageManager.DELETE_SUCCEEDED : PackageManager.DELETE_FAILED_INTERNAL_ERROR; return res ? PackageManager.DELETE_SUCCEEDED : PackageManager.DELETE_FAILED_INTERNAL_ERROR; } } Loading services/core/java/com/android/server/pm/PackageInstallerService.java +34 −0 Original line number Original line Diff line number Diff line Loading @@ -861,6 +861,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements synchronized (mSessions) { synchronized (mSessions) { mSessions.put(sessionId, session); mSessions.put(sessionId, session); } } mPm.addInstallerPackageName(session.getInstallSource()); mCallbacks.notifySessionCreated(session.sessionId, session.userId); mCallbacks.notifySessionCreated(session.sessionId, session.userId); Loading Loading @@ -1735,4 +1736,37 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements .setPackage(sessionInfo.installerPackageName); .setPackage(sessionInfo.installerPackageName); mContext.sendBroadcastAsUser(sessionUpdatedIntent, UserHandle.of(userId)); mContext.sendBroadcastAsUser(sessionUpdatedIntent, UserHandle.of(userId)); } } /** * Abandon unfinished sessions if the installer package has been uninstalled. * @param installerAppId the app ID of the installer package that has been uninstalled. * @param userId the user that has the installer package uninstalled. */ void onInstallerPackageDeleted(int installerAppId, int userId) { synchronized (mSessions) { for (int i = 0; i < mSessions.size(); i++) { final PackageInstallerSession session = mSessions.valueAt(i); if (!matchesInstaller(session, installerAppId, userId)) { continue; } // Find parent session and only abandon parent session if installer matches PackageInstallerSession root = !session.hasParentSessionId() ? session : mSessions.get(session.getParentSessionId()); if (root != null && matchesInstaller(root, installerAppId, userId) && !root.isDestroyed()) { root.abandon(); } } } } private boolean matchesInstaller(PackageInstallerSession session, int installerAppId, int userId) { final int installerUid = session.getInstallerUid(); if (installerAppId == UserHandle.USER_ALL) { return UserHandle.getAppId(installerUid) == installerAppId; } else { return UserHandle.getUid(userId, installerAppId) == installerUid; } } } } services/core/java/com/android/server/pm/PackageManagerService.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -7168,4 +7168,10 @@ public class PackageManagerService implements PackageSender, TestUtilityService void notifyInstantAppPackageInstalled(String packageName, int[] newUsers) { void notifyInstantAppPackageInstalled(String packageName, int[] newUsers) { mInstantAppRegistry.onPackageInstalled(snapshotComputer(), packageName, newUsers); mInstantAppRegistry.onPackageInstalled(snapshotComputer(), packageName, newUsers); } } void addInstallerPackageName(InstallSource installSource) { synchronized (mLock) { mSettings.addInstallerPackageNames(installSource); } } } } services/core/java/com/android/server/pm/Settings.java +6 −2 Original line number Original line Diff line number Diff line Loading @@ -380,8 +380,8 @@ public final class Settings implements Watchable, Snappable { private final SnapshotCache<WatchedArrayMap<String, PackageSetting>> mPackagesSnapshot; private final SnapshotCache<WatchedArrayMap<String, PackageSetting>> mPackagesSnapshot; /** /** * List of packages that were involved in installing other packages, i.e. are listed * List of packages that were involved in installing other packages, i.e. packages that created * in at least one app's InstallSource. * new sessions or are listed in at least one app's InstallSource. */ */ @Watched @Watched private final WatchedArraySet<String> mInstallerPackages; private final WatchedArraySet<String> mInstallerPackages; Loading Loading @@ -5923,4 +5923,8 @@ public final class Settings implements Watchable, Snappable { } } } } } } boolean isInstallerPackage(@NonNull String packageName) { return mInstallerPackages.contains(packageName); } } } Loading
services/core/java/com/android/server/pm/DeletePackageHelper.java +11 −1 Original line number Original line Diff line number Diff line Loading @@ -108,7 +108,7 @@ final class DeletePackageHelper { } } /** /** * This method is an internal method that could be get invoked either * This method is an internal method that could be invoked either * to delete an installed package or to clean up a failed installation. * to delete an installed package or to clean up a failed installation. * After deleting an installed package, a broadcast is sent to notify any * After deleting an installed package, a broadcast is sent to notify any * listeners that the package has been removed. For cleaning up a failed * listeners that the package has been removed. For cleaning up a failed Loading Loading @@ -146,6 +146,8 @@ final class DeletePackageHelper { int[] allUsers; int[] allUsers; final int freezeUser; final int freezeUser; final SparseArray<TempUserState> priorUserStates; final SparseArray<TempUserState> priorUserStates; final boolean isInstallerPackage; /** enabled state of the uninstalled application */ /** enabled state of the uninstalled application */ synchronized (mPm.mLock) { synchronized (mPm.mLock) { final Computer computer = mPm.snapshotComputer(); final Computer computer = mPm.snapshotComputer(); Loading Loading @@ -226,6 +228,8 @@ final class DeletePackageHelper { freezeUser = removeUser; freezeUser = removeUser; priorUserStates = null; priorUserStates = null; } } isInstallerPackage = mPm.mSettings.isInstallerPackage(packageName); } } synchronized (mPm.mInstallLock) { synchronized (mPm.mInstallLock) { Loading Loading @@ -324,6 +328,12 @@ final class DeletePackageHelper { } } } } if (res && isInstallerPackage) { final PackageInstallerService packageInstallerService = mPm.mInjector.getPackageInstallerService(); packageInstallerService.onInstallerPackageDeleted(uninstalledPs.getAppId(), removeUser); } return res ? PackageManager.DELETE_SUCCEEDED : PackageManager.DELETE_FAILED_INTERNAL_ERROR; return res ? PackageManager.DELETE_SUCCEEDED : PackageManager.DELETE_FAILED_INTERNAL_ERROR; } } Loading
services/core/java/com/android/server/pm/PackageInstallerService.java +34 −0 Original line number Original line Diff line number Diff line Loading @@ -861,6 +861,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements synchronized (mSessions) { synchronized (mSessions) { mSessions.put(sessionId, session); mSessions.put(sessionId, session); } } mPm.addInstallerPackageName(session.getInstallSource()); mCallbacks.notifySessionCreated(session.sessionId, session.userId); mCallbacks.notifySessionCreated(session.sessionId, session.userId); Loading Loading @@ -1735,4 +1736,37 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements .setPackage(sessionInfo.installerPackageName); .setPackage(sessionInfo.installerPackageName); mContext.sendBroadcastAsUser(sessionUpdatedIntent, UserHandle.of(userId)); mContext.sendBroadcastAsUser(sessionUpdatedIntent, UserHandle.of(userId)); } } /** * Abandon unfinished sessions if the installer package has been uninstalled. * @param installerAppId the app ID of the installer package that has been uninstalled. * @param userId the user that has the installer package uninstalled. */ void onInstallerPackageDeleted(int installerAppId, int userId) { synchronized (mSessions) { for (int i = 0; i < mSessions.size(); i++) { final PackageInstallerSession session = mSessions.valueAt(i); if (!matchesInstaller(session, installerAppId, userId)) { continue; } // Find parent session and only abandon parent session if installer matches PackageInstallerSession root = !session.hasParentSessionId() ? session : mSessions.get(session.getParentSessionId()); if (root != null && matchesInstaller(root, installerAppId, userId) && !root.isDestroyed()) { root.abandon(); } } } } private boolean matchesInstaller(PackageInstallerSession session, int installerAppId, int userId) { final int installerUid = session.getInstallerUid(); if (installerAppId == UserHandle.USER_ALL) { return UserHandle.getAppId(installerUid) == installerAppId; } else { return UserHandle.getUid(userId, installerAppId) == installerUid; } } } }
services/core/java/com/android/server/pm/PackageManagerService.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -7168,4 +7168,10 @@ public class PackageManagerService implements PackageSender, TestUtilityService void notifyInstantAppPackageInstalled(String packageName, int[] newUsers) { void notifyInstantAppPackageInstalled(String packageName, int[] newUsers) { mInstantAppRegistry.onPackageInstalled(snapshotComputer(), packageName, newUsers); mInstantAppRegistry.onPackageInstalled(snapshotComputer(), packageName, newUsers); } } void addInstallerPackageName(InstallSource installSource) { synchronized (mLock) { mSettings.addInstallerPackageNames(installSource); } } } }
services/core/java/com/android/server/pm/Settings.java +6 −2 Original line number Original line Diff line number Diff line Loading @@ -380,8 +380,8 @@ public final class Settings implements Watchable, Snappable { private final SnapshotCache<WatchedArrayMap<String, PackageSetting>> mPackagesSnapshot; private final SnapshotCache<WatchedArrayMap<String, PackageSetting>> mPackagesSnapshot; /** /** * List of packages that were involved in installing other packages, i.e. are listed * List of packages that were involved in installing other packages, i.e. packages that created * in at least one app's InstallSource. * new sessions or are listed in at least one app's InstallSource. */ */ @Watched @Watched private final WatchedArraySet<String> mInstallerPackages; private final WatchedArraySet<String> mInstallerPackages; Loading Loading @@ -5923,4 +5923,8 @@ public final class Settings implements Watchable, Snappable { } } } } } } boolean isInstallerPackage(@NonNull String packageName) { return mInstallerPackages.contains(packageName); } } }