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

Commit 6cc3735a authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Fix issue #23581553: Ignore Battery Optimization not work for...

Merge "Fix issue #23581553: Ignore Battery Optimization not work for re-install app" into mnc-dr-dev
parents 5c18d051 1b79ad74
Loading
Loading
Loading
Loading
+20 −3
Original line number Original line Diff line number Diff line
@@ -242,6 +242,14 @@ public class DeviceIdleController extends SystemService
            if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {
            if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {
                int plugged = intent.getIntExtra("plugged", 0);
                int plugged = intent.getIntExtra("plugged", 0);
                updateChargingLocked(plugged != 0);
                updateChargingLocked(plugged != 0);
            } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) {
                if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
                    Uri data = intent.getData();
                    String ssp;
                    if (data != null && (ssp=data.getSchemeSpecificPart()) != null) {
                        removePowerSaveWhitelistAppInternal(ssp);
                    }
                }
            } else if (ACTION_STEP_IDLE_STATE.equals(intent.getAction())) {
            } else if (ACTION_STEP_IDLE_STATE.equals(intent.getAction())) {
                synchronized (DeviceIdleController.this) {
                synchronized (DeviceIdleController.this) {
                    stepIdleStateLocked();
                    stepIdleStateLocked();
@@ -912,6 +920,10 @@ public class DeviceIdleController extends SystemService
                filter.addAction(Intent.ACTION_BATTERY_CHANGED);
                filter.addAction(Intent.ACTION_BATTERY_CHANGED);
                filter.addAction(ACTION_STEP_IDLE_STATE);
                filter.addAction(ACTION_STEP_IDLE_STATE);
                getContext().registerReceiver(mReceiver, filter);
                getContext().registerReceiver(mReceiver, filter);
                filter = new IntentFilter();
                filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
                filter.addDataScheme("package");
                getContext().registerReceiver(mReceiver, filter);


                mLocalPowerManager.setDeviceIdleWhitelist(mPowerSaveWhitelistAllAppIdArray);
                mLocalPowerManager.setDeviceIdleWhitelist(mPowerSaveWhitelistAllAppIdArray);


@@ -924,7 +936,10 @@ public class DeviceIdleController extends SystemService
    public boolean addPowerSaveWhitelistAppInternal(String name) {
    public boolean addPowerSaveWhitelistAppInternal(String name) {
        synchronized (this) {
        synchronized (this) {
            try {
            try {
                ApplicationInfo ai = getContext().getPackageManager().getApplicationInfo(name, 0);
                ApplicationInfo ai = getContext().getPackageManager().getApplicationInfo(name,
                        PackageManager.GET_UNINSTALLED_PACKAGES
                                | PackageManager.GET_DISABLED_COMPONENTS
                                | PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS);
                if (mPowerSaveWhitelistUserApps.put(name, UserHandle.getAppId(ai.uid)) == null) {
                if (mPowerSaveWhitelistUserApps.put(name, UserHandle.getAppId(ai.uid)) == null) {
                    reportPowerSaveWhitelistChangedLocked();
                    reportPowerSaveWhitelistChangedLocked();
                    updateWhitelistAppIdsLocked();
                    updateWhitelistAppIdsLocked();
@@ -1518,7 +1533,6 @@ public class DeviceIdleController extends SystemService
            } catch (IOException e) {
            } catch (IOException e) {
            }
            }
        }
        }

    }
    }


    private void readConfigFileLocked(XmlPullParser parser) {
    private void readConfigFileLocked(XmlPullParser parser) {
@@ -1547,7 +1561,10 @@ public class DeviceIdleController extends SystemService
                    String name = parser.getAttributeValue(null, "n");
                    String name = parser.getAttributeValue(null, "n");
                    if (name != null) {
                    if (name != null) {
                        try {
                        try {
                            ApplicationInfo ai = pm.getApplicationInfo(name, 0);
                            ApplicationInfo ai = pm.getApplicationInfo(name,
                                    PackageManager.GET_UNINSTALLED_PACKAGES
                                            | PackageManager.GET_DISABLED_COMPONENTS
                                            | PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS);
                            mPowerSaveWhitelistUserApps.put(ai.packageName,
                            mPowerSaveWhitelistUserApps.put(ai.packageName,
                                    UserHandle.getAppId(ai.uid));
                                    UserHandle.getAppId(ai.uid));
                        } catch (PackageManager.NameNotFoundException e) {
                        } catch (PackageManager.NameNotFoundException e) {