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

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

Merge "Only check bg restriction if an app is idle" into pi-dev

parents 64bbb201 7926e688
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -8694,7 +8694,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    }
    @Override
    public boolean isAppForeground(int uid) throws RemoteException {
    public boolean isAppForeground(int uid) {
        synchronized (this) {
            UidRecord uidRec = mActiveUids.get(uid);
            if (uidRec == null || uidRec.idle) {
@@ -14162,13 +14162,17 @@ public class ActivityManagerService extends IActivityManager.Stub
    public boolean isUidActive(int uid, String callingPackage) {
        if (!hasUsageStatsPermission(callingPackage)) {
            enforceCallingPermission(android.Manifest.permission.PACKAGE_USAGE_STATS,
                    "getPackageProcessState");
                    "isUidActive");
        }
        synchronized (this) {
            return isUidActiveLocked(uid);
        }
    }
    boolean isUidActiveLocked(int uid) {
        final UidRecord uidRecord = mActiveUids.get(uid);
        return uidRecord != null && !uidRecord.setIdle;
    }
    }
    @Override
    public boolean convertFromTranslucent(IBinder token) {
@@ -21153,6 +21157,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                }
            }
            if (brOptions.isDontSendToRestrictedApps()
                    && !isUidActiveLocked(callingUid)
                    && isBackgroundRestrictedNoCheck(callingUid, callerPackage)) {
                Slog.i(TAG, "Not sending broadcast " + action + " - app " + callerPackage
                        + " has background restrictions");