Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b739fa6a authored by Lyn Han's avatar Lyn Han
Browse files

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
parent d3388d71
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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";
  }
+12 −1
Original line number Diff line number Diff line
@@ -9015,7 +9015,7 @@ public final class Settings {
            ASSIST_GESTURE_WAKE_ENABLED,
            VR_DISPLAY_MODE,
            NOTIFICATION_BADGING,
            NOTIFICATION_BUBBLES,
            NOTIFICATION_BUBBLES,                               // moved to global
            NOTIFICATION_DISMISS_RTL,
            QS_AUTO_ADDED_TILES,
            SCREENSAVER_ENABLED,
@@ -9385,6 +9385,16 @@ public final class Settings {
         */
        public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/global");
        /**
         * Whether the notification bubbles are globally enabled
         * The value is boolean (1 or 0).
         * @hide
         */
        @TestApi
        public static final String NOTIFICATION_BUBBLES = "notification_bubbles";
        private static final Validator NOTIFICATION_BUBBLES_VALIDATOR = BOOLEAN_VALIDATOR;
        /**
         * Whether users are allowed to add more users or guest from lockscreen.
         * <p>
@@ -13910,6 +13920,7 @@ public final class Settings {
            VALIDATORS.put(AWARE_ALLOWED, AWARE_ALLOWED_VALIDATOR);
            VALIDATORS.put(POWER_BUTTON_LONG_PRESS, POWER_BUTTON_LONG_PRESS_VALIDATOR);
            VALIDATORS.put(POWER_BUTTON_VERY_LONG_PRESS, POWER_BUTTON_VERY_LONG_PRESS_VALIDATOR);
            VALIDATORS.put(NOTIFICATION_BUBBLES, NOTIFICATION_BUBBLES_VALIDATOR);
        }
        /**
+1 −0
Original line number Diff line number Diff line
@@ -688,6 +688,7 @@ message GlobalSettingsProto {
        // Configuration options for smart replies and smart actions in notifications. This is
        // encoded as a key=value list separated by commas.
        optional SettingProto smart_suggestions_in_notifications_flags = 5 [ (android.privacy).dest = DEST_AUTOMATIC ];
        optional SettingProto bubbles = 6 [ (android.privacy).dest = DEST_AUTOMATIC ];
    }
    optional Notification notification = 82;

+3 −0
Original line number Diff line number Diff line
@@ -1056,6 +1056,9 @@ class SettingsProtoDumpUtil {
        dumpSetting(s, p,
                Settings.Global.NOTIFICATION_SNOOZE_OPTIONS,
                GlobalSettingsProto.Notification.SNOOZE_OPTIONS);
        dumpSetting(s, p,
                Settings.Global.NOTIFICATION_BUBBLES,
                GlobalSettingsProto.Notification.BUBBLES);
        dumpSetting(s, p,
                Settings.Global.SMART_REPLIES_IN_NOTIFICATIONS_FLAGS,
                GlobalSettingsProto.Notification.SMART_REPLIES_IN_NOTIFICATIONS_FLAGS);
+17 −20
Original line number Diff line number Diff line
@@ -4255,19 +4255,7 @@ public class SettingsProvider extends ContentProvider {

                if (currentVersion == 173) {
                    // Version 173: Set the default value for Secure Settings: NOTIFICATION_BUBBLES

                    final SettingsState secureSettings = getSecureSettingsLocked(userId);

                    final Setting bubblesSetting = secureSettings.getSettingLocked(
                            Secure.NOTIFICATION_BUBBLES);

                    if (bubblesSetting.isNull()) {
                        secureSettings.insertSettingLocked(Secure.NOTIFICATION_BUBBLES,
                                getContext().getResources().getBoolean(
                                        R.bool.def_notification_bubbles) ? "1" : "0", null,
                                true, SettingsState.SYSTEM_PACKAGE_NAME);
                    }

                    // Removed. Moved NOTIFICATION_BUBBLES to Global Settings.
                    currentVersion = 174;
                }

@@ -4391,14 +4379,9 @@ public class SettingsProvider extends ContentProvider {
                if (currentVersion == 179) {
                    // Version 178: Reset the default for Secure Settings: NOTIFICATION_BUBBLES
                    // This is originally set in version 173, however, the default value changed
                    // so this step is to ensure the value is updated to the correct defaulte
                    final SettingsState secureSettings = getSecureSettingsLocked(userId);

                    secureSettings.insertSettingLocked(Secure.NOTIFICATION_BUBBLES,
                            getContext().getResources().getBoolean(
                                    R.bool.def_notification_bubbles) ? "1" : "0", null,
                                    true, SettingsState.SYSTEM_PACKAGE_NAME);
                    // so this step is to ensure the value is updated to the correct default.

                    // Removed. Moved NOTIFICATION_BUBBLES to Global Settings.
                    currentVersion = 180;
                }

@@ -4452,6 +4435,20 @@ public class SettingsProvider extends ContentProvider {
                    currentVersion = 182;
                }

                if (currentVersion == 182) {
                    // Remove secure bubble settings.
                    getSecureSettingsLocked(userId).deleteSettingLocked(
                            Secure.NOTIFICATION_BUBBLES);

                    // Add global bubble settings.
                    getGlobalSettingsLocked().insertSettingLocked(Global.NOTIFICATION_BUBBLES,
                            getContext().getResources().getBoolean(
                                    R.bool.def_notification_bubbles) ? "1" : "0", null /* tag */,
                            true /* makeDefault */, SettingsState.SYSTEM_PACKAGE_NAME);

                    currentVersion = 183;
                }

                // vXXX: Add new settings above this point.

                if (currentVersion != newVersion) {