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

Commit 738dd102 authored by Kunal's avatar Kunal
Browse files

Updating flag and updating usage of ProcessRecord directly instead of

fetching only from targetService

Bug: 296558535

Test: m and atest
Change-Id: Ide55667628332919b1562de0575cdf65a155b722
parent 40bfa5ab
Loading
Loading
Loading
Loading
+14 −10
Original line number Diff line number Diff line
@@ -8150,7 +8150,7 @@ public final class ActiveServices {
                BackgroundStartPrivileges.NONE);
        @ReasonCode int allowStartFgs = shouldAllowFgsStartForegroundNoBindingCheckLocked(
                allowWhileInUse, callingPid, callingUid, callingPackage, null /* targetService */,
                BackgroundStartPrivileges.NONE);
                BackgroundStartPrivileges.NONE, null);

        if (allowStartFgs == REASON_DENIED) {
            if (canBindingClientStartFgsLocked(callingUid) != null) {
@@ -8406,7 +8406,8 @@ public final class ActiveServices {
                                                allowWhileInUse2,
                                                clientPid, clientUid, clientPackageName,
                                                null /* targetService */,
                                                BackgroundStartPrivileges.NONE);
                                                BackgroundStartPrivileges.NONE,
                                                pr);
                                if (allowStartFgs != REASON_DENIED) {
                                    return new Pair<>(allowStartFgs, clientPackageName);
                                } else {
@@ -8443,7 +8444,7 @@ public final class ActiveServices {
        ActivityManagerService.FgsTempAllowListItem tempAllowListReason =
                r.mInfoTempFgsAllowListReason = mAm.isAllowlistedForFgsStartLOSP(callingUid);
        int ret = shouldAllowFgsStartForegroundNoBindingCheckLocked(allowWhileInUse, callingPid,
                callingUid, callingPackage, r, backgroundStartPrivileges);
                callingUid, callingPackage, r, backgroundStartPrivileges, null);

        // If an app (App 1) is bound by another app (App 2) that could start an FGS, then App 1
        // is also allowed to start an FGS. We check all the binding
@@ -8499,7 +8500,8 @@ public final class ActiveServices {
    private @ReasonCode int shouldAllowFgsStartForegroundNoBindingCheckLocked(
            @ReasonCode int allowWhileInUse, int callingPid, int callingUid, String callingPackage,
            @Nullable ServiceRecord targetService,
            BackgroundStartPrivileges backgroundStartPrivileges) {
            BackgroundStartPrivileges backgroundStartPrivileges,
            @Nullable ProcessRecord targetRecord) {
        int ret = allowWhileInUse;

        if (ret == REASON_DENIED) {
@@ -8561,13 +8563,15 @@ public final class ActiveServices {
        if (ret == REASON_DENIED) {
            // Flag check: are we disabling SAW FGS background starts?
            final boolean shouldDisableSaw = Flags.fgsDisableSaw()
                    && CompatChanges.isChangeEnabled(FGS_BOOT_COMPLETED_RESTRICTIONS, callingUid);
                    && CompatChanges.isChangeEnabled(FGS_SAW_RESTRICTIONS, callingUid);
            if (shouldDisableSaw) {
                final ProcessRecord processRecord = mAm
                        .getProcessRecordLocked(targetService.processName,
                                targetService.appInfo.uid);
                if (processRecord != null) {
                    if (processRecord.mState.hasOverlayUi()) {
                if (targetRecord == null) {
                    synchronized (mAm.mPidsSelfLocked) {
                        targetRecord = mAm.mPidsSelfLocked.get(callingPid);
                    }
                }
                if (targetRecord != null) {
                    if (targetRecord.mState.hasOverlayUi()) {
                        if (mAm.mAtmInternal.hasSystemAlertWindowPermission(callingUid, callingPid,
                                callingPackage)) {
                            ret = REASON_SYSTEM_ALERT_WINDOW_PERMISSION;