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

Commit 0d36a90c authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Relax bg->fgs restriction for system initiated transitions." into main

parents f288adce d4306ec9
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -1033,8 +1033,9 @@ public final class ActiveServices {
        }

        if (fgRequired) {
            logFgsBackgroundStart(r);
            if (!r.isFgsAllowedStart() && isBgFgsRestrictionEnabled(r, callingUid)) {
            boolean isBgFgsRestrictionEnabledForService =  isBgFgsRestrictionEnabled(r, callingUid);
            logFgsBackgroundStart(r, isBgFgsRestrictionEnabledForService);
            if (!r.isFgsAllowedStart() && isBgFgsRestrictionEnabledForService) {
                String msg = "startForegroundService() not allowed due to "
                        + "mAllowStartForeground false: service "
                        + r.shortInstanceName;
@@ -2292,8 +2293,10 @@ public final class ActiveServices {
                }

                // Whether FGS-BG-start restriction is enabled for this service.
                final boolean isBgFgsRestrictionEnabledForService = isBgFgsRestrictionEnabled(r,
                        callingUidIfStart);
                // Valid only if not system initiated tranistion.
                final boolean isBgFgsRestrictionEnabledForService =
                        (!systemRequestedTransition && isBgFgsRestrictionEnabled(r,
                                callingUidIfStart));

                // Whether to extend the SHORT_SERVICE time out.
                boolean extendShortServiceTimeout = false;
@@ -2549,7 +2552,7 @@ public final class ActiveServices {
                    }
                    r.maybeLogFgsLogicChange();
                    if (!bypassBfslCheck) {
                        logFgsBackgroundStart(r);
                        logFgsBackgroundStart(r, isBgFgsRestrictionEnabledForService);
                        if (!r.isFgsAllowedStart()
                                && isBgFgsRestrictionEnabledForService) {
                            final String msg = "Service.startForeground() not allowed due to "
@@ -8984,7 +8987,7 @@ public final class ActiveServices {
        return true;
    }

    private void logFgsBackgroundStart(ServiceRecord r) {
    private void logFgsBackgroundStart(ServiceRecord r, boolean isBgFgsRestrictedForService) {
        /*
        // Only log if FGS is started from background.
        if (!isFgsBgStart(r.mAllowStartForeground)) {
@@ -8993,7 +8996,8 @@ public final class ActiveServices {
        */
        if (!r.mLoggedInfoAllowStartForeground) {
            final String msg = "Background started FGS: "
                    + (r.isFgsAllowedStart() ? "Allowed " : "Disallowed ")
                    + (r.isFgsAllowedStart() || !isBgFgsRestrictedForService ? "Allowed "
                    : "Disallowed ")
                    + r.mInfoAllowStartForeground
                    + (r.isShortFgs() ? " (Called on SHORT_SERVICE)" : "");
            if (r.isFgsAllowedStart()) {
@@ -9003,11 +9007,7 @@ public final class ActiveServices {
                }
                Slog.i(TAG, msg);
            } else {
                //if (ActivityManagerUtils.shouldSamplePackageForAtom(r.packageName,
                //        mAm.mConstants.mFgsStartDeniedLogSampleRate)) {
                    Slog.wtfQuiet(TAG, msg);
                //}
                Slog.w(TAG, msg);
                Slog.wtf(TAG, msg);
            }
            r.mLoggedInfoAllowStartForeground = true;
        }