From e7af1942bac3e674e09019f158de139cba1cbd0b Mon Sep 17 00:00:00 2001 From: Svet Ganov Date: Tue, 4 Aug 2015 11:13:44 -0700 Subject: [PATCH] Ensure per package and per UID state share same package settings. When renaming a package during an OTA we were getting in a state where the package setting mapped to the package UID was not the same instance as the one we create for the new package mapped. This leads to a drift between the permissions state for the package and that state for the UID, resulting in broken for UID permission checks as granted permissions were never appearing in the per UID package setting. bug:22928831 Change-Id: Ib0372632ec84a917304561fd94032cd09bb4c12f --- .../core/java/com/android/server/pm/Settings.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java index 736b15380aca2..82ffa474867c8 100644 --- a/services/core/java/com/android/server/pm/Settings.java +++ b/services/core/java/com/android/server/pm/Settings.java @@ -613,6 +613,7 @@ final class Settings { p.sharedUser = origPackage.sharedUser; p.appId = origPackage.appId; p.origPackage = origPackage; + p.getPermissionsState().copyFrom(origPackage.getPermissionsState()); mRenamedPackages.put(name, origPackage.name); name = origPackage.name; // Update new package state. @@ -812,6 +813,20 @@ final class Settings { p.sharedUser = sharedUser; p.appId = sharedUser.userId; } + + // If the we know about this user id, we have to update it as it + // has to point to the same PackageSetting instance as the package. + Object userIdPs = getUserIdLPr(p.appId); + if (sharedUser == null) { + if (userIdPs != null && userIdPs != p) { + replaceUserIdLPw(p.appId, p); + } + } else { + if (userIdPs != null && userIdPs != sharedUser) { + replaceUserIdLPw(p.appId, sharedUser); + } + } + IntentFilterVerificationInfo ivi = mRestoredIntentFilterVerifications.get(name); if (ivi != null) { if (DEBUG_DOMAIN_VERIFICATION) {