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:
ykhung
2022-05-04 23:57:15 +08:00
parent 3d1b6fd065
commit be10538a09
8 changed files with 71 additions and 6 deletions

View File

@@ -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);
}
/**