Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a0a0d554 authored by Lucas Silva's avatar Lucas Silva Committed by Automerger Merge Worker
Browse files

Merge "Don't show home controls complication if not available." into udc-dev...

Merge "Don't show home controls complication if not available." into udc-dev am: 66a64d23 am: 4a11e9c1

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22789679



Change-Id: Ic1bcb26a9262f6aa043d3ebf3e40ed8b5e324cf7
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents c1657cac 4a11e9c1
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -199,7 +199,8 @@ public class DreamOverlayStateController implements
                    if (mShouldShowComplications) {
                        return (requiredTypes & getAvailableComplicationTypes()) == requiredTypes;
                    }
                    return (requiredTypes & mSupportedTypes) == requiredTypes;
                    final int typesToAlwaysShow = mSupportedTypes & getAvailableComplicationTypes();
                    return (requiredTypes & typesToAlwaysShow) == requiredTypes;
                })
                .collect(Collectors.toCollection(HashSet::new))
                : mComplications);
+28 −0
Original line number Diff line number Diff line
@@ -376,6 +376,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) {
        return new DreamOverlayStateController(mExecutor, overlayEnabled, mFeatureFlags);
    }