From a3b89868f46da99bd2dee930d4f9f7d415eb00ff Mon Sep 17 00:00:00 2001 From: ykhung Date: Sat, 11 Sep 2021 00:42:56 +0800 Subject: [PATCH] Fix the icon flash issue cause from the shared drawable icon different time slot may have the same application entry, we should not make them share the same drawable instance to impact the states, we will use newDrawable() method to create a new one for each application entry Bug: 198553245 Test: make SettingsRoboTests Change-Id: I4a321133ba171817fca1ab7ad47b9af8f7450675 --- src/com/android/settings/fuelgauge/BatteryDiffEntry.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/fuelgauge/BatteryDiffEntry.java b/src/com/android/settings/fuelgauge/BatteryDiffEntry.java index 0074f9351e2..f7d01d9711f 100644 --- a/src/com/android/settings/fuelgauge/BatteryDiffEntry.java +++ b/src/com/android/settings/fuelgauge/BatteryDiffEntry.java @@ -113,7 +113,7 @@ public class BatteryDiffEntry { /** Gets the app icon {@link Drawable} for this entry. */ public Drawable getAppIcon() { loadLabelAndIcon(); - return mAppIcon; + return mAppIcon.getConstantState().newDrawable(); } /** Gets the app icon id for this entry. */ @@ -348,8 +348,8 @@ public class BatteryDiffEntry { private Drawable getBadgeIconForUser(Drawable icon) { final int userId = UserHandle.getUserId((int) mBatteryHistEntry.mUid); - final UserHandle userHandle = new UserHandle(userId); - return mUserManager.getBadgedIconForUser(icon, userHandle); + return userId == UserHandle.USER_OWNER ? icon : + mUserManager.getBadgedIconForUser(icon, new UserHandle(userId)); } private static boolean isSystemUid(int uid) {