Show "Turns on at bedtime" in Dark theme setting based on feature flag

Test: atest SettingsRoboTests:com.android.settings.display.darkmode.*
Bug: 217866453
Change-Id: Ic40975d4506f812790768339e48441a048529df3
This commit is contained in:
Steven Ng
2022-02-04 15:48:15 +00:00
parent 949ee0518c
commit 89f5e2e497
2 changed files with 10 additions and 0 deletions

View File

@@ -17,11 +17,13 @@
package com.android.settings.display.darkmode;
import static android.provider.Settings.ACTION_BEDTIME_SETTINGS;
import static android.util.FeatureFlagUtils.SETTINGS_APP_ALLOW_DARK_THEME_ACTIVATION_AT_BEDTIME;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.util.FeatureFlagUtils;
import androidx.annotation.Nullable;
@@ -44,6 +46,10 @@ public final class BedtimeSettings {
*/
@Nullable
public Intent getBedtimeSettingsIntent() {
if (!FeatureFlagUtils.isEnabled(mContext,
SETTINGS_APP_ALLOW_DARK_THEME_ACTIVATION_AT_BEDTIME)) {
return null;
}
Intent bedtimeSettingsIntent = new Intent(ACTION_BEDTIME_SETTINGS).setPackage(
mWellbeingPackage);
ResolveInfo bedtimeSettingInfo = mPackageManager.resolveActivity(bedtimeSettingsIntent,

View File

@@ -17,6 +17,7 @@
package com.android.settings.testutils;
import static android.provider.Settings.ACTION_BEDTIME_SETTINGS;
import static android.util.FeatureFlagUtils.SETTINGS_APP_ALLOW_DARK_THEME_ACTIVATION_AT_BEDTIME;
import static org.robolectric.Shadows.shadowOf;
@@ -25,6 +26,7 @@ import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.ResolveInfo;
import android.util.FeatureFlagUtils;
/** A helper class for installing bedtime settings activity. */
public final class BedtimeSettingsUtils {
@@ -35,6 +37,8 @@ public final class BedtimeSettingsUtils {
}
public void installBedtimeSettings(String wellbeingPackage, boolean enabled) {
FeatureFlagUtils.setEnabled(mContext, SETTINGS_APP_ALLOW_DARK_THEME_ACTIVATION_AT_BEDTIME,
true /* enabled */);
Intent bedtimeSettingsIntent = new Intent(ACTION_BEDTIME_SETTINGS)
.setPackage(wellbeingPackage);
ResolveInfo bedtimeResolveInfo = new ResolveInfo();