Update channel DND setting

... to reflect DND changes elsewhere in the system. Update the summary
and make the setting always available.

Test: make -j RunSettingsRoboTests
Change-Id: Ia51c349d863e1470e8a043293fa60f22632fa2df
Fixes: 76137346
This commit is contained in:
Julia Reynolds
2018-03-29 11:16:36 -04:00
parent 5506097efd
commit cb78269637
3 changed files with 9 additions and 50 deletions

View File

@@ -29,10 +29,9 @@ import com.android.settingslib.core.lifecycle.events.OnResume;
public class DndPreferenceController extends NotificationPreferenceController
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener,
LifecycleObserver, OnResume {
LifecycleObserver {
private static final String KEY_BYPASS_DND = "bypass_dnd";
private boolean mVisualEffectsSuppressed;
public DndPreferenceController(Context context, Lifecycle lifecycle,
NotificationBackend backend) {
@@ -42,12 +41,6 @@ public class DndPreferenceController extends NotificationPreferenceController
}
}
@Override
public void onResume() {
NotificationManager.Policy policy = mNm.getNotificationPolicy();
mVisualEffectsSuppressed = policy != null && policy.suppressedVisualEffects != 0;
}
@Override
public String getPreferenceKey() {
return KEY_BYPASS_DND;
@@ -55,12 +48,10 @@ public class DndPreferenceController extends NotificationPreferenceController
@Override
public boolean isAvailable() {
if (!super.isAvailable()) {
if (!super.isAvailable() || mChannel == null) {
return false;
}
return checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT)
|| (checkCanBeVisible(NotificationManager.IMPORTANCE_LOW)
&& mVisualEffectsSuppressed);
return true;
}
public void updateState(Preference preference) {
@@ -82,5 +73,4 @@ public class DndPreferenceController extends NotificationPreferenceController
}
return true;
}
}