diff options
author | Mariia Sandrikova <mariiasand@google.com> | 2021-12-15 02:34:05 +0000 |
---|---|---|
committer | Mariia Sandrikova <mariiasand@google.com> | 2021-12-17 00:18:57 +0000 |
commit | 24f4d8a9521d0281721fe5703b32569c8fd7e151 (patch) | |
tree | 6eb5c0f8575a289e19cdc1447fed3958704f3f73 /libs | |
parent | aa7a8cdda5c7bf7ad30c93bdec3dd875ca6985e5 (diff) |
[2/n] Camera Compat UI: Add interfaces for client-server communication.
Changes:
- Listens to changes from the client coming through IActivityClientController#requestCompatCameraControl to ActivityRecord#updateCameraCompatState
- ActivityRecord#updateCameraCompatState sends updated state via TaskInfo to WM Shell
- ITaskOrganizerController#updateCameraCompatControlState to dispatch the user interactions with the control from WM Shell triggers callback to ActivityRecord#updateCameraCompatStateFromUser
- ActivityRecord#updateCameraCompatStateFromUser remembers the user's choice and asks client to apply treatment through ICompatCameraControlCallback
Feature is guarded with config_isCameraCompatControlForStretchedIssuesEnabled
Test: atest WMShellUnitTests:ShellTaskOrganizerTests, atest WmTests:ActivityRecordTests
Bug: 206602997
Change-Id: I083aa6718bd67456bedd9444e9b78740c041f870
Diffstat (limited to 'libs')
-rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/ShellTaskOrganizer.java | 4 | ||||
-rw-r--r-- | libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/ShellTaskOrganizerTests.java | 79 |
2 files changed, 81 insertions, 2 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/ShellTaskOrganizer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/ShellTaskOrganizer.java index 8b3a35688f11..1bbc9a508233 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/ShellTaskOrganizer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/ShellTaskOrganizer.java @@ -458,7 +458,7 @@ public class ShellTaskOrganizer extends TaskOrganizer implements newListener.onTaskInfoChanged(taskInfo); } notifyLocusVisibilityIfNeeded(taskInfo); - if (updated || !taskInfo.equalsForSizeCompat(data.getTaskInfo())) { + if (updated || !taskInfo.equalsForCompatUi(data.getTaskInfo())) { // Notify the compat UI if the listener or task info changed. notifyCompatUI(taskInfo, newListener); } @@ -633,7 +633,7 @@ public class ShellTaskOrganizer extends TaskOrganizer implements // The task is vanished or doesn't support compat UI, notify to remove compat UI // on this Task if there is any. if (taskListener == null || !taskListener.supportCompatUI() - || !taskInfo.topActivityInSizeCompat || !taskInfo.isVisible) { + || !taskInfo.hasCompatUI() || !taskInfo.isVisible) { mCompatUI.onCompatInfoChanged(taskInfo.displayId, taskInfo.taskId, null /* taskConfig */, null /* taskListener */); return; diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/ShellTaskOrganizerTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/ShellTaskOrganizerTests.java index a3b98a8fc880..7c204e636588 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/ShellTaskOrganizerTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/ShellTaskOrganizerTests.java @@ -37,6 +37,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import android.app.ActivityManager.RunningTaskInfo; +import android.app.TaskInfo; import android.content.Context; import android.content.LocusId; import android.content.pm.ParceledListSlice; @@ -366,6 +367,84 @@ public class ShellTaskOrganizerTests { } @Test + public void testOnCameraCompatActivityChanged() { + final RunningTaskInfo taskInfo1 = createTaskInfo(1, WINDOWING_MODE_FULLSCREEN); + taskInfo1.displayId = DEFAULT_DISPLAY; + taskInfo1.cameraCompatControlState = TaskInfo.CAMERA_COMPAT_CONTROL_HIDDEN; + final TrackingTaskListener taskListener = new TrackingTaskListener(); + mOrganizer.addListenerForType(taskListener, TASK_LISTENER_TYPE_FULLSCREEN); + mOrganizer.onTaskAppeared(taskInfo1, null); + + // Task listener sent to compat UI is null if top activity doesn't request a camera + // compat control. + verify(mCompatUI).onCompatInfoChanged(taskInfo1.displayId, taskInfo1.taskId, + null /* taskConfig */, null /* taskListener */); + + // Task linster is non-null when request a camera compat control for a visible task. + clearInvocations(mCompatUI); + final RunningTaskInfo taskInfo2 = + createTaskInfo(taskInfo1.taskId, taskInfo1.getWindowingMode()); + taskInfo2.displayId = taskInfo1.displayId; + taskInfo2.cameraCompatControlState = TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED; + taskInfo2.isVisible = true; + mOrganizer.onTaskInfoChanged(taskInfo2); + verify(mCompatUI).onCompatInfoChanged(taskInfo1.displayId, taskInfo1.taskId, + taskInfo1.configuration, taskListener); + + // CompatUIController#onCompatInfoChanged is called when requested state for a camera + // compat control changes for a visible task. + clearInvocations(mCompatUI); + final RunningTaskInfo taskInfo3 = + createTaskInfo(taskInfo1.taskId, taskInfo1.getWindowingMode()); + taskInfo3.displayId = taskInfo1.displayId; + taskInfo3.cameraCompatControlState = TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED; + taskInfo3.isVisible = true; + mOrganizer.onTaskInfoChanged(taskInfo3); + verify(mCompatUI).onCompatInfoChanged(taskInfo1.displayId, taskInfo1.taskId, + taskInfo1.configuration, taskListener); + + // CompatUIController#onCompatInfoChanged is called when a top activity goes in size compat + // mode for a visible task that has a compat control. + clearInvocations(mCompatUI); + final RunningTaskInfo taskInfo4 = + createTaskInfo(taskInfo1.taskId, taskInfo1.getWindowingMode()); + taskInfo4.displayId = taskInfo1.displayId; + taskInfo4.topActivityInSizeCompat = true; + taskInfo4.cameraCompatControlState = TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED; + taskInfo4.isVisible = true; + mOrganizer.onTaskInfoChanged(taskInfo4); + verify(mCompatUI).onCompatInfoChanged(taskInfo1.displayId, taskInfo1.taskId, + taskInfo1.configuration, taskListener); + + // Task linster is null when a camera compat control is dimissed for a visible task. + clearInvocations(mCompatUI); + final RunningTaskInfo taskInfo5 = + createTaskInfo(taskInfo1.taskId, taskInfo1.getWindowingMode()); + taskInfo5.displayId = taskInfo1.displayId; + taskInfo5.cameraCompatControlState = TaskInfo.CAMERA_COMPAT_CONTROL_DISMISSED; + taskInfo5.isVisible = true; + mOrganizer.onTaskInfoChanged(taskInfo5); + verify(mCompatUI).onCompatInfoChanged(taskInfo1.displayId, taskInfo1.taskId, + null /* taskConfig */, null /* taskListener */); + + // Task linster is null when request a camera compat control for a invisible task. + clearInvocations(mCompatUI); + final RunningTaskInfo taskInfo6 = + createTaskInfo(taskInfo1.taskId, taskInfo1.getWindowingMode()); + taskInfo6.displayId = taskInfo1.displayId; + taskInfo6.cameraCompatControlState = TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED; + taskInfo6.isVisible = false; + mOrganizer.onTaskInfoChanged(taskInfo6); + verify(mCompatUI).onCompatInfoChanged(taskInfo1.displayId, taskInfo1.taskId, + null /* taskConfig */, null /* taskListener */); + + clearInvocations(mCompatUI); + mOrganizer.onTaskVanished(taskInfo1); + verify(mCompatUI).onCompatInfoChanged(taskInfo1.displayId, taskInfo1.taskId, + null /* taskConfig */, null /* taskListener */); + } + + @Test public void testAddLocusListener() { RunningTaskInfo task1 = createTaskInfo(1, WINDOWING_MODE_MULTI_WINDOW); task1.isVisible = true; |