Fix visibility of settings on channel page
Properly hide fields if the parent app or group is blocked. This is needed because apps can link directly to this screen. Test: atest Fixes: 130184191 Change-Id: I8c39410574940615fbb607a201e20e480ec02d87
This commit is contained in:
@@ -50,12 +50,18 @@ public class ImportancePreferenceController extends NotificationPreferenceContro
|
||||
if (mAppRow == null) {
|
||||
return false;
|
||||
}
|
||||
if (mAppRow.banned) {
|
||||
return false;
|
||||
}
|
||||
if (mChannel == null) {
|
||||
return false;
|
||||
}
|
||||
if (isDefaultChannel()) {
|
||||
return false;
|
||||
}
|
||||
if (mChannelGroup != null && mChannelGroup.isBlocked()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -73,12 +73,12 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
|
||||
if (mAppRow.banned) {
|
||||
return false;
|
||||
}
|
||||
if (mChannel != null) {
|
||||
return mChannel.getImportance() != IMPORTANCE_NONE;
|
||||
}
|
||||
if (mChannelGroup != null) {
|
||||
return !mChannelGroup.isBlocked();
|
||||
}
|
||||
if (mChannel != null) {
|
||||
return mChannel.getImportance() != IMPORTANCE_NONE;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.notification;
|
||||
|
||||
import static android.app.NotificationChannel.DEFAULT_CHANNEL_ID;
|
||||
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
|
||||
import static android.app.NotificationManager.IMPORTANCE_HIGH;
|
||||
import static android.app.NotificationManager.IMPORTANCE_LOW;
|
||||
import static android.app.NotificationManager.IMPORTANCE_NONE;
|
||||
@@ -36,6 +37,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationChannelGroup;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.os.UserManager;
|
||||
@@ -100,7 +102,18 @@ public class ImportancePreferenceControllerTest {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.banned = true;
|
||||
mController.onResume(appRow, mock(NotificationChannel.class), null, null);
|
||||
assertTrue(mController.isAvailable());
|
||||
assertFalse(mController.isAvailable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAvailable_isGroupBlocked() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
|
||||
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
|
||||
when(group.isBlocked()).thenReturn(true);
|
||||
mController.onResume(appRow, channel, group, null);
|
||||
assertFalse(mController.isAvailable());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -117,6 +117,7 @@ public class NotificationPreferenceControllerTest {
|
||||
public void isAvailable_notIfChannelGroupBlocked() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
|
||||
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
|
||||
|
||||
mController.onResume(appRow, channel, group, null);
|
||||
|
Reference in New Issue
Block a user