Loading src/com/android/settings/fuelgauge/BatteryUtils.java +19 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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. * Loading src/com/android/settings/fuelgauge/batteryusage/BatteryDiffEntry.java +5 −7 Original line number Diff line number Diff line Loading @@ -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); } Loading Loading @@ -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: Loading @@ -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: Loading @@ -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; } Loading Loading
src/com/android/settings/fuelgauge/BatteryUtils.java +19 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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. * Loading
src/com/android/settings/fuelgauge/batteryusage/BatteryDiffEntry.java +5 −7 Original line number Diff line number Diff line Loading @@ -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); } Loading Loading @@ -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: Loading @@ -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: Loading @@ -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; } Loading