Merge "Cleanup dream complication setting to reflect single toggle users see in Settings." into tm-qpr-dev am: e16a86cf1c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19699462 Change-Id: I95e0810838925833e869ed171bdafdd4b34dfe87 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -9142,14 +9142,12 @@ public final class Settings {
|
|||||||
public static final String SCREENSAVER_DEFAULT_COMPONENT = "screensaver_default_component";
|
public static final String SCREENSAVER_DEFAULT_COMPONENT = "screensaver_default_component";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The complications that are enabled to be shown over the screensaver by the user. Holds
|
* Whether complications are enabled to be shown over the screensaver by the user.
|
||||||
* a comma separated list of
|
|
||||||
* {@link com.android.settingslib.dream.DreamBackend.ComplicationType}.
|
|
||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static final String SCREENSAVER_ENABLED_COMPLICATIONS =
|
public static final String SCREENSAVER_COMPLICATIONS_ENABLED =
|
||||||
"screensaver_enabled_complications";
|
"screensaver_complications_enabled";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2384,9 +2384,6 @@
|
|||||||
<!-- The list of supported dream complications -->
|
<!-- The list of supported dream complications -->
|
||||||
<integer-array name="config_supportedDreamComplications">
|
<integer-array name="config_supportedDreamComplications">
|
||||||
</integer-array>
|
</integer-array>
|
||||||
<!-- The list of dream complications which should be enabled by default -->
|
|
||||||
<integer-array name="config_dreamComplicationsEnabledByDefault">
|
|
||||||
</integer-array>
|
|
||||||
|
|
||||||
<!-- Are we allowed to dream while not plugged in? -->
|
<!-- Are we allowed to dream while not plugged in? -->
|
||||||
<bool name="config_dreamsEnabledOnBattery">false</bool>
|
<bool name="config_dreamsEnabledOnBattery">false</bool>
|
||||||
|
|||||||
@@ -2219,7 +2219,6 @@
|
|||||||
<java-symbol type="string" name="config_dreamsDefaultComponent" />
|
<java-symbol type="string" name="config_dreamsDefaultComponent" />
|
||||||
<java-symbol type="bool" name="config_dreamsOnlyEnabledForSystemUser" />
|
<java-symbol type="bool" name="config_dreamsOnlyEnabledForSystemUser" />
|
||||||
<java-symbol type="array" name="config_supportedDreamComplications" />
|
<java-symbol type="array" name="config_supportedDreamComplications" />
|
||||||
<java-symbol type="array" name="config_dreamComplicationsEnabledByDefault" />
|
|
||||||
<java-symbol type="array" name="config_disabledDreamComponents" />
|
<java-symbol type="array" name="config_disabledDreamComponents" />
|
||||||
<java-symbol type="bool" name="config_dismissDreamOnActivityStart" />
|
<java-symbol type="bool" name="config_dismissDreamOnActivityStart" />
|
||||||
<java-symbol type="string" name="config_loggable_dream_prefix" />
|
<java-symbol type="string" name="config_loggable_dream_prefix" />
|
||||||
|
|||||||
@@ -1601,21 +1601,6 @@
|
|||||||
<!-- Content description of the no calling for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
|
<!-- Content description of the no calling for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_no_calling">No calling.</string>
|
<string name="accessibility_no_calling">No calling.</string>
|
||||||
|
|
||||||
<!-- Screensaver overlay which displays the time. [CHAR LIMIT=20] -->
|
|
||||||
<string name="dream_complication_title_time">Time</string>
|
|
||||||
<!-- Screensaver overlay which displays the date. [CHAR LIMIT=20] -->
|
|
||||||
<string name="dream_complication_title_date">Date</string>
|
|
||||||
<!-- Screensaver overlay which displays the weather. [CHAR LIMIT=20] -->
|
|
||||||
<string name="dream_complication_title_weather">Weather</string>
|
|
||||||
<!-- Screensaver overlay which displays air quality. [CHAR LIMIT=20] -->
|
|
||||||
<string name="dream_complication_title_aqi">Air Quality</string>
|
|
||||||
<!-- Screensaver overlay which displays cast info. [CHAR LIMIT=20] -->
|
|
||||||
<string name="dream_complication_title_cast_info">Cast Info</string>
|
|
||||||
<!-- Screensaver overlay which displays home controls. [CHAR LIMIT=20] -->
|
|
||||||
<string name="dream_complication_title_home_controls">Home Controls</string>
|
|
||||||
<!-- Screensaver overlay which displays smartspace. [CHAR LIMIT=20] -->
|
|
||||||
<string name="dream_complication_title_smartspace">Smartspace</string>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Title for a screen allowing the user to choose a profile picture. [CHAR LIMIT=NONE] -->
|
<!-- Title for a screen allowing the user to choose a profile picture. [CHAR LIMIT=NONE] -->
|
||||||
<string name="avatar_picker_title">Choose a profile picture</string>
|
<string name="avatar_picker_title">Choose a profile picture</string>
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
package com.android.settingslib.dream;
|
package com.android.settingslib.dream;
|
||||||
|
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.annotation.Nullable;
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -32,17 +31,14 @@ import android.os.ServiceManager;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.service.dreams.DreamService;
|
import android.service.dreams.DreamService;
|
||||||
import android.service.dreams.IDreamManager;
|
import android.service.dreams.IDreamManager;
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.settingslib.R;
|
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -64,18 +60,21 @@ public class DreamBackend {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder(DreamInfo.class.getSimpleName());
|
StringBuilder sb = new StringBuilder(DreamInfo.class.getSimpleName());
|
||||||
sb.append('[').append(caption);
|
sb.append('[').append(caption);
|
||||||
if (isActive)
|
if (isActive) {
|
||||||
sb.append(",active");
|
sb.append(",active");
|
||||||
|
}
|
||||||
sb.append(',').append(componentName);
|
sb.append(',').append(componentName);
|
||||||
if (settingsComponentName != null)
|
if (settingsComponentName != null) {
|
||||||
sb.append("settings=").append(settingsComponentName);
|
sb.append("settings=").append(settingsComponentName);
|
||||||
|
}
|
||||||
return sb.append(']').toString();
|
return sb.append(']').toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@IntDef({WHILE_CHARGING, WHILE_DOCKED, EITHER, NEVER})
|
@IntDef({WHILE_CHARGING, WHILE_DOCKED, EITHER, NEVER})
|
||||||
public @interface WhenToDream {}
|
public @interface WhenToDream {
|
||||||
|
}
|
||||||
|
|
||||||
public static final int WHILE_CHARGING = 0;
|
public static final int WHILE_CHARGING = 0;
|
||||||
public static final int WHILE_DOCKED = 1;
|
public static final int WHILE_DOCKED = 1;
|
||||||
@@ -96,7 +95,8 @@ public class DreamBackend {
|
|||||||
COMPLICATION_TYPE_SMARTSPACE
|
COMPLICATION_TYPE_SMARTSPACE
|
||||||
})
|
})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface ComplicationType {}
|
public @interface ComplicationType {
|
||||||
|
}
|
||||||
|
|
||||||
public static final int COMPLICATION_TYPE_TIME = 1;
|
public static final int COMPLICATION_TYPE_TIME = 1;
|
||||||
public static final int COMPLICATION_TYPE_DATE = 2;
|
public static final int COMPLICATION_TYPE_DATE = 2;
|
||||||
@@ -114,8 +114,6 @@ public class DreamBackend {
|
|||||||
private final boolean mDreamsActivatedOnDockByDefault;
|
private final boolean mDreamsActivatedOnDockByDefault;
|
||||||
private final Set<ComponentName> mDisabledDreams;
|
private final Set<ComponentName> mDisabledDreams;
|
||||||
private final Set<Integer> mSupportedComplications;
|
private final Set<Integer> mSupportedComplications;
|
||||||
private final Set<Integer> mDefaultEnabledComplications;
|
|
||||||
|
|
||||||
private static DreamBackend sInstance;
|
private static DreamBackend sInstance;
|
||||||
|
|
||||||
public static DreamBackend getInstance(Context context) {
|
public static DreamBackend getInstance(Context context) {
|
||||||
@@ -147,13 +145,6 @@ public class DreamBackend {
|
|||||||
com.android.internal.R.array.config_supportedDreamComplications))
|
com.android.internal.R.array.config_supportedDreamComplications))
|
||||||
.boxed()
|
.boxed()
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
mDefaultEnabledComplications = Arrays.stream(resources.getIntArray(
|
|
||||||
com.android.internal.R.array.config_dreamComplicationsEnabledByDefault))
|
|
||||||
.boxed()
|
|
||||||
// A complication can only be enabled by default if it is also supported.
|
|
||||||
.filter(mSupportedComplications::contains)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DreamInfo> getDreamInfos() {
|
public List<DreamInfo> getDreamInfos() {
|
||||||
@@ -251,7 +242,8 @@ public class DreamBackend {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @WhenToDream int getWhenToDreamSetting() {
|
@WhenToDream
|
||||||
|
public int getWhenToDreamSetting() {
|
||||||
return isActivatedOnDock() && isActivatedOnSleep() ? EITHER
|
return isActivatedOnDock() && isActivatedOnSleep() ? EITHER
|
||||||
: isActivatedOnDock() ? WHILE_DOCKED
|
: isActivatedOnDock() ? WHILE_DOCKED
|
||||||
: isActivatedOnSleep() ? WHILE_CHARGING
|
: isActivatedOnSleep() ? WHILE_CHARGING
|
||||||
@@ -283,22 +275,24 @@ public class DreamBackend {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns whether a particular complication is enabled */
|
|
||||||
public boolean isComplicationEnabled(@ComplicationType int complication) {
|
|
||||||
return getEnabledComplications().contains(complication);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Gets all complications which have been enabled by the user. */
|
/** Gets all complications which have been enabled by the user. */
|
||||||
public Set<Integer> getEnabledComplications() {
|
public Set<Integer> getEnabledComplications() {
|
||||||
final String enabledComplications = Settings.Secure.getString(
|
return getComplicationsEnabled() ? mSupportedComplications : Collections.emptySet();
|
||||||
mContext.getContentResolver(),
|
|
||||||
Settings.Secure.SCREENSAVER_ENABLED_COMPLICATIONS);
|
|
||||||
|
|
||||||
if (enabledComplications == null) {
|
|
||||||
return mDefaultEnabledComplications;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return parseFromString(enabledComplications);
|
/** Sets complication enabled state. */
|
||||||
|
public void setComplicationsEnabled(boolean enabled) {
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.SCREENSAVER_COMPLICATIONS_ENABLED, enabled ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether complications are enabled on this device
|
||||||
|
*/
|
||||||
|
public boolean getComplicationsEnabled() {
|
||||||
|
return Settings.Secure.getInt(
|
||||||
|
mContext.getContentResolver(),
|
||||||
|
Settings.Secure.SCREENSAVER_COMPLICATIONS_ENABLED, 1) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets all dream complications which are supported on this device. **/
|
/** Gets all dream complications which are supported on this device. **/
|
||||||
@@ -306,77 +300,6 @@ public class DreamBackend {
|
|||||||
return mSupportedComplications;
|
return mSupportedComplications;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables or disables a particular dream complication.
|
|
||||||
*
|
|
||||||
* @param complicationType The dream complication to be enabled/disabled.
|
|
||||||
* @param value If true, the complication is enabled. Otherwise it is disabled.
|
|
||||||
*/
|
|
||||||
public void setComplicationEnabled(@ComplicationType int complicationType, boolean value) {
|
|
||||||
if (!mSupportedComplications.contains(complicationType)) return;
|
|
||||||
|
|
||||||
Set<Integer> enabledComplications = getEnabledComplications();
|
|
||||||
if (value) {
|
|
||||||
enabledComplications.add(complicationType);
|
|
||||||
} else {
|
|
||||||
enabledComplications.remove(complicationType);
|
|
||||||
}
|
|
||||||
|
|
||||||
Settings.Secure.putString(mContext.getContentResolver(),
|
|
||||||
Settings.Secure.SCREENSAVER_ENABLED_COMPLICATIONS,
|
|
||||||
convertToString(enabledComplications));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the title of a particular complication type to be displayed to the user. If there
|
|
||||||
* is no title, null is returned.
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
public CharSequence getComplicationTitle(@ComplicationType int complicationType) {
|
|
||||||
int res = 0;
|
|
||||||
switch (complicationType) {
|
|
||||||
case COMPLICATION_TYPE_TIME:
|
|
||||||
res = R.string.dream_complication_title_time;
|
|
||||||
break;
|
|
||||||
case COMPLICATION_TYPE_DATE:
|
|
||||||
res = R.string.dream_complication_title_date;
|
|
||||||
break;
|
|
||||||
case COMPLICATION_TYPE_WEATHER:
|
|
||||||
res = R.string.dream_complication_title_weather;
|
|
||||||
break;
|
|
||||||
case COMPLICATION_TYPE_AIR_QUALITY:
|
|
||||||
res = R.string.dream_complication_title_aqi;
|
|
||||||
break;
|
|
||||||
case COMPLICATION_TYPE_CAST_INFO:
|
|
||||||
res = R.string.dream_complication_title_cast_info;
|
|
||||||
break;
|
|
||||||
case COMPLICATION_TYPE_HOME_CONTROLS:
|
|
||||||
res = R.string.dream_complication_title_home_controls;
|
|
||||||
break;
|
|
||||||
case COMPLICATION_TYPE_SMARTSPACE:
|
|
||||||
res = R.string.dream_complication_title_smartspace;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return mContext.getString(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String convertToString(Set<Integer> set) {
|
|
||||||
return set.stream()
|
|
||||||
.map(String::valueOf)
|
|
||||||
.collect(Collectors.joining(","));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Set<Integer> parseFromString(String string) {
|
|
||||||
if (TextUtils.isEmpty(string)) {
|
|
||||||
return new HashSet<>();
|
|
||||||
}
|
|
||||||
return Arrays.stream(string.split(","))
|
|
||||||
.map(Integer::parseInt)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return getBoolean(Settings.Secure.SCREENSAVER_ENABLED, mDreamsEnabledByDefault);
|
return getBoolean(Settings.Secure.SCREENSAVER_ENABLED, mDreamsEnabledByDefault);
|
||||||
}
|
}
|
||||||
@@ -416,10 +339,11 @@ public class DreamBackend {
|
|||||||
|
|
||||||
public void setActiveDream(ComponentName dream) {
|
public void setActiveDream(ComponentName dream) {
|
||||||
logd("setActiveDream(%s)", dream);
|
logd("setActiveDream(%s)", dream);
|
||||||
if (mDreamManager == null)
|
if (mDreamManager == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
ComponentName[] dreams = { dream };
|
ComponentName[] dreams = {dream};
|
||||||
mDreamManager.setDreamComponents(dream == null ? null : dreams);
|
mDreamManager.setDreamComponents(dream == null ? null : dreams);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.w(TAG, "Failed to set active dream to " + dream, e);
|
Log.w(TAG, "Failed to set active dream to " + dream, e);
|
||||||
@@ -427,8 +351,9 @@ public class DreamBackend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ComponentName getActiveDream() {
|
public ComponentName getActiveDream() {
|
||||||
if (mDreamManager == null)
|
if (mDreamManager == null) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
ComponentName[] dreams = mDreamManager.getDreamComponents();
|
ComponentName[] dreams = mDreamManager.getDreamComponents();
|
||||||
return dreams != null && dreams.length > 0 ? dreams[0] : null;
|
return dreams != null && dreams.length > 0 ? dreams[0] : null;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
|
||||||
@@ -34,29 +35,35 @@ import org.robolectric.RobolectricTestRunner;
|
|||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.shadows.ShadowSettings;
|
import org.robolectric.shadows.ShadowSettings;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Config(shadows = {ShadowSettings.ShadowSecure.class})
|
@Config(shadows = {ShadowSettings.ShadowSecure.class})
|
||||||
public final class DreamBackendTest {
|
public final class DreamBackendTest {
|
||||||
private static final int[] SUPPORTED_DREAM_COMPLICATIONS = {1, 2, 3};
|
private static final int[] SUPPORTED_DREAM_COMPLICATIONS = {1, 2, 3};
|
||||||
private static final int[] DEFAULT_DREAM_COMPLICATIONS = {1, 3, 4};
|
private static final List<Integer> SUPPORTED_DREAM_COMPLICATIONS_LIST = Arrays.stream(
|
||||||
|
SUPPORTED_DREAM_COMPLICATIONS).boxed().collect(
|
||||||
|
Collectors.toList());
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
@Mock
|
||||||
|
private ContentResolver mMockResolver;
|
||||||
private DreamBackend mBackend;
|
private DreamBackend mBackend;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
when(mContext.getApplicationContext()).thenReturn(mContext);
|
when(mContext.getApplicationContext()).thenReturn(mContext);
|
||||||
|
when(mContext.getContentResolver()).thenReturn(mMockResolver);
|
||||||
|
|
||||||
final Resources res = mock(Resources.class);
|
final Resources res = mock(Resources.class);
|
||||||
when(mContext.getResources()).thenReturn(res);
|
when(mContext.getResources()).thenReturn(res);
|
||||||
when(res.getIntArray(
|
when(res.getIntArray(
|
||||||
com.android.internal.R.array.config_supportedDreamComplications)).thenReturn(
|
com.android.internal.R.array.config_supportedDreamComplications)).thenReturn(
|
||||||
SUPPORTED_DREAM_COMPLICATIONS);
|
SUPPORTED_DREAM_COMPLICATIONS);
|
||||||
when(res.getIntArray(
|
|
||||||
com.android.internal.R.array.config_dreamComplicationsEnabledByDefault)).thenReturn(
|
|
||||||
DEFAULT_DREAM_COMPLICATIONS);
|
|
||||||
when(res.getStringArray(
|
when(res.getStringArray(
|
||||||
com.android.internal.R.array.config_disabledDreamComponents)).thenReturn(
|
com.android.internal.R.array.config_disabledDreamComponents)).thenReturn(
|
||||||
new String[]{});
|
new String[]{});
|
||||||
@@ -69,31 +76,25 @@ public final class DreamBackendTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSupportedComplications() {
|
public void testComplicationsEnabledByDefault() {
|
||||||
assertThat(mBackend.getSupportedComplications()).containsExactly(1, 2, 3);
|
assertThat(mBackend.getComplicationsEnabled()).isTrue();
|
||||||
|
assertThat(mBackend.getEnabledComplications()).containsExactlyElementsIn(
|
||||||
|
SUPPORTED_DREAM_COMPLICATIONS_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetEnabledDreamComplications_default() {
|
public void testEnableComplicationExplicitly() {
|
||||||
assertThat(mBackend.getEnabledComplications()).containsExactly(1, 3);
|
mBackend.setComplicationsEnabled(true);
|
||||||
|
assertThat(mBackend.getEnabledComplications()).containsExactlyElementsIn(
|
||||||
|
SUPPORTED_DREAM_COMPLICATIONS_LIST);
|
||||||
|
assertThat(mBackend.getComplicationsEnabled()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEnableComplication() {
|
public void testDisableComplications() {
|
||||||
mBackend.setComplicationEnabled(/* complicationType= */ 2, true);
|
mBackend.setComplicationsEnabled(false);
|
||||||
assertThat(mBackend.getEnabledComplications()).containsExactly(1, 2, 3);
|
assertThat(mBackend.getEnabledComplications()).isEmpty();
|
||||||
}
|
assertThat(mBackend.getComplicationsEnabled()).isFalse();
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testEnableComplication_notSupported() {
|
|
||||||
mBackend.setComplicationEnabled(/* complicationType= */ 5, true);
|
|
||||||
assertThat(mBackend.getEnabledComplications()).containsExactly(1, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDisableComplication() {
|
|
||||||
mBackend.setComplicationEnabled(/* complicationType= */ 1, false);
|
|
||||||
assertThat(mBackend.getEnabledComplications()).containsExactly(3);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class ComplicationTypesUpdater extends CoreStartable {
|
|||||||
};
|
};
|
||||||
|
|
||||||
mSecureSettings.registerContentObserverForUser(
|
mSecureSettings.registerContentObserverForUser(
|
||||||
Settings.Secure.SCREENSAVER_ENABLED_COMPLICATIONS,
|
Settings.Secure.SCREENSAVER_COMPLICATIONS_ENABLED,
|
||||||
settingsObserver,
|
settingsObserver,
|
||||||
UserHandle.myUserId());
|
UserHandle.myUserId());
|
||||||
settingsObserver.onChange(false);
|
settingsObserver.onChange(false);
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public class ComplicationTypesUpdaterTest extends SysuiTestCase {
|
|||||||
|
|
||||||
private ContentObserver captureSettingsObserver() {
|
private ContentObserver captureSettingsObserver() {
|
||||||
verify(mSecureSettings).registerContentObserverForUser(
|
verify(mSecureSettings).registerContentObserverForUser(
|
||||||
eq(Settings.Secure.SCREENSAVER_ENABLED_COMPLICATIONS),
|
eq(Settings.Secure.SCREENSAVER_COMPLICATIONS_ENABLED),
|
||||||
mSettingsObserverCaptor.capture(), eq(UserHandle.myUserId()));
|
mSettingsObserverCaptor.capture(), eq(UserHandle.myUserId()));
|
||||||
return mSettingsObserverCaptor.getValue();
|
return mSettingsObserverCaptor.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user