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

Commit 4e48452a authored by Kweku Adams's avatar Kweku Adams Committed by Automerger Merge Worker
Browse files

Merge "Disallow long regular jobs in Doze and battery saver." into sc-dev am: 94691f3c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13701627

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I35ad872ef1ed5477e2ecebc26f50691343de9421
parents aa77661b 94691f3c
Loading
Loading
Loading
Loading
+11 −9
Original line number Original line Diff line number Diff line
@@ -753,13 +753,22 @@ class JobConcurrencyManager {
            return null;
            return null;
        }
        }


        // We're over the minimum guaranteed runtime. Stop the job if we're over config limits,
        // there are pending jobs that could replace this one, or the device state is not conducive
        // to long runs.

        if (mPowerManager.isPowerSaveMode()) {
            return "battery saver";
        }
        if (mPowerManager.isDeviceIdleMode()) {
            return "deep doze";
        }

        // Update config in case memory usage has changed significantly.
        // Update config in case memory usage has changed significantly.
        updateCounterConfigLocked();
        updateCounterConfigLocked();


        @WorkType final int workType = context.getRunningJobWorkType();
        @WorkType final int workType = context.getRunningJobWorkType();


        // We're over the minimum guaranteed runtime. Stop the job if we're over config limits or
        // there are pending jobs that could replace this one.
        if (mRunningJobs.size() > mWorkTypeConfig.getMaxTotal()
        if (mRunningJobs.size() > mWorkTypeConfig.getMaxTotal()
                || mWorkCountTracker.isOverTypeLimit(workType)) {
                || mWorkCountTracker.isOverTypeLimit(workType)) {
            return "too many jobs running";
            return "too many jobs running";
@@ -786,13 +795,6 @@ class JobConcurrencyManager {
                    return "blocking " + workTypeToString(workType) + " queue";
                    return "blocking " + workTypeToString(workType) + " queue";
                }
                }
            }
            }

            if (mPowerManager.isPowerSaveMode()) {
                return "battery saver";
            }
            if (mPowerManager.isDeviceIdleMode()) {
                return "deep doze";
            }
        }
        }


        // Easy check. If there are pending jobs of the same work type, then we know that
        // Easy check. If there are pending jobs of the same work type, then we know that