Don't consider managedProfile in PowerUsageAdvanced
When calculating how many uses exists, we shouldn't count the managedProfile since this is not the normal user. Bug: 37681923 Test: RunSettingsRoboTests Change-Id: Ic24e98f8e8696530d534bc9e1d8f675ad6ad5063
This commit is contained in:
@@ -18,6 +18,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.BatteryStats;
|
||||
import android.os.Bundle;
|
||||
@@ -250,7 +251,7 @@ public class PowerUsageAdvanced extends PowerUsageBase {
|
||||
boolean shouldHideCategory(PowerUsageData powerUsageData) {
|
||||
return powerUsageData.usageType == UsageType.UNACCOUNTED
|
||||
|| powerUsageData.usageType == UsageType.OVERCOUNTED
|
||||
|| (powerUsageData.usageType == UsageType.USER && mUserManager.getUserCount() == 1)
|
||||
|| (powerUsageData.usageType == UsageType.USER && isSingleNormalUser())
|
||||
|| (powerUsageData.usageType == UsageType.CELL
|
||||
&& !DataUsageUtils.hasMobileData(getContext()));
|
||||
}
|
||||
@@ -373,6 +374,18 @@ public class PowerUsageAdvanced extends PowerUsageBase {
|
||||
mBatteryUtils = batteryUtils;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean isSingleNormalUser() {
|
||||
int count = 0;
|
||||
for (UserInfo userInfo : mUserManager.getUsers()) {
|
||||
if (userInfo.isEnabled() && !userInfo.isManagedProfile()) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class that contains data used in {@link PowerGaugePreference}.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user