From b739fa6a9e1f4130440efd1a3cfef6fd5963d0ff Mon Sep 17 00:00:00 2001 From: Lyn Han Date: Thu, 27 Jun 2019 18:41:11 -0700 Subject: Global bubble settings Background: Bubble settings have the following levels - Global (developer options flag) - App-level - Channel-level Issue: Global settings do not propagate to the work profile user because we are storing NOTIFICATION_BUBBLES in the Secure Settings table instead of the Global Settings table. Settings are global XOR per-user. This change - Sets default value for NOTIFICATION_BUBBLES in global settings table. - Adds Global.NOTIFICATIONS_BUBBLES to frameworks/base/api/test-current.txt - Keeps old upgrade steps as no-op to keep db versioning stable. Bug: 136034310 Test: RunSettingsRoboTests ROBOTEST_FILTER="Bubble" Change-Id: I21d3dae75e2a4ab0fac10f3d7ea7eed16e0f5d6c --- api/test-current.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'api') diff --git a/api/test-current.txt b/api/test-current.txt index a3ef9c41d5d2..af13c391c1c8 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -2343,6 +2343,7 @@ package android.provider { field public static final String LOCATION_IGNORE_SETTINGS_PACKAGE_WHITELIST = "location_ignore_settings_package_whitelist"; field public static final String LOW_POWER_MODE = "low_power"; field public static final String LOW_POWER_MODE_STICKY = "low_power_sticky"; + field public static final String NOTIFICATION_BUBBLES = "notification_bubbles"; field public static final String OVERLAY_DISPLAY_DEVICES = "overlay_display_devices"; field public static final String USE_OPEN_WIFI_PACKAGE = "use_open_wifi_package"; } -- cgit v1.2.3-59-g8ed1b From ead1b80bbcb81470b03b9e6505d8fc847009f193 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Mon, 22 Jul 2019 16:41:19 -0700 Subject: Update the setting to use Global instead of secure, deprecate old one Deprecates the Secure setting so it's clear we're not using it anymore. Since this work is for a QPR we need to listen for both the new Global setting as well as the old Secure setting so that CTS may pass without code changes: * When the secure setting is changed (only CTS uses it now), the global setting will also be updated. * When the global setting is changed (i.e. switching developer toggle), the global setting is updated and so is the secure setting. Test: atest NotificationManagerTest Bug: 137876221 Change-Id: Ib4623689aa4ec1fc79e2ec130702fdf9785834d8 --- api/test-current.txt | 2 +- core/java/android/provider/Settings.java | 6 +++ .../providers/settings/SettingsProtoDumpUtil.java | 2 +- .../notification/NotificationManagerService.java | 45 ++++++++++++++++++++-- .../server/notification/PreferencesHelper.java | 2 +- 5 files changed, 50 insertions(+), 7 deletions(-) (limited to 'api') diff --git a/api/test-current.txt b/api/test-current.txt index 0b674c728a91..d3bea18fb944 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -2368,7 +2368,7 @@ package android.provider { field public static final String LOCATION_ACCESS_CHECK_DELAY_MILLIS = "location_access_check_delay_millis"; field public static final String LOCATION_ACCESS_CHECK_INTERVAL_MILLIS = "location_access_check_interval_millis"; field public static final String NOTIFICATION_BADGING = "notification_badging"; - field public static final String NOTIFICATION_BUBBLES = "notification_bubbles"; + field @Deprecated public static final String NOTIFICATION_BUBBLES = "notification_bubbles"; field @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public static final String SYNC_PARENT_SOUNDS = "sync_parent_sounds"; field public static final String USER_SETUP_COMPLETE = "user_setup_complete"; field public static final String VOICE_INTERACTION_SERVICE = "voice_interaction_service"; diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 6b4a04060264..82125870d920 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -8687,10 +8687,16 @@ public final class Settings { * Whether the notification bubbles are globally enabled * The value is boolean (1 or 0). * @hide + * @deprecated use {@link Global#NOTIFICATION_BUBBLES} instead. */ @TestApi + @Deprecated public static final String NOTIFICATION_BUBBLES = "notification_bubbles"; + /** + * @deprecated use {@link Global#NOTIFICATION_BUBBLES_VALIDATOR} instead. + */ + @Deprecated private static final Validator NOTIFICATION_BUBBLES_VALIDATOR = BOOLEAN_VALIDATOR; /** diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java index cc39f5c79333..f8c9bcce1b1c 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java @@ -2153,7 +2153,7 @@ class SettingsProtoDumpUtil { Settings.Secure.NOTIFICATION_BADGING, SecureSettingsProto.Notification.BADGING); dumpSetting(s, p, - Settings.Secure.NOTIFICATION_BUBBLES, + Settings.Global.NOTIFICATION_BUBBLES, SecureSettingsProto.Notification.BUBBLES); dumpSetting(s, p, Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 842f4c182d45..653d9db8ae97 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -91,6 +91,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_TOAST; import static com.android.server.am.PendingIntentRecord.FLAG_ACTIVITY_SENDER; import static com.android.server.am.PendingIntentRecord.FLAG_BROADCAST_SENDER; import static com.android.server.am.PendingIntentRecord.FLAG_SERVICE_SENDER; +import static com.android.server.notification.PreferencesHelper.DEFAULT_ALLOW_BUBBLE; import static com.android.server.utils.PriorityDump.PRIORITY_ARG; import static com.android.server.utils.PriorityDump.PRIORITY_ARG_CRITICAL; import static com.android.server.utils.PriorityDump.PRIORITY_ARG_NORMAL; @@ -1358,8 +1359,10 @@ public class NotificationManagerService extends SystemService { private final class SettingsObserver extends ContentObserver { private final Uri NOTIFICATION_BADGING_URI = Settings.Secure.getUriFor(Settings.Secure.NOTIFICATION_BADGING); - private final Uri NOTIFICATION_BUBBLES_URI - = Settings.Secure.getUriFor(Settings.Global.NOTIFICATION_BUBBLES); + private final Uri NOTIFICATION_BUBBLES_URI_GLOBAL + = Settings.Global.getUriFor(Settings.Global.NOTIFICATION_BUBBLES); + private final Uri NOTIFICATION_BUBBLES_URI_SECURE + = Settings.Secure.getUriFor(Settings.Secure.NOTIFICATION_BUBBLES); private final Uri NOTIFICATION_LIGHT_PULSE_URI = Settings.System.getUriFor(Settings.System.NOTIFICATION_LIGHT_PULSE); private final Uri NOTIFICATION_RATE_LIMIT_URI @@ -1377,7 +1380,9 @@ public class NotificationManagerService extends SystemService { false, this, UserHandle.USER_ALL); resolver.registerContentObserver(NOTIFICATION_RATE_LIMIT_URI, false, this, UserHandle.USER_ALL); - resolver.registerContentObserver(NOTIFICATION_BUBBLES_URI, + resolver.registerContentObserver(NOTIFICATION_BUBBLES_URI_GLOBAL, + false, this, UserHandle.USER_ALL); + resolver.registerContentObserver(NOTIFICATION_BUBBLES_URI_SECURE, false, this, UserHandle.USER_ALL); update(null); } @@ -1404,9 +1409,41 @@ public class NotificationManagerService extends SystemService { if (uri == null || NOTIFICATION_BADGING_URI.equals(uri)) { mPreferencesHelper.updateBadgingEnabled(); } - if (uri == null || NOTIFICATION_BUBBLES_URI.equals(uri)) { + // In QPR we moved the setting to Global rather than Secure so that the setting + // applied to work profiles. Unfortunately we need to maintain both to pass CTS without + // a change to CTS outside of a normal letter release. + if (uri == null || NOTIFICATION_BUBBLES_URI_GLOBAL.equals(uri)) { + syncBubbleSettings(resolver, NOTIFICATION_BUBBLES_URI_GLOBAL); mPreferencesHelper.updateBubblesEnabled(); } + if (NOTIFICATION_BUBBLES_URI_SECURE.equals(uri)) { + syncBubbleSettings(resolver, NOTIFICATION_BUBBLES_URI_SECURE); + } + } + + private void syncBubbleSettings(ContentResolver resolver, Uri settingToFollow) { + boolean followSecureSetting = settingToFollow.equals(NOTIFICATION_BUBBLES_URI_SECURE); + + int secureSettingValue = Settings.Secure.getInt(resolver, + Settings.Secure.NOTIFICATION_BUBBLES, DEFAULT_ALLOW_BUBBLE ? 1 : 0); + int globalSettingValue = Settings.Global.getInt(resolver, + Settings.Global.NOTIFICATION_BUBBLES, DEFAULT_ALLOW_BUBBLE ? 1 : 0); + + if (globalSettingValue == secureSettingValue) { + return; + } + + if (followSecureSetting) { + // Global => secure + Settings.Global.putInt(resolver, + Settings.Global.NOTIFICATION_BUBBLES, + secureSettingValue); + } else { + // Secure => Global + Settings.Secure.putInt(resolver, + Settings.Secure.NOTIFICATION_BADGING, + globalSettingValue); + } } } diff --git a/services/core/java/com/android/server/notification/PreferencesHelper.java b/services/core/java/com/android/server/notification/PreferencesHelper.java index 4f319baabf92..f0947295b77b 100644 --- a/services/core/java/com/android/server/notification/PreferencesHelper.java +++ b/services/core/java/com/android/server/notification/PreferencesHelper.java @@ -100,7 +100,7 @@ public class PreferencesHelper implements RankingConfig { @VisibleForTesting static final boolean DEFAULT_HIDE_SILENT_STATUS_BAR_ICONS = false; private static final boolean DEFAULT_SHOW_BADGE = true; - private static final boolean DEFAULT_ALLOW_BUBBLE = true; + static final boolean DEFAULT_ALLOW_BUBBLE = true; private static final boolean DEFAULT_OEM_LOCKED_IMPORTANCE = false; private static final boolean DEFAULT_APP_LOCKED_IMPORTANCE = false; -- cgit v1.2.3-59-g8ed1b From 02cbff442568f70084d7c4b1e6e54dd30eab9aae Mon Sep 17 00:00:00 2001 From: Sasha Smundak Date: Thu, 15 Aug 2019 08:27:51 -0700 Subject: Android.bp file to convert current.api to XML format. Fixes: 139281092 Test: atest CtsDevicePolicyManagerTestCases Change-Id: Iffec912af4ee9dd3de2090a31bd475abc5016854 --- api/Android.bp | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 api/Android.bp (limited to 'api') diff --git a/api/Android.bp b/api/Android.bp new file mode 100644 index 000000000000..54ff82c97e17 --- /dev/null +++ b/api/Android.bp @@ -0,0 +1,7 @@ +genrule { + name: "current-api-xml", + tools: ["metalava"], + srcs: ["current.txt"], + out: ["current.api"], + cmd: "$(location metalava) --no-banner -convert2xmlnostrip $(in) $(out)", +} -- cgit v1.2.3-59-g8ed1b