Merge "Add a device config for FGS denied notification." into sc-dev am: e06a55ba9f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14825247 Change-Id: Id1f2db054adb140b21c025cdd9bac7d30f4075c1
This commit is contained in:
@@ -6165,8 +6165,10 @@ public final class ActiveServices {
|
||||
&& code != REASON_UID_VISIBLE;
|
||||
}
|
||||
|
||||
// TODO: remove this notification after feature development is done
|
||||
private void showFgsBgRestrictedNotificationLocked(ServiceRecord r) {
|
||||
if (!mAm.mConstants.mFgsStartRestrictionNotificationEnabled /* default is false */) {
|
||||
return;
|
||||
}
|
||||
final Context context = mAm.mContext;
|
||||
final String title = "Foreground Service BG-Launch Restricted";
|
||||
final String content = "App restricted: " + r.mRecentCallingPackage;
|
||||
|
||||
@@ -197,6 +197,13 @@ final class ActivityManagerConstants extends ContentObserver {
|
||||
private static final String KEY_DEFAULT_FGS_STARTS_RESTRICTION_ENABLED =
|
||||
"default_fgs_starts_restriction_enabled";
|
||||
|
||||
/**
|
||||
* Default value for mFgsStartRestrictionNotificationEnabled if not explicitly set in
|
||||
* Settings.Global.
|
||||
*/
|
||||
private static final String KEY_DEFAULT_FGS_STARTS_RESTRICTION_NOTIFICATION_ENABLED =
|
||||
"default_fgs_starts_restriction_notification_enabled";
|
||||
|
||||
/**
|
||||
* Default value for mFgsStartRestrictionCheckCallerTargetSdk if not explicitly set in
|
||||
* Settings.Global.
|
||||
@@ -432,6 +439,10 @@ final class ActivityManagerConstants extends ContentObserver {
|
||||
// at all.
|
||||
volatile boolean mFlagFgsStartRestrictionEnabled = true;
|
||||
|
||||
// Whether to display a notification when a service is restricted from startForeground due to
|
||||
// foreground service background start restriction.
|
||||
volatile boolean mFgsStartRestrictionNotificationEnabled = false;
|
||||
|
||||
/**
|
||||
* Indicates whether the foreground service background start restriction is enabled for
|
||||
* caller app that is targeting S+.
|
||||
@@ -652,6 +663,9 @@ final class ActivityManagerConstants extends ContentObserver {
|
||||
case KEY_DEFAULT_FGS_STARTS_RESTRICTION_ENABLED:
|
||||
updateFgsStartsRestriction();
|
||||
break;
|
||||
case KEY_DEFAULT_FGS_STARTS_RESTRICTION_NOTIFICATION_ENABLED:
|
||||
updateFgsStartsRestrictionNotification();
|
||||
break;
|
||||
case KEY_DEFAULT_FGS_STARTS_RESTRICTION_CHECK_CALLER_TARGET_SDK:
|
||||
updateFgsStartsRestrictionCheckCallerTargetSdk();
|
||||
break;
|
||||
@@ -953,6 +967,13 @@ final class ActivityManagerConstants extends ContentObserver {
|
||||
/*defaultValue*/ true);
|
||||
}
|
||||
|
||||
private void updateFgsStartsRestrictionNotification() {
|
||||
mFgsStartRestrictionNotificationEnabled = DeviceConfig.getBoolean(
|
||||
DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
|
||||
KEY_DEFAULT_FGS_STARTS_RESTRICTION_NOTIFICATION_ENABLED,
|
||||
/*defaultValue*/ false);
|
||||
}
|
||||
|
||||
private void updateFgsStartsRestrictionCheckCallerTargetSdk() {
|
||||
mFgsStartRestrictionCheckCallerTargetSdk = DeviceConfig.getBoolean(
|
||||
DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
|
||||
@@ -1272,6 +1293,9 @@ final class ActivityManagerConstants extends ContentObserver {
|
||||
pw.print("="); pw.println(mFlagBackgroundFgsStartRestrictionEnabled);
|
||||
pw.print(" "); pw.print(KEY_DEFAULT_FGS_STARTS_RESTRICTION_ENABLED); pw.print("=");
|
||||
pw.println(mFlagFgsStartRestrictionEnabled);
|
||||
pw.print(" "); pw.print(KEY_DEFAULT_FGS_STARTS_RESTRICTION_NOTIFICATION_ENABLED);
|
||||
pw.print("=");
|
||||
pw.println(mFgsStartRestrictionNotificationEnabled);
|
||||
pw.print(" "); pw.print(KEY_DEFAULT_FGS_STARTS_RESTRICTION_CHECK_CALLER_TARGET_SDK);
|
||||
pw.print("="); pw.println(mFgsStartRestrictionCheckCallerTargetSdk);
|
||||
pw.print(" "); pw.print(KEY_FGS_ATOM_SAMPLE_RATE);
|
||||
|
||||
Reference in New Issue
Block a user