Merge "Enable common logic for proto 1 and proto 2" into tm-qpr-dev am: 4613b0f07d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20653236 Change-Id: Ie0c51e8cace60f9e56ab82016b3414d89016ef65 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -692,7 +692,7 @@ public abstract class WMShellBaseModule {
|
|||||||
// Use optional-of-lazy for the dependency that this provider relies on.
|
// Use optional-of-lazy for the dependency that this provider relies on.
|
||||||
// Lazy ensures that this provider will not be the cause the dependency is created
|
// Lazy ensures that this provider will not be the cause the dependency is created
|
||||||
// when it will not be returned due to the condition below.
|
// when it will not be returned due to the condition below.
|
||||||
if (DesktopModeStatus.IS_SUPPORTED) {
|
if (DesktopModeStatus.isProto1Enabled()) {
|
||||||
return desktopModeController.map(Lazy::get);
|
return desktopModeController.map(Lazy::get);
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
@@ -709,7 +709,7 @@ public abstract class WMShellBaseModule {
|
|||||||
// Use optional-of-lazy for the dependency that this provider relies on.
|
// Use optional-of-lazy for the dependency that this provider relies on.
|
||||||
// Lazy ensures that this provider will not be the cause the dependency is created
|
// Lazy ensures that this provider will not be the cause the dependency is created
|
||||||
// when it will not be returned due to the condition below.
|
// when it will not be returned due to the condition below.
|
||||||
if (DesktopModeStatus.IS_SUPPORTED) {
|
if (DesktopModeStatus.isAnyEnabled()) {
|
||||||
return desktopModeTaskRepository.map(Lazy::get);
|
return desktopModeTaskRepository.map(Lazy::get);
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public class DesktopModeController implements RemoteCallable<DesktopModeControll
|
|||||||
mDesktopModeTaskRepository = desktopModeTaskRepository;
|
mDesktopModeTaskRepository = desktopModeTaskRepository;
|
||||||
mMainExecutor = mainExecutor;
|
mMainExecutor = mainExecutor;
|
||||||
mSettingsObserver = new SettingsObserver(mContext, mainHandler);
|
mSettingsObserver = new SettingsObserver(mContext, mainHandler);
|
||||||
if (DesktopModeStatus.isSupported()) {
|
if (DesktopModeStatus.isProto1Enabled()) {
|
||||||
shellInit.addInitCallback(this::onInit, this);
|
shellInit.addInitCallback(this::onInit, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,16 +33,37 @@ public class DesktopModeStatus {
|
|||||||
/**
|
/**
|
||||||
* Flag to indicate whether desktop mode is available on the device
|
* Flag to indicate whether desktop mode is available on the device
|
||||||
*/
|
*/
|
||||||
public static final boolean IS_SUPPORTED = SystemProperties.getBoolean(
|
private static final boolean IS_SUPPORTED = SystemProperties.getBoolean(
|
||||||
"persist.wm.debug.desktop_mode", false);
|
"persist.wm.debug.desktop_mode", false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag to indicate whether desktop mode proto 2 is available on the device
|
||||||
|
*/
|
||||||
|
private static final boolean IS_PROTO2_ENABLED = SystemProperties.getBoolean(
|
||||||
|
"persist.wm.debug.desktop_mode_2", false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return {@code true} if desktop mode support is enabled
|
* Return {@code true} if desktop mode support is enabled
|
||||||
*/
|
*/
|
||||||
public static boolean isSupported() {
|
public static boolean isProto1Enabled() {
|
||||||
return IS_SUPPORTED;
|
return IS_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return {@code true} is desktop windowing proto 2 is enabled
|
||||||
|
*/
|
||||||
|
public static boolean isProto2Enabled() {
|
||||||
|
return IS_PROTO2_ENABLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return {@code true} if proto 1 or 2 is enabled.
|
||||||
|
* Can be used to guard logic that is common for both prototypes.
|
||||||
|
*/
|
||||||
|
public static boolean isAnyEnabled() {
|
||||||
|
return isProto1Enabled() || isProto2Enabled();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if desktop mode is active
|
* Check if desktop mode is active
|
||||||
*
|
*
|
||||||
@@ -61,5 +82,4 @@ public class DesktopModeStatus {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class FreeformTaskListener implements ShellTaskOrganizer.TaskListener,
|
|||||||
|
|
||||||
private void onInit() {
|
private void onInit() {
|
||||||
mShellTaskOrganizer.addListenerForType(this, TASK_LISTENER_TYPE_FREEFORM);
|
mShellTaskOrganizer.addListenerForType(this, TASK_LISTENER_TYPE_FREEFORM);
|
||||||
if (DesktopModeStatus.IS_SUPPORTED) {
|
if (DesktopModeStatus.isAnyEnabled()) {
|
||||||
mShellTaskOrganizer.addFocusListener(this);
|
mShellTaskOrganizer.addFocusListener(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ public class FreeformTaskListener implements ShellTaskOrganizer.TaskListener,
|
|||||||
t.apply();
|
t.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DesktopModeStatus.IS_SUPPORTED) {
|
if (DesktopModeStatus.isAnyEnabled()) {
|
||||||
mDesktopModeTaskRepository.ifPresent(repository -> {
|
mDesktopModeTaskRepository.ifPresent(repository -> {
|
||||||
repository.addOrMoveFreeformTaskToTop(taskInfo.taskId);
|
repository.addOrMoveFreeformTaskToTop(taskInfo.taskId);
|
||||||
if (taskInfo.isVisible) {
|
if (taskInfo.isVisible) {
|
||||||
@@ -110,7 +110,7 @@ public class FreeformTaskListener implements ShellTaskOrganizer.TaskListener,
|
|||||||
taskInfo.taskId);
|
taskInfo.taskId);
|
||||||
mTasks.remove(taskInfo.taskId);
|
mTasks.remove(taskInfo.taskId);
|
||||||
|
|
||||||
if (DesktopModeStatus.IS_SUPPORTED) {
|
if (DesktopModeStatus.isAnyEnabled()) {
|
||||||
mDesktopModeTaskRepository.ifPresent(repository -> {
|
mDesktopModeTaskRepository.ifPresent(repository -> {
|
||||||
repository.removeFreeformTask(taskInfo.taskId);
|
repository.removeFreeformTask(taskInfo.taskId);
|
||||||
if (repository.removeActiveTask(taskInfo.taskId)) {
|
if (repository.removeActiveTask(taskInfo.taskId)) {
|
||||||
@@ -134,7 +134,7 @@ public class FreeformTaskListener implements ShellTaskOrganizer.TaskListener,
|
|||||||
taskInfo.taskId);
|
taskInfo.taskId);
|
||||||
mWindowDecorationViewModel.onTaskInfoChanged(state.mTaskInfo);
|
mWindowDecorationViewModel.onTaskInfoChanged(state.mTaskInfo);
|
||||||
|
|
||||||
if (DesktopModeStatus.IS_SUPPORTED) {
|
if (DesktopModeStatus.isAnyEnabled()) {
|
||||||
mDesktopModeTaskRepository.ifPresent(repository -> {
|
mDesktopModeTaskRepository.ifPresent(repository -> {
|
||||||
if (taskInfo.isVisible) {
|
if (taskInfo.isVisible) {
|
||||||
if (repository.addActiveTask(taskInfo.taskId)) {
|
if (repository.addActiveTask(taskInfo.taskId)) {
|
||||||
@@ -152,7 +152,7 @@ public class FreeformTaskListener implements ShellTaskOrganizer.TaskListener,
|
|||||||
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TASK_ORG,
|
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TASK_ORG,
|
||||||
"Freeform Task Focus Changed: #%d focused=%b",
|
"Freeform Task Focus Changed: #%d focused=%b",
|
||||||
taskInfo.taskId, taskInfo.isFocused);
|
taskInfo.taskId, taskInfo.isFocused);
|
||||||
if (DesktopModeStatus.IS_SUPPORTED && taskInfo.isFocused) {
|
if (DesktopModeStatus.isAnyEnabled() && taskInfo.isFocused) {
|
||||||
mDesktopModeTaskRepository.ifPresent(repository -> {
|
mDesktopModeTaskRepository.ifPresent(repository -> {
|
||||||
repository.addOrMoveFreeformTaskToTop(taskInfo.taskId);
|
repository.addOrMoveFreeformTaskToTop(taskInfo.taskId);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -517,7 +517,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
|
|||||||
|
|
||||||
private boolean shouldShowWindowDecor(RunningTaskInfo taskInfo) {
|
private boolean shouldShowWindowDecor(RunningTaskInfo taskInfo) {
|
||||||
if (taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM) return true;
|
if (taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM) return true;
|
||||||
return DesktopModeStatus.IS_SUPPORTED
|
return DesktopModeStatus.isAnyEnabled()
|
||||||
&& taskInfo.getActivityType() == ACTIVITY_TYPE_STANDARD
|
&& taskInfo.getActivityType() == ACTIVITY_TYPE_STANDARD
|
||||||
&& mDisplayController.getDisplayContext(taskInfo.displayId)
|
&& mDisplayController.getDisplayContext(taskInfo.displayId)
|
||||||
.getResources().getConfiguration().smallestScreenWidthDp >= 600;
|
.getResources().getConfiguration().smallestScreenWidthDp >= 600;
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public class DesktopModeControllerTest extends ShellTestCase {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mMockitoSession = mockitoSession().mockStatic(DesktopModeStatus.class).startMocking();
|
mMockitoSession = mockitoSession().mockStatic(DesktopModeStatus.class).startMocking();
|
||||||
when(DesktopModeStatus.isSupported()).thenReturn(true);
|
when(DesktopModeStatus.isProto1Enabled()).thenReturn(true);
|
||||||
when(DesktopModeStatus.isActive(any())).thenReturn(true);
|
when(DesktopModeStatus.isActive(any())).thenReturn(true);
|
||||||
|
|
||||||
mShellInit = Mockito.spy(new ShellInit(mTestExecutor));
|
mShellInit = Mockito.spy(new ShellInit(mTestExecutor));
|
||||||
@@ -129,7 +129,7 @@ public class DesktopModeControllerTest extends ShellTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void instantiate_flagOff_doNotAddInitCallback() {
|
public void instantiate_flagOff_doNotAddInitCallback() {
|
||||||
when(DesktopModeStatus.isSupported()).thenReturn(false);
|
when(DesktopModeStatus.isProto1Enabled()).thenReturn(false);
|
||||||
clearInvocations(mShellInit);
|
clearInvocations(mShellInit);
|
||||||
|
|
||||||
createController();
|
createController();
|
||||||
|
|||||||
Reference in New Issue
Block a user