Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 434009d7 authored by YK Hung's avatar YK Hung Committed by Android (Google) Code Review
Browse files

Merge "Support special tethering and removed apps UID in the usage list" into tm-dev

parents afe6d302 be10538a
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -6627,10 +6627,14 @@
    <!-- Menu label for refreshing with latest usage numbers -->
    <string name="menu_stats_refresh">Refresh</string>
    <!-- Label for mediaserver process in battery usage -->
    <!-- Label for mediaserver process in battery usage [CHAR_LIMIT=NONE] -->
    <string name="process_mediaserver_label">Mediaserver</string>
    <!-- Label for dex2oat process in battery usage used for the optimization of one or more apps -->
    <string name="process_dex2oat_label">App optimization</string>
    <!-- Label for network tethering UID label in battery usage [CHAR_LIMIT=NONE] -->
    <string name="process_network_tethering">Tethering</string>
    <!-- Label for removed apps UID lablel in battery usage [CHAR_LIMIT=NONE] -->
    <string name="process_removed_apps">Removed apps</string>
    <!-- Battery saver: Label for feature, title + menu item [CHAR_LIMIT=40] -->
    <string name="battery_saver">Battery Saver</string>
+4 −1
Original line number Diff line number Diff line
@@ -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);
+5 −2
Original line number Diff line number Diff line
@@ -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;
    }
+4 −0
Original line number Diff line number Diff line
@@ -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) ||
+8 −1
Original line number Diff line number Diff line
@@ -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);
    }

    /**
Loading