Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 503a7514 authored by Fan Zhang's avatar Fan Zhang Committed by Android (Google) Code Review
Browse files

Merge "Never disable DnD receiver to dislay condition correctly." into nyc-mr1-dev

parents 47c6adbd bebba447
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -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();
    }
+6 −0
Original line number Diff line number Diff line
@@ -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;
    }
}