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

Commit d932c418 authored by Keith Cheung's avatar Keith Cheung Committed by android-build-merger
Browse files

Merge "Include work app in battery optimization settings" into nyc-dev

am: 9b167a68

* commit '9b167a68':
  Include work app in battery optimization settings

Change-Id: I9998aecbbd7acea6222aa65c6928864b5ea4cd5f
parents ec2516dc 9b167a68
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -56,7 +56,7 @@ public class AppStatePowerBridge extends AppStateBaseBridge {
    }
    }


    public static final AppFilter FILTER_POWER_WHITELISTED = new CompoundFilter(
    public static final AppFilter FILTER_POWER_WHITELISTED = new CompoundFilter(
            ApplicationsState.FILTER_PERSONAL_WITHOUT_DISABLED_UNTIL_USED, new AppFilter() {
            ApplicationsState.FILTER_WITHOUT_DISABLED_UNTIL_USED, new AppFilter() {
        @Override
        @Override
        public void init() {
        public void init() {
        }
        }
+41 −3
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import android.app.Application;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageItemInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.icu.text.AlphabeticIndex;
import android.icu.text.AlphabeticIndex;
import android.os.*;
import android.os.*;
@@ -138,7 +139,7 @@ public class ManageApplications extends InstrumentedFragment
    // This is the string labels for the filter modes above, the order must be kept in sync.
    // This is the string labels for the filter modes above, the order must be kept in sync.
    public static final int[] FILTER_LABELS = new int[]{
    public static final int[] FILTER_LABELS = new int[]{
            R.string.high_power_filter_on, // High power whitelist, on
            R.string.high_power_filter_on, // High power whitelist, on
            R.string.filter_all_apps,      // All apps label, but personal filter (for high power);
            R.string.filter_all_apps,      // Without disabled until used
            R.string.filter_all_apps,      // All apps
            R.string.filter_all_apps,      // All apps
            R.string.filter_enabled_apps,  // Enabled
            R.string.filter_enabled_apps,  // Enabled
            R.string.filter_apps_disabled, // Disabled
            R.string.filter_apps_disabled, // Disabled
@@ -159,8 +160,8 @@ public class ManageApplications extends InstrumentedFragment
    public static final AppFilter[] FILTERS = new AppFilter[]{
    public static final AppFilter[] FILTERS = new AppFilter[]{
            new CompoundFilter(AppStatePowerBridge.FILTER_POWER_WHITELISTED,
            new CompoundFilter(AppStatePowerBridge.FILTER_POWER_WHITELISTED,
                    ApplicationsState.FILTER_ALL_ENABLED),     // High power whitelist, on
                    ApplicationsState.FILTER_ALL_ENABLED),     // High power whitelist, on
            new CompoundFilter(ApplicationsState.FILTER_PERSONAL_WITHOUT_DISABLED_UNTIL_USED,
            new CompoundFilter(ApplicationsState.FILTER_WITHOUT_DISABLED_UNTIL_USED,
                    ApplicationsState.FILTER_ALL_ENABLED),     // All apps label, but personal filter
                    ApplicationsState.FILTER_ALL_ENABLED),     // Without disabled until used
            ApplicationsState.FILTER_EVERYTHING,  // All apps
            ApplicationsState.FILTER_EVERYTHING,  // All apps
            ApplicationsState.FILTER_ALL_ENABLED, // Enabled
            ApplicationsState.FILTER_ALL_ENABLED, // Enabled
            ApplicationsState.FILTER_DISABLED,    // Disabled
            ApplicationsState.FILTER_DISABLED,    // Disabled
@@ -901,9 +902,46 @@ public class ManageApplications extends InstrumentedFragment
                // Don't have new list yet, but can continue using the old one.
                // Don't have new list yet, but can continue using the old one.
                return;
                return;
            }
            }
            if (mFilterMode == FILTER_APPS_POWER_WHITELIST ||
                mFilterMode == FILTER_APPS_POWER_WHITELIST_ALL) {
                entries = removeDuplicateIgnoringUser(entries);
            }
            onRebuildComplete(entries);
            onRebuildComplete(entries);
        }
        }



        static private boolean packageNameEquals(PackageItemInfo info1, PackageItemInfo info2) {
            if (info1 == null || info2 == null) {
                return false;
            }
            if (info1.packageName == null || info2.packageName == null) {
                return false;
            }
            return info1.packageName.equals(info2.packageName);
        }

        private ArrayList<ApplicationsState.AppEntry> removeDuplicateIgnoringUser(
                ArrayList<ApplicationsState.AppEntry> entries)
        {
            int size = entries.size();
            // returnList will not have more entries than entries
            ArrayList<ApplicationsState.AppEntry> returnEntries = new
                    ArrayList<ApplicationsState.AppEntry>(size);

            // assume appinfo of same package but different users are grouped together
            PackageItemInfo lastInfo = null;
            for (int i = 0; i < size; i++) {
                AppEntry appEntry = entries.get(i);
                PackageItemInfo info = appEntry.info;
                if (!packageNameEquals(lastInfo, appEntry.info)) {
                    returnEntries.add(appEntry);
                }
                lastInfo = info;
            }
            returnEntries.trimToSize();
            return returnEntries;
        }

        @Override
        @Override
        public void onRebuildComplete(ArrayList<AppEntry> entries) {
        public void onRebuildComplete(ArrayList<AppEntry> entries) {
            mBaseEntries = entries;
            mBaseEntries = entries;