Never disable DnD receiver to dislay condition correctly.
Bug: 30360853 Change-Id: I3e470c2955d7f066970442e281f9d66b153b8d10
This commit is contained in:
@@ -38,6 +38,12 @@ public abstract class Condition {
|
||||
// All conditions must live in this package.
|
||||
Condition(ConditionManager manager) {
|
||||
mManager = manager;
|
||||
Class<?> receiverClass = getReceiverClass();
|
||||
if (receiverClass != null && shouldAlwaysListenToBroadcast()) {
|
||||
PackageManager pm = mManager.getContext().getPackageManager();
|
||||
pm.setComponentEnabledSetting(new ComponentName(mManager.getContext(), receiverClass),
|
||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0 /* flag */);
|
||||
}
|
||||
}
|
||||
|
||||
void restoreState(PersistableBundle bundle) {
|
||||
@@ -93,6 +99,10 @@ public abstract class Condition {
|
||||
}
|
||||
|
||||
private void onSilenceChanged(boolean silenced) {
|
||||
if (shouldAlwaysListenToBroadcast()) {
|
||||
// Don't try to disable BroadcastReceiver if we want it always on.
|
||||
return;
|
||||
}
|
||||
Class<?> clz = getReceiverClass();
|
||||
if (clz == null) {
|
||||
return;
|
||||
@@ -109,6 +119,10 @@ public abstract class Condition {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected boolean shouldAlwaysListenToBroadcast() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean shouldShow() {
|
||||
return isActive() && !isSilenced();
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ import android.os.PersistableBundle;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.Global;
|
||||
import android.service.notification.ZenModeConfig;
|
||||
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
|
||||
@@ -143,4 +144,9 @@ public class DndCondition extends Condition {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldAlwaysListenToBroadcast() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user