Fix work profile apps are in Uninstalled

Context: work profile apps needs to pass userId to packageManager to get the uid.
Fixed screenshot: https://screenshot.googleplex.com/AkXfMWvmREyQJvv

Bug: 315477872
Fix: 315477872
Test: manual
Change-Id: I96eb42ef6ce27f15415f0e1fc32060d69b3fab2d
This commit is contained in:
Jun Lan
2023-12-18 17:00:39 +08:00
parent 1ab510bc3c
commit cd516c8d46
2 changed files with 24 additions and 8 deletions

View File

@@ -324,7 +324,8 @@ public class BatteryDiffEntry {
}
}
int uid = BatteryUtils.getInstance(mContext).getPackageUid(packageName);
int uid =
BatteryUtils.getInstance(mContext).getPackageUidAsUser(packageName, (int) mUserId);
synchronized (sPackageNameAndUidCacheLock) {
sPackageNameAndUidCache.put(packageName, uid);
}
@@ -379,8 +380,7 @@ public class BatteryDiffEntry {
mAppIcon = nameAndIconForUser.mIcon;
mAppLabel = nameAndIconForUser.mName;
putResourceCache(
getKey(),
new NameAndIcon(mAppLabel, mAppIcon, /* iconId= */ 0));
getKey(), new NameAndIcon(mAppLabel, mAppIcon, /* iconId= */ 0));
}
break;
case ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY:
@@ -392,8 +392,7 @@ public class BatteryDiffEntry {
mAppIconId = nameAndIconForSystem.mIconId;
mAppIcon = mContext.getDrawable(nameAndIconForSystem.mIconId);
}
putResourceCache(
getKey(), new NameAndIcon(mAppLabel, mAppIcon, mAppIconId));
putResourceCache(getKey(), new NameAndIcon(mAppLabel, mAppIcon, mAppIconId));
}
break;
case ConvertUtils.CONSUMER_TYPE_UID_BATTERY:
@@ -406,8 +405,7 @@ public class BatteryDiffEntry {
mAppIcon = getBadgeIconForUser(mAppIcon);
if (mAppLabel != null || mAppIcon != null) {
putResourceCache(
getKey(),
new NameAndIcon(mAppLabel, mAppIcon, /* iconId= */ 0));
getKey(), new NameAndIcon(mAppLabel, mAppIcon, /* iconId= */ 0));
}
break;
}