Merge "Change bubble settings to use Secure rather than Global" into sc-dev
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.settings.notification;
|
||||
|
||||
import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;
|
||||
import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.ContentResolver;
|
||||
@@ -88,14 +88,14 @@ public class BubbleNotificationPreferenceController extends TogglePreferenceCont
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return Settings.Global.getInt(mContext.getContentResolver(),
|
||||
return Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES, ON) == ON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
return Settings.Global.putInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES, isChecked ? ON : OFF);
|
||||
return Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
|
||||
isChecked ? ON : OFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,7 +106,7 @@ public class BubbleNotificationPreferenceController extends TogglePreferenceCont
|
||||
class SettingObserver extends ContentObserver {
|
||||
|
||||
private final Uri NOTIFICATION_BUBBLES_URI =
|
||||
Settings.Global.getUriFor(NOTIFICATION_BUBBLES);
|
||||
Settings.Secure.getUriFor(NOTIFICATION_BUBBLES);
|
||||
|
||||
private final Preference mPreference;
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.settings.notification;
|
||||
|
||||
import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;
|
||||
import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
@@ -54,7 +54,7 @@ public class BubbleSummaryNotificationPreferenceController extends BasePreferenc
|
||||
}
|
||||
|
||||
private boolean areBubblesEnabled() {
|
||||
return Settings.Global.getInt(mContext.getContentResolver(),
|
||||
return Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES, ON) == ON;
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.settings.notification.app;
|
||||
|
||||
import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;
|
||||
import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -67,7 +67,7 @@ public class BubbleCategoryPreferenceController extends NotificationPreferenceCo
|
||||
|
||||
|
||||
private boolean areBubblesEnabled() {
|
||||
return Settings.Global.getInt(mContext.getContentResolver(),
|
||||
return Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES, ON) == ON;
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.settings.notification.app;
|
||||
|
||||
import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;
|
||||
import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -67,7 +67,7 @@ public class BubbleLinkPreferenceController extends NotificationPreferenceContro
|
||||
|
||||
|
||||
private boolean areBubblesEnabled() {
|
||||
return Settings.Global.getInt(mContext.getContentResolver(),
|
||||
return Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES, ON) == ON;
|
||||
}
|
||||
}
|
||||
|
@@ -17,10 +17,10 @@
|
||||
package com.android.settings.notification.app;
|
||||
|
||||
import static android.app.NotificationManager.BUBBLE_PREFERENCE_NONE;
|
||||
import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;
|
||||
import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.NotificationChannel;
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
@@ -72,7 +72,7 @@ public class BubblePreferenceController extends NotificationPreferenceController
|
||||
if (!super.isAvailable()) {
|
||||
return false;
|
||||
}
|
||||
if (!mIsAppPage && !isGloballyEnabled()) {
|
||||
if (!mIsAppPage && !isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
if (mChannel != null) {
|
||||
@@ -101,7 +101,7 @@ public class BubblePreferenceController extends NotificationPreferenceController
|
||||
BubblePreference pref = (BubblePreference) preference;
|
||||
pref.setDisabledByAdmin(mAdmin);
|
||||
pref.setSelectedVisibility(!mHasSentInvalidMsg || mNumConversations > 0);
|
||||
if (!isGloballyEnabled()) {
|
||||
if (!isEnabled()) {
|
||||
pref.setSelectedPreference(BUBBLE_PREFERENCE_NONE);
|
||||
} else {
|
||||
pref.setSelectedPreference(backEndPref);
|
||||
@@ -110,7 +110,7 @@ public class BubblePreferenceController extends NotificationPreferenceController
|
||||
// We're on the channel specific notification page which displays a toggle.
|
||||
RestrictedSwitchPreference switchpref = (RestrictedSwitchPreference) preference;
|
||||
switchpref.setDisabledByAdmin(mAdmin);
|
||||
switchpref.setChecked(mChannel.canBubble() && isGloballyEnabled());
|
||||
switchpref.setChecked(mChannel.canBubble() && isEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public class BubblePreferenceController extends NotificationPreferenceController
|
||||
BubblePreference pref = (BubblePreference) preference;
|
||||
if (mAppRow != null && mFragmentManager != null) {
|
||||
final int value = (int) newValue;
|
||||
if (!isGloballyEnabled()
|
||||
if (!isEnabled()
|
||||
&& pref.getSelectedPreference() == BUBBLE_PREFERENCE_NONE) {
|
||||
// if the global setting is off, toggling app level permission requires extra
|
||||
// confirmation
|
||||
@@ -145,9 +145,9 @@ public class BubblePreferenceController extends NotificationPreferenceController
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isGloballyEnabled() {
|
||||
private boolean isEnabled() {
|
||||
ActivityManager am = mContext.getSystemService(ActivityManager.class);
|
||||
return !am.isLowRamDevice() && Settings.Global.getInt(mContext.getContentResolver(),
|
||||
return !am.isLowRamDevice() && Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF) == SYSTEM_WIDE_ON;
|
||||
}
|
||||
|
||||
@@ -155,25 +155,27 @@ public class BubblePreferenceController extends NotificationPreferenceController
|
||||
* Used in app level prompt that confirms the user is ok with turning on bubbles
|
||||
* globally. If they aren't, undo that.
|
||||
*/
|
||||
public static void revertBubblesApproval(Context mContext, String pkg, int uid) {
|
||||
public static void revertBubblesApproval(Context context, String pkg, int uid) {
|
||||
NotificationBackend backend = new NotificationBackend();
|
||||
backend.setAllowBubbles(pkg, uid, BUBBLE_PREFERENCE_NONE);
|
||||
|
||||
// changing the global settings will cause the observer on the host page to reload
|
||||
// correct preference state
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
|
||||
Settings.Secure.putInt(context.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES,
|
||||
SYSTEM_WIDE_OFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply global bubbles approval
|
||||
*/
|
||||
public static void applyBubblesApproval(Context mContext, String pkg, int uid, int pref) {
|
||||
public static void applyBubblesApproval(Context context, String pkg, int uid, int pref) {
|
||||
NotificationBackend backend = new NotificationBackend();
|
||||
backend.setAllowBubbles(pkg, uid, pref);
|
||||
// changing the global settings will cause the observer on the host page to reload
|
||||
// correct preference state
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(context.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES,
|
||||
SYSTEM_WIDE_ON);
|
||||
}
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ package com.android.settings.notification.app;
|
||||
|
||||
import static android.app.NotificationManager.BUBBLE_PREFERENCE_ALL;
|
||||
import static android.app.NotificationManager.BUBBLE_PREFERENCE_NONE;
|
||||
import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;
|
||||
import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
@@ -106,7 +106,7 @@ public class BubbleSummaryPreferenceController extends NotificationPreferenceCon
|
||||
|
||||
private boolean isGloballyEnabled() {
|
||||
ActivityManager am = mContext.getSystemService(ActivityManager.class);
|
||||
return !am.isLowRamDevice() && Settings.Global.getInt(mContext.getContentResolver(),
|
||||
return !am.isLowRamDevice() && Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES, ON) == ON;
|
||||
}
|
||||
}
|
||||
|
@@ -47,8 +47,8 @@ public class GlobalBubblePermissionObserverMixin extends ContentObserver {
|
||||
|
||||
public void onStart() {
|
||||
mContext.getContentResolver().registerContentObserver(
|
||||
Settings.Global.getUriFor(
|
||||
Settings.Global.NOTIFICATION_BUBBLES),
|
||||
Settings.Secure.getUriFor(
|
||||
Settings.Secure.NOTIFICATION_BUBBLES),
|
||||
false /* notifyForDescendants */,
|
||||
this /* observer */);
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.settings.notification;
|
||||
|
||||
import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;
|
||||
import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
@@ -91,7 +91,7 @@ public class BubbleNotificationPreferenceControllerTest {
|
||||
@Test
|
||||
public void updateState_settingIsOn_preferenceSetChecked() {
|
||||
final TwoStatePreference preference = mock(TwoStatePreference.class);
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON);
|
||||
|
||||
mController.updateState(preference);
|
||||
|
||||
@@ -101,8 +101,8 @@ public class BubbleNotificationPreferenceControllerTest {
|
||||
@Test
|
||||
public void updateState_settingIsOff_preferenceSetUnchecked() {
|
||||
final TwoStatePreference preference = mock(TwoStatePreference.class);
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF);
|
||||
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF);
|
||||
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES, ON)).isEqualTo(OFF);
|
||||
|
||||
mController.updateState(preference);
|
||||
@@ -112,24 +112,24 @@ public class BubbleNotificationPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void isChecked_settingIsOff_shouldReturnFalse() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF);
|
||||
|
||||
assertThat(mController.isChecked()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isChecked_settingIsOn_shouldReturnTrue() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON);
|
||||
|
||||
assertThat(mController.isChecked()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_setFalse_disablesSetting() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON);
|
||||
|
||||
mController.setChecked(false);
|
||||
int updatedValue = Settings.Global.getInt(mContext.getContentResolver(),
|
||||
int updatedValue = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES, -1);
|
||||
|
||||
assertThat(updatedValue).isEqualTo(OFF);
|
||||
@@ -137,10 +137,10 @@ public class BubbleNotificationPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void setChecked_setTrue_enablesSetting() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF);
|
||||
|
||||
mController.setChecked(true);
|
||||
int updatedValue = Settings.Global.getInt(mContext.getContentResolver(),
|
||||
int updatedValue = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES, -1);
|
||||
|
||||
assertThat(updatedValue).isEqualTo(ON);
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.settings.notification;
|
||||
|
||||
import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;
|
||||
import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
@@ -61,14 +61,14 @@ public class BubbleSummaryNotificationPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void getSummary_NOTIFICATION_BUBBLESIsOff_returnOffString() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF);
|
||||
|
||||
assertThat(mController.getSummary()).isEqualTo("Off");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSummary_NOTIFICATION_BUBBLESIsOff_returnOnString() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON);
|
||||
|
||||
String onString = mContext.getString(R.string.notifications_bubble_setting_on_summary);
|
||||
assertThat(mController.getSummary()).isEqualTo(onString);
|
||||
|
@@ -23,7 +23,7 @@ import static android.app.NotificationManager.BUBBLE_PREFERENCE_SELECTED;
|
||||
import static android.app.NotificationManager.IMPORTANCE_HIGH;
|
||||
import static android.app.NotificationManager.IMPORTANCE_LOW;
|
||||
import static android.app.NotificationManager.IMPORTANCE_NONE;
|
||||
import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;
|
||||
import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
|
||||
|
||||
import static com.android.settings.notification.app.BubblePreferenceController.SYSTEM_WIDE_OFF;
|
||||
import static com.android.settings.notification.app.BubblePreferenceController.SYSTEM_WIDE_ON;
|
||||
@@ -71,8 +71,8 @@ import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.shadow.api.Shadow;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
import org.robolectric.shadows.ShadowActivityManager;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -124,7 +124,7 @@ public class BubblePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void isAvailable_notIfAppBlocked() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.banned = true;
|
||||
mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null, null);
|
||||
@@ -133,7 +133,7 @@ public class BubblePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void isAvailable_notIfChannelBlocked() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
|
||||
@@ -143,7 +143,7 @@ public class BubblePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void isAvailable_channel_notIfAppOff() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.bubblePreference = BUBBLE_PREFERENCE_NONE;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
@@ -157,7 +157,7 @@ public class BubblePreferenceControllerTest {
|
||||
public void isNotAvailable_ifOffGlobally_app() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
mController.onResume(appRow, null, null, null, null, null, null);
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
|
||||
|
||||
assertFalse(mController.isAvailable());
|
||||
@@ -181,7 +181,7 @@ public class BubblePreferenceControllerTest {
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
mController.onResume(appRow, channel, null, null, null, null, null);
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
|
||||
|
||||
assertFalse(mController.isAvailable());
|
||||
@@ -191,7 +191,7 @@ public class BubblePreferenceControllerTest {
|
||||
public void isAvailable_ifNotLowRam() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
mController.onResume(appRow, null, null, null, null, null, null);
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
|
||||
final ShadowActivityManager activityManager =
|
||||
Shadow.extract(mContext.getSystemService(ActivityManager.class));
|
||||
@@ -203,7 +203,7 @@ public class BubblePreferenceControllerTest {
|
||||
public void isAvailable_app_evenIfOffGlobally() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
mAppPageController.onResume(appRow, null, null, null, null, null, null);
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
|
||||
|
||||
assertTrue(mAppPageController.isAvailable());
|
||||
@@ -213,7 +213,7 @@ public class BubblePreferenceControllerTest {
|
||||
public void isAvailable_app() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
mController.onResume(appRow, null, null, null, null, null, null);
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
|
||||
assertTrue(mController.isAvailable());
|
||||
}
|
||||
@@ -226,7 +226,7 @@ public class BubblePreferenceControllerTest {
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
|
||||
mController.onResume(appRow, channel, null, null, null, null, null);
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
|
||||
assertTrue(mController.isAvailable());
|
||||
}
|
||||
@@ -237,8 +237,9 @@ public class BubblePreferenceControllerTest {
|
||||
appRow.bubblePreference = BUBBLE_PREFERENCE_ALL;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
|
||||
mController.onResume(appRow, channel, null, null, null, null, null);
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
|
||||
assertTrue(mController.isAvailable());
|
||||
}
|
||||
@@ -251,7 +252,7 @@ public class BubblePreferenceControllerTest {
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
mController.onResume(appRow, channel, null, null, null, null,
|
||||
ImmutableList.of(NotificationChannel.EDIT_CONVERSATION));
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
|
||||
assertTrue(mController.isAvailable());
|
||||
}
|
||||
@@ -263,7 +264,7 @@ public class BubblePreferenceControllerTest {
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
mController.onResume(appRow, channel, null, null, null, null, new ArrayList<>());
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
|
||||
assertFalse(mController.isAvailable());
|
||||
}
|
||||
@@ -298,7 +299,7 @@ public class BubblePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void updateState_channel_channelNotBlockable() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.pkg = "a";
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
@@ -313,7 +314,7 @@ public class BubblePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void updateState_channel() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.pkg = "a";
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
@@ -334,7 +335,7 @@ public class BubblePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void updateState_app() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.pkg = "a";
|
||||
appRow.label = "App!";
|
||||
@@ -360,7 +361,7 @@ public class BubblePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void updateState_app_offGlobally() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.pkg = "a";
|
||||
@@ -375,7 +376,7 @@ public class BubblePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_on_channel() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.pkg = "a";
|
||||
appRow.bubblePreference = BUBBLE_PREFERENCE_SELECTED;
|
||||
@@ -395,7 +396,7 @@ public class BubblePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_off_channel() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.pkg = "a";
|
||||
appRow.bubblePreference = BUBBLE_PREFERENCE_SELECTED;
|
||||
@@ -416,7 +417,7 @@ public class BubblePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_app_all() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.pkg = "a";
|
||||
appRow.bubblePreference = BUBBLE_PREFERENCE_NONE;
|
||||
@@ -435,7 +436,7 @@ public class BubblePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testOnPreferenceChange_app_all_offGlobally() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
|
||||
SYSTEM_WIDE_OFF);
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.pkg = "a";
|
||||
@@ -456,7 +457,7 @@ public class BubblePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_app_selected() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.pkg = "a";
|
||||
appRow.bubblePreference = BUBBLE_PREFERENCE_ALL;
|
||||
@@ -475,7 +476,7 @@ public class BubblePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_app_none() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.pkg = "a";
|
||||
appRow.bubblePreference = BUBBLE_PREFERENCE_ALL;
|
||||
@@ -494,7 +495,7 @@ public class BubblePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_dependentFieldListenerCalled() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.pkg = "a";
|
||||
appRow.bubblePreference = BUBBLE_PREFERENCE_ALL;
|
||||
|
@@ -21,7 +21,7 @@ import static android.app.NotificationManager.BUBBLE_PREFERENCE_ALL;
|
||||
import static android.app.NotificationManager.BUBBLE_PREFERENCE_NONE;
|
||||
import static android.app.NotificationManager.BUBBLE_PREFERENCE_SELECTED;
|
||||
import static android.app.NotificationManager.IMPORTANCE_HIGH;
|
||||
import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;
|
||||
import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
|
||||
|
||||
import static com.android.settings.notification.app.BubblePreferenceController.SYSTEM_WIDE_OFF;
|
||||
import static com.android.settings.notification.app.BubblePreferenceController.SYSTEM_WIDE_ON;
|
||||
@@ -96,7 +96,7 @@ public class BubbleSummaryPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void isAvailable_NOTIFICATION_BUBBLESisOn_shouldReturnTrue() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
mController.onResume(mAppRow, null, null, null, null, null, null);
|
||||
|
||||
assertTrue(mController.isAvailable());
|
||||
@@ -104,7 +104,7 @@ public class BubbleSummaryPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void isAvailable_NOTIFICATION_BUBBLESisOn_neverSentMsg_shouldReturnFalse() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
mController.onResume(mAppRow, null, null, null, null, null, null);
|
||||
when(mBackend.hasSentValidMsg(anyString(), anyInt())).thenReturn(false);
|
||||
|
||||
@@ -113,7 +113,7 @@ public class BubbleSummaryPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void isAvailable_NOTIFICATION_BUBBLESisOff_shouldReturnFalse() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
|
||||
SYSTEM_WIDE_OFF);
|
||||
mController.onResume(mAppRow, null, null, null, null, null, null);
|
||||
|
||||
@@ -122,7 +122,7 @@ public class BubbleSummaryPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void isAvailable_nonNullChannelNOTIFICATION_BUBBLESisOff_shouldReturnFalse() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
|
||||
SYSTEM_WIDE_OFF);
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
@@ -133,7 +133,7 @@ public class BubbleSummaryPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void isAvailable_defaultChannelNOTIFICATION_BUBBLESisOn_shouldReturnTrue() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
|
||||
@@ -144,7 +144,7 @@ public class BubbleSummaryPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void isAvailable_lowRam_shouldReturnFalse() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
mController.onResume(mAppRow, null, null, null, null, null, null);
|
||||
|
||||
final ShadowActivityManager activityManager =
|
||||
@@ -155,7 +155,7 @@ public class BubbleSummaryPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void isAvailable_notLowRam_shouldReturnTrue() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
|
||||
mController.onResume(mAppRow, null, null, null, null, null, null);
|
||||
|
||||
final ShadowActivityManager activityManager =
|
||||
@@ -176,7 +176,7 @@ public class BubbleSummaryPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void getSummary_NOTIFICATION_BUBBLESIsOff_returnsNoneString() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
|
||||
SYSTEM_WIDE_OFF);
|
||||
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
@@ -188,7 +188,7 @@ public class BubbleSummaryPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void getSummary_BUBBLE_PREFERENCE_NONEisSelected_returnsNoneString() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
|
||||
SYSTEM_WIDE_ON);
|
||||
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
@@ -201,7 +201,7 @@ public class BubbleSummaryPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void getSummary_BUBBLE_PREFERENCE_ALLisSelected_returnsAllString() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
|
||||
SYSTEM_WIDE_ON);
|
||||
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
@@ -214,7 +214,7 @@ public class BubbleSummaryPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void getSummary_BUBBLE_PREFERENCE_SELECTEDisSelected_returnsSelectedString() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
|
||||
SYSTEM_WIDE_ON);
|
||||
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
|
Reference in New Issue
Block a user