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

Commit 70f08d9e authored by David Brazdil's avatar David Brazdil Committed by Android (Google) Code Review
Browse files

Merge "Do not update idle apps on OTA" into nyc-dev

parents d1519107 ae4cde1c
Loading
Loading
Loading
Loading
+23 −10
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ import android.app.admin.DevicePolicyManagerInternal;
import android.app.admin.IDevicePolicyManager;
import android.app.admin.SecurityLog;
import android.app.backup.IBackupManager;
import android.app.usage.UsageStatsManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -7005,11 +7006,28 @@ public class PackageManagerService extends IPackageManager.Stub {
            pkgs = PackageManagerServiceUtils.getPackagesForDexopt(mPackages.values(), this);
        }
        UsageStatsManager usageMgr =
                (UsageStatsManager) mContext.getSystemService(Context.USAGE_STATS_SERVICE);
        int curr = 0;
        int total = pkgs.size();
        for (PackageParser.Package pkg : pkgs) {
            curr++;
            if (!PackageDexOptimizer.canOptimizePackage(pkg)) {
                if (DEBUG_DEXOPT) {
                    Log.i(TAG, "Skipping update of of non-optimizable app " + pkg.packageName);
                }
                continue;
            }
            if (!causeFirstBoot && usageMgr.isAppInactive(pkg.packageName)) {
                if (DEBUG_DEXOPT) {
                    Log.i(TAG, "Skipping update of of idle app " + pkg.packageName);
                }
                continue;
            }
            if (DEBUG_DEXOPT) {
                Log.i(TAG, "Extracting app " + curr + " of " + total + ": " + pkg.packageName);
            }
@@ -7023,10 +7041,6 @@ public class PackageManagerService extends IPackageManager.Stub {
                }
            }
            if (PackageDexOptimizer.canOptimizePackage(pkg)) {
                // If the cache was pruned, any compiled odex files will likely be out of date
                // and would have to be patched (would be SELF_PATCHOAT, which is deprecated).
                // Instead, force the extraction in this case.
            performDexOpt(pkg.packageName,
                    null /* instructionSet */,
                    false /* checkProfiles */,
@@ -7034,7 +7048,6 @@ public class PackageManagerService extends IPackageManager.Stub {
                    false /* force */);
        }
    }
    }
    @Override
    public void notifyPackageUse(String packageName) {
+23 −18
Original line number Diff line number Diff line
@@ -144,6 +144,7 @@ public class UsageStatsService extends SystemService implements
    private long mLastAppIdleParoledTime;

    private volatile boolean mPendingOneTimeCheckIdleStates;
    private boolean mSystemServicesReady = false;

    @GuardedBy("mLock")
    private AppIdleHistory mAppIdleHistory;
@@ -232,6 +233,8 @@ public class UsageStatsService extends SystemService implements
            if (mPendingOneTimeCheckIdleStates) {
                postOneTimeCheckIdleStates();
            }

            mSystemServicesReady = true;
        } else if (phase == PHASE_BOOT_COMPLETED) {
            setAppIdleParoled(getContext().getSystemService(BatteryManager.class).isCharging());
        }
@@ -810,6 +813,7 @@ public class UsageStatsService extends SystemService implements
            // retain this for safety).
            return false;
        }
        if (mSystemServicesReady) {
            try {
                // We allow all whitelisted apps, including those that don't want to be whitelisted
                // for idle mode, because app idle (aka app standby) is really not as big an issue
@@ -833,6 +837,7 @@ public class UsageStatsService extends SystemService implements
                    && mAppWidgetManager.isBoundWidgetPackage(packageName, userId)) {
                return false;
            }
        }

        if (!isAppIdleUnfiltered(packageName, userId, elapsedRealtime)) {
            return false;