Support special tethering and removed apps UID in the usage list
There is a special UID for network data tethering usage, we will handle it in a special case to avoid the current rule considering it as an invalid UID case without showing in the usage list. We will disable the click behavior to protect the optimization mode page first. Bug: 227395125 Test: make RunSettingsRoboTests -j56 ROBOTEST_FILTER="com.android.settings.fuelgauge" Change-Id: I8d96473d382ebc3253748cce8345d6f2261a233d
This commit is contained in:
@@ -243,7 +243,8 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro
|
||||
continue;
|
||||
}
|
||||
|
||||
final UserHandle userHandle = new UserHandle(UserHandle.getUserId(entry.getUid()));
|
||||
final int uid = entry.getUid();
|
||||
final UserHandle userHandle = new UserHandle(UserHandle.getUserId(uid));
|
||||
final Drawable badgedIcon = mUserManager.getBadgedIconForUser(entry.getIcon(),
|
||||
userHandle);
|
||||
final CharSequence contentDescription = mUserManager.getBadgedLabelForUser(
|
||||
@@ -261,6 +262,8 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro
|
||||
pref.setOrder(i + 1);
|
||||
pref.setPercent(percentOfTotal);
|
||||
pref.shouldShowAnomalyIcon(false);
|
||||
pref.setEnabled(uid != BatteryUtils.UID_TETHERING
|
||||
&& uid != BatteryUtils.UID_REMOVED_APPS);
|
||||
setUsageSummary(pref, entry);
|
||||
addedSome = true;
|
||||
mAppListGroup.addPreference(pref);
|
||||
|
@@ -153,13 +153,16 @@ public class BatteryDiffEntry {
|
||||
case ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY:
|
||||
return true;
|
||||
case ConvertUtils.CONSUMER_TYPE_UID_BATTERY:
|
||||
if (mBatteryHistEntry.mIsHidden) {
|
||||
final int uid = (int) mBatteryHistEntry.mUid;
|
||||
if (mBatteryHistEntry.mIsHidden
|
||||
|| uid == BatteryUtils.UID_REMOVED_APPS
|
||||
|| uid == BatteryUtils.UID_TETHERING) {
|
||||
return true;
|
||||
}
|
||||
final boolean combineSystemComponents =
|
||||
mContext.getResources().getBoolean(
|
||||
R.bool.config_battery_combine_system_components);
|
||||
return combineSystemComponents && isSystemUid((int) mBatteryHistEntry.mUid);
|
||||
return combineSystemComponents && isSystemUid(uid);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -550,6 +550,10 @@ public class BatteryEntry {
|
||||
Drawable icon = context.getDrawable(R.drawable.ic_power_system);
|
||||
if (uid == 0) {
|
||||
name = context.getResources().getString(R.string.process_kernel_label);
|
||||
} else if (uid == BatteryUtils.UID_REMOVED_APPS) {
|
||||
name = context.getResources().getString(R.string.process_removed_apps);
|
||||
} else if (uid == BatteryUtils.UID_TETHERING) {
|
||||
name = context.getResources().getString(R.string.process_network_tethering);
|
||||
} else if ("mediaserver".equals(name)) {
|
||||
name = context.getResources().getString(R.string.process_mediaserver_label);
|
||||
} else if ("dex2oat".equals(name) || "dex2oat32".equals(name) ||
|
||||
|
@@ -65,6 +65,10 @@ import java.util.List;
|
||||
public class BatteryUtils {
|
||||
public static final int UID_NULL = -1;
|
||||
public static final int SDK_NULL = -1;
|
||||
/** Special UID value for data usage by removed apps. */
|
||||
public static final int UID_REMOVED_APPS = -4;
|
||||
/** Special UID value for data usage by tethering. */
|
||||
public static final int UID_TETHERING = -5;
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({StatusType.SCREEN_USAGE,
|
||||
@@ -188,7 +192,10 @@ public class BatteryUtils {
|
||||
*/
|
||||
boolean shouldHideUidBatteryConsumerUnconditionally(UidBatteryConsumer consumer,
|
||||
String[] packages) {
|
||||
return consumer.getUid() < 0 || isHiddenSystemModule(packages);
|
||||
final int uid = consumer.getUid();
|
||||
return uid == UID_TETHERING
|
||||
? false
|
||||
: uid < 0 || isHiddenSystemModule(packages);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user