Merge "Update DndCondition settings summary" into pi-dev
am: 9fc72be6c8
Change-Id: Iaa7fc0deaeea08b528ba82c237696464abaf4854
This commit is contained in:
@@ -42,9 +42,10 @@ public class DndCondition extends Condition {
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final IntentFilter DND_FILTER =
|
static final IntentFilter DND_FILTER =
|
||||||
new IntentFilter(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED_INTERNAL);
|
new IntentFilter(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED_INTERNAL);
|
||||||
|
@VisibleForTesting
|
||||||
|
protected ZenModeConfig mConfig;
|
||||||
|
|
||||||
private int mZen;
|
private int mZen;
|
||||||
private ZenModeConfig mConfig;
|
|
||||||
private final Receiver mReceiver;
|
private final Receiver mReceiver;
|
||||||
|
|
||||||
public DndCondition(ConditionManager manager) {
|
public DndCondition(ConditionManager manager) {
|
||||||
@@ -93,7 +94,7 @@ public class DndCondition extends Condition {
|
|||||||
@Override
|
@Override
|
||||||
public CharSequence getSummary() {
|
public CharSequence getSummary() {
|
||||||
return ZenModeConfig.getDescription(mManager.getContext(), mZen != Global.ZEN_MODE_OFF,
|
return ZenModeConfig.getDescription(mManager.getContext(), mZen != Global.ZEN_MODE_OFF,
|
||||||
mConfig);
|
mConfig, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -136,7 +136,7 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
|||||||
|
|
||||||
if (zenMode != Settings.Global.ZEN_MODE_OFF) {
|
if (zenMode != Settings.Global.ZEN_MODE_OFF) {
|
||||||
ZenModeConfig config = NotificationManager.from(mContext).getZenModeConfig();
|
ZenModeConfig config = NotificationManager.from(mContext).getZenModeConfig();
|
||||||
String description = ZenModeConfig.getDescription(mContext, true, config);
|
String description = ZenModeConfig.getDescription(mContext, true, config, false);
|
||||||
|
|
||||||
if (description == null) {
|
if (description == null) {
|
||||||
return mContext.getString(R.string.zen_mode_sound_summary_on);
|
return mContext.getString(R.string.zen_mode_sound_summary_on);
|
||||||
|
@@ -23,6 +23,8 @@ import static org.mockito.Mockito.times;
|
|||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
@@ -104,4 +106,13 @@ public class DndConditionTest {
|
|||||||
|
|
||||||
verify(mContext, never()).unregisterReceiver(any(DndCondition.Receiver.class));
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user