[Battery usage U] Add an item "Others" in the app list to group small usage apps. This will make the total percetage 100%, which is easy to understand for users.
Bug: 258124173 Fix: 258124173 Test: manual Change-Id: I5965eeb73a2071c4a9994655e4ed24ec3adf64e8
This commit is contained in:
@@ -5079,6 +5079,8 @@
|
|||||||
<string name="battery_usage_without_time"></string>
|
<string name="battery_usage_without_time"></string>
|
||||||
<!-- Description for system apps aggregated battery usage data [CHAR LIMIT=120] -->
|
<!-- Description for system apps aggregated battery usage data [CHAR LIMIT=120] -->
|
||||||
<string name="battery_usage_system_apps">System apps</string>
|
<string name="battery_usage_system_apps">System apps</string>
|
||||||
|
<!-- Description for others battery usage data [CHAR LIMIT=120] -->
|
||||||
|
<string name="battery_usage_others">Others</string>
|
||||||
|
|
||||||
<!-- Description for battery time left, i.e. 50min Estimated time left. [CHAR LIMIT=80]-->
|
<!-- Description for battery time left, i.e. 50min Estimated time left. [CHAR LIMIT=80]-->
|
||||||
<string name="estimated_time_left">Estimated time left</string>
|
<string name="estimated_time_left">Estimated time left</string>
|
||||||
|
@@ -132,6 +132,11 @@ public interface PowerUsageFeatureProvider {
|
|||||||
*/
|
*/
|
||||||
Intent getResumeChargeIntent(boolean isDockDefender);
|
Intent getResumeChargeIntent(boolean isDockDefender);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@link Set} for the system component ids which are combined into others.
|
||||||
|
*/
|
||||||
|
Set<Integer> getOthersSystemComponentSet(Context context);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@link Set} for hiding system component ids in the usage screen.
|
* Returns {@link Set} for hiding system component ids in the usage screen.
|
||||||
*/
|
*/
|
||||||
|
@@ -152,6 +152,11 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Integer> getOthersSystemComponentSet(Context context) {
|
||||||
|
return new ArraySet<>();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Integer> getHideSystemComponentSet(Context context) {
|
public Set<Integer> getHideSystemComponentSet(Context context) {
|
||||||
return new ArraySet<>();
|
return new ArraySet<>();
|
||||||
|
@@ -435,4 +435,45 @@ public class BatteryDiffEntry {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Specific battery diff entry for others. */
|
||||||
|
static class OthersBatteryDiffEntry extends BatteryDiffEntry {
|
||||||
|
OthersBatteryDiffEntry(Context context) {
|
||||||
|
super(context,
|
||||||
|
/*foregroundUsageTimeInMs=*/ 0,
|
||||||
|
/*backgroundUsageTimeInMs=*/ 0,
|
||||||
|
/*screenOnTimeInMs=*/ 0,
|
||||||
|
/*consumePower=*/ 0,
|
||||||
|
/*foregroundUsageConsumePower=*/ 0,
|
||||||
|
/*foregroundServiceUsageConsumePower=*/ 0,
|
||||||
|
/*backgroundUsageConsumePower=*/ 0,
|
||||||
|
/*cachedUsageConsumePower=*/ 0,
|
||||||
|
new BatteryHistEntry(new ContentValues()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getKey() {
|
||||||
|
return "S|Others";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAppLabel() {
|
||||||
|
return mContext.getString(R.string.battery_usage_others);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Drawable getAppIcon() {
|
||||||
|
return mContext.getDrawable(R.drawable.ic_settings_ethernet);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean validForRestriction() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSystemEntry() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1719,6 +1719,7 @@ public final class DataProcessor {
|
|||||||
batteryDiffData.setTotalConsumePower();
|
batteryDiffData.setTotalConsumePower();
|
||||||
batteryDiffData.sortEntries();
|
batteryDiffData.sortEntries();
|
||||||
combineIntoSystemApps(context, batteryDiffData);
|
combineIntoSystemApps(context, batteryDiffData);
|
||||||
|
combineSystemItemsIntoOthers(context, batteryDiffData);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1744,6 +1745,33 @@ public final class DataProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void combineSystemItemsIntoOthers(
|
||||||
|
final Context context, final BatteryDiffData batteryDiffData) {
|
||||||
|
final Set<Integer> othersSystemComponentSet =
|
||||||
|
FeatureFactory.getFactory(context)
|
||||||
|
.getPowerUsageFeatureProvider(context)
|
||||||
|
.getOthersSystemComponentSet(context);
|
||||||
|
|
||||||
|
BatteryDiffEntry.OthersBatteryDiffEntry othersDiffEntry = null;
|
||||||
|
final Iterator<BatteryDiffEntry> systemListIterator =
|
||||||
|
batteryDiffData.getSystemDiffEntryList().iterator();
|
||||||
|
while (systemListIterator.hasNext()) {
|
||||||
|
final BatteryDiffEntry batteryDiffEntry = systemListIterator.next();
|
||||||
|
if (othersSystemComponentSet.contains(batteryDiffEntry.mBatteryHistEntry.mDrainType)) {
|
||||||
|
if (othersDiffEntry == null) {
|
||||||
|
othersDiffEntry = new BatteryDiffEntry.OthersBatteryDiffEntry(context);
|
||||||
|
}
|
||||||
|
othersDiffEntry.mConsumePower += batteryDiffEntry.mConsumePower;
|
||||||
|
othersDiffEntry.setTotalConsumePower(
|
||||||
|
batteryDiffEntry.getTotalConsumePower());
|
||||||
|
systemListIterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (othersDiffEntry != null) {
|
||||||
|
batteryDiffData.getSystemDiffEntryList().add(othersDiffEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void combineIntoSystemApps(
|
private static void combineIntoSystemApps(
|
||||||
final Context context, final BatteryDiffData batteryDiffData) {
|
final Context context, final BatteryDiffData batteryDiffData) {
|
||||||
final List<String> systemAppsAllowlist =
|
final List<String> systemAppsAllowlist =
|
||||||
|
Reference in New Issue
Block a user