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

Commit 4463f84e authored by Lyn Han's avatar Lyn Han
Browse files

Secure => global bubble settings pt 1

Follow up to http://ag/8222583, which enables bubbles globally instead
of at the per-user level
- Remove user-specific tracking
- Remove Secure.NOTIFICATION_BUBBLES from backup
- Replace references to Secure.NOTIFICATION_BUBBLES with
Global.NOTIFICATION_BUBBLES
- Update tests

Fixes: 136034310
Bug: 129158983
Test: m RunSettingsRoboTests
Test: atest SystemUITests
Test: manual - work profile bubbles show up
Change-Id: I931f8f2640ac01fdf4c30ef9f9474fde7ca2d262
parent 6a79551e
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -9015,7 +9015,6 @@ public final class Settings {
            ASSIST_GESTURE_WAKE_ENABLED,
            VR_DISPLAY_MODE,
            NOTIFICATION_BADGING,
            NOTIFICATION_BUBBLES,                               // moved to global
            NOTIFICATION_DISMISS_RTL,
            QS_AUTO_ADDED_TILES,
            SCREENSAVER_ENABLED,
+1 −2
Original line number Diff line number Diff line
@@ -41,10 +41,9 @@ public class BubbleExtractor implements NotificationSignalExtractor {
            if (DBG) Slog.d(TAG, "missing config");
            return null;
        }
        boolean userWantsBubbles = mConfig.bubblesEnabled(record.sbn.getUser());
        boolean appCanShowBubble =
                mConfig.areBubblesAllowed(record.sbn.getPackageName(), record.sbn.getUid());
        if (!userWantsBubbles || !appCanShowBubble) {
        if (!mConfig.bubblesEnabled() || !appCanShowBubble) {
            record.setAllowBubble(false);
        } else {
            if (record.getChannel() != null) {
+2 −2
Original line number Diff line number Diff line
@@ -1359,7 +1359,7 @@ public class NotificationManagerService extends SystemService {
        private final Uri NOTIFICATION_BADGING_URI
                = Settings.Secure.getUriFor(Settings.Secure.NOTIFICATION_BADGING);
        private final Uri NOTIFICATION_BUBBLES_URI
                = Settings.Secure.getUriFor(Settings.Secure.NOTIFICATION_BUBBLES);
                = Settings.Secure.getUriFor(Settings.Global.NOTIFICATION_BUBBLES);
        private final Uri NOTIFICATION_LIGHT_PULSE_URI
                = Settings.System.getUriFor(Settings.System.NOTIFICATION_LIGHT_PULSE);
        private final Uri NOTIFICATION_RATE_LIMIT_URI
@@ -4843,7 +4843,7 @@ public class NotificationManagerService extends SystemService {
        // Does the app want to bubble & is able to bubble
        boolean canBubble = intentCanBubble
                && mPreferencesHelper.areBubblesAllowed(pkg, userId)
                && mPreferencesHelper.bubblesEnabled(r.sbn.getUser())
                && mPreferencesHelper.bubblesEnabled()
                && r.getChannel().canBubble()
                && !mActivityManager.isLowRamDevice();

+8 −29
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ public class PreferencesHelper implements RankingConfig {
    private final ZenModeHelper mZenModeHelper;

    private SparseBooleanArray mBadgingEnabled;
    private SparseBooleanArray mBubblesEnabled;
    private boolean mBubblesEnabled;
    private boolean mAreChannelsBypassingDnd;
    private boolean mHideSilentStatusBarIcons = DEFAULT_HIDE_SILENT_STATUS_BAR_ICONS;

@@ -1818,39 +1818,18 @@ public class PreferencesHelper implements RankingConfig {
    }

    public void updateBubblesEnabled() {
        if (mBubblesEnabled == null) {
            mBubblesEnabled = new SparseBooleanArray();
        }
        boolean changed = false;
        // update the cached values
        for (int index = 0; index < mBubblesEnabled.size(); index++) {
            int userId = mBubblesEnabled.keyAt(index);
            final boolean oldValue = mBubblesEnabled.get(userId);
            final boolean newValue = Settings.Secure.getIntForUser(mContext.getContentResolver(),
                    Settings.Secure.NOTIFICATION_BUBBLES,
                    DEFAULT_ALLOW_BUBBLE ? 1 : 0, userId) != 0;
            mBubblesEnabled.put(userId, newValue);
            changed |= oldValue != newValue;
        }
        if (changed) {
        final boolean newValue = Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.NOTIFICATION_BUBBLES,
                DEFAULT_ALLOW_BUBBLE ? 1 : 0) == 1;
        if (newValue != mBubblesEnabled) {
            mBubblesEnabled = newValue;
            updateConfig();
        }
    }

    public boolean bubblesEnabled(UserHandle userHandle) {
        int userId = userHandle.getIdentifier();
        if (userId == UserHandle.USER_ALL) {
            return false;
    public boolean bubblesEnabled() {
        return mBubblesEnabled;
    }
        if (mBubblesEnabled.indexOfKey(userId) < 0) {
            mBubblesEnabled.put(userId,
                    Settings.Secure.getIntForUser(mContext.getContentResolver(),
                            Settings.Secure.NOTIFICATION_BUBBLES,
                            DEFAULT_ALLOW_BUBBLE ? 1 : 0, userId) != 0);
        }
        return mBubblesEnabled.get(userId, DEFAULT_ALLOW_BUBBLE);
    }


    public void updateBadgingEnabled() {
        if (mBadgingEnabled == null) {
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ public interface RankingConfig {
    boolean canShowBadge(String packageName, int uid);
    boolean badgingEnabled(UserHandle userHandle);
    boolean areBubblesAllowed(String packageName, int uid);
    boolean bubblesEnabled(UserHandle userHandle);
    boolean bubblesEnabled();
    boolean isGroupBlocked(String packageName, int uid, String groupId);

    Collection<NotificationChannelGroup> getNotificationChannelGroups(String pkg,
Loading