Merge "Don't show home controls complication if not available." into tm-qpr-dev
This commit is contained in:
@@ -197,7 +197,8 @@ public class DreamOverlayStateController implements
|
|||||||
if (mShouldShowComplications) {
|
if (mShouldShowComplications) {
|
||||||
return (requiredTypes & getAvailableComplicationTypes()) == requiredTypes;
|
return (requiredTypes & getAvailableComplicationTypes()) == requiredTypes;
|
||||||
}
|
}
|
||||||
return (requiredTypes & mSupportedTypes) == requiredTypes;
|
final int typesToAlwaysShow = mSupportedTypes & getAvailableComplicationTypes();
|
||||||
|
return (requiredTypes & typesToAlwaysShow) == requiredTypes;
|
||||||
})
|
})
|
||||||
.collect(Collectors.toCollection(HashSet::new))
|
.collect(Collectors.toCollection(HashSet::new))
|
||||||
: mComplications);
|
: mComplications);
|
||||||
|
|||||||
@@ -353,6 +353,34 @@ public class DreamOverlayStateControllerTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testHomeControlsDoNotShowIfNotAvailable_featureEnabled() {
|
||||||
|
when(mFeatureFlags.isEnabled(Flags.ALWAYS_SHOW_HOME_CONTROLS_ON_DREAMS)).thenReturn(true);
|
||||||
|
|
||||||
|
final DreamOverlayStateController stateController = getDreamOverlayStateController(true);
|
||||||
|
stateController.setShouldShowComplications(true);
|
||||||
|
|
||||||
|
final Complication homeControlsComplication = Mockito.mock(Complication.class);
|
||||||
|
when(homeControlsComplication.getRequiredTypeAvailability())
|
||||||
|
.thenReturn(Complication.COMPLICATION_TYPE_HOME_CONTROLS);
|
||||||
|
|
||||||
|
stateController.addComplication(homeControlsComplication);
|
||||||
|
|
||||||
|
final DreamOverlayStateController.Callback callback =
|
||||||
|
Mockito.mock(DreamOverlayStateController.Callback.class);
|
||||||
|
|
||||||
|
stateController.addCallback(callback);
|
||||||
|
mExecutor.runAllReady();
|
||||||
|
|
||||||
|
// No home controls since it is not available.
|
||||||
|
assertThat(stateController.getComplications()).doesNotContain(homeControlsComplication);
|
||||||
|
|
||||||
|
stateController.setAvailableComplicationTypes(Complication.COMPLICATION_TYPE_HOME_CONTROLS
|
||||||
|
| Complication.COMPLICATION_TYPE_WEATHER);
|
||||||
|
mExecutor.runAllReady();
|
||||||
|
assertThat(stateController.getComplications()).contains(homeControlsComplication);
|
||||||
|
}
|
||||||
|
|
||||||
private DreamOverlayStateController getDreamOverlayStateController(boolean overlayEnabled) {
|
private DreamOverlayStateController getDreamOverlayStateController(boolean overlayEnabled) {
|
||||||
return new DreamOverlayStateController(mExecutor, overlayEnabled, mFeatureFlags);
|
return new DreamOverlayStateController(mExecutor, overlayEnabled, mFeatureFlags);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user