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

Commit 3b7abccc 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 am: 486451e9

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



Change-Id: I470e36951003125f6a97dca2c71d655b2904abcd
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents e0c2d574 486451e9
Loading
Loading
Loading
Loading
+0 −27
Original line number Original line Diff line number Diff line
@@ -252,33 +252,6 @@ public class BatteryEntry {
        return mPowerComponentId;
        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. */
    /** Loads the app label and icon image and stores into the cache. */
    public static NameAndIcon loadNameAndIcon(
    public static NameAndIcon loadNameAndIcon(
            Context context,
            Context context,
+0 −13
Original line number Original line Diff line number Diff line
@@ -51,8 +51,6 @@ import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.RuntimeEnvironment;


import java.util.Locale;

@RunWith(RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class BatteryEntryTest {
public class BatteryEntryTest {


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


    @Ignore
    @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
    @Test
    public void getKey_UidBatteryConsumer() {
    public void getKey_UidBatteryConsumer() {
        final BatteryEntry entry = createBatteryEntryForApp(null, null, null);
        final BatteryEntry entry = createBatteryEntryForApp(null, null, null);