Disable Enhanced notifications setting when default NAS is not available
Test: NotificationAssistantPreferenceControllerTest
Bug: 251400808
Change-Id: Idec520013bea32cfaea0285f33c525a6e37f0124
(cherry picked from commit 873b8544e1
)
This commit is contained in:
@@ -141,7 +141,10 @@ public class NotificationAssistantPreferenceController extends TogglePreferenceC
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
if (isNASSettingActivityAvailable()) {
|
||||
if (mDefaultNASComponent == null) {
|
||||
preference.setEnabled(false);
|
||||
((PrimarySwitchPreference) preference).setSwitchEnabled(false);
|
||||
} else if (isNASSettingActivityAvailable()) {
|
||||
preference.setIntent(mNASSettingIntent);
|
||||
} else {
|
||||
// Cannot find settings activity from the default NAS app
|
||||
|
@@ -226,4 +226,14 @@ public class NotificationAssistantPreferenceControllerTest {
|
||||
.setNASMigrationDoneAndResetDefault(eq(10), anyBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNASUnavailable_settingDisabled() throws Exception {
|
||||
when(mBackend.getDefaultNotificationAssistant()).thenReturn(null);
|
||||
mPreferenceController.getDefaultNASIntent();
|
||||
mPreferenceController.updateState(mPreference);
|
||||
|
||||
verify(mPreference, times(1)).setSwitchEnabled(eq(false));
|
||||
assertFalse(mPreference.isEnabled());
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user