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

Commit 2d77c0f0 authored by Jason Monk's avatar Jason Monk
Browse files

Random hacks to make QS DND work

 - Don't clear out as much state on attach
 - Make sure condition updates trigger a reflecting radio check
 - Assume that null conditions are forever

Test: manual
Fixes: 37944320
Fixes: 36031650

Change-Id: Ie926d16226e7b5431551a33515ac2b847e1d7a93
parent 0b1b1c43
Loading
Loading
Loading
Loading
+5 −10
Original line number Diff line number Diff line
@@ -57,7 +57,6 @@ import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.R.string;
import com.android.systemui.statusbar.policy.ZenModeController;

import java.io.FileDescriptor;
@@ -294,11 +293,6 @@ public class ZenModePanel extends FrameLayout {
    private void onAttach() {
        setExpanded(true);
        mAttached = true;
        for (int i = 0; i < mZenRadioGroupContent.getChildCount(); i++) {
            ConditionTag tag = getConditionTagAt(i);
            if (tag != null) tag.rb.setChecked(false);
            mZenRadioGroupContent.getChildAt(i).setTag(null);
        }
        mAttachedZen = mController.getZen();
        ZenRule manualRule = mController.getManualRule();
        mExitCondition = manualRule != null ? manualRule.condition : null;
@@ -311,6 +305,7 @@ public class ZenModePanel extends FrameLayout {
        setSessionExitCondition(copy(mExitCondition));
        updateWidgets();
        setRequestingConditions(!mHidden);
        ensureSelection();
    }

    private void onDetach() {
@@ -366,9 +361,6 @@ public class ZenModePanel extends FrameLayout {
        if (expanded == mExpanded) return;
        if (DEBUG) Log.d(mTag, "setExpanded " + expanded);
        mExpanded = expanded;
        if (mExpanded) {
            ensureSelection();
        }
        updateWidgets();
        fireExpanded();
    }
@@ -464,7 +456,8 @@ public class ZenModePanel extends FrameLayout {
                    ActivityManager.getCurrentUser(), false);
            return c;
        }
        return null;
        // If there is a manual rule, but it has no condition listed then it is forever.
        return forever();
    }

    private void handleUpdateZen(int zen) {
@@ -491,6 +484,7 @@ public class ZenModePanel extends FrameLayout {
            final ConditionTag tag = getConditionTagAt(i);
            if (tag != null && sameConditionId(tag.condition, mExitCondition)) {
                bind(exitCondition, mZenRadioGroupContent.getChildAt(i), i);
                tag.rb.setChecked(true);
                return;
            }
        }
@@ -498,6 +492,7 @@ public class ZenModePanel extends FrameLayout {
                exitCondition.id)) {
            bind(exitCondition, mZenRadioGroupContent.getChildAt(COUNTDOWN_CONDITION_INDEX),
                    COUNTDOWN_CONDITION_INDEX);
            getConditionTagAt(COUNTDOWN_CONDITION_INDEX).rb.setChecked(true);
        }
    }