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:
jackqdyulei
2017-08-11 13:00:04 -07:00
committed by Lei Yu
parent 073c5cbe30
commit 44dc63ec7b
2 changed files with 12 additions and 0 deletions

View File

@@ -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);