Skip to content

Commit d3b2aaf

Browse files
author
Android Build Coastguard Worker
committed
Merge cherrypicks of ['googleplex-android-review.googlesource.com/22815560'] into tm-qpr3-release.
Change-Id: I5570c93c08339d78cf0b66909d62a4bddfcfad2c
2 parents 5d6d481 + 1dd4240 commit d3b2aaf

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayStateController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ public Collection<Complication> getComplications(boolean filterByAvailability) {
197197
if (mShouldShowComplications) {
198198
return (requiredTypes & getAvailableComplicationTypes()) == requiredTypes;
199199
}
200-
return (requiredTypes & mSupportedTypes) == requiredTypes;
200+
final int typesToAlwaysShow = mSupportedTypes & getAvailableComplicationTypes();
201+
return (requiredTypes & typesToAlwaysShow) == requiredTypes;
201202
})
202203
.collect(Collectors.toCollection(HashSet::new))
203204
: mComplications);

packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayStateControllerTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,34 @@ public void testShouldShowComplicationsSetToFalse_stillShowsSupportedTypes_featu
353353
}
354354
}
355355

356+
@Test
357+
public void testHomeControlsDoNotShowIfNotAvailable_featureEnabled() {
358+
when(mFeatureFlags.isEnabled(Flags.ALWAYS_SHOW_HOME_CONTROLS_ON_DREAMS)).thenReturn(true);
359+
360+
final DreamOverlayStateController stateController = getDreamOverlayStateController(true);
361+
stateController.setShouldShowComplications(true);
362+
363+
final Complication homeControlsComplication = Mockito.mock(Complication.class);
364+
when(homeControlsComplication.getRequiredTypeAvailability())
365+
.thenReturn(Complication.COMPLICATION_TYPE_HOME_CONTROLS);
366+
367+
stateController.addComplication(homeControlsComplication);
368+
369+
final DreamOverlayStateController.Callback callback =
370+
Mockito.mock(DreamOverlayStateController.Callback.class);
371+
372+
stateController.addCallback(callback);
373+
mExecutor.runAllReady();
374+
375+
// No home controls since it is not available.
376+
assertThat(stateController.getComplications()).doesNotContain(homeControlsComplication);
377+
378+
stateController.setAvailableComplicationTypes(Complication.COMPLICATION_TYPE_HOME_CONTROLS
379+
| Complication.COMPLICATION_TYPE_WEATHER);
380+
mExecutor.runAllReady();
381+
assertThat(stateController.getComplications()).contains(homeControlsComplication);
382+
}
383+
356384
private DreamOverlayStateController getDreamOverlayStateController(boolean overlayEnabled) {
357385
return new DreamOverlayStateController(mExecutor, overlayEnabled, mFeatureFlags);
358386
}

0 commit comments

Comments
 (0)