Update "Dark Theme" Settings screen to account for Modes that can toggle it

Bedtime is no longer a special case.

Fixes: 361592187
Test: atest com.android.settings.display.darkmode
Flag: android.app.modes_ui
Change-Id: Iddc5d8142d6bc0bb1f5c4ead876ee201c8818b12
This commit is contained in:
Matías Hernández
2024-09-10 12:13:41 +02:00
parent 1ffafd365e
commit 2a3e8b3070
10 changed files with 562 additions and 156 deletions

View File

@@ -2929,6 +2929,8 @@
<string name="dark_ui_summary_off_auto_mode_custom">Will turn on automatically at <xliff:g name="time" example="6 AM">%1$s</xliff:g></string> <string name="dark_ui_summary_off_auto_mode_custom">Will turn on automatically at <xliff:g name="time" example="6 AM">%1$s</xliff:g></string>
<!-- Display settings screen, summary of Dark UI when off and will turn on automatically at bedtime. [CHAR LIMIT=NONE] --> <!-- Display settings screen, summary of Dark UI when off and will turn on automatically at bedtime. [CHAR LIMIT=NONE] -->
<string name="dark_ui_summary_off_auto_mode_custom_bedtime">Will turn on automatically at bedtime</string> <string name="dark_ui_summary_off_auto_mode_custom_bedtime">Will turn on automatically at bedtime</string>
<!-- Display settings screen, summary of Dark UI when off and controlled by Modes. [CHAR LIMIT=NONE] -->
<string name="dark_ui_summary_off_auto_mode_modes">Will turn on when <xliff:g name="modeName" example="Bedtime">%1$s</xliff:g> starts</string>
<!-- Display settings screen, summary of Dark UI when on and will *never* turn off automatically. [CHAR LIMIT=NONE] --> <!-- Display settings screen, summary of Dark UI when on and will *never* turn off automatically. [CHAR LIMIT=NONE] -->
<string name="dark_ui_summary_on_auto_mode_never">Will never turn off automatically</string> <string name="dark_ui_summary_on_auto_mode_never">Will never turn off automatically</string>
<!-- Display settings screen, summary of Dark UI when on and will turn off automatically at sunrise. [CHAR LIMIT=NONE] --> <!-- Display settings screen, summary of Dark UI when on and will turn off automatically at sunrise. [CHAR LIMIT=NONE] -->
@@ -2937,12 +2939,26 @@
<string name="dark_ui_summary_on_auto_mode_custom">Will turn off automatically at <xliff:g name="time" example="10 PM">%1$s</xliff:g></string> <string name="dark_ui_summary_on_auto_mode_custom">Will turn off automatically at <xliff:g name="time" example="10 PM">%1$s</xliff:g></string>
<!-- Display settings screen, summary of Dark UI when on and will turn off automatically after bedtime. [CHAR LIMIT=NONE] --> <!-- Display settings screen, summary of Dark UI when on and will turn off automatically after bedtime. [CHAR LIMIT=NONE] -->
<string name="dark_ui_summary_on_auto_mode_custom_bedtime">Will turn off automatically after bedtime</string> <string name="dark_ui_summary_on_auto_mode_custom_bedtime">Will turn off automatically after bedtime</string>
<!-- Display settings screen, summary of Dark UI when on and controlled by Modes. [CHAR LIMIT=NONE] -->
<string name="dark_ui_summary_on_auto_mode_modes">Will turn off when <xliff:g name="modeName" example="Bedtime">%1$s</xliff:g> ends</string>
<!-- Dark theme screen, description of Dark theme feature. [CHAR LIMIT=NONE] --> <!-- Dark theme screen, description of Dark theme feature. [CHAR LIMIT=NONE] -->
<string name="dark_ui_text">Dark theme uses a black background to help keep battery alive longer on some screens. Dark theme schedules wait to turn on until your screen is off.</string> <string name="dark_ui_text">Dark theme uses a black background to help keep battery alive longer on some screens. Dark theme schedules wait to turn on until your screen is off.</string>
<!-- Dark UI screen footer summary text shown when the when Dark theme turns on/off automatically according to a user bedtime schedule. [CHAR LIMIT=NONE] --> <!-- Dark UI screen footer summary text shown when the when Dark theme turns on/off automatically according to a user bedtime schedule. [CHAR LIMIT=NONE] -->
<string name="dark_ui_bedtime_footer_summary">Dark theme is currently following your Bedtime mode schedule</string> <string name="dark_ui_bedtime_footer_summary">Dark theme is currently following your Bedtime mode schedule</string>
<!-- Dark UI screen footer action text shown when the when Dark theme turns on/off automatically according to a user bedtime schedule. [CHAR LIMIT=NONE] --> <!-- Dark UI screen footer action text shown when the when Dark theme turns on/off automatically according to a user bedtime schedule. [CHAR LIMIT=NONE] -->
<string name="dark_ui_bedtime_footer_action">Bedtime mode settings</string> <string name="dark_ui_bedtime_footer_action">Bedtime mode settings</string>
<!-- Dark UI screen footer summary text shown to indicate Modes may turn on/off Dark theme automatically according to their triggers. [CHAR LIMIT=NONE] -->
<string name="dark_ui_modes_footer_summary">
{count, plural, offset:2
=0 {Modes can also activate dark theme}
=1 {{mode_1} also activates dark theme}
=2 {{mode_1} and {mode_2} also activate dark theme}
=3 {{mode_1}, {mode_2}, and {mode_3} also activate dark theme}
other {{mode_1}, {mode_2}, and # more also activate dark theme}
}
</string>
<!-- Dark UI screen footer action text linking to Modes settings. [CHAR LIMIT=NONE] -->
<string name="dark_ui_modes_footer_action">Modes settings</string>
<!-- Even Dimmer setting title. Allows device to reduce brightness even further than standard range. [CHAR LIMIT=NONE] --> <!-- Even Dimmer setting title. Allows device to reduce brightness even further than standard range. [CHAR LIMIT=NONE] -->
<string name="even_dimmer_display_title">Even dimmer</string> <string name="even_dimmer_display_title">Even dimmer</string>
<!-- Even Dimmer setting summary. [CHAR LIMIT=NONE] --> <!-- Even Dimmer setting summary. [CHAR LIMIT=NONE] -->

View File

@@ -60,6 +60,6 @@
android:title="@string/dark_ui_bedtime_footer_summary" android:title="@string/dark_ui_bedtime_footer_summary"
android:selectable="false" android:selectable="false"
settings:searchable="false" settings:searchable="false"
settings:controller="com.android.settings.display.darkmode.DarkModeCustomBedtimePreferenceController" /> settings:controller="com.android.settings.display.darkmode.DarkModeCustomModesPreferenceController" />
</PreferenceScreen> </PreferenceScreen>

View File

@@ -0,0 +1,105 @@
/*
* Copyright (C) 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.display.darkmode;
import static android.app.UiModeManager.MODE_ATTENTION_THEME_OVERLAY_NIGHT;
import static android.app.UiModeManager.MODE_NIGHT_AUTO;
import static android.app.UiModeManager.MODE_NIGHT_CUSTOM_TYPE_BEDTIME;
import static android.app.UiModeManager.MODE_NIGHT_CUSTOM_TYPE_SCHEDULE;
import static com.google.common.base.Preconditions.checkNotNull;
import android.app.Flags;
import android.app.UiModeManager;
import android.content.Context;
import com.android.settings.R;
import com.android.settingslib.notification.modes.ZenMode;
import com.android.settingslib.notification.modes.ZenModesBackend;
import java.time.LocalTime;
import java.util.List;
class AutoDarkTheme {
static String getStatus(Context context, boolean active) {
UiModeManager uiModeManager = checkNotNull(context.getSystemService(UiModeManager.class));
final int mode = uiModeManager.getNightMode();
if (mode == MODE_NIGHT_AUTO) {
return context.getString(active
? R.string.dark_ui_summary_on_auto_mode_auto
: R.string.dark_ui_summary_off_auto_mode_auto);
}
if (Flags.modesUi()) {
if (active && uiModeManager.getAttentionModeThemeOverlay()
== MODE_ATTENTION_THEME_OVERLAY_NIGHT) {
List<String> modes = getActiveModesThatChangeDarkTheme(context);
if (!modes.isEmpty()) {
return context.getString(R.string.dark_ui_summary_on_auto_mode_modes,
modes.get(0));
}
} else if (!active) {
List<String> modes = getModesThatChangeDarkTheme(context);
if (!modes.isEmpty()) {
return context.getString(R.string.dark_ui_summary_off_auto_mode_modes,
modes.get(0));
}
}
}
if (mode == UiModeManager.MODE_NIGHT_CUSTOM) {
int modeCustomType = uiModeManager.getNightModeCustomType();
if (!Flags.modesUi() && modeCustomType == MODE_NIGHT_CUSTOM_TYPE_BEDTIME) {
return context.getString(active
? R.string.dark_ui_summary_on_auto_mode_custom_bedtime
: R.string.dark_ui_summary_off_auto_mode_custom_bedtime);
}
if (modeCustomType == MODE_NIGHT_CUSTOM_TYPE_SCHEDULE) {
final LocalTime time = active
? uiModeManager.getCustomNightModeEnd()
: uiModeManager.getCustomNightModeStart();
final String timeStr = new TimeFormatter(context).of(time);
return context.getString(active
? R.string.dark_ui_summary_on_auto_mode_custom
: R.string.dark_ui_summary_off_auto_mode_custom, timeStr);
}
}
return context.getString(active
? R.string.dark_ui_summary_on_auto_mode_never
: R.string.dark_ui_summary_off_auto_mode_never);
}
static List<String> getModesThatChangeDarkTheme(Context context) {
return ZenModesBackend.getInstance(context)
.getModes().stream()
.filter(m -> m.getDeviceEffects().shouldUseNightMode())
.map(ZenMode::getName)
.toList();
}
static List<String> getActiveModesThatChangeDarkTheme(Context context) {
return ZenModesBackend.getInstance(context)
.getModes().stream()
.filter(ZenMode::isActive)
.filter(m -> m.getDeviceEffects().shouldUseNightMode())
.map(ZenMode::getName)
.toList();
}
}

View File

@@ -24,14 +24,11 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController; import com.android.settings.core.BasePreferenceController;
import com.android.settings.overlay.FeatureFactory; import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.widget.MainSwitchPreference; import com.android.settingslib.widget.MainSwitchPreference;
import java.time.LocalTime;
/** /**
* Controller for activate/deactivate night mode button * Controller for activate/deactivate night mode button
*/ */
@@ -40,22 +37,14 @@ public class DarkModeActivationPreferenceController extends BasePreferenceContro
private final UiModeManager mUiModeManager; private final UiModeManager mUiModeManager;
private final MetricsFeatureProvider mMetricsFeatureProvider; private final MetricsFeatureProvider mMetricsFeatureProvider;
private TimeFormatter mFormat;
private MainSwitchPreference mPreference; private MainSwitchPreference mPreference;
public DarkModeActivationPreferenceController(Context context, String preferenceKey) { public DarkModeActivationPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey); super(context, preferenceKey);
mUiModeManager = context.getSystemService(UiModeManager.class); mUiModeManager = context.getSystemService(UiModeManager.class);
mFormat = new TimeFormatter(context);
mMetricsFeatureProvider = FeatureFactory.getFeatureFactory().getMetricsFeatureProvider(); mMetricsFeatureProvider = FeatureFactory.getFeatureFactory().getMetricsFeatureProvider();
} }
public DarkModeActivationPreferenceController(Context context, String preferenceKey,
TimeFormatter f) {
this(context, preferenceKey);
mFormat = f;
}
@Override @Override
public final void updateState(Preference preference) { public final void updateState(Preference preference) {
final boolean active = (mContext.getResources().getConfiguration().uiMode final boolean active = (mContext.getResources().getConfiguration().uiMode
@@ -67,32 +56,7 @@ public class DarkModeActivationPreferenceController extends BasePreferenceContro
public CharSequence getSummary() { public CharSequence getSummary() {
final boolean isActivated = (mContext.getResources().getConfiguration().uiMode final boolean isActivated = (mContext.getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_YES) != 0; & Configuration.UI_MODE_NIGHT_YES) != 0;
final int mode = mUiModeManager.getNightMode(); return AutoDarkTheme.getStatus(mContext, isActivated);
if (mode == UiModeManager.MODE_NIGHT_AUTO) {
return mContext.getString(isActivated
? R.string.dark_ui_summary_on_auto_mode_auto
: R.string.dark_ui_summary_off_auto_mode_auto);
} else if (mode == UiModeManager.MODE_NIGHT_CUSTOM) {
if (mUiModeManager.getNightModeCustomType()
== UiModeManager.MODE_NIGHT_CUSTOM_TYPE_BEDTIME) {
return mContext.getString(isActivated
? R.string.dark_ui_summary_on_auto_mode_custom_bedtime
: R.string.dark_ui_summary_off_auto_mode_custom_bedtime);
}
final LocalTime time = isActivated
? mUiModeManager.getCustomNightModeEnd()
: mUiModeManager.getCustomNightModeStart();
final String timeStr = mFormat.of(time);
return mContext.getString(isActivated
? R.string.dark_ui_summary_on_auto_mode_custom
: R.string.dark_ui_summary_off_auto_mode_custom, timeStr);
} else {
return mContext.getString(isActivated
? R.string.dark_ui_summary_on_auto_mode_never
: R.string.dark_ui_summary_off_auto_mode_never);
}
} }
@Override @Override

View File

@@ -1,74 +0,0 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.display.darkmode;
import static android.app.UiModeManager.MODE_NIGHT_CUSTOM_TYPE_BEDTIME;
import android.app.UiModeManager;
import android.content.Context;
import android.content.Intent;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.widget.FooterPreference;
/** Controller for the night mode bedtime custom mode footer. */
public class DarkModeCustomBedtimePreferenceController extends BasePreferenceController {
private final UiModeManager mUiModeManager;
private FooterPreference mFooterPreference;
private BedtimeSettings mBedtimeSettings;
public DarkModeCustomBedtimePreferenceController(Context context, String key) {
super(context, key);
mUiModeManager = context.getSystemService(UiModeManager.class);
mBedtimeSettings = new BedtimeSettings(context);
}
@Override
public int getAvailabilityStatus() {
return mBedtimeSettings.getBedtimeSettingsIntent() == null
? UNSUPPORTED_ON_DEVICE
: AVAILABLE_UNSEARCHABLE;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mFooterPreference = screen.findPreference(getPreferenceKey());
mFooterPreference.setLearnMoreAction(
v -> {
Intent bedtimeSettingsIntent = mBedtimeSettings.getBedtimeSettingsIntent();
if (bedtimeSettingsIntent != null) {
v.getContext().startActivity(bedtimeSettingsIntent);
}
});
mFooterPreference.setLearnMoreText(
mContext.getString(R.string.dark_ui_bedtime_footer_action));
}
@Override
public void updateState(Preference preference) {
if (mUiModeManager.getNightModeCustomType() != MODE_NIGHT_CUSTOM_TYPE_BEDTIME) {
preference.setVisible(false);
return;
}
preference.setVisible(true);
}
}

View File

@@ -0,0 +1,112 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.display.darkmode;
import static android.app.UiModeManager.MODE_NIGHT_CUSTOM_TYPE_BEDTIME;
import static android.app.settings.SettingsEnums.DARK_UI_SETTINGS;
import static com.google.common.base.Preconditions.checkNotNull;
import android.app.Flags;
import android.app.UiModeManager;
import android.content.Context;
import android.content.Intent;
import android.icu.text.MessageFormat;
import androidx.annotation.NonNull;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.notification.modes.ZenModesListFragment;
import com.android.settingslib.widget.FooterPreference;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
/** Controller for the dark theme Modes / Bedtime custom footer. */
public class DarkModeCustomModesPreferenceController extends BasePreferenceController {
private final UiModeManager mUiModeManager;
private final BedtimeSettings mBedtimeSettings;
public DarkModeCustomModesPreferenceController(@NonNull Context context, @NonNull String key) {
super(context, key);
mUiModeManager = context.getSystemService(UiModeManager.class);
mBedtimeSettings = new BedtimeSettings(context);
}
@Override
public int getAvailabilityStatus() {
return (Flags.modesUi() || mBedtimeSettings.getBedtimeSettingsIntent() != null)
? AVAILABLE_UNSEARCHABLE
: UNSUPPORTED_ON_DEVICE;
}
@Override
public void displayPreference(@NonNull PreferenceScreen screen) {
super.displayPreference(screen);
FooterPreference footerPreference = checkNotNull(screen.findPreference(getPreferenceKey()));
if (Flags.modesUi()) {
List<String> modesUsingDarkTheme = AutoDarkTheme.getModesThatChangeDarkTheme(
screen.getContext());
MessageFormat titleFormat = new MessageFormat(
mContext.getString(R.string.dark_ui_modes_footer_summary),
Locale.getDefault());
Map<String, Object> args = new HashMap<>();
args.put("count", modesUsingDarkTheme.size());
for (int i = 0; i < modesUsingDarkTheme.size() && i < 3; i++) {
args.put("mode_" + (i + 1), modesUsingDarkTheme.get(i));
}
footerPreference.setTitle(titleFormat.format(args));
footerPreference.setLearnMoreAction(
v -> new SubSettingLauncher(v.getContext())
.setDestination(ZenModesListFragment.class.getName())
.setSourceMetricsCategory(DARK_UI_SETTINGS)
.launch());
footerPreference.setLearnMoreText(
mContext.getString(R.string.dark_ui_modes_footer_action));
} else {
footerPreference.setTitle(R.string.dark_ui_bedtime_footer_summary);
footerPreference.setLearnMoreAction(
v -> {
Intent bedtimeSettingsIntent = mBedtimeSettings.getBedtimeSettingsIntent();
if (bedtimeSettingsIntent != null) {
v.getContext().startActivity(bedtimeSettingsIntent);
}
});
footerPreference.setLearnMoreText(
mContext.getString(R.string.dark_ui_bedtime_footer_action));
}
}
@Override
public void updateState(@NonNull Preference preference) {
if (!Flags.modesUi()) {
if (mUiModeManager.getNightModeCustomType() != MODE_NIGHT_CUSTOM_TYPE_BEDTIME) {
preference.setVisible(false);
return;
}
preference.setVisible(true);
}
}
}

View File

@@ -23,8 +23,6 @@ import android.util.AttributeSet;
import com.android.settings.R; import com.android.settings.R;
import com.android.settingslib.PrimarySwitchPreference; import com.android.settingslib.PrimarySwitchPreference;
import java.time.LocalTime;
/** /**
* component for the display settings dark ui summary * component for the display settings dark ui summary
*/ */
@@ -71,36 +69,8 @@ public class DarkModePreference extends PrimarySwitchPreference {
? R.string.dark_ui_mode_disabled_summary_dark_theme_on ? R.string.dark_ui_mode_disabled_summary_dark_theme_on
: R.string.dark_ui_mode_disabled_summary_dark_theme_off; : R.string.dark_ui_mode_disabled_summary_dark_theme_off;
setSummary(getContext().getString(stringId)); setSummary(getContext().getString(stringId));
return;
}
final int mode = mUiModeManager.getNightMode();
String summary;
if (mode == UiModeManager.MODE_NIGHT_AUTO) {
summary = getContext().getString(active
? R.string.dark_ui_summary_on_auto_mode_auto
: R.string.dark_ui_summary_off_auto_mode_auto);
} else if (mode == UiModeManager.MODE_NIGHT_CUSTOM) {
if (mUiModeManager.getNightModeCustomType()
== UiModeManager.MODE_NIGHT_CUSTOM_TYPE_BEDTIME) {
summary = getContext().getString(active
? R.string.dark_ui_summary_on_auto_mode_custom_bedtime
: R.string.dark_ui_summary_off_auto_mode_custom_bedtime);
} else {
final LocalTime time = active
? mUiModeManager.getCustomNightModeEnd()
: mUiModeManager.getCustomNightModeStart();
final String timeStr = mFormat.of(time);
summary = getContext().getString(active
? R.string.dark_ui_summary_on_auto_mode_custom
: R.string.dark_ui_summary_off_auto_mode_custom, timeStr);
}
} else { } else {
summary = getContext().getString(active setSummary(AutoDarkTheme.getStatus(getContext(), active));
? R.string.dark_ui_summary_on_auto_mode_never
: R.string.dark_ui_summary_off_auto_mode_never);
} }
setSummary(summary);
} }
} }

View File

@@ -0,0 +1,207 @@
/*
* Copyright (C) 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.display.darkmode;
import static android.app.UiModeManager.MODE_ATTENTION_THEME_OVERLAY_NIGHT;
import static android.app.UiModeManager.MODE_NIGHT_AUTO;
import static android.app.UiModeManager.MODE_NIGHT_CUSTOM;
import static android.app.UiModeManager.MODE_NIGHT_CUSTOM_TYPE_BEDTIME;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.when;
import android.app.Flags;
import android.app.UiModeManager;
import android.content.Context;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.service.notification.ZenDeviceEffects;
import androidx.test.core.app.ApplicationProvider;
import com.android.settingslib.notification.modes.TestModeBuilder;
import com.android.settingslib.notification.modes.ZenMode;
import com.android.settingslib.notification.modes.ZenModesBackend;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.shadows.ShadowApplication;
import java.time.LocalTime;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
public class AutoDarkThemeTest {
@Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
private static final ZenDeviceEffects DEVICE_EFFECTS_WITH_DARK_THEME =
new ZenDeviceEffects.Builder().setShouldUseNightMode(true).build();
private static final ZenMode MODE_WITH_DARK_THEME = new TestModeBuilder()
.setName("Sechseläuten")
.setDeviceEffects(DEVICE_EFFECTS_WITH_DARK_THEME)
.build();
private Context mContext;
@Mock private UiModeManager mUiModeManager;
@Mock private ZenModesBackend mZenModesBackend;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = ApplicationProvider.getApplicationContext();
ShadowApplication shadowApp = ShadowApplication.getInstance();
shadowApp.setSystemService(Context.UI_MODE_SERVICE, mUiModeManager);
ZenModesBackend.setInstance(mZenModesBackend);
when(mZenModesBackend.getModes()).thenReturn(List.of());
}
@Test
public void getStatus_inactiveButAuto() {
when(mUiModeManager.getNightMode()).thenReturn(MODE_NIGHT_AUTO);
assertThat(getStatus(false)).isEqualTo("Will turn on automatically at sunset");
}
@Test
public void getStatus_activeDueToAuto() {
when(mUiModeManager.getNightMode()).thenReturn(MODE_NIGHT_AUTO);
assertThat(getStatus(true)).isEqualTo("Will turn off automatically at sunrise");
}
@Test
@EnableFlags(Flags.FLAG_MODES_UI)
public void getStatus_inactiveButUsedInModes() {
when(mUiModeManager.getNightMode()).thenReturn(MODE_NIGHT_CUSTOM);
when(mZenModesBackend.getModes()).thenReturn(List.of(MODE_WITH_DARK_THEME));
assertThat(getStatus(false)).isEqualTo("Will turn on when Sechseläuten starts");
}
@Test
@EnableFlags(Flags.FLAG_MODES_UI)
public void getStatus_activeDueToModes() {
when(mUiModeManager.getNightMode()).thenReturn(MODE_NIGHT_CUSTOM);
when(mUiModeManager.getAttentionModeThemeOverlay()).thenReturn(
MODE_ATTENTION_THEME_OVERLAY_NIGHT);
when(mZenModesBackend.getModes()).thenReturn(
List.of(new TestModeBuilder(MODE_WITH_DARK_THEME).setActive(true).build()));
assertThat(getStatus(true)).isEqualTo("Will turn off when Sechseläuten ends");
}
@Test
@DisableFlags(Flags.FLAG_MODES_UI)
public void getStatus_inactiveButUsingBedtime() {
when(mUiModeManager.getNightMode()).thenReturn(MODE_NIGHT_CUSTOM);
when(mUiModeManager.getNightModeCustomType()).thenReturn(MODE_NIGHT_CUSTOM_TYPE_BEDTIME);
assertThat(getStatus(false)).isEqualTo("Will turn on automatically at bedtime");
}
@Test
@DisableFlags(Flags.FLAG_MODES_UI)
public void getStatus_activeDueToBedtime() {
when(mUiModeManager.getNightMode()).thenReturn(MODE_NIGHT_CUSTOM);
when(mUiModeManager.getNightModeCustomType()).thenReturn(MODE_NIGHT_CUSTOM_TYPE_BEDTIME);
assertThat(getStatus(true)).isEqualTo("Will turn off automatically after bedtime");
}
@Test
public void getStatus_inactiveButHasSchedule() {
when(mUiModeManager.getNightMode()).thenReturn(MODE_NIGHT_CUSTOM);
when(mUiModeManager.getCustomNightModeStart()).thenReturn(LocalTime.of(22, 0, 0, 0));
when(mUiModeManager.getCustomNightModeEnd()).thenReturn(LocalTime.of(8, 0, 0, 0));
assertThat(getStatus(false)).isEqualTo("Will turn on automatically at 10:00 PM");
}
@Test
public void getStatus_activeDueToSchedule() {
when(mUiModeManager.getNightMode()).thenReturn(MODE_NIGHT_CUSTOM);
when(mUiModeManager.getCustomNightModeStart()).thenReturn(LocalTime.of(22, 0, 0, 0));
when(mUiModeManager.getCustomNightModeEnd()).thenReturn(LocalTime.of(8, 0, 0, 0));
assertThat(getStatus(true)).isEqualTo("Will turn off automatically at 8:00 AM");
}
private String getStatus(boolean active) {
return AutoDarkTheme.getStatus(mContext, active);
}
@Test
@EnableFlags(Flags.FLAG_MODES_UI)
public void getModesThatChangeDarkTheme_returnsModeNames() {
ZenMode modeThatChanges1 = new TestModeBuilder()
.setName("Inactive")
.setDeviceEffects(DEVICE_EFFECTS_WITH_DARK_THEME)
.setActive(false)
.build();
ZenMode modeThatDoesNotChange = new TestModeBuilder()
.setName("Unrelated")
.build();
ZenMode modeThatChanges2 = new TestModeBuilder()
.setName("Active")
.setDeviceEffects(DEVICE_EFFECTS_WITH_DARK_THEME)
.setActive(true)
.build();
when(mZenModesBackend.getModes()).thenReturn(
List.of(modeThatChanges1, modeThatDoesNotChange, modeThatChanges2));
assertThat(AutoDarkTheme.getModesThatChangeDarkTheme(mContext))
.containsExactly("Inactive", "Active")
.inOrder();
}
@Test
@EnableFlags(Flags.FLAG_MODES_UI)
public void getActiveModesThatChangeDarkTheme_returnsModeNames() {
ZenMode inactiveModeThatUsesDarkTheme = new TestModeBuilder()
.setName("Inactive")
.setDeviceEffects(DEVICE_EFFECTS_WITH_DARK_THEME)
.setActive(false)
.build();
ZenMode otherInactiveMode = new TestModeBuilder()
.setName("Unrelated, inactive")
.setActive(false)
.build();
ZenMode otherActiveMode = new TestModeBuilder()
.setName("Unrelated, active")
.setActive(true)
.build();
ZenMode activeModeThatUsesDarkTheme = new TestModeBuilder()
.setName("Active")
.setDeviceEffects(DEVICE_EFFECTS_WITH_DARK_THEME)
.setActive(true)
.build();
when(mZenModesBackend.getModes()).thenReturn(
List.of(inactiveModeThatUsesDarkTheme, otherInactiveMode, otherActiveMode,
activeModeThatUsesDarkTheme));
assertThat(AutoDarkTheme.getActiveModesThatChangeDarkTheme(mContext))
.containsExactly("Active");
}
}

View File

@@ -22,23 +22,29 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import android.app.Flags;
import android.app.UiModeManager; import android.app.UiModeManager;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.PowerManager; import android.os.PowerManager;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.testutils.FakeFeatureFactory; import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settingslib.notification.modes.ZenModesBackend;
import com.android.settingslib.widget.MainSwitchPreference; import com.android.settingslib.widget.MainSwitchPreference;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
@@ -47,6 +53,8 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment; import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config; import org.robolectric.annotation.Config;
import java.time.LocalTime;
import java.util.List;
import java.util.Locale; import java.util.Locale;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
@@ -57,6 +65,9 @@ public class DarkModeActivationPreferenceControllerTest {
private DarkModeActivationPreferenceController mController; private DarkModeActivationPreferenceController mController;
private String mPreferenceKey = "key"; private String mPreferenceKey = "key";
@Rule
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
private MainSwitchPreference mPreference; private MainSwitchPreference mPreference;
@Mock @Mock
private PreferenceScreen mScreen; private PreferenceScreen mScreen;
@@ -67,7 +78,7 @@ public class DarkModeActivationPreferenceControllerTest {
@Mock @Mock
private PowerManager mPM; private PowerManager mPM;
@Mock @Mock
private TimeFormatter mFormat; private ZenModesBackend mZenModesBackend;
private Context mContext; private Context mContext;
private Configuration mConfigNightYes = new Configuration(); private Configuration mConfigNightYes = new Configuration();
@@ -87,7 +98,6 @@ public class DarkModeActivationPreferenceControllerTest {
when(mContext.getSystemService(PowerManager.class)).thenReturn(mPM); when(mContext.getSystemService(PowerManager.class)).thenReturn(mPM);
when(mScreen.findPreference(anyString())).thenReturn(mPreference); when(mScreen.findPreference(anyString())).thenReturn(mPreference);
when(mService.setNightModeActivated(anyBoolean())).thenReturn(true); when(mService.setNightModeActivated(anyBoolean())).thenReturn(true);
when(mFormat.of(any())).thenReturn("10:00 AM");
when(mContext.getString( when(mContext.getString(
R.string.dark_ui_activation_off_auto)).thenReturn("off_auto"); R.string.dark_ui_activation_off_auto)).thenReturn("off_auto");
when(mContext.getString( when(mContext.getString(
@@ -104,20 +114,23 @@ public class DarkModeActivationPreferenceControllerTest {
R.string.dark_ui_summary_off_auto_mode_never)).thenReturn("summary_off_manual"); R.string.dark_ui_summary_off_auto_mode_never)).thenReturn("summary_off_manual");
when(mContext.getString( when(mContext.getString(
R.string.dark_ui_summary_on_auto_mode_never)).thenReturn("summary_on_manual"); R.string.dark_ui_summary_on_auto_mode_never)).thenReturn("summary_on_manual");
when(mContext.getString(R.string.dark_ui_summary_on_auto_mode_custom, "10:00 AM")) when(mContext.getString(eq(R.string.dark_ui_summary_on_auto_mode_custom), any()))
.thenReturn("summary_on_custom"); .thenReturn("summary_on_custom");
when(mContext.getString(R.string.dark_ui_summary_off_auto_mode_custom, "10:00 AM")) when(mContext.getString(eq(R.string.dark_ui_summary_off_auto_mode_custom), any()))
.thenReturn("summary_off_custom"); .thenReturn("summary_off_custom");
when(mContext.getString(R.string.dark_ui_summary_on_auto_mode_custom_bedtime)) when(mContext.getString(R.string.dark_ui_summary_on_auto_mode_custom_bedtime))
.thenReturn("summary_on_custom_bedtime"); .thenReturn("summary_on_custom_bedtime");
when(mContext.getString(R.string.dark_ui_summary_off_auto_mode_custom_bedtime)) when(mContext.getString(R.string.dark_ui_summary_off_auto_mode_custom_bedtime))
.thenReturn("summary_off_custom_bedtime"); .thenReturn("summary_off_custom_bedtime");
mController = new DarkModeActivationPreferenceController(mContext, mPreferenceKey, mFormat); mController = new DarkModeActivationPreferenceController(mContext, mPreferenceKey);
mController.displayPreference(mScreen); mController.displayPreference(mScreen);
mConfigNightNo.uiMode = Configuration.UI_MODE_NIGHT_NO; mConfigNightNo.uiMode = Configuration.UI_MODE_NIGHT_NO;
mConfigNightYes.uiMode = Configuration.UI_MODE_NIGHT_YES; mConfigNightYes.uiMode = Configuration.UI_MODE_NIGHT_YES;
mConfigNightNo.locale = mLocal; mConfigNightNo.locale = mLocal;
mConfigNightYes.locale = mLocal; mConfigNightYes.locale = mLocal;
ZenModesBackend.setInstance(mZenModesBackend);
when(mZenModesBackend.getModes()).thenReturn(List.of());
} }
@Test @Test
@@ -145,6 +158,8 @@ public class DarkModeActivationPreferenceControllerTest {
@Test @Test
public void nightMode_toggleButton_onCustom() { public void nightMode_toggleButton_onCustom() {
when(mService.getNightMode()).thenReturn(UiModeManager.MODE_NIGHT_CUSTOM); when(mService.getNightMode()).thenReturn(UiModeManager.MODE_NIGHT_CUSTOM);
when(mService.getCustomNightModeStart()).thenReturn(LocalTime.of(10, 0, 0, 0));
when(mService.getCustomNightModeEnd()).thenReturn(LocalTime.of(12, 0, 0, 0));
when(mRes.getConfiguration()).thenReturn(mConfigNightYes); when(mRes.getConfiguration()).thenReturn(mConfigNightYes);
mController.updateState(mPreference); mController.updateState(mPreference);
@@ -156,6 +171,8 @@ public class DarkModeActivationPreferenceControllerTest {
@Test @Test
public void nightMode_toggleButton_offCustom() { public void nightMode_toggleButton_offCustom() {
when(mService.getNightMode()).thenReturn(UiModeManager.MODE_NIGHT_CUSTOM); when(mService.getNightMode()).thenReturn(UiModeManager.MODE_NIGHT_CUSTOM);
when(mService.getCustomNightModeStart()).thenReturn(LocalTime.of(10, 0, 0, 0));
when(mService.getCustomNightModeEnd()).thenReturn(LocalTime.of(12, 0, 0, 0));
when(mRes.getConfiguration()).thenReturn(mConfigNightNo); when(mRes.getConfiguration()).thenReturn(mConfigNightNo);
mController.updateState(mPreference); mController.updateState(mPreference);
@@ -165,6 +182,7 @@ public class DarkModeActivationPreferenceControllerTest {
} }
@Test @Test
@DisableFlags(Flags.FLAG_MODES_UI)
public void nightMode_toggleButton_onCustomBedtime() { public void nightMode_toggleButton_onCustomBedtime() {
when(mService.getNightMode()).thenReturn(UiModeManager.MODE_NIGHT_CUSTOM); when(mService.getNightMode()).thenReturn(UiModeManager.MODE_NIGHT_CUSTOM);
when(mService.getNightModeCustomType()) when(mService.getNightModeCustomType())
@@ -178,6 +196,7 @@ public class DarkModeActivationPreferenceControllerTest {
} }
@Test @Test
@DisableFlags(Flags.FLAG_MODES_UI)
public void nightMode_toggleButton_offCustomBedtime() { public void nightMode_toggleButton_offCustomBedtime() {
when(mService.getNightMode()).thenReturn(UiModeManager.MODE_NIGHT_CUSTOM); when(mService.getNightMode()).thenReturn(UiModeManager.MODE_NIGHT_CUSTOM);
when(mService.getNightModeCustomType()) when(mService.getNightModeCustomType())

View File

@@ -27,42 +27,62 @@ import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
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 android.app.Flags;
import android.app.UiModeManager; import android.app.UiModeManager;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.service.notification.ZenDeviceEffects;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import androidx.test.core.app.ApplicationProvider; import androidx.test.core.app.ApplicationProvider;
import com.android.settings.testutils.BedtimeSettingsUtils; import com.android.settings.testutils.BedtimeSettingsUtils;
import com.android.settings.testutils.FakeFeatureFactory; import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settingslib.notification.modes.TestModeBuilder;
import com.android.settingslib.notification.modes.ZenMode;
import com.android.settingslib.notification.modes.ZenModesBackend;
import com.android.settingslib.widget.FooterPreference; import com.android.settingslib.widget.FooterPreference;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner; import org.robolectric.RobolectricTestRunner;
import java.util.List;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
public class DarkModeCustomBedtimePreferenceControllerTest { public class DarkModeCustomModesPreferenceControllerTest {
private static final ZenMode MODE_WITH_DARK_THEME = new TestModeBuilder()
.setDeviceEffects(new ZenDeviceEffects.Builder().setShouldUseNightMode(true).build())
.build();
@Rule
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
@Mock @Mock
private UiModeManager mService; private UiModeManager mService;
@Mock @Mock
private PreferenceScreen mScreen; private PreferenceScreen mScreen;
@Mock @Mock
private Resources mResources;
@Mock
private FooterPreference mFooterPreference; private FooterPreference mFooterPreference;
@Mock
private ZenModesBackend mZenModesBackend;
private DarkModeCustomBedtimePreferenceController mController; private DarkModeCustomModesPreferenceController mController;
private Context mContext; private Context mContext;
private BedtimeSettingsUtils mBedtimeSettingsUtils; private BedtimeSettingsUtils mBedtimeSettingsUtils;
@@ -75,17 +95,78 @@ public class DarkModeCustomBedtimePreferenceControllerTest {
mBedtimeSettingsUtils = new BedtimeSettingsUtils(mContext); mBedtimeSettingsUtils = new BedtimeSettingsUtils(mContext);
when(mContext.getSystemService(UiModeManager.class)).thenReturn(mService); when(mContext.getSystemService(UiModeManager.class)).thenReturn(mService);
Resources res = spy(mContext.getResources());
when(mContext.getResources()).thenReturn(mResources); when(res.getString(com.android.internal.R.string.config_systemWellbeing))
when(mResources.getString(com.android.internal.R.string.config_systemWellbeing))
.thenReturn("wellbeing"); .thenReturn("wellbeing");
when(mContext.getResources()).thenReturn(res);
when(mScreen.findPreference(anyString())).thenReturn(mFooterPreference); when(mScreen.findPreference(anyString())).thenReturn(mFooterPreference);
mController = new DarkModeCustomBedtimePreferenceController(mContext, "key"); mController = new DarkModeCustomModesPreferenceController(mContext, "key");
ZenModesBackend.setInstance(mZenModesBackend);
when(mZenModesBackend.getModes()).thenReturn(List.of());
} }
@Test @Test
@EnableFlags(Flags.FLAG_MODES_UI)
public void displayPreference_withOneModeTogglingDarkTheme() {
when(mZenModesBackend.getModes()).thenReturn(List.of(
new TestModeBuilder(MODE_WITH_DARK_THEME).setName("A").build()));
mController.displayPreference(mScreen);
verify(mFooterPreference).setTitle("A also activates dark theme");
verify(mFooterPreference).setLearnMoreAction(any());
verify(mFooterPreference).setLearnMoreText("Modes settings");
}
@Test
@EnableFlags(Flags.FLAG_MODES_UI)
public void displayPreference_withTwoModesTogglingDarkTheme() {
when(mZenModesBackend.getModes()).thenReturn(List.of(
new TestModeBuilder(MODE_WITH_DARK_THEME).setName("A").build(),
new TestModeBuilder(MODE_WITH_DARK_THEME).setName("B").build()));
mController.displayPreference(mScreen);
verify(mFooterPreference).setTitle("A and B also activate dark theme");
verify(mFooterPreference).setLearnMoreAction(any());
verify(mFooterPreference).setLearnMoreText("Modes settings");
}
@Test
@EnableFlags(Flags.FLAG_MODES_UI)
public void displayPreference_withManyModesTogglingDarkTheme() {
when(mZenModesBackend.getModes()).thenReturn(List.of(
new TestModeBuilder(MODE_WITH_DARK_THEME).setName("A").build(),
new TestModeBuilder(MODE_WITH_DARK_THEME).setName("B").build(),
new TestModeBuilder(MODE_WITH_DARK_THEME).setName("C").build(),
new TestModeBuilder(MODE_WITH_DARK_THEME).setName("D").build(),
new TestModeBuilder(MODE_WITH_DARK_THEME).setName("E").build()
));
mController.displayPreference(mScreen);
verify(mFooterPreference).setTitle("A, B, and 3 more also activate dark theme");
verify(mFooterPreference).setLearnMoreAction(any());
verify(mFooterPreference).setLearnMoreText("Modes settings");
}
@Test
@EnableFlags(Flags.FLAG_MODES_UI)
public void displayPreference_withZeroModesTogglingDarkTheme() {
when(mZenModesBackend.getModes()).thenReturn(List.of());
mController.displayPreference(mScreen);
verify(mFooterPreference).setTitle("Modes can also activate dark theme");
verify(mFooterPreference).setLearnMoreAction(any());
verify(mFooterPreference).setLearnMoreText("Modes settings");
}
@Test
@DisableFlags(Flags.FLAG_MODES_UI)
public void getAvailabilityStatus_bedtimeSettingsExist_shouldBeAvailableUnsearchable() { public void getAvailabilityStatus_bedtimeSettingsExist_shouldBeAvailableUnsearchable() {
mBedtimeSettingsUtils.installBedtimeSettings("wellbeing" /* wellbeingPackage */, mBedtimeSettingsUtils.installBedtimeSettings("wellbeing" /* wellbeingPackage */,
true /* enabled */); true /* enabled */);
@@ -95,6 +176,7 @@ public class DarkModeCustomBedtimePreferenceControllerTest {
} }
@Test @Test
@DisableFlags(Flags.FLAG_MODES_UI)
public void getAvailabilityStatus_bedtimeSettingsDisabled_shouldBeUnsupportedOnDevice() { public void getAvailabilityStatus_bedtimeSettingsDisabled_shouldBeUnsupportedOnDevice() {
mBedtimeSettingsUtils.installBedtimeSettings("wellbeing" /* wellbeingPackage */, mBedtimeSettingsUtils.installBedtimeSettings("wellbeing" /* wellbeingPackage */,
false /* enabled */); false /* enabled */);
@@ -104,6 +186,7 @@ public class DarkModeCustomBedtimePreferenceControllerTest {
} }
@Test @Test
@DisableFlags(Flags.FLAG_MODES_UI)
public void nightModeCustomModeBedtime_bedtimeSettingsExist_shouldShowFooterPreference() { public void nightModeCustomModeBedtime_bedtimeSettingsExist_shouldShowFooterPreference() {
mBedtimeSettingsUtils.installBedtimeSettings("wellbeing" /* wellbeingPackage */, mBedtimeSettingsUtils.installBedtimeSettings("wellbeing" /* wellbeingPackage */,
true /* enabled */); true /* enabled */);
@@ -116,6 +199,7 @@ public class DarkModeCustomBedtimePreferenceControllerTest {
} }
@Test @Test
@DisableFlags(Flags.FLAG_MODES_UI)
public void nightModeCustomModeSchedule_bedtimeSettingsExist_shouldHideFooterPreference() { public void nightModeCustomModeSchedule_bedtimeSettingsExist_shouldHideFooterPreference() {
mBedtimeSettingsUtils.installBedtimeSettings("wellbeing" /* wellbeingPackage */, mBedtimeSettingsUtils.installBedtimeSettings("wellbeing" /* wellbeingPackage */,
true /* enabled */); true /* enabled */);
@@ -127,6 +211,7 @@ public class DarkModeCustomBedtimePreferenceControllerTest {
} }
@Test @Test
@DisableFlags(Flags.FLAG_MODES_UI)
public void nightModeNo_bedtimeSettingsExist_shouldHideFooterPreference() { public void nightModeNo_bedtimeSettingsExist_shouldHideFooterPreference() {
mBedtimeSettingsUtils.installBedtimeSettings("wellbeing" /* wellbeingPackage */, mBedtimeSettingsUtils.installBedtimeSettings("wellbeing" /* wellbeingPackage */,
true /* enabled */); true /* enabled */);
@@ -138,6 +223,7 @@ public class DarkModeCustomBedtimePreferenceControllerTest {
} }
@Test @Test
@DisableFlags(Flags.FLAG_MODES_UI)
public void nightModeYes_bedtimeSettingsExist_shouldHideFooterPreference() { public void nightModeYes_bedtimeSettingsExist_shouldHideFooterPreference() {
mBedtimeSettingsUtils.installBedtimeSettings("wellbeing" /* wellbeingPackage */, mBedtimeSettingsUtils.installBedtimeSettings("wellbeing" /* wellbeingPackage */,
true /* enabled */); true /* enabled */);
@@ -149,6 +235,7 @@ public class DarkModeCustomBedtimePreferenceControllerTest {
} }
@Test @Test
@DisableFlags(Flags.FLAG_MODES_UI)
public void nightModeAuto_bedtimeSettingsExist_shouldHideFooterPreference() { public void nightModeAuto_bedtimeSettingsExist_shouldHideFooterPreference() {
mBedtimeSettingsUtils.installBedtimeSettings("wellbeing" /* wellbeingPackage */, mBedtimeSettingsUtils.installBedtimeSettings("wellbeing" /* wellbeingPackage */,
true /* enabled */); true /* enabled */);