Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 486451e9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix testUidCache_switchLocale_shouldCleanCache in BatteryEntryTest"...

Merge "Fix testUidCache_switchLocale_shouldCleanCache in BatteryEntryTest" into udc-qpr-dev am: b544871b

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/24002332



Change-Id: I67b7e296e56e50c9745ca36e5994f06663ccb56d
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 4fbf549b b544871b
Loading
Loading
Loading
Loading
+0 −27
Original line number Diff line number Diff line
@@ -252,33 +252,6 @@ public class BatteryEntry {
        return mPowerComponentId;
    }

    void getQuickNameIconForUid(
            final int uid, final String[] packages, final boolean loadDataInBackground) {
        // Locale sync to system config in Settings
        final Locale locale = Locale.getDefault();
        if (sCurrentLocale != locale) {
            clearUidCache();
            sCurrentLocale = locale;
        }

        final String uidString = Integer.toString(uid);
        if (sUidCache.containsKey(uidString)) {
            UidToDetail utd = sUidCache.get(uidString);
            mDefaultPackageName = utd.mPackageName;
            mName = utd.mName;
            mIcon = utd.mIcon;
            return;
        }

        if (packages == null || packages.length == 0) {
            final NameAndIcon nameAndIcon = getNameAndIconFromUid(mContext, mName, uid);
            mIcon = nameAndIcon.mIcon;
            mName = nameAndIcon.mName;
        } else {
            mIcon = mContext.getPackageManager().getDefaultActivityIcon();
        }
    }

    /** Loads the app label and icon image and stores into the cache. */
    public static NameAndIcon loadNameAndIcon(
            Context context,
+0 −13
Original line number Diff line number Diff line
@@ -51,8 +51,6 @@ import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;

import java.util.Locale;

@RunWith(RobolectricTestRunner.class)
public class BatteryEntryTest {

@@ -234,17 +232,6 @@ public class BatteryEntryTest {
    }

    @Ignore
    @Test
    public void testUidCache_switchLocale_shouldCleanCache() {
        Locale.setDefault(new Locale("en_US"));
        BatteryEntry.sUidCache.put(Integer.toString(APP_UID), null);
        assertThat(BatteryEntry.sUidCache).isNotEmpty();

        Locale.setDefault(new Locale("zh_TW"));
        createBatteryEntryForApp(null, null, HIGH_DRAIN_PACKAGE);
        assertThat(BatteryEntry.sUidCache).isEmpty(); // check if cache is clear
    }

    @Test
    public void getKey_UidBatteryConsumer() {
        final BatteryEntry entry = createBatteryEntryForApp(null, null, null);