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

Commit de38aa10 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Treat fg service alarms like bg service alarms under FAS" into pi-dev

parents 47a8ecce da3dc921
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -3023,20 +3023,26 @@ class AlarmManagerService extends SystemService {
    }

    private boolean isBackgroundRestricted(Alarm alarm) {
        final boolean allowWhileIdle = (alarm.flags & FLAG_ALLOW_WHILE_IDLE) != 0;
        boolean exemptOnBatterySaver = (alarm.flags & FLAG_ALLOW_WHILE_IDLE) != 0;
        if (alarm.alarmClock != null) {
            // Don't block alarm clocks
            // Don't defer alarm clocks
            return false;
        }
        if (alarm.operation != null
                && (alarm.operation.isActivity() || alarm.operation.isForegroundService())) {
            // Don't block starting foreground components
        if (alarm.operation != null) {
            if (alarm.operation.isActivity()) {
                // Don't defer starting actual UI
                return false;
            }
            if (alarm.operation.isForegroundService()) {
                // FG service alarms are nearly as important; consult AST policy
                exemptOnBatterySaver = true;
            }
        }
        final String sourcePackage = alarm.sourcePackage;
        final int sourceUid = alarm.creatorUid;
        return (mAppStateTracker != null) &&
                mAppStateTracker.areAlarmsRestricted(sourceUid, sourcePackage, allowWhileIdle);
                mAppStateTracker.areAlarmsRestricted(sourceUid, sourcePackage,
                        exemptOnBatterySaver);
    }

    private native long init();
+2 −2
Original line number Diff line number Diff line
@@ -1056,9 +1056,9 @@ public class AppStateTracker {
     * @return whether alarms should be restricted for a UID package-name.
     */
    public boolean areAlarmsRestricted(int uid, @NonNull String packageName,
            boolean allowWhileIdle) {
            boolean isExemptOnBatterySaver) {
        return isRestricted(uid, packageName, /*useTempWhitelistToo=*/ false,
                /* exemptOnBatterySaver =*/ allowWhileIdle);
                isExemptOnBatterySaver);
    }

    /**