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

Commit 3e019f74 authored by Lyn Han's avatar Lyn Han Committed by Android (Google) Code Review
Browse files

Merge "Revert "Secure => global bubble settings pt 1"" into qt-r1-bubbles-dev

parents c3b8412d d2b7708b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -9015,6 +9015,7 @@ 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 −1
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.Global.NOTIFICATION_BUBBLES);
                = 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
+6 −6
Original line number Diff line number Diff line
@@ -1826,9 +1826,9 @@ public class PreferencesHelper implements RankingConfig {
        for (int index = 0; index < mBubblesEnabled.size(); index++) {
            int userId = mBubblesEnabled.keyAt(index);
            final boolean oldValue = mBubblesEnabled.get(userId);
            final boolean newValue = Settings.Global.getInt(mContext.getContentResolver(),
                    Settings.Global.NOTIFICATION_BUBBLES,
                    DEFAULT_ALLOW_BUBBLE ? 1 : 0) != 0;
            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;
        }
@@ -1844,9 +1844,9 @@ public class PreferencesHelper implements RankingConfig {
        }
        if (mBubblesEnabled.indexOfKey(userId) < 0) {
            mBubblesEnabled.put(userId,
                    Settings.Global.getInt(mContext.getContentResolver(),
                            Settings.Global.NOTIFICATION_BUBBLES,
                            DEFAULT_ALLOW_BUBBLE ? 1 : 0) != 0);
                    Settings.Secure.getIntForUser(mContext.getContentResolver(),
                            Settings.Secure.NOTIFICATION_BUBBLES,
                            DEFAULT_ALLOW_BUBBLE ? 1 : 0, userId) != 0);
        }
        return mBubblesEnabled.get(userId, DEFAULT_ALLOW_BUBBLE);
    }
+21 −7
Original line number Diff line number Diff line
@@ -58,9 +58,7 @@ import android.net.Uri;
import android.os.Build;
import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Settings.Global;
import android.provider.Settings.Secure;

import android.test.suitebuilder.annotation.SmallTest;
import android.testing.TestableContentResolver;
import android.util.ArrayMap;
@@ -154,7 +152,8 @@ public class PreferencesHelperTest extends UiServiceTestCase {
        contentResolver.setFallbackToExisting(false);
        Secure.putIntForUser(contentResolver,
                Secure.NOTIFICATION_BADGING, 1, UserHandle.getUserId(UID_N_MR1));
        Global.putInt(contentResolver, Global.NOTIFICATION_BUBBLES, 1);
        Secure.putIntForUser(contentResolver,
                Secure.NOTIFICATION_BUBBLES, 1, UserHandle.getUserId(UID_N_MR1));

        ContentProvider testContentProvider = mock(ContentProvider.class);
        when(testContentProvider.getIContentProvider()).thenReturn(mTestIContentProvider);
@@ -1949,16 +1948,18 @@ public class PreferencesHelperTest extends UiServiceTestCase {

    @Test
    public void testBubblesOverrideTrue() {
        Global.putInt(getContext().getContentResolver(),
                Global.NOTIFICATION_BUBBLES, 1);
        Secure.putIntForUser(getContext().getContentResolver(),
                Secure.NOTIFICATION_BUBBLES, 1,
                USER.getIdentifier());
        mHelper.updateBubblesEnabled(); // would be called by settings observer
        assertTrue(mHelper.bubblesEnabled(USER));
    }

    @Test
    public void testBubblesOverrideFalse() {
        Global.putInt(getContext().getContentResolver(),
                Global.NOTIFICATION_BUBBLES, 0);
        Secure.putIntForUser(getContext().getContentResolver(),
                Secure.NOTIFICATION_BUBBLES, 0,
                USER.getIdentifier());
        mHelper.updateBubblesEnabled(); // would be called by settings observer
        assertFalse(mHelper.bubblesEnabled(USER));
    }
@@ -1972,6 +1973,19 @@ public class PreferencesHelperTest extends UiServiceTestCase {
        }
    }

    @Test
    public void testBubblesOverrideUserIsolation() {
        Secure.putIntForUser(getContext().getContentResolver(),
                Secure.NOTIFICATION_BUBBLES, 0,
                USER.getIdentifier());
        Secure.putIntForUser(getContext().getContentResolver(),
                Secure.NOTIFICATION_BUBBLES, 1,
                USER2.getIdentifier());
        mHelper.updateBubblesEnabled(); // would be called by settings observer
        assertFalse(mHelper.bubblesEnabled(USER));
        assertTrue(mHelper.bubblesEnabled(USER2));
    }

    @Test
    public void testOnLocaleChanged_updatesDefaultChannels() throws Exception {
        String newLabel = "bananas!";