summaryrefslogtreecommitdiff
path: root/services/core/java/com/android/server/am/AppRestrictionController.java
diff options
context:
space:
mode:
Diffstat (limited to 'services/core/java/com/android/server/am/AppRestrictionController.java')
-rw-r--r--services/core/java/com/android/server/am/AppRestrictionController.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/am/AppRestrictionController.java b/services/core/java/com/android/server/am/AppRestrictionController.java
index e37d7b057986..6076eb1f69ee 100644
--- a/services/core/java/com/android/server/am/AppRestrictionController.java
+++ b/services/core/java/com/android/server/am/AppRestrictionController.java
@@ -1115,6 +1115,14 @@ public final class AppRestrictionController {
DEVICE_CONFIG_SUBNAMESPACE_PREFIX + "prompt_fgs_with_noti_on_long_running";
/**
+ * The behavior for an app with a FGS, when the system detects it's running for
+ * a very long time, should we prompt the user.
+ * {@code true} - we'll show the prompt to user, {@code false} - we'll not show it.
+ */
+ static final String KEY_BG_PROMPT_FGS_ON_LONG_RUNNING =
+ DEVICE_CONFIG_SUBNAMESPACE_PREFIX + "prompt_fgs_on_long_running";
+
+ /**
* The list of packages to be exempted from all these background restrictions.
*/
static final String KEY_BG_RESTRICTION_EXEMPTED_PACKAGES =
@@ -1154,6 +1162,11 @@ public final class AppRestrictionController {
static final boolean DEFAULT_BG_PROMPT_FGS_WITH_NOTIFICATION_ON_LONG_RUNNING = false;
/**
+ * Default value to {@link #mBgPromptFgsOnLongRunning}.
+ */
+ static final boolean DEFAULT_BG_PROMPT_FGS_ON_LONG_RUNNING = true;
+
+ /**
* Default value to {@link #mBgPromptFgsWithNotiToBgRestricted}.
*/
final boolean mDefaultBgPromptFgsWithNotiToBgRestricted;
@@ -1191,6 +1204,11 @@ public final class AppRestrictionController {
volatile boolean mBgPromptFgsWithNotiOnLongRunning;
/**
+ * @see #KEY_BG_PROMPT_FGS_ON_LONG_RUNNING.
+ */
+ volatile boolean mBgPromptFgsOnLongRunning;
+
+ /**
* @see #KEY_BG_PROMPT_ABUSIVE_APPS_TO_BG_RESTRICTED.
*/
volatile boolean mBgPromptAbusiveAppsToBgRestricted;
@@ -1228,6 +1246,9 @@ public final class AppRestrictionController {
case KEY_BG_PROMPT_FGS_WITH_NOTIFICATION_ON_LONG_RUNNING:
updateBgPromptFgsWithNotiOnLongRunning();
break;
+ case KEY_BG_PROMPT_FGS_ON_LONG_RUNNING:
+ updateBgPromptFgsOnLongRunning();
+ break;
case KEY_BG_PROMPT_ABUSIVE_APPS_TO_BG_RESTRICTED:
updateBgPromptAbusiveAppToBgRestricted();
break;
@@ -1269,6 +1290,7 @@ public final class AppRestrictionController {
updateBgLongFgsNotificationMinimalInterval();
updateBgPromptFgsWithNotiToBgRestricted();
updateBgPromptFgsWithNotiOnLongRunning();
+ updateBgPromptFgsOnLongRunning();
updateBgPromptAbusiveAppToBgRestricted();
updateBgRestrictionExemptedPackages();
}
@@ -1319,6 +1341,13 @@ public final class AppRestrictionController {
DEFAULT_BG_PROMPT_FGS_WITH_NOTIFICATION_ON_LONG_RUNNING);
}
+ private void updateBgPromptFgsOnLongRunning() {
+ mBgPromptFgsOnLongRunning = DeviceConfig.getBoolean(
+ DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
+ KEY_BG_PROMPT_FGS_ON_LONG_RUNNING,
+ DEFAULT_BG_PROMPT_FGS_ON_LONG_RUNNING);
+ }
+
private void updateBgPromptAbusiveAppToBgRestricted() {
mBgPromptAbusiveAppsToBgRestricted = DeviceConfig.getBoolean(
DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
@@ -1365,6 +1394,14 @@ public final class AppRestrictionController {
pw.print('=');
pw.println(mBgLongFgsNotificationMinIntervalMs);
pw.print(prefix);
+ pw.print(KEY_BG_PROMPT_FGS_ON_LONG_RUNNING);
+ pw.print('=');
+ pw.println(mBgPromptFgsOnLongRunning);
+ pw.print(prefix);
+ pw.print(KEY_BG_PROMPT_FGS_WITH_NOTIFICATION_ON_LONG_RUNNING);
+ pw.print('=');
+ pw.println(mBgPromptFgsWithNotiOnLongRunning);
+ pw.print(prefix);
pw.print(KEY_BG_PROMPT_FGS_WITH_NOTIFICATION_TO_BG_RESTRICTED);
pw.print('=');
pw.println(mBgPromptFgsWithNotiToBgRestricted);
@@ -2500,6 +2537,12 @@ public final class AppRestrictionController {
ActivityManager.isLowRamDeviceStatic(),
mBgController.getRestrictionLevel(uid));
PendingIntent pendingIntent;
+ if (!mBgController.mConstantsObserver.mBgPromptFgsOnLongRunning) {
+ if (DEBUG_BG_RESTRICTION_CONTROLLER) {
+ Slog.i(TAG, "Long-running FGS prompt is disabled.");
+ }
+ return;
+ }
if (!mBgController.mConstantsObserver.mBgPromptFgsWithNotiOnLongRunning
&& mBgController.hasForegroundServiceNotifications(packageName, uid)) {
if (DEBUG_BG_RESTRICTION_CONTROLLER) {