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

Commit 9fc72be6 authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "Update DndCondition settings summary" into pi-dev

parents 631ee514 98c63ed1
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -42,9 +42,10 @@ public class DndCondition extends Condition {
    @VisibleForTesting
    static final IntentFilter DND_FILTER =
        new IntentFilter(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED_INTERNAL);
    @VisibleForTesting
    protected ZenModeConfig mConfig;

    private int mZen;
    private ZenModeConfig mConfig;
    private final Receiver mReceiver;

    public DndCondition(ConditionManager manager) {
@@ -93,7 +94,7 @@ public class DndCondition extends Condition {
    @Override
    public CharSequence getSummary() {
        return ZenModeConfig.getDescription(mManager.getContext(), mZen != Global.ZEN_MODE_OFF,
                mConfig);
                mConfig, true);
    }

    @Override
+1 −1
Original line number Diff line number Diff line
@@ -136,7 +136,7 @@ public class ZenModeSettings extends ZenModeSettingsBase {

            if (zenMode != Settings.Global.ZEN_MODE_OFF) {
                ZenModeConfig config = NotificationManager.from(mContext).getZenModeConfig();
                String description = ZenModeConfig.getDescription(mContext, true, config);
                String description = ZenModeConfig.getDescription(mContext, true, config, false);

                if (description == null) {
                    return mContext.getString(R.string.zen_mode_sound_summary_on);
+11 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import static com.google.common.truth.Truth.assertThat;

import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -104,4 +106,13 @@ public class DndConditionTest {

        verify(mContext, never()).unregisterReceiver(any(DndCondition.Receiver.class));
    }

    @Test
    public void nullZenConfig_noCrash() {
        DndCondition condition = new DndCondition(mConditionManager);
        assertThat(condition.mConfig).isNull();

        // should not crash, instead summary is null
        assertThat(condition.getSummary()).isNull();
    }
}