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

Commit eead0246 authored by Christopher Tate's avatar Christopher Tate Committed by android-build-merger
Browse files

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

am: de38aa10

Change-Id: I055045bc4d6585fc507fe394f9f3ee21e1076a1b
parents 2b557beb de38aa10
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);
    }

    /**