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

Commit 540cc710 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Clarify this is a debug message only." into sc-dev am: 455cbb77

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13463980

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I7cab9872f87d27cba225e04d4cabf0ac24b7ceea
parents 6c5e4b84 455cbb77
Loading
Loading
Loading
Loading
+54 −46
Original line number Original line Diff line number Diff line
@@ -671,11 +671,7 @@ public final class ActiveServices {
        }
        }


        if (fgRequired) {
        if (fgRequired) {
            if (isFgsBgStart(r.mAllowStartForeground)) {
            logFgsBackgroundStart(r);
                if (!r.mLoggedInfoAllowStartForeground) {
                    Slog.wtf(TAG, "Background started FGS " + r.mInfoAllowStartForeground);
                    r.mLoggedInfoAllowStartForeground = true;
                }
            if (r.mAllowStartForeground == FGS_FEATURE_DENIED && isBgFgsRestrictionEnabled(r)) {
            if (r.mAllowStartForeground == FGS_FEATURE_DENIED && isBgFgsRestrictionEnabled(r)) {
                String msg = "startForegroundService() not allowed due to "
                String msg = "startForegroundService() not allowed due to "
                        + "mAllowStartForeground false: service "
                        + "mAllowStartForeground false: service "
@@ -700,7 +696,6 @@ public final class ActiveServices {
                return null;
                return null;
            }
            }
        }
        }
        }


        // If this is a direct-to-foreground start, make sure it is allowed as per the app op.
        // If this is a direct-to-foreground start, make sure it is allowed as per the app op.
        boolean forceSilentAbort = false;
        boolean forceSilentAbort = false;
@@ -1768,12 +1763,7 @@ public final class ActiveServices {
                }
                }


                if (!ignoreForeground) {
                if (!ignoreForeground) {
                    if (isFgsBgStart(r.mAllowStartForeground)) {
                    logFgsBackgroundStart(r);
                        if (!r.mLoggedInfoAllowStartForeground) {
                            Slog.wtf(TAG, "Background started FGS "
                                    + r.mInfoAllowStartForeground);
                            r.mLoggedInfoAllowStartForeground = true;
                        }
                    if (r.mAllowStartForeground == FGS_FEATURE_DENIED
                    if (r.mAllowStartForeground == FGS_FEATURE_DENIED
                            && isBgFgsRestrictionEnabled(r)) {
                            && isBgFgsRestrictionEnabled(r)) {
                        final String msg = "Service.startForeground() not allowed due to "
                        final String msg = "Service.startForeground() not allowed due to "
@@ -1789,7 +1779,6 @@ public final class ActiveServices {
                        }
                        }
                    }
                    }
                }
                }
                }


                // Apps under strict background restrictions simply don't get to have foreground
                // Apps under strict background restrictions simply don't get to have foreground
                // services, so now that we've enforced the startForegroundService() contract
                // services, so now that we've enforced the startForegroundService() contract
@@ -5732,4 +5721,23 @@ public final class ActiveServices {
        return mAm.mConstants.mFlagFgsStartRestrictionEnabled
        return mAm.mConstants.mFlagFgsStartRestrictionEnabled
                && CompatChanges.isChangeEnabled(FGS_BG_START_RESTRICTION_CHANGE_ID, r.appInfo.uid);
                && CompatChanges.isChangeEnabled(FGS_BG_START_RESTRICTION_CHANGE_ID, r.appInfo.uid);
    }
    }

    private void logFgsBackgroundStart(ServiceRecord r) {
        // Only log if FGS is started from background.
        if (!isFgsBgStart(r.mAllowStartForeground)) {
            return;
        }
        if (!r.mLoggedInfoAllowStartForeground) {
            final String msg = "Background started FGS: "
                    + ((r.mAllowStartForeground != FGS_FEATURE_DENIED) ? "Allowed " : "Disallowed ")
                    + r.mInfoAllowStartForeground;
            Slog.wtfQuiet(TAG, msg);
            if (r.mAllowStartForeground != FGS_FEATURE_DENIED) {
                Slog.i(TAG, msg);
            } else {
                Slog.w(TAG, msg);
            }
            r.mLoggedInfoAllowStartForeground = true;
        }
    }
}
}