Merge "Add new config to hide certain dreams."

This commit is contained in:
Lucas Silva
2022-01-27 15:00:05 +00:00
committed by Android (Google) Code Review
3 changed files with 13 additions and 2 deletions

View File

@@ -2373,6 +2373,9 @@
<bool name="config_dreamsActivatedOnSleepByDefault">false</bool>
<!-- ComponentName of the default dream (Settings.Secure.DEFAULT_SCREENSAVER_COMPONENT) -->
<string name="config_dreamsDefaultComponent" translatable="false">com.android.deskclock/com.android.deskclock.Screensaver</string>
<!-- ComponentNames of the dreams that we should hide -->
<string-array name="config_disabledDreamComponents" translatable="false">
</string-array>
<!-- Are we allowed to dream while not plugged in? -->
<bool name="config_dreamsEnabledOnBattery">false</bool>

View File

@@ -2211,6 +2211,7 @@
<java-symbol type="integer" name="config_dreamsBatteryLevelDrainCutoff" />
<java-symbol type="string" name="config_dreamsDefaultComponent" />
<java-symbol type="drawable" name="default_dream_preview" />
<java-symbol type="array" name="config_disabledDreamComponents" />
<java-symbol type="string" name="config_dozeComponent" />
<java-symbol type="string" name="enable_explore_by_touch_warning_title" />
<java-symbol type="string" name="enable_explore_by_touch_warning_message" />

View File

@@ -116,6 +116,7 @@ public class DreamBackend {
private final boolean mDreamsEnabledByDefault;
private final boolean mDreamsActivatedOnSleepByDefault;
private final boolean mDreamsActivatedOnDockByDefault;
private final Set<ComponentName> mDisabledDreams;
private final Set<Integer> mSupportedComplications;
private final Set<Integer> mDefaultEnabledComplications;
@@ -143,6 +144,10 @@ public class DreamBackend {
com.android.internal.R.bool.config_dreamsActivatedOnDockByDefault);
mDreamPreviewDefault = resources.getDrawable(
com.android.internal.R.drawable.default_dream_preview);
mDisabledDreams = Arrays.stream(resources.getStringArray(
com.android.internal.R.array.config_disabledDreamComponents))
.map(ComponentName::unflattenFromString)
.collect(Collectors.toSet());
mSupportedComplications =
Arrays.stream(resources.getIntArray(R.array.config_supportedDreamComplications))
@@ -166,14 +171,16 @@ public class DreamBackend {
PackageManager.GET_META_DATA);
List<DreamInfo> dreamInfos = new ArrayList<>(resolveInfos.size());
for (ResolveInfo resolveInfo : resolveInfos) {
if (resolveInfo.serviceInfo == null) {
final ComponentName componentName = getDreamComponentName(resolveInfo);
if (componentName == null || mDisabledDreams.contains(componentName)) {
continue;
}
DreamInfo dreamInfo = new DreamInfo();
dreamInfo.caption = resolveInfo.loadLabel(pm);
dreamInfo.icon = resolveInfo.loadIcon(pm);
dreamInfo.description = getDescription(resolveInfo, pm);
dreamInfo.componentName = getDreamComponentName(resolveInfo);
dreamInfo.componentName = componentName;
dreamInfo.isActive = dreamInfo.componentName.equals(activeDream);
final DreamMetadata dreamMetadata = getDreamMetadata(pm, resolveInfo);