Support multi-user privacy for battery usage chart
When there are multiple accounts in the devices, the battery usage list is shared in the current design. We will aggregate other users usage data into a single item to support multi-user privacy requirements Screenshot: https://screenshot.googleplex.com/AkFTUtNvnoxcuGR Bug: 202119550 Test: make RunSettingsRoboTests Change-Id: I6cb55f0d50a4caca83212a0a54410530a032c089
This commit is contained in:
@@ -113,6 +113,9 @@ public class BatteryDiffEntry {
|
||||
|
||||
/** Gets the app label name for this entry. */
|
||||
public String getAppLabel() {
|
||||
if (isOtherUsers()) {
|
||||
return mContext.getString(R.string.battery_usage_other_users);
|
||||
}
|
||||
loadLabelAndIcon();
|
||||
// Returns default applicationn label if we cannot find it.
|
||||
return mAppLabel == null || mAppLabel.length() == 0
|
||||
@@ -122,6 +125,9 @@ public class BatteryDiffEntry {
|
||||
|
||||
/** Gets the app icon {@link Drawable} for this entry. */
|
||||
public Drawable getAppIcon() {
|
||||
if (isOtherUsers()) {
|
||||
return mContext.getDrawable(R.drawable.ic_power_system);
|
||||
}
|
||||
loadLabelAndIcon();
|
||||
return mAppIcon != null && mAppIcon.getConstantState() != null
|
||||
? mAppIcon.getConstantState().newDrawable()
|
||||
@@ -156,6 +162,9 @@ public class BatteryDiffEntry {
|
||||
|
||||
/** Whether the current BatteryDiffEntry is system component or not. */
|
||||
public boolean isSystemEntry() {
|
||||
if (isOtherUsers()) {
|
||||
return true;
|
||||
}
|
||||
switch (mBatteryHistEntry.mConsumerType) {
|
||||
case ConvertUtils.CONSUMER_TYPE_USER_BATTERY:
|
||||
case ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY:
|
||||
@@ -175,6 +184,11 @@ public class BatteryDiffEntry {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isOtherUsers() {
|
||||
return mBatteryHistEntry.mConsumerType == ConvertUtils.CONSUMER_TYPE_UID_BATTERY
|
||||
&& mBatteryHistEntry.mUid == BatteryUtils.UID_OTHER_USERS;
|
||||
}
|
||||
|
||||
void loadLabelAndIcon() {
|
||||
if (mIsLoaded) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user