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

Commit 3023320d authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Fix issue #35309312: Background start not allowed: service..."

parents 908c4606 b1e7776e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -274,6 +274,11 @@ public abstract class PackageManagerInternal {

    public abstract void setExternalSourcesPolicy(ExternalSourcesPolicy policy);

    /**
     * Return true if the given package is a persistent app process.
     */
    public abstract boolean isPackagePersistent(String packageName);

    /**
     * Get all overlay packages for a user.
     * @param userId The user for which to get the overlays.
+4 −5
Original line number Diff line number Diff line
@@ -4227,7 +4227,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                            validateUid = mValidateUids.get(item.uid);
                            if (validateUid == null && change != UidRecord.CHANGE_GONE
                                    && change != UidRecord.CHANGE_GONE_IDLE) {
                                validateUid = new UidRecord(item.uid, false);
                                validateUid = new UidRecord(item.uid);
                                mValidateUids.put(item.uid, validateUid);
                            }
                        }
@@ -6335,7 +6335,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
        UidRecord uidRec = mActiveUids.get(proc.uid);
        if (uidRec == null) {
            uidRec = new UidRecord(proc.uid, proc.persistent);
            uidRec = new UidRecord(proc.uid);
            // This is the first appearance of the uid, report it now!
            if (DEBUG_UID_OBSERVERS) Slog.i(TAG_UID_OBSERVERS,
                    "Creating new process uid: " + uidRec);
@@ -8134,9 +8134,8 @@ public class ActivityManagerService extends IActivityManager.Stub
    // some other background operations are not.  If we're doing a check
    // of service-launch policy, allow those callers to proceed unrestricted.
    int appServicesRestrictedInBackgroundLocked(int uid, String packageName, int packageTargetSdk) {
        // Persistent app?  NB: expects that persistent uids are always active.
        final UidRecord appIdRec = mActiveUids.get(UserHandle.getAppId(uid));
        if (appIdRec != null && appIdRec.persistent) {
        // Persistent app?
        if (mPackageManagerInt.isPackagePersistent(packageName)) {
            if (DEBUG_BACKGROUND_CHECK) {
                Slog.i(TAG, "App " + uid + "/" + packageName
                        + " is persistent; not restricted in background");
+1 −3
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import android.util.TimeUtils;
 */
public final class UidRecord {
    final int uid;
    final boolean persistent;
    int curProcState;
    int setProcState = ActivityManager.PROCESS_STATE_NONEXISTENT;
    long lastBackgroundTime;
@@ -52,9 +51,8 @@ public final class UidRecord {

    ChangeItem pendingChange;

    public UidRecord(int _uid, boolean _persist) {
    public UidRecord(int _uid) {
        uid = _uid;
        persistent = _persist;
        reset();
    }

+12 −0
Original line number Diff line number Diff line
@@ -22790,6 +22790,18 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
            }
        }
        @Override
        public boolean isPackagePersistent(String packageName) {
            synchronized (mPackages) {
                PackageParser.Package pkg = mPackages.get(packageName);
                return pkg != null
                        ? ((pkg.applicationInfo.flags&(ApplicationInfo.FLAG_SYSTEM
                                        | ApplicationInfo.FLAG_PERSISTENT)) ==
                                (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_PERSISTENT))
                        : false;
            }
        }
        @Override
        public List<PackageInfo> getOverlayPackages(int userId) {
            final ArrayList<PackageInfo> overlayPackages = new ArrayList<PackageInfo>();