Remove OS items in battery main page.
We want to hide the OS items from battery usage page and let users focus on the items that they can control. Currently the hidden items are: Android OS, Android System, Phone idle, Cell Standby Bug: 34274844 Test: RunSettingsRoboTests & screenshots Change-Id: I75165376d5038b6ec17a7b73ae3c5fcd24753fa9
This commit is contained in:
@@ -319,7 +319,7 @@ public class PowerUsageSummary extends PowerUsageBase {
|
||||
final int numSippers = usageList.size();
|
||||
for (int i = 0; i < numSippers; i++) {
|
||||
final BatterySipper sipper = usageList.get(i);
|
||||
if ((sipper.totalPowerMah * SECONDS_IN_HOUR) < MIN_POWER_THRESHOLD_MILLI_AMP) {
|
||||
if (shouldHideSipper(sipper)) {
|
||||
continue;
|
||||
}
|
||||
double totalPower = USE_FAKE_DATA ? 4000 : mStatsHelper.getTotalPower();
|
||||
@@ -375,7 +375,7 @@ public class PowerUsageSummary extends PowerUsageBase {
|
||||
pref.setTitle(entry.getLabel());
|
||||
pref.setOrder(i + 1);
|
||||
pref.setPercent(percentOfMax, percentOfTotal);
|
||||
if ((sipper.drainType != DrainType.APP || sipper.uidObj.getUid() == 0)
|
||||
if ((sipper.drainType != DrainType.APP || sipper.uidObj.getUid() == Process.ROOT_UID)
|
||||
&& sipper.drainType != DrainType.USER) {
|
||||
pref.setTint(colorControl);
|
||||
}
|
||||
@@ -395,6 +395,16 @@ public class PowerUsageSummary extends PowerUsageBase {
|
||||
BatteryEntry.startRequestQueue();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean shouldHideSipper(BatterySipper sipper) {
|
||||
final DrainType drainType = sipper.drainType;
|
||||
final int uid = sipper.getUid();
|
||||
|
||||
return drainType == DrainType.IDLE || drainType == DrainType.CELL
|
||||
|| uid == Process.ROOT_UID || uid == Process.SYSTEM_UID
|
||||
|| (sipper.totalPowerMah * SECONDS_IN_HOUR) < MIN_POWER_THRESHOLD_MILLI_AMP;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
String extractKeyFromSipper(BatterySipper sipper) {
|
||||
if (sipper.uidObj != null) {
|
||||
|
@@ -17,6 +17,7 @@ package com.android.settings.fuelgauge;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Process;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
@@ -28,7 +29,6 @@ import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
@@ -52,6 +52,7 @@ import static org.mockito.Mockito.when;
|
||||
public class PowerUsageSummaryTest {
|
||||
private static final String[] PACKAGE_NAMES = {"com.app1", "com.app2"};
|
||||
private static final int UID = 123;
|
||||
private static final int POWER_MAH = 100;
|
||||
|
||||
private static final Intent ADDITIONAL_BATTERY_INFO_INTENT =
|
||||
new Intent("com.example.app.ADDITIONAL_BATTERY_INFO");
|
||||
@@ -96,6 +97,7 @@ public class PowerUsageSummaryTest {
|
||||
|
||||
when(mBatterySipper.getPackages()).thenReturn(PACKAGE_NAMES);
|
||||
when(mBatterySipper.getUid()).thenReturn(UID);
|
||||
mBatterySipper.totalPowerMah = POWER_MAH;
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -152,6 +154,39 @@ public class PowerUsageSummaryTest {
|
||||
assertThat(key).isEqualTo(Integer.toString(mBatterySipper.getUid()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShouldHideSipper_TypeIdle_ReturnTrue() {
|
||||
mBatterySipper.drainType = BatterySipper.DrainType.IDLE;
|
||||
assertThat(mPowerUsageSummary.shouldHideSipper(mBatterySipper)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShouldHideSipper_TypeCell_ReturnTrue() {
|
||||
mBatterySipper.drainType = BatterySipper.DrainType.CELL;
|
||||
assertThat(mPowerUsageSummary.shouldHideSipper(mBatterySipper)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShouldHideSipper_UidRoot_ReturnTrue() {
|
||||
mBatterySipper.drainType = BatterySipper.DrainType.APP;
|
||||
when(mBatterySipper.getUid()).thenReturn(Process.ROOT_UID);
|
||||
assertThat(mPowerUsageSummary.shouldHideSipper(mBatterySipper)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShouldHideSipper_UidSystem_ReturnTrue() {
|
||||
mBatterySipper.drainType = BatterySipper.DrainType.APP;
|
||||
when(mBatterySipper.getUid()).thenReturn(Process.SYSTEM_UID);
|
||||
assertThat(mPowerUsageSummary.shouldHideSipper(mBatterySipper)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShouldHideSipper_UidNormal_ReturnFalse() {
|
||||
mBatterySipper.drainType = BatterySipper.DrainType.APP;
|
||||
when(mBatterySipper.getUid()).thenReturn(UID);
|
||||
assertThat(mPowerUsageSummary.shouldHideSipper(mBatterySipper)).isFalse();
|
||||
}
|
||||
|
||||
public static class TestFragment extends PowerUsageSummary {
|
||||
|
||||
private Context mContext;
|
||||
|
Reference in New Issue
Block a user