Loading services/core/java/com/android/server/pm/InstallParams.java +4 −1 Original line number Diff line number Diff line Loading @@ -1207,7 +1207,10 @@ final class InstallParams extends HandlerParams { // Check for shared user id changes String invalidPackageName = null; if (!Objects.equals(oldPackage.getSharedUserId(), parsedPackage.getSharedUserId())) { parsedPackage.getSharedUserId()) // Don't mark as invalid if the app is trying to // leave a sharedUserId && parsedPackage.getSharedUserId() != null) { invalidPackageName = parsedPackage.getPackageName(); } Loading services/core/java/com/android/server/pm/PackageManagerService.java +26 −15 Original line number Diff line number Diff line Loading @@ -13528,10 +13528,6 @@ public class PackageManagerService extends IPackageManager.Stub } } /** * Returns the actual scan flags depending upon the state of the other settings. * <p>Updated system applications will not have the following flags set Loading Loading @@ -13699,10 +13695,10 @@ public class PackageManagerService extends IPackageManager.Stub */ boolean optimisticallyRegisterAppId(@NonNull ScanResult result) throws PackageManagerException { if (!result.mExistingSettingCopied) { if (!result.mExistingSettingCopied || result.mNeedsNewAppId) { // THROWS: when we can't allocate a user id. add call to check if there's // enough space to ensure we won't throw; otherwise, don't modify state return mSettings.registerAppIdLPw(result.mPkgSetting); return mSettings.registerAppIdLPw(result.mPkgSetting, result.mNeedsNewAppId); } return false; } Loading Loading @@ -14072,7 +14068,16 @@ public class PackageManagerService extends IPackageManager.Stub } } boolean leavingSharedUser = false; if (pkgSetting != null && pkgSetting.sharedUser != sharedUserSetting) { if (pkgSetting.sharedUser != null && sharedUserSetting == null) { leavingSharedUser = true; // Log that something is leaving shareduid and keep going Slog.i(TAG, "Package " + parsedPackage.getPackageName() + " shared user changed from " + pkgSetting.sharedUser.name + " to " + "<nothing>."); } else { PackageManagerService.reportSettingsProblem(Log.WARN, "Package " + parsedPackage.getPackageName() + " shared user changed from " + (pkgSetting.sharedUser != null Loading @@ -14082,6 +14087,7 @@ public class PackageManagerService extends IPackageManager.Stub + "; replacing with new"); pkgSetting = null; } } String[] usesStaticLibraries = null; if (!parsedPackage.getUsesStaticLibraries().isEmpty()) { Loading Loading @@ -14356,7 +14362,8 @@ public class PackageManagerService extends IPackageManager.Stub } return new ScanResult(request, true, pkgSetting, changedAbiCodePath, !createNewPackage /* existingSettingCopied */, staticSharedLibraryInfo, !createNewPackage /* existingSettingCopied */, leavingSharedUser /* needsNewAppId */, staticSharedLibraryInfo, dynamicSharedLibraryInfos); } Loading Loading @@ -21735,6 +21742,10 @@ public class PackageManagerService extends IPackageManager.Stub continue; } // TODO@ashfall check ScanResult.mNeedsNewAppId, and if true instead // of creating app data, migrate / change ownership of existing // data. if (ps.getInstalled(user.id)) { // TODO: when user data is locked, mark that we're still dirty prepareAppData(batch, pkg, user.id, flags).thenRun(() -> { services/core/java/com/android/server/pm/ScanResult.java +7 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,11 @@ final class ScanResult { * commit. */ public final boolean mExistingSettingCopied; /** * Whether or not the original PackageSetting needs to be updated with * a new uid. Useful when leaving a sharedUserID. */ public final boolean mNeedsNewAppId; /** * The final package settings. This may be the same object passed in * the {@link ScanRequest}, but, with modified values. Loading @@ -52,6 +57,7 @@ final class ScanResult { ScanRequest request, boolean success, @Nullable PackageSetting pkgSetting, @Nullable List<String> changedAbiCodePath, boolean existingSettingCopied, boolean needsNewAppId, SharedLibraryInfo staticSharedLibraryInfo, List<SharedLibraryInfo> dynamicSharedLibraryInfos) { mRequest = request; Loading @@ -59,6 +65,7 @@ final class ScanResult { mPkgSetting = pkgSetting; mChangedAbiCodePath = changedAbiCodePath; mExistingSettingCopied = existingSettingCopied; mNeedsNewAppId = needsNewAppId; mStaticSharedLibraryInfo = staticSharedLibraryInfo; mDynamicSharedLibraryInfos = dynamicSharedLibraryInfos; } Loading services/core/java/com/android/server/pm/Settings.java +2 −2 Original line number Diff line number Diff line Loading @@ -1126,9 +1126,9 @@ public final class Settings implements Watchable, Snappable { * already registered. * @throws PackageManagerException If a user ID could not be allocated. */ boolean registerAppIdLPw(PackageSetting p) throws PackageManagerException { boolean registerAppIdLPw(PackageSetting p, boolean forceNew) throws PackageManagerException { final boolean createdNew; if (p.appId == 0) { if (p.appId == 0 || forceNew) { // Assign new user ID p.appId = acquireAndRegisterNewAppIdLPw(p); createdNew = true; Loading Loading
services/core/java/com/android/server/pm/InstallParams.java +4 −1 Original line number Diff line number Diff line Loading @@ -1207,7 +1207,10 @@ final class InstallParams extends HandlerParams { // Check for shared user id changes String invalidPackageName = null; if (!Objects.equals(oldPackage.getSharedUserId(), parsedPackage.getSharedUserId())) { parsedPackage.getSharedUserId()) // Don't mark as invalid if the app is trying to // leave a sharedUserId && parsedPackage.getSharedUserId() != null) { invalidPackageName = parsedPackage.getPackageName(); } Loading
services/core/java/com/android/server/pm/PackageManagerService.java +26 −15 Original line number Diff line number Diff line Loading @@ -13528,10 +13528,6 @@ public class PackageManagerService extends IPackageManager.Stub } } /** * Returns the actual scan flags depending upon the state of the other settings. * <p>Updated system applications will not have the following flags set Loading Loading @@ -13699,10 +13695,10 @@ public class PackageManagerService extends IPackageManager.Stub */ boolean optimisticallyRegisterAppId(@NonNull ScanResult result) throws PackageManagerException { if (!result.mExistingSettingCopied) { if (!result.mExistingSettingCopied || result.mNeedsNewAppId) { // THROWS: when we can't allocate a user id. add call to check if there's // enough space to ensure we won't throw; otherwise, don't modify state return mSettings.registerAppIdLPw(result.mPkgSetting); return mSettings.registerAppIdLPw(result.mPkgSetting, result.mNeedsNewAppId); } return false; } Loading Loading @@ -14072,7 +14068,16 @@ public class PackageManagerService extends IPackageManager.Stub } } boolean leavingSharedUser = false; if (pkgSetting != null && pkgSetting.sharedUser != sharedUserSetting) { if (pkgSetting.sharedUser != null && sharedUserSetting == null) { leavingSharedUser = true; // Log that something is leaving shareduid and keep going Slog.i(TAG, "Package " + parsedPackage.getPackageName() + " shared user changed from " + pkgSetting.sharedUser.name + " to " + "<nothing>."); } else { PackageManagerService.reportSettingsProblem(Log.WARN, "Package " + parsedPackage.getPackageName() + " shared user changed from " + (pkgSetting.sharedUser != null Loading @@ -14082,6 +14087,7 @@ public class PackageManagerService extends IPackageManager.Stub + "; replacing with new"); pkgSetting = null; } } String[] usesStaticLibraries = null; if (!parsedPackage.getUsesStaticLibraries().isEmpty()) { Loading Loading @@ -14356,7 +14362,8 @@ public class PackageManagerService extends IPackageManager.Stub } return new ScanResult(request, true, pkgSetting, changedAbiCodePath, !createNewPackage /* existingSettingCopied */, staticSharedLibraryInfo, !createNewPackage /* existingSettingCopied */, leavingSharedUser /* needsNewAppId */, staticSharedLibraryInfo, dynamicSharedLibraryInfos); } Loading Loading @@ -21735,6 +21742,10 @@ public class PackageManagerService extends IPackageManager.Stub continue; } // TODO@ashfall check ScanResult.mNeedsNewAppId, and if true instead // of creating app data, migrate / change ownership of existing // data. if (ps.getInstalled(user.id)) { // TODO: when user data is locked, mark that we're still dirty prepareAppData(batch, pkg, user.id, flags).thenRun(() -> {
services/core/java/com/android/server/pm/ScanResult.java +7 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,11 @@ final class ScanResult { * commit. */ public final boolean mExistingSettingCopied; /** * Whether or not the original PackageSetting needs to be updated with * a new uid. Useful when leaving a sharedUserID. */ public final boolean mNeedsNewAppId; /** * The final package settings. This may be the same object passed in * the {@link ScanRequest}, but, with modified values. Loading @@ -52,6 +57,7 @@ final class ScanResult { ScanRequest request, boolean success, @Nullable PackageSetting pkgSetting, @Nullable List<String> changedAbiCodePath, boolean existingSettingCopied, boolean needsNewAppId, SharedLibraryInfo staticSharedLibraryInfo, List<SharedLibraryInfo> dynamicSharedLibraryInfos) { mRequest = request; Loading @@ -59,6 +65,7 @@ final class ScanResult { mPkgSetting = pkgSetting; mChangedAbiCodePath = changedAbiCodePath; mExistingSettingCopied = existingSettingCopied; mNeedsNewAppId = needsNewAppId; mStaticSharedLibraryInfo = staticSharedLibraryInfo; mDynamicSharedLibraryInfos = dynamicSharedLibraryInfos; } Loading
services/core/java/com/android/server/pm/Settings.java +2 −2 Original line number Diff line number Diff line Loading @@ -1126,9 +1126,9 @@ public final class Settings implements Watchable, Snappable { * already registered. * @throws PackageManagerException If a user ID could not be allocated. */ boolean registerAppIdLPw(PackageSetting p) throws PackageManagerException { boolean registerAppIdLPw(PackageSetting p, boolean forceNew) throws PackageManagerException { final boolean createdNew; if (p.appId == 0) { if (p.appId == 0 || forceNew) { // Assign new user ID p.appId = acquireAndRegisterNewAppIdLPw(p); createdNew = true; Loading