Loading services/core/java/com/android/server/am/ActiveServices.java +26 −12 Original line number Diff line number Diff line Loading @@ -558,11 +558,18 @@ public final class ActiveServices { } if (r.mAllowStartForeground == FGS_FEATURE_DENIED && mAm.mConstants.mFlagFgsStartRestrictionEnabled) { if (mAm.mConstants.mFlagFgsStartTempAllowListEnabled && mAm.isOnDeviceIdleWhitelistLocked(r.appInfo.uid, false)) { // uid is on DeviceIdleController's allowlist. Slog.d(TAG, "startForegroundService() mAllowStartForeground false " + "but allowlist true: service " + r.shortInstanceName); } else { Slog.w(TAG, "startForegroundService() not allowed due to " + "mAllowStartForeground false: service " + r.shortInstanceName); showFgsBgRestrictedNotificationLocked(r); forcedStandby = true; return null; } } } } Loading Loading @@ -1462,8 +1469,14 @@ public final class ActiveServices { } if (r.mAllowStartForeground == FGS_FEATURE_DENIED && mAm.mConstants.mFlagFgsStartRestrictionEnabled) { Slog.w(TAG, "Service.startForeground() not allowed due to " if (mAm.mConstants.mFlagFgsStartTempAllowListEnabled && mAm.isOnDeviceIdleWhitelistLocked(r.appInfo.uid, false)) { // uid is on DeviceIdleController's allowlist. Slog.d(TAG, "Service.startForeground() " + "mAllowStartForeground false but allowlist true: service " + r.shortInstanceName); } else { Slog.w(TAG, "Service.startForeground() not allowed due to " + "mAllowStartForeground false: service " + r.shortInstanceName); showFgsBgRestrictedNotificationLocked(r); Loading @@ -1472,6 +1485,7 @@ 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 services/core/java/com/android/server/am/ActivityManagerConstants.java +21 −0 Original line number Diff line number Diff line Loading @@ -161,6 +161,13 @@ final class ActivityManagerConstants extends ContentObserver { private static final String KEY_DEFAULT_FGS_STARTS_RESTRICTION_ENABLED = "default_fgs_starts_restriction_enabled"; /** * Default value for mFlagFgsStartTempAllowListEnabled if not explicitly set in * Settings.Global. */ private static final String KEY_DEFAULT_FGS_STARTS_TEMP_ALLOWLIST_ENABLED = "default_fgs_starts_temp_allowlist_enabled"; // Maximum number of cached processes we will allow. public int MAX_CACHED_PROCESSES = DEFAULT_MAX_CACHED_PROCESSES; Loading Loading @@ -321,6 +328,10 @@ final class ActivityManagerConstants extends ContentObserver { // at all. volatile boolean mFlagFgsStartRestrictionEnabled = false; // When the foreground service background start restriction is enabled, if the app in // DeviceIdleController's Temp AllowList is allowed to bypass the restriction. volatile boolean mFlagFgsStartTempAllowListEnabled = false; private final ActivityManagerService mService; private ContentResolver mResolver; private final KeyValueListParser mParser = new KeyValueListParser(','); Loading Loading @@ -472,6 +483,9 @@ final class ActivityManagerConstants extends ContentObserver { case KEY_DEFAULT_FGS_STARTS_RESTRICTION_ENABLED: updateFgsStartsRestriction(); break; case KEY_DEFAULT_FGS_STARTS_TEMP_ALLOWLIST_ENABLED: updateFgsStartsTempAllowList(); break; case KEY_OOMADJ_UPDATE_POLICY: updateOomAdjUpdatePolicy(); break; Loading Loading @@ -724,6 +738,13 @@ final class ActivityManagerConstants extends ContentObserver { /*defaultValue*/ false); } private void updateFgsStartsTempAllowList() { mFlagFgsStartTempAllowListEnabled = DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, KEY_DEFAULT_FGS_STARTS_TEMP_ALLOWLIST_ENABLED, /*defaultValue*/ false); } private void updateOomAdjUpdatePolicy() { OOMADJ_UPDATE_QUICK = DeviceConfig.getInt( DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, Loading Loading
services/core/java/com/android/server/am/ActiveServices.java +26 −12 Original line number Diff line number Diff line Loading @@ -558,11 +558,18 @@ public final class ActiveServices { } if (r.mAllowStartForeground == FGS_FEATURE_DENIED && mAm.mConstants.mFlagFgsStartRestrictionEnabled) { if (mAm.mConstants.mFlagFgsStartTempAllowListEnabled && mAm.isOnDeviceIdleWhitelistLocked(r.appInfo.uid, false)) { // uid is on DeviceIdleController's allowlist. Slog.d(TAG, "startForegroundService() mAllowStartForeground false " + "but allowlist true: service " + r.shortInstanceName); } else { Slog.w(TAG, "startForegroundService() not allowed due to " + "mAllowStartForeground false: service " + r.shortInstanceName); showFgsBgRestrictedNotificationLocked(r); forcedStandby = true; return null; } } } } Loading Loading @@ -1462,8 +1469,14 @@ public final class ActiveServices { } if (r.mAllowStartForeground == FGS_FEATURE_DENIED && mAm.mConstants.mFlagFgsStartRestrictionEnabled) { Slog.w(TAG, "Service.startForeground() not allowed due to " if (mAm.mConstants.mFlagFgsStartTempAllowListEnabled && mAm.isOnDeviceIdleWhitelistLocked(r.appInfo.uid, false)) { // uid is on DeviceIdleController's allowlist. Slog.d(TAG, "Service.startForeground() " + "mAllowStartForeground false but allowlist true: service " + r.shortInstanceName); } else { Slog.w(TAG, "Service.startForeground() not allowed due to " + "mAllowStartForeground false: service " + r.shortInstanceName); showFgsBgRestrictedNotificationLocked(r); Loading @@ -1472,6 +1485,7 @@ 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
services/core/java/com/android/server/am/ActivityManagerConstants.java +21 −0 Original line number Diff line number Diff line Loading @@ -161,6 +161,13 @@ final class ActivityManagerConstants extends ContentObserver { private static final String KEY_DEFAULT_FGS_STARTS_RESTRICTION_ENABLED = "default_fgs_starts_restriction_enabled"; /** * Default value for mFlagFgsStartTempAllowListEnabled if not explicitly set in * Settings.Global. */ private static final String KEY_DEFAULT_FGS_STARTS_TEMP_ALLOWLIST_ENABLED = "default_fgs_starts_temp_allowlist_enabled"; // Maximum number of cached processes we will allow. public int MAX_CACHED_PROCESSES = DEFAULT_MAX_CACHED_PROCESSES; Loading Loading @@ -321,6 +328,10 @@ final class ActivityManagerConstants extends ContentObserver { // at all. volatile boolean mFlagFgsStartRestrictionEnabled = false; // When the foreground service background start restriction is enabled, if the app in // DeviceIdleController's Temp AllowList is allowed to bypass the restriction. volatile boolean mFlagFgsStartTempAllowListEnabled = false; private final ActivityManagerService mService; private ContentResolver mResolver; private final KeyValueListParser mParser = new KeyValueListParser(','); Loading Loading @@ -472,6 +483,9 @@ final class ActivityManagerConstants extends ContentObserver { case KEY_DEFAULT_FGS_STARTS_RESTRICTION_ENABLED: updateFgsStartsRestriction(); break; case KEY_DEFAULT_FGS_STARTS_TEMP_ALLOWLIST_ENABLED: updateFgsStartsTempAllowList(); break; case KEY_OOMADJ_UPDATE_POLICY: updateOomAdjUpdatePolicy(); break; Loading Loading @@ -724,6 +738,13 @@ final class ActivityManagerConstants extends ContentObserver { /*defaultValue*/ false); } private void updateFgsStartsTempAllowList() { mFlagFgsStartTempAllowListEnabled = DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, KEY_DEFAULT_FGS_STARTS_TEMP_ALLOWLIST_ENABLED, /*defaultValue*/ false); } private void updateOomAdjUpdatePolicy() { OOMADJ_UPDATE_QUICK = DeviceConfig.getInt( DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, Loading