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

Commit 4d894275 authored by David Brazdil's avatar David Brazdil Committed by android-build-merger
Browse files

Merge "Do not update idle apps on OTA" into nyc-dev am: 70f08d9e

am: 7507efdd

* commit '7507efdd':
  Do not update idle apps on OTA

Change-Id: Ifb55449fa8c37f7dc782597f15890aed9277971d
parents 216f3328 7507efdd
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;
@@ -7011,11 +7012,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);
            }
@@ -7029,10 +7047,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 */,
@@ -7040,7 +7054,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;