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

Commit 77ff25af authored by Uma M Maradana's avatar Uma M Maradana Committed by Uma Maradana
Browse files

Fix powersave/powersave idle whitelist

Presently powersave/powersaveexceptidle whitelist
generated for only system user installed apps. In multi
user environment system/secondary user apps also required
to be whitelisted. Some apps disabled for system user and
enabled for non-system users, then those apps cannot be
whitelisted for powermode.  System config cannot read the
config other than system/etc, product/etc or vendor/etc
hence these partitions cannot be remounted in production
devices.
Hence to fix this need to enable to get the package info
for all users by adding filter with MATCH_ANY_USER.

Bug: 307334623

Test: Make system app installed for non-SYSTEM user and
      check that app whether it is whitelisted for power
      save/idle power save list.
Change-Id: I55a5a5ba8a01846ab4990589acf714c559310287
parent 8c7e75eb
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -2628,8 +2628,13 @@ public class DeviceIdleController extends SystemService
            for (int i=0; i<allowPowerExceptIdle.size(); i++) {
                String pkg = allowPowerExceptIdle.valueAt(i);
                try {
                    // On some devices (eg. HSUM), some apps may
                    // be not be pre-installed on user 0, but may be
                    // pre-installed on FULL users. Look for pre-installed system
                    // apps across all users to make sure they're properly
                    // allowlisted.
                    ApplicationInfo ai = pm.getApplicationInfo(pkg,
                            PackageManager.MATCH_SYSTEM_ONLY);
                            PackageManager.MATCH_ANY_USER | PackageManager.MATCH_SYSTEM_ONLY);
                    int appid = UserHandle.getAppId(ai.uid);
                    mPowerSaveWhitelistAppsExceptIdle.put(ai.packageName, appid);
                    mPowerSaveWhitelistSystemAppIdsExceptIdle.put(appid, true);
@@ -2640,8 +2645,13 @@ public class DeviceIdleController extends SystemService
            for (int i=0; i<allowPower.size(); i++) {
                String pkg = allowPower.valueAt(i);
                try {
                    // On some devices (eg. HSUM), some apps may
                    // be not be pre-installed on user 0, but may be
                    // pre-installed on FULL users. Look for pre-installed system
                    // apps across all users to make sure they're properly
                    // allowlisted.
                    ApplicationInfo ai = pm.getApplicationInfo(pkg,
                            PackageManager.MATCH_SYSTEM_ONLY);
                            PackageManager.MATCH_ANY_USER | PackageManager.MATCH_SYSTEM_ONLY);
                    int appid = UserHandle.getAppId(ai.uid);
                    // These apps are on both the whitelist-except-idle as well
                    // as the full whitelist, so they apply in all cases.