Merge "Hide block pref on non-configurable channels"
This commit is contained in:
committed by
Android (Google) Code Review
commit
fe805d7a41
@@ -138,11 +138,11 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
|
|||||||
|
|
||||||
protected boolean isChannelBlockable() {
|
protected boolean isChannelBlockable() {
|
||||||
if (mChannel != null && mAppRow != null) {
|
if (mChannel != null && mAppRow != null) {
|
||||||
if (!mAppRow.systemApp) {
|
if (!isChannelConfigurable()) {
|
||||||
return true;
|
return mChannel.getImportance() == IMPORTANCE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mChannel.isBlockableSystem()
|
return mChannel.isBlockableSystem() || !mAppRow.systemApp
|
||||||
|| mChannel.getImportance() == IMPORTANCE_NONE;
|
|| mChannel.getImportance() == IMPORTANCE_NONE;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@@ -138,6 +138,7 @@ public class BlockPreferenceControllerTest {
|
|||||||
public void testIsAvailable_nonSystemApp() {
|
public void testIsAvailable_nonSystemApp() {
|
||||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||||
appRow.systemApp = false;
|
appRow.systemApp = false;
|
||||||
|
appRow.lockedChannelId = "not this";
|
||||||
NotificationChannel channel = mock(NotificationChannel.class);
|
NotificationChannel channel = mock(NotificationChannel.class);
|
||||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||||
mController.onResume(appRow, channel, null, null);
|
mController.onResume(appRow, channel, null, null);
|
||||||
|
@@ -261,6 +261,34 @@ public class NotificationPreferenceControllerTest {
|
|||||||
assertTrue(mController.isChannelBlockable());
|
assertTrue(mController.isChannelBlockable());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsChannelBlockable_notConfigurable() {
|
||||||
|
String sameId = "apples";
|
||||||
|
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||||
|
appRow.systemApp = false;
|
||||||
|
appRow.lockedChannelId = sameId;
|
||||||
|
NotificationChannel channel = mock(NotificationChannel.class);
|
||||||
|
when(channel.getId()).thenReturn(sameId);
|
||||||
|
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
|
||||||
|
|
||||||
|
mController.onResume(appRow, channel, null, null);
|
||||||
|
assertFalse(mController.isChannelBlockable());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsChannelBlockable_notConfigurableButBlocked() {
|
||||||
|
String sameId = "apples";
|
||||||
|
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||||
|
appRow.systemApp = false;
|
||||||
|
appRow.lockedChannelId = sameId;
|
||||||
|
NotificationChannel channel = mock(NotificationChannel.class);
|
||||||
|
when(channel.getId()).thenReturn(sameId);
|
||||||
|
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
|
||||||
|
|
||||||
|
mController.onResume(appRow, channel, null, null);
|
||||||
|
assertTrue(mController.isChannelBlockable());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsChannelGroupBlockable_nonSystemBlockable() {
|
public void testIsChannelGroupBlockable_nonSystemBlockable() {
|
||||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||||
|
Reference in New Issue
Block a user