Merge "Show Dream Home Controls regardless of overlay on dream." into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b7fff582dc
@@ -27,6 +27,8 @@ import com.android.internal.annotations.VisibleForTesting;
|
|||||||
import com.android.systemui.dagger.SysUISingleton;
|
import com.android.systemui.dagger.SysUISingleton;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
import com.android.systemui.dreams.complication.Complication;
|
import com.android.systemui.dreams.complication.Complication;
|
||||||
|
import com.android.systemui.flags.FeatureFlags;
|
||||||
|
import com.android.systemui.flags.Flags;
|
||||||
import com.android.systemui.statusbar.policy.CallbackController;
|
import com.android.systemui.statusbar.policy.CallbackController;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -102,15 +104,27 @@ public class DreamOverlayStateController implements
|
|||||||
|
|
||||||
private final Collection<Complication> mComplications = new HashSet();
|
private final Collection<Complication> mComplications = new HashSet();
|
||||||
|
|
||||||
|
private final FeatureFlags mFeatureFlags;
|
||||||
|
|
||||||
|
private final int mSupportedTypes;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@Inject
|
@Inject
|
||||||
public DreamOverlayStateController(@Main Executor executor,
|
public DreamOverlayStateController(@Main Executor executor,
|
||||||
@Named(DREAM_OVERLAY_ENABLED) boolean overlayEnabled) {
|
@Named(DREAM_OVERLAY_ENABLED) boolean overlayEnabled,
|
||||||
|
FeatureFlags featureFlags) {
|
||||||
mExecutor = executor;
|
mExecutor = executor;
|
||||||
mOverlayEnabled = overlayEnabled;
|
mOverlayEnabled = overlayEnabled;
|
||||||
|
mFeatureFlags = featureFlags;
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "Dream overlay enabled:" + mOverlayEnabled);
|
Log.d(TAG, "Dream overlay enabled:" + mOverlayEnabled);
|
||||||
}
|
}
|
||||||
|
if (mFeatureFlags.isEnabled(Flags.ALWAYS_SHOW_HOME_CONTROLS_ON_DREAMS)) {
|
||||||
|
mSupportedTypes = Complication.COMPLICATION_TYPE_NONE
|
||||||
|
| Complication.COMPLICATION_TYPE_HOME_CONTROLS;
|
||||||
|
} else {
|
||||||
|
mSupportedTypes = Complication.COMPLICATION_TYPE_NONE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -179,7 +193,7 @@ public class DreamOverlayStateController implements
|
|||||||
if (mShouldShowComplications) {
|
if (mShouldShowComplications) {
|
||||||
return (requiredTypes & getAvailableComplicationTypes()) == requiredTypes;
|
return (requiredTypes & getAvailableComplicationTypes()) == requiredTypes;
|
||||||
}
|
}
|
||||||
return requiredTypes == Complication.COMPLICATION_TYPE_NONE;
|
return (requiredTypes & mSupportedTypes) == requiredTypes;
|
||||||
})
|
})
|
||||||
.collect(Collectors.toCollection(HashSet::new))
|
.collect(Collectors.toCollection(HashSet::new))
|
||||||
: mComplications);
|
: mComplications);
|
||||||
|
|||||||
@@ -428,6 +428,11 @@ object Flags {
|
|||||||
1004,
|
1004,
|
||||||
"enable_low_light_clock_undocked", teamfood = true)
|
"enable_low_light_clock_undocked", teamfood = true)
|
||||||
|
|
||||||
|
// TODO(b/273509374): Tracking Bug
|
||||||
|
@JvmField
|
||||||
|
val ALWAYS_SHOW_HOME_CONTROLS_ON_DREAMS = unreleasedFlag(1006,
|
||||||
|
"always_show_home_controls_on_dreams")
|
||||||
|
|
||||||
// 1100 - windowing
|
// 1100 - windowing
|
||||||
@Keep
|
@Keep
|
||||||
@JvmField
|
@JvmField
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ import androidx.test.filters.SmallTest;
|
|||||||
|
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.systemui.dreams.complication.Complication;
|
import com.android.systemui.dreams.complication.Complication;
|
||||||
|
import com.android.systemui.flags.FeatureFlags;
|
||||||
|
import com.android.systemui.flags.Flags;
|
||||||
import com.android.systemui.util.concurrency.FakeExecutor;
|
import com.android.systemui.util.concurrency.FakeExecutor;
|
||||||
import com.android.systemui.util.time.FakeSystemClock;
|
import com.android.systemui.util.time.FakeSystemClock;
|
||||||
|
|
||||||
@@ -53,17 +55,21 @@ public class DreamOverlayStateControllerTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
Complication mComplication;
|
Complication mComplication;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private FeatureFlags mFeatureFlags;
|
||||||
|
|
||||||
final FakeExecutor mExecutor = new FakeExecutor(new FakeSystemClock());
|
final FakeExecutor mExecutor = new FakeExecutor(new FakeSystemClock());
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
|
when(mFeatureFlags.isEnabled(Flags.ALWAYS_SHOW_HOME_CONTROLS_ON_DREAMS)).thenReturn(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStateChange_overlayActive() {
|
public void testStateChange_overlayActive() {
|
||||||
final DreamOverlayStateController stateController = new DreamOverlayStateController(
|
final DreamOverlayStateController stateController = getDreamOverlayStateController(true);
|
||||||
mExecutor, true);
|
|
||||||
stateController.addCallback(mCallback);
|
stateController.addCallback(mCallback);
|
||||||
stateController.setOverlayActive(true);
|
stateController.setOverlayActive(true);
|
||||||
mExecutor.runAllReady();
|
mExecutor.runAllReady();
|
||||||
@@ -84,8 +90,7 @@ public class DreamOverlayStateControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCallback() {
|
public void testCallback() {
|
||||||
final DreamOverlayStateController stateController = new DreamOverlayStateController(
|
final DreamOverlayStateController stateController = getDreamOverlayStateController(true);
|
||||||
mExecutor, true);
|
|
||||||
stateController.addCallback(mCallback);
|
stateController.addCallback(mCallback);
|
||||||
|
|
||||||
// Add complication and verify callback is notified.
|
// Add complication and verify callback is notified.
|
||||||
@@ -110,8 +115,7 @@ public class DreamOverlayStateControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNotifyOnCallbackAdd() {
|
public void testNotifyOnCallbackAdd() {
|
||||||
final DreamOverlayStateController stateController =
|
final DreamOverlayStateController stateController = getDreamOverlayStateController(true);
|
||||||
new DreamOverlayStateController(mExecutor, true);
|
|
||||||
|
|
||||||
stateController.addComplication(mComplication);
|
stateController.addComplication(mComplication);
|
||||||
mExecutor.runAllReady();
|
mExecutor.runAllReady();
|
||||||
@@ -124,8 +128,7 @@ public class DreamOverlayStateControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNotifyOnCallbackAddOverlayDisabled() {
|
public void testNotifyOnCallbackAddOverlayDisabled() {
|
||||||
final DreamOverlayStateController stateController =
|
final DreamOverlayStateController stateController = getDreamOverlayStateController(false);
|
||||||
new DreamOverlayStateController(mExecutor, false);
|
|
||||||
|
|
||||||
stateController.addComplication(mComplication);
|
stateController.addComplication(mComplication);
|
||||||
mExecutor.runAllReady();
|
mExecutor.runAllReady();
|
||||||
@@ -139,8 +142,7 @@ public class DreamOverlayStateControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testComplicationFilteringWhenShouldShowComplications() {
|
public void testComplicationFilteringWhenShouldShowComplications() {
|
||||||
final DreamOverlayStateController stateController =
|
final DreamOverlayStateController stateController = getDreamOverlayStateController(true);
|
||||||
new DreamOverlayStateController(mExecutor, true);
|
|
||||||
stateController.setShouldShowComplications(true);
|
stateController.setShouldShowComplications(true);
|
||||||
|
|
||||||
final Complication alwaysAvailableComplication = Mockito.mock(Complication.class);
|
final Complication alwaysAvailableComplication = Mockito.mock(Complication.class);
|
||||||
@@ -179,8 +181,7 @@ public class DreamOverlayStateControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testComplicationFilteringWhenShouldHideComplications() {
|
public void testComplicationFilteringWhenShouldHideComplications() {
|
||||||
final DreamOverlayStateController stateController =
|
final DreamOverlayStateController stateController = getDreamOverlayStateController(true);
|
||||||
new DreamOverlayStateController(mExecutor, true);
|
|
||||||
stateController.setShouldShowComplications(true);
|
stateController.setShouldShowComplications(true);
|
||||||
|
|
||||||
final Complication alwaysAvailableComplication = Mockito.mock(Complication.class);
|
final Complication alwaysAvailableComplication = Mockito.mock(Complication.class);
|
||||||
@@ -226,8 +227,7 @@ public class DreamOverlayStateControllerTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testComplicationWithNoTypeNotFiltered() {
|
public void testComplicationWithNoTypeNotFiltered() {
|
||||||
final Complication complication = Mockito.mock(Complication.class);
|
final Complication complication = Mockito.mock(Complication.class);
|
||||||
final DreamOverlayStateController stateController =
|
final DreamOverlayStateController stateController = getDreamOverlayStateController(true);
|
||||||
new DreamOverlayStateController(mExecutor, true);
|
|
||||||
stateController.addComplication(complication);
|
stateController.addComplication(complication);
|
||||||
mExecutor.runAllReady();
|
mExecutor.runAllReady();
|
||||||
assertThat(stateController.getComplications(true).contains(complication))
|
assertThat(stateController.getComplications(true).contains(complication))
|
||||||
@@ -236,8 +236,7 @@ public class DreamOverlayStateControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNotifyLowLightChanged() {
|
public void testNotifyLowLightChanged() {
|
||||||
final DreamOverlayStateController stateController =
|
final DreamOverlayStateController stateController = getDreamOverlayStateController(true);
|
||||||
new DreamOverlayStateController(mExecutor, true);
|
|
||||||
|
|
||||||
stateController.addCallback(mCallback);
|
stateController.addCallback(mCallback);
|
||||||
mExecutor.runAllReady();
|
mExecutor.runAllReady();
|
||||||
@@ -252,8 +251,7 @@ public class DreamOverlayStateControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNotifyLowLightExit() {
|
public void testNotifyLowLightExit() {
|
||||||
final DreamOverlayStateController stateController =
|
final DreamOverlayStateController stateController = getDreamOverlayStateController(true);
|
||||||
new DreamOverlayStateController(mExecutor, true);
|
|
||||||
|
|
||||||
stateController.addCallback(mCallback);
|
stateController.addCallback(mCallback);
|
||||||
mExecutor.runAllReady();
|
mExecutor.runAllReady();
|
||||||
@@ -276,8 +274,7 @@ public class DreamOverlayStateControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNotifyEntryAnimationsFinishedChanged() {
|
public void testNotifyEntryAnimationsFinishedChanged() {
|
||||||
final DreamOverlayStateController stateController =
|
final DreamOverlayStateController stateController = getDreamOverlayStateController(true);
|
||||||
new DreamOverlayStateController(mExecutor, true);
|
|
||||||
|
|
||||||
stateController.addCallback(mCallback);
|
stateController.addCallback(mCallback);
|
||||||
mExecutor.runAllReady();
|
mExecutor.runAllReady();
|
||||||
@@ -289,4 +286,57 @@ public class DreamOverlayStateControllerTest extends SysuiTestCase {
|
|||||||
verify(mCallback, times(1)).onStateChanged();
|
verify(mCallback, times(1)).onStateChanged();
|
||||||
assertThat(stateController.areEntryAnimationsFinished()).isTrue();
|
assertThat(stateController.areEntryAnimationsFinished()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testShouldShowComplicationsSetToFalse_stillShowsSupportedTypes_featureEnabled() {
|
||||||
|
when(mFeatureFlags.isEnabled(Flags.ALWAYS_SHOW_HOME_CONTROLS_ON_DREAMS)).thenReturn(true);
|
||||||
|
|
||||||
|
final DreamOverlayStateController stateController = getDreamOverlayStateController(true);
|
||||||
|
stateController.setShouldShowComplications(true);
|
||||||
|
|
||||||
|
final Complication noneComplication = Mockito.mock(Complication.class);
|
||||||
|
when(noneComplication.getRequiredTypeAvailability())
|
||||||
|
.thenReturn(Complication.COMPLICATION_TYPE_NONE);
|
||||||
|
|
||||||
|
final Complication homeControlsComplication = Mockito.mock(Complication.class);
|
||||||
|
when(homeControlsComplication.getRequiredTypeAvailability())
|
||||||
|
.thenReturn(Complication.COMPLICATION_TYPE_HOME_CONTROLS);
|
||||||
|
|
||||||
|
stateController.addComplication(noneComplication);
|
||||||
|
stateController.addComplication(homeControlsComplication);
|
||||||
|
|
||||||
|
final DreamOverlayStateController.Callback callback =
|
||||||
|
Mockito.mock(DreamOverlayStateController.Callback.class);
|
||||||
|
|
||||||
|
stateController.setAvailableComplicationTypes(
|
||||||
|
Complication.COMPLICATION_TYPE_HOME_CONTROLS);
|
||||||
|
stateController.addCallback(callback);
|
||||||
|
mExecutor.runAllReady();
|
||||||
|
|
||||||
|
{
|
||||||
|
clearInvocations(callback);
|
||||||
|
stateController.setShouldShowComplications(true);
|
||||||
|
mExecutor.runAllReady();
|
||||||
|
|
||||||
|
verify(callback).onAvailableComplicationTypesChanged();
|
||||||
|
final Collection<Complication> complications = stateController.getComplications();
|
||||||
|
assertThat(complications.contains(noneComplication)).isTrue();
|
||||||
|
assertThat(complications.contains(homeControlsComplication)).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
clearInvocations(callback);
|
||||||
|
stateController.setShouldShowComplications(false);
|
||||||
|
mExecutor.runAllReady();
|
||||||
|
|
||||||
|
verify(callback).onAvailableComplicationTypesChanged();
|
||||||
|
final Collection<Complication> complications = stateController.getComplications();
|
||||||
|
assertThat(complications.contains(noneComplication)).isTrue();
|
||||||
|
assertThat(complications.contains(homeControlsComplication)).isTrue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private DreamOverlayStateController getDreamOverlayStateController(boolean overlayEnabled) {
|
||||||
|
return new DreamOverlayStateController(mExecutor, overlayEnabled, mFeatureFlags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user