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:
@@ -144,7 +144,6 @@ public class BatteryUtils {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
|
||||
/** Gets the process time */
|
||||
public long getProcessTimeMs(@StatusType int type, @Nullable BatteryStats.Uid uid, int which) {
|
||||
if (uid == null) {
|
||||
@@ -344,6 +343,25 @@ public class BatteryUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find package uid from package name
|
||||
*
|
||||
* @param packageName used to find the uid
|
||||
* @param userId The user handle identifier to look up the package under
|
||||
* @return uid for packageName, or {@link #UID_NULL} if exception happens or {@code packageName}
|
||||
* is null
|
||||
*/
|
||||
public int getPackageUidAsUser(String packageName, int userId) {
|
||||
try {
|
||||
return packageName == null
|
||||
? UID_NULL
|
||||
: mPackageManager.getPackageUidAsUser(
|
||||
packageName, PackageManager.GET_META_DATA, userId);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return UID_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses proto object from string.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user