Add userId to key when type is USER
Before this cl, the app list couldn't distinguish different users because all of them have the same key: USER. This cl adds userId into key, to make sure the preference key is unique. Bug: 64605854 Test: RunSettingsRoboTests Change-Id: Ia4de2ff85b214465a35f1983ca69a9280d053154
This commit is contained in:
@@ -724,6 +724,8 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
String extractKeyFromSipper(BatterySipper sipper) {
|
||||
if (sipper.uidObj != null) {
|
||||
return extractKeyFromUid(sipper.getUid());
|
||||
} else if (sipper.drainType == DrainType.USER) {
|
||||
return sipper.drainType.toString() + sipper.userId;
|
||||
} else if (sipper.drainType != DrainType.APP) {
|
||||
return sipper.drainType.toString();
|
||||
} else if (sipper.getPackages() != null) {
|
||||
|
@@ -313,6 +313,16 @@ public class PowerUsageSummaryTest {
|
||||
assertThat(key).isEqualTo(mNormalBatterySipper.drainType.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtractKeyFromSipper_typeUser_returnDrainTypeWithUserId() {
|
||||
mNormalBatterySipper.uidObj = null;
|
||||
mNormalBatterySipper.drainType = BatterySipper.DrainType.USER;
|
||||
mNormalBatterySipper.userId = 2;
|
||||
|
||||
final String key = mFragment.extractKeyFromSipper(mNormalBatterySipper);
|
||||
assertThat(key).isEqualTo("USER2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtractKeyFromSipper_typeAPPUidObjectNotNull_returnUid() {
|
||||
mNormalBatterySipper.uidObj = new BatteryStatsImpl.Uid(new BatteryStatsImpl(), UID);
|
||||
|
Reference in New Issue
Block a user