Merge "Fix testUidCache_switchLocale_shouldCleanCache in BatteryEntryTest" into udc-qpr-dev am: b544871b38
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/24002332 Change-Id: I67b7e296e56e50c9745ca36e5994f06663ccb56d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -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,
|
||||||
|
@@ -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);
|
||||||
|
Reference in New Issue
Block a user