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

Commit 5465402e authored by Chris Tate's avatar Chris Tate Committed by android-build-merger
Browse files

Merge "Tie FAS service-start to the same idleness state as O+ bg restrictions" into pi-dev

am: 590ef18e

Change-Id: I938a015357e69257c4d56c5b93088b842b269d00
parents 1729947c 590ef18e
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -422,13 +422,9 @@ public final class ActiveServices {
        }

        // If we're starting indirectly (e.g. from PendingIntent), figure out whether
        // we're launching into an app in a background state.
        final int uidState = mAm.getUidStateLocked(r.appInfo.uid);
        if (DEBUG_SERVICE) {
            Slog.v(TAG_SERVICE, "Uid state " + uidState + " indirect starting " + r.shortName);
        }
        final boolean bgLaunch = (uidState >
                ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND);
        // we're launching into an app in a background state.  This keys off of the same
        // idleness state tracking as e.g. O+ background service start policy.
        final boolean bgLaunch = !mAm.isUidActiveLocked(r.appInfo.uid);

        // If the app has strict background restrictions, we treat any bg service
        // start analogously to the legacy-app forced-restrictions case, regardless
@@ -1197,10 +1193,13 @@ public final class ActiveServices {

                if (!ignoreForeground &&
                        appRestrictedAnyInBackground(r.appInfo.uid, r.packageName)) {
                    ignoreForeground = true;
                    Slog.w(TAG,
                            "Service.startForeground() not allowed due to bg restriction: service "
                            + r.shortName);
                    // Back off of any foreground expectations around this service, since we've
                    // just turned down its fg request.
                    updateServiceForegroundLocked(r.app, false);
                    ignoreForeground = true;
                }

                // Apps under strict background restrictions simply don't get to have foreground
+1 −2
Original line number Diff line number Diff line
@@ -26500,8 +26500,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        @Override
        public boolean isUidActive(int uid) {
            synchronized (ActivityManagerService.this) {
                final UidRecord uidRec = mActiveUids.get(uid);
                return (uidRec != null) && !uidRec.idle;
                return isUidActiveLocked(uid);
            }
        }