From 9f06a92fa99883d272c3ad9dbbbe0b40b095121b Mon Sep 17 00:00:00 2001 From: Songchun Fan Date: Wed, 23 Feb 2022 20:09:35 +0000 Subject: [PATCH] [pm] fix acquireAndRegisterNewAppId after app removal mFirstAvailableUid becomes (the last removed app ID + 1) after an app removal. acquireAndRegisterNewAppId should use the offset of mFirstAvailableUid as an index, not its actual value. Test: manual for now BUG: 216658672 Change-Id: Ie1b9ecafeb191129320243608c7f70eb2ea5c79e --- services/core/java/com/android/server/pm/Settings.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java index 394c8fb731562..29bf2ae90d89c 100644 --- a/services/core/java/com/android/server/pm/Settings.java +++ b/services/core/java/com/android/server/pm/Settings.java @@ -410,7 +410,7 @@ public final class Settings implements Watchable, Snappable { int[] excludedUserIds; } - private static int mFirstAvailableUid = 0; + private static int mFirstAvailableUid = Process.FIRST_APPLICATION_UID; /** Map from volume UUID to {@link VersionInfo} */ @Watched @@ -4271,7 +4271,7 @@ public final class Settings implements Watchable, Snappable { private int acquireAndRegisterNewAppIdLPw(SettingBase obj) { // Let's be stupidly inefficient for now... final int size = mAppIds.size(); - for (int i = mFirstAvailableUid; i < size; i++) { + for (int i = mFirstAvailableUid - Process.FIRST_APPLICATION_UID; i < size; i++) { if (mAppIds.get(i) == null) { mAppIds.set(i, obj); return Process.FIRST_APPLICATION_UID + i;