Loading services/core/java/com/android/server/am/ActiveServices.java +54 −46 Original line number Diff line number Diff line Loading @@ -671,11 +671,7 @@ public final class ActiveServices { } if (fgRequired) { if (isFgsBgStart(r.mAllowStartForeground)) { if (!r.mLoggedInfoAllowStartForeground) { Slog.wtf(TAG, "Background started FGS " + r.mInfoAllowStartForeground); r.mLoggedInfoAllowStartForeground = true; } logFgsBackgroundStart(r); if (r.mAllowStartForeground == FGS_FEATURE_DENIED && isBgFgsRestrictionEnabled(r)) { String msg = "startForegroundService() not allowed due to " + "mAllowStartForeground false: service " Loading @@ -700,7 +696,6 @@ public final class ActiveServices { return null; } } } // If this is a direct-to-foreground start, make sure it is allowed as per the app op. boolean forceSilentAbort = false; Loading Loading @@ -1768,12 +1763,7 @@ public final class ActiveServices { } if (!ignoreForeground) { if (isFgsBgStart(r.mAllowStartForeground)) { if (!r.mLoggedInfoAllowStartForeground) { Slog.wtf(TAG, "Background started FGS " + r.mInfoAllowStartForeground); r.mLoggedInfoAllowStartForeground = true; } logFgsBackgroundStart(r); if (r.mAllowStartForeground == FGS_FEATURE_DENIED && isBgFgsRestrictionEnabled(r)) { final String msg = "Service.startForeground() not allowed due to " Loading @@ -1789,7 +1779,6 @@ public final class ActiveServices { } } } } // Apps under strict background restrictions simply don't get to have foreground // services, so now that we've enforced the startForegroundService() contract Loading Loading @@ -5732,4 +5721,23 @@ public final class ActiveServices { return mAm.mConstants.mFlagFgsStartRestrictionEnabled && 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; } } } Loading
services/core/java/com/android/server/am/ActiveServices.java +54 −46 Original line number Diff line number Diff line Loading @@ -671,11 +671,7 @@ public final class ActiveServices { } if (fgRequired) { if (isFgsBgStart(r.mAllowStartForeground)) { if (!r.mLoggedInfoAllowStartForeground) { Slog.wtf(TAG, "Background started FGS " + r.mInfoAllowStartForeground); r.mLoggedInfoAllowStartForeground = true; } logFgsBackgroundStart(r); if (r.mAllowStartForeground == FGS_FEATURE_DENIED && isBgFgsRestrictionEnabled(r)) { String msg = "startForegroundService() not allowed due to " + "mAllowStartForeground false: service " Loading @@ -700,7 +696,6 @@ public final class ActiveServices { return null; } } } // If this is a direct-to-foreground start, make sure it is allowed as per the app op. boolean forceSilentAbort = false; Loading Loading @@ -1768,12 +1763,7 @@ public final class ActiveServices { } if (!ignoreForeground) { if (isFgsBgStart(r.mAllowStartForeground)) { if (!r.mLoggedInfoAllowStartForeground) { Slog.wtf(TAG, "Background started FGS " + r.mInfoAllowStartForeground); r.mLoggedInfoAllowStartForeground = true; } logFgsBackgroundStart(r); if (r.mAllowStartForeground == FGS_FEATURE_DENIED && isBgFgsRestrictionEnabled(r)) { final String msg = "Service.startForeground() not allowed due to " Loading @@ -1789,7 +1779,6 @@ public final class ActiveServices { } } } } // Apps under strict background restrictions simply don't get to have foreground // services, so now that we've enforced the startForegroundService() contract Loading Loading @@ -5732,4 +5721,23 @@ public final class ActiveServices { return mAm.mConstants.mFlagFgsStartRestrictionEnabled && 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; } } }