Merge "Update the categorize rule for system and app item bucket" into tm-dev

This commit is contained in:
YK Hung
2022-03-15 13:17:53 +00:00
committed by Android (Google) Code Review
3 changed files with 13 additions and 4 deletions

View File

@@ -618,4 +618,6 @@
<!-- Whether the dream setup activity should be enabled as part of setupwizard --> <!-- Whether the dream setup activity should be enabled as part of setupwizard -->
<bool name="dream_setup_supported">false</bool> <bool name="dream_setup_supported">false</bool>
<!-- Whether to put the apps with system UID into system component bucket or not -->
<bool name="config_battery_combine_system_components">false</bool>
</resources> </resources>

View File

@@ -25,6 +25,7 @@ import android.util.Log;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import com.android.settings.R;
import com.android.settingslib.utils.StringUtil; import com.android.settingslib.utils.StringUtil;
import java.util.Comparator; import java.util.Comparator;
@@ -52,6 +53,7 @@ public class BatteryDiffEntry {
public double mConsumePower; public double mConsumePower;
// A BatteryHistEntry corresponding to this diff usage data. // A BatteryHistEntry corresponding to this diff usage data.
public final BatteryHistEntry mBatteryHistEntry; public final BatteryHistEntry mBatteryHistEntry;
private double mTotalConsumePower; private double mTotalConsumePower;
private double mPercentOfTotal; private double mPercentOfTotal;
@@ -151,8 +153,13 @@ public class BatteryDiffEntry {
case ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY: case ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY:
return true; return true;
case ConvertUtils.CONSUMER_TYPE_UID_BATTERY: case ConvertUtils.CONSUMER_TYPE_UID_BATTERY:
return isSystemUid((int) mBatteryHistEntry.mUid) if (mBatteryHistEntry.mIsHidden) {
|| mBatteryHistEntry.mIsHidden; return true;
}
final boolean combineSystemComponents =
mContext.getResources().getBoolean(
R.bool.config_battery_combine_system_components);
return combineSystemComponents && isSystemUid((int) mBatteryHistEntry.mUid);
} }
return false; return false;
} }

View File

@@ -349,12 +349,12 @@ public final class BatteryDiffEntryTest {
} }
@Test @Test
public void testIsSystemEntry_uidBatteryWithSystemProcess_returnTrue() { public void testIsSystemEntry_uidBatteryWithSystemProcess_returnFalse() {
final BatteryDiffEntry entry = final BatteryDiffEntry entry =
createBatteryDiffEntry( createBatteryDiffEntry(
ConvertUtils.CONSUMER_TYPE_UID_BATTERY, ConvertUtils.CONSUMER_TYPE_UID_BATTERY,
/*uid=*/ 1230, /*isHidden=*/ false); /*uid=*/ 1230, /*isHidden=*/ false);
assertThat(entry.isSystemEntry()).isTrue(); assertThat(entry.isSystemEntry()).isFalse();
} }
@Test @Test