From aec26c4f686a7a21d789d2880d1061432507482a Mon Sep 17 00:00:00 2001 From: Aurimas Liutikas Date: Wed, 5 Jan 2022 22:09:57 +0000 Subject: [PATCH] DO NOT MERGE Revert "[3/n] Camera Compat UI: Add a camera compat control." Revert submission 16468379 Reason for revert: Feature development is moving to T. Reverted Changes: Id9b9a8930:[3/n] Camera Compat UI: Add a camera compat contro... Id6be4a954:Enable a camera app compat control on Large screen... I083aa6718:[2/n] Camera Compat UI: Add interfaces for client-... Bug: 206602997 Change-Id: I318b89b87cd3b05a3f3dcd428e3d80fe81465011 --- ....xml => size_compat_background_ripple.xml} | 0 .../drawable/camera_compat_dismiss_button.xml | 33 ---- .../drawable/camera_compat_dismiss_ripple.xml | 20 --- ...camera_compat_treatment_applied_button.xml | 32 ---- ...camera_compat_treatment_applied_ripple.xml | 20 --- ...mera_compat_treatment_suggested_button.xml | 53 ------ ...mera_compat_treatment_suggested_ripple.xml | 20 --- .../drawable/size_compat_restart_button.xml | 4 +- .../size_compat_restart_button_ripple.xml | 2 +- .../Shell/res/layout/compat_mode_hint.xml | 4 +- .../Shell/res/layout/compat_ui_layout.xml | 38 +---- libs/WindowManager/Shell/res/values/dimen.xml | 6 - .../Shell/res/values/strings.xml | 13 -- .../android/wm/shell/ShellTaskOrganizer.java | 20 +-- .../wm/shell/compatui/CompatUIController.java | 74 ++++----- .../wm/shell/compatui/CompatUILayout.java | 80 +-------- .../shell/compatui/CompatUIWindowManager.java | 114 +------------ .../wm/shell/ShellTaskOrganizerTests.java | 33 ++-- .../compatui/CompatUIControllerTest.java | 126 +++++--------- .../wm/shell/compatui/CompatUILayoutTest.java | 93 +---------- .../compatui/CompatUIWindowManagerTest.java | 157 +++--------------- 21 files changed, 143 insertions(+), 799 deletions(-) rename libs/WindowManager/Shell/res/color/{compat_background_ripple.xml => size_compat_background_ripple.xml} (100%) delete mode 100644 libs/WindowManager/Shell/res/drawable/camera_compat_dismiss_button.xml delete mode 100644 libs/WindowManager/Shell/res/drawable/camera_compat_dismiss_ripple.xml delete mode 100644 libs/WindowManager/Shell/res/drawable/camera_compat_treatment_applied_button.xml delete mode 100644 libs/WindowManager/Shell/res/drawable/camera_compat_treatment_applied_ripple.xml delete mode 100644 libs/WindowManager/Shell/res/drawable/camera_compat_treatment_suggested_button.xml delete mode 100644 libs/WindowManager/Shell/res/drawable/camera_compat_treatment_suggested_ripple.xml diff --git a/libs/WindowManager/Shell/res/color/compat_background_ripple.xml b/libs/WindowManager/Shell/res/color/size_compat_background_ripple.xml similarity index 100% rename from libs/WindowManager/Shell/res/color/compat_background_ripple.xml rename to libs/WindowManager/Shell/res/color/size_compat_background_ripple.xml diff --git a/libs/WindowManager/Shell/res/drawable/camera_compat_dismiss_button.xml b/libs/WindowManager/Shell/res/drawable/camera_compat_dismiss_button.xml deleted file mode 100644 index 1c8cb914af81b..0000000000000 --- a/libs/WindowManager/Shell/res/drawable/camera_compat_dismiss_button.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - diff --git a/libs/WindowManager/Shell/res/drawable/camera_compat_dismiss_ripple.xml b/libs/WindowManager/Shell/res/drawable/camera_compat_dismiss_ripple.xml deleted file mode 100644 index c81013966c354..0000000000000 --- a/libs/WindowManager/Shell/res/drawable/camera_compat_dismiss_ripple.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - \ No newline at end of file diff --git a/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_applied_button.xml b/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_applied_button.xml deleted file mode 100644 index c796b5967f981..0000000000000 --- a/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_applied_button.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - diff --git a/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_applied_ripple.xml b/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_applied_ripple.xml deleted file mode 100644 index 3e9fe6dc3b99b..0000000000000 --- a/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_applied_ripple.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - diff --git a/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_suggested_button.xml b/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_suggested_button.xml deleted file mode 100644 index af505d1cb73ca..0000000000000 --- a/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_suggested_button.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - diff --git a/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_suggested_ripple.xml b/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_suggested_ripple.xml deleted file mode 100644 index c0f1c89b0cbb7..0000000000000 --- a/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_suggested_ripple.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - diff --git a/libs/WindowManager/Shell/res/drawable/size_compat_restart_button.xml b/libs/WindowManager/Shell/res/drawable/size_compat_restart_button.xml index e6ae282079705..ab74e43472c34 100644 --- a/libs/WindowManager/Shell/res/drawable/size_compat_restart_button.xml +++ b/libs/WindowManager/Shell/res/drawable/size_compat_restart_button.xml @@ -21,9 +21,7 @@ android:viewportHeight="48"> + android:pathData="M0,24 a24,24 0 1,0 48,0 a24,24 0 1,0 -48,0" /> diff --git a/libs/WindowManager/Shell/res/drawable/size_compat_restart_button_ripple.xml b/libs/WindowManager/Shell/res/drawable/size_compat_restart_button_ripple.xml index 6551edf6d0e63..95decff24ac4b 100644 --- a/libs/WindowManager/Shell/res/drawable/size_compat_restart_button_ripple.xml +++ b/libs/WindowManager/Shell/res/drawable/size_compat_restart_button_ripple.xml @@ -15,6 +15,6 @@ ~ limitations under the License. --> + android:color="@color/size_compat_background_ripple"> \ No newline at end of file diff --git a/libs/WindowManager/Shell/res/layout/compat_mode_hint.xml b/libs/WindowManager/Shell/res/layout/compat_mode_hint.xml index 44b2f45052ba3..bb48bf7b8b2c5 100644 --- a/libs/WindowManager/Shell/res/layout/compat_mode_hint.xml +++ b/libs/WindowManager/Shell/res/layout/compat_mode_hint.xml @@ -16,7 +16,7 @@ --> - - - - - - - - - - + layout="@layout/compat_mode_hint"/> 7dp - - 188dp - - - 143dp - 200dp diff --git a/libs/WindowManager/Shell/res/values/strings.xml b/libs/WindowManager/Shell/res/values/strings.xml index ab0013a2b0b4b..c88fc16e218e8 100644 --- a/libs/WindowManager/Shell/res/values/strings.xml +++ b/libs/WindowManager/Shell/res/values/strings.xml @@ -158,17 +158,4 @@ Tap to restart this app and go full screen. - - - Camera issues?\nTap to refit - - - Didn\u2019t fix it?\nTap to revert - - - No camera issues? Tap to dismiss. - 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 91ea436f81b6a..1bbc9a5082334 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/ShellTaskOrganizer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/ShellTaskOrganizer.java @@ -607,19 +607,6 @@ public class ShellTaskOrganizer extends TaskOrganizer implements restartTaskTopActivityProcessIfVisible(info.getTaskInfo().token); } - @Override - public void onCameraControlStateUpdated( - int taskId, @TaskInfo.CameraCompatControlState int state) { - final TaskAppearedInfo info; - synchronized (mLock) { - info = mTasks.get(taskId); - } - if (info == null) { - return; - } - updateCameraCompatControlState(info.getTaskInfo().token, state); - } - private void logSizeCompatRestartButtonEventReported(@NonNull TaskAppearedInfo info, int event) { ActivityInfo topActivityInfo = info.getTaskInfo().topActivityInfo; @@ -647,10 +634,13 @@ public class ShellTaskOrganizer extends TaskOrganizer implements // on this Task if there is any. if (taskListener == null || !taskListener.supportCompatUI() || !taskInfo.hasCompatUI() || !taskInfo.isVisible) { - mCompatUI.onCompatInfoChanged(taskInfo, null /* taskListener */); + mCompatUI.onCompatInfoChanged(taskInfo.displayId, taskInfo.taskId, + null /* taskConfig */, null /* taskListener */); return; } - mCompatUI.onCompatInfoChanged(taskInfo, taskListener); + + mCompatUI.onCompatInfoChanged(taskInfo.displayId, taskInfo.taskId, + taskInfo.configuration, taskListener); } private TaskListener getTaskListener(RunningTaskInfo runningTaskInfo) { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java index 8f4cfb0a49a41..e0b23873a980b 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java @@ -17,8 +17,6 @@ package com.android.wm.shell.compatui; import android.annotation.Nullable; -import android.app.TaskInfo; -import android.app.TaskInfo.CameraCompatControlState; import android.content.Context; import android.content.res.Configuration; import android.hardware.display.DisplayManager; @@ -55,14 +53,12 @@ import java.util.function.Predicate; public class CompatUIController implements OnDisplaysChangedListener, DisplayImeController.ImePositionProcessor { - /** Callback for compat UI interaction. */ + /** Callback for size compat UI interaction. */ public interface CompatUICallback { /** Called when the size compat restart button appears. */ void onSizeCompatRestartButtonAppeared(int taskId); /** Called when the size compat restart button is clicked. */ void onSizeCompatRestartButtonClicked(int taskId); - /** Called when the camera compat control state is updated. */ - void onCameraControlStateUpdated(int taskId, @CameraCompatControlState int state); } private static final String TAG = "CompatUIController"; @@ -90,12 +86,10 @@ public class CompatUIController implements OnDisplaysChangedListener, private CompatUICallback mCallback; - // Only show once automatically in the process life. - private boolean mHasShownSizeCompatHint; - private boolean mHasShownCameraCompatHint; - - // Indicates if the keyguard is currently occluded, in which case compat UIs shouldn't - // be shown. + /** Only show once automatically in the process life. */ + private boolean mHasShownHint; + /** Indicates if the keyguard is currently occluded, in which case compat UIs shouldn't + * be shown. */ private boolean mKeyguardOccluded; public CompatUIController(Context context, @@ -128,20 +122,23 @@ public class CompatUIController implements OnDisplaysChangedListener, * Called when the Task info changed. Creates and updates the compat UI if there is an * activity in size compat, or removes the UI if there is no size compat activity. * - * @param taskInfo {@link TaskInfo} task the activity is in. + * @param displayId display the task and activity are in. + * @param taskId task the activity is in. + * @param taskConfig task config to place the compat UI with. * @param taskListener listener to handle the Task Surface placement. */ - public void onCompatInfoChanged(TaskInfo taskInfo, + public void onCompatInfoChanged(int displayId, int taskId, + @Nullable Configuration taskConfig, @Nullable ShellTaskOrganizer.TaskListener taskListener) { - if (taskInfo.configuration == null || taskListener == null) { + if (taskConfig == null || taskListener == null) { // Null token means the current foreground activity is not in compatibility mode. - removeLayout(taskInfo.taskId); - } else if (mActiveLayouts.contains(taskInfo.taskId)) { + removeLayout(taskId); + } else if (mActiveLayouts.contains(taskId)) { // UI already exists, update the UI layout. - updateLayout(taskInfo, taskListener); + updateLayout(taskId, taskConfig, taskListener); } else { // Create a new compat UI. - createLayout(taskInfo, taskListener); + createLayout(displayId, taskId, taskConfig, taskListener); } } @@ -218,45 +215,38 @@ public class CompatUIController implements OnDisplaysChangedListener, return mDisplaysWithIme.contains(displayId); } - private void createLayout(TaskInfo taskInfo, ShellTaskOrganizer.TaskListener taskListener) { - final Context context = getOrCreateDisplayContext(taskInfo.displayId); + private void createLayout(int displayId, int taskId, Configuration taskConfig, + ShellTaskOrganizer.TaskListener taskListener) { + final Context context = getOrCreateDisplayContext(displayId); if (context == null) { - Log.e(TAG, "Cannot get context for display " + taskInfo.displayId); + Log.e(TAG, "Cannot get context for display " + displayId); return; } final CompatUIWindowManager compatUIWindowManager = - createLayout(context, taskInfo, taskListener); - mActiveLayouts.put(taskInfo.taskId, compatUIWindowManager); - compatUIWindowManager.createLayout(showOnDisplay(taskInfo.displayId), - taskInfo.topActivityInSizeCompat, taskInfo.cameraCompatControlState); + createLayout(context, displayId, taskId, taskConfig, taskListener); + mActiveLayouts.put(taskId, compatUIWindowManager); + compatUIWindowManager.createLayout(showOnDisplay(displayId)); } @VisibleForTesting - CompatUIWindowManager createLayout(Context context, TaskInfo taskInfo, - ShellTaskOrganizer.TaskListener taskListener) { + CompatUIWindowManager createLayout(Context context, int displayId, int taskId, + Configuration taskConfig, ShellTaskOrganizer.TaskListener taskListener) { final CompatUIWindowManager compatUIWindowManager = new CompatUIWindowManager(context, - taskInfo.configuration, mSyncQueue, mCallback, taskInfo.taskId, taskListener, - mDisplayController.getDisplayLayout(taskInfo.displayId), mHasShownSizeCompatHint, - mHasShownCameraCompatHint); - // Only show hints for the first time. - if (taskInfo.topActivityInSizeCompat) { - mHasShownSizeCompatHint = true; - } - if (taskInfo.hasCameraCompatControl()) { - mHasShownCameraCompatHint = true; - } + taskConfig, mSyncQueue, mCallback, taskId, taskListener, + mDisplayController.getDisplayLayout(displayId), mHasShownHint); + // Only show hint for the first time. + mHasShownHint = true; return compatUIWindowManager; } - private void updateLayout(TaskInfo taskInfo, ShellTaskOrganizer.TaskListener taskListener) { - final CompatUIWindowManager layout = mActiveLayouts.get(taskInfo.taskId); + private void updateLayout(int taskId, Configuration taskConfig, + ShellTaskOrganizer.TaskListener taskListener) { + final CompatUIWindowManager layout = mActiveLayouts.get(taskId); if (layout == null) { return; } - layout.updateCompatInfo(taskInfo.configuration, taskListener, - showOnDisplay(layout.getDisplayId()), taskInfo.topActivityInSizeCompat, - taskInfo.cameraCompatControlState); + layout.updateCompatInfo(taskConfig, taskListener, showOnDisplay(layout.getDisplayId())); } private void removeLayout(int taskId) { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUILayout.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUILayout.java index 29b2baa221e77..ea4f209684385 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUILayout.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUILayout.java @@ -16,9 +16,6 @@ package com.android.wm.shell.compatui; -import android.annotation.IdRes; -import android.app.TaskInfo; -import android.app.TaskInfo.CameraCompatControlState; import android.content.Context; import android.util.AttributeSet; import android.view.View; @@ -56,53 +53,6 @@ public class CompatUILayout extends LinearLayout { mWindowManager = windowManager; } - void updateCameraTreatmentButton(@CameraCompatControlState int newState) { - int buttonBkgId = newState == TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED - ? R.drawable.camera_compat_treatment_suggested_ripple - : R.drawable.camera_compat_treatment_applied_ripple; - int hintStringId = newState == TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED - ? R.string.camera_compat_treatment_suggested_button_description - : R.string.camera_compat_treatment_applied_button_description; - final ImageButton button = findViewById(R.id.camera_compat_treatment_button); - button.setImageResource(buttonBkgId); - button.setContentDescription(getResources().getString(hintStringId)); - final LinearLayout hint = findViewById(R.id.camera_compat_hint); - ((TextView) hint.findViewById(R.id.compat_mode_hint_text)).setText(hintStringId); - } - - void setSizeCompatHintVisibility(boolean show) { - setViewVisibility(R.id.size_compat_hint, show); - } - - void setCameraCompatHintVisibility(boolean show) { - setViewVisibility(R.id.camera_compat_hint, show); - } - - void setRestartButtonVisibility(boolean show) { - setViewVisibility(R.id.size_compat_restart_button, show); - // Hint should never be visible without button. - if (!show) { - setSizeCompatHintVisibility(/* show= */ false); - } - } - - void setCameraControlVisibility(boolean show) { - setViewVisibility(R.id.camera_compat_control, show); - // Hint should never be visible without button. - if (!show) { - setCameraCompatHintVisibility(/* show= */ false); - } - } - - private void setViewVisibility(@IdRes int resId, boolean show) { - final View view = findViewById(resId); - int visibility = show ? View.VISIBLE : View.GONE; - if (view.getVisibility() == visibility) { - return; - } - view.setVisibility(visibility); - } - @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); @@ -111,6 +61,15 @@ public class CompatUILayout extends LinearLayout { mWindowManager.relayout(); } + void setSizeCompatHintVisibility(boolean show) { + final LinearLayout sizeCompatHint = findViewById(R.id.size_compat_hint); + int visibility = show ? View.VISIBLE : View.GONE; + if (sizeCompatHint.getVisibility() == visibility) { + return; + } + sizeCompatHint.setVisibility(visibility); + } + @Override protected void onFinishInflate() { super.onFinishInflate(); @@ -126,26 +85,5 @@ public class CompatUILayout extends LinearLayout { ((TextView) sizeCompatHint.findViewById(R.id.compat_mode_hint_text)) .setText(R.string.restart_button_description); sizeCompatHint.setOnClickListener(view -> setSizeCompatHintVisibility(/* show= */ false)); - - final ImageButton cameraTreatmentButton = - findViewById(R.id.camera_compat_treatment_button); - cameraTreatmentButton.setOnClickListener( - view -> mWindowManager.onCameraTreatmentButtonClicked()); - cameraTreatmentButton.setOnLongClickListener(view -> { - mWindowManager.onCameraButtonLongClicked(); - return true; - }); - - final ImageButton cameraDismissButton = findViewById(R.id.camera_compat_dismiss_button); - cameraDismissButton.setOnClickListener( - view -> mWindowManager.onCameraDismissButtonClicked()); - cameraDismissButton.setOnLongClickListener(view -> { - mWindowManager.onCameraButtonLongClicked(); - return true; - }); - - final LinearLayout cameraCompatHint = findViewById(R.id.camera_compat_hint); - cameraCompatHint.setOnClickListener( - view -> setCameraCompatHintVisibility(/* show= */ false)); } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManager.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManager.java index 44526b00bf0df..997ad04e3b579 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManager.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManager.java @@ -16,10 +16,6 @@ package com.android.wm.shell.compatui; -import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_DISMISSED; -import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_HIDDEN; -import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED; -import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED; import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION; @@ -27,7 +23,6 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERL import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import android.annotation.Nullable; -import android.app.TaskInfo.CameraCompatControlState; import android.content.Context; import android.content.res.Configuration; import android.graphics.PixelFormat; @@ -68,17 +63,8 @@ class CompatUIWindowManager extends WindowlessWindowManager { private ShellTaskOrganizer.TaskListener mTaskListener; private DisplayLayout mDisplayLayout; - // Remember the last reported states in case visibility changes due to keyguard or - // IME updates. @VisibleForTesting - boolean mHasSizeCompat; - @CameraCompatControlState - private int mCameraCompatControlState = CAMERA_COMPAT_CONTROL_HIDDEN; - - @VisibleForTesting - boolean mShouldShowSizeCompatHint; - @VisibleForTesting - boolean mShouldShowCameraCompatHint; + boolean mShouldShowHint; @Nullable @VisibleForTesting @@ -92,7 +78,7 @@ class CompatUIWindowManager extends WindowlessWindowManager { CompatUIWindowManager(Context context, Configuration taskConfig, SyncTransactionQueue syncQueue, CompatUIController.CompatUICallback callback, int taskId, ShellTaskOrganizer.TaskListener taskListener, DisplayLayout displayLayout, - boolean hasShownSizeCompatHint, boolean hasShownCameraCompatHint) { + boolean hasShownHint) { super(taskConfig, null /* rootSurface */, null /* hostInputToken */); mContext = context; mSyncQueue = syncQueue; @@ -102,8 +88,7 @@ class CompatUIWindowManager extends WindowlessWindowManager { mTaskId = taskId; mTaskListener = taskListener; mDisplayLayout = displayLayout; - mShouldShowSizeCompatHint = !hasShownSizeCompatHint; - mShouldShowCameraCompatHint = !hasShownCameraCompatHint; + mShouldShowHint = !hasShownHint; mStableBounds = new Rect(); mDisplayLayout.getStableBounds(mStableBounds); } @@ -128,10 +113,7 @@ class CompatUIWindowManager extends WindowlessWindowManager { } /** Creates the layout for compat controls. */ - void createLayout(boolean show, boolean hasSizeCompat, - @CameraCompatControlState int cameraCompatControlState) { - mHasSizeCompat = hasSizeCompat; - mCameraCompatControlState = cameraCompatControlState; + void createLayout(boolean show) { if (!show || mCompatUILayout != null) { // Wait until compat controls should be visible. return; @@ -140,27 +122,16 @@ class CompatUIWindowManager extends WindowlessWindowManager { initCompatUi(); updateSurfacePosition(); - if (hasSizeCompat) { - mCallback.onSizeCompatRestartButtonAppeared(mTaskId); - } - } - - private void createLayout(boolean show) { - createLayout(show, mHasSizeCompat, mCameraCompatControlState); + mCallback.onSizeCompatRestartButtonAppeared(mTaskId); } /** Called when compat info changed. */ void updateCompatInfo(Configuration taskConfig, - ShellTaskOrganizer.TaskListener taskListener, boolean show, boolean hasSizeCompat, - @CameraCompatControlState int cameraCompatControlState) { + ShellTaskOrganizer.TaskListener taskListener, boolean show) { final Configuration prevTaskConfig = mTaskConfig; final ShellTaskOrganizer.TaskListener prevTaskListener = mTaskListener; mTaskConfig = taskConfig; mTaskListener = taskListener; - final boolean prevHasSizeCompat = mHasSizeCompat; - final int prevCameraCompatControlState = mCameraCompatControlState; - mHasSizeCompat = hasSizeCompat; - mCameraCompatControlState = cameraCompatControlState; // Update configuration. mContext = mContext.createConfigurationContext(taskConfig); @@ -173,11 +144,6 @@ class CompatUIWindowManager extends WindowlessWindowManager { return; } - if (prevHasSizeCompat != mHasSizeCompat - || prevCameraCompatControlState != mCameraCompatControlState) { - updateVisibilityOfViews(); - } - if (!taskConfig.windowConfiguration.getBounds() .equals(prevTaskConfig.windowConfiguration.getBounds())) { // Reposition the UI surfaces. @@ -189,7 +155,6 @@ class CompatUIWindowManager extends WindowlessWindowManager { mCompatUILayout.setLayoutDirection(taskConfig.getLayoutDirection()); updateSurfacePosition(); } - } /** Called when the visibility of the UI should change. */ @@ -230,34 +195,6 @@ class CompatUIWindowManager extends WindowlessWindowManager { mCallback.onSizeCompatRestartButtonClicked(mTaskId); } - /** Called when the camera treatment button is clicked. */ - void onCameraTreatmentButtonClicked() { - if (!shouldShowCameraControl()) { - Log.w(TAG, "Camera compat shouldn't receive clicks in the hidden state."); - return; - } - // When a camera control is shown, only two states are allowed: "treament applied" and - // "treatment suggested". Clicks on the conrol's treatment button toggle between these - // two states. - mCameraCompatControlState = - mCameraCompatControlState == CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED - ? CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED - : CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED; - mCallback.onCameraControlStateUpdated(mTaskId, mCameraCompatControlState); - mCompatUILayout.updateCameraTreatmentButton(mCameraCompatControlState); - } - - /** Called when the camera dismiss button is clicked. */ - void onCameraDismissButtonClicked() { - if (!shouldShowCameraControl()) { - Log.w(TAG, "Camera compat shouldn't receive clicks in the hidden state."); - return; - } - mCameraCompatControlState = CAMERA_COMPAT_CONTROL_DISMISSED; - mCallback.onCameraControlStateUpdated(mTaskId, CAMERA_COMPAT_CONTROL_DISMISSED); - mCompatUILayout.setCameraControlVisibility(/* show= */ false); - } - /** Called when the restart button is long clicked. */ void onRestartButtonLongClicked() { if (mCompatUILayout == null) { @@ -266,14 +203,6 @@ class CompatUIWindowManager extends WindowlessWindowManager { mCompatUILayout.setSizeCompatHintVisibility(/* show= */ true); } - /** Called when either dismiss or treatment camera buttons is long clicked. */ - void onCameraButtonLongClicked() { - if (mCompatUILayout == null) { - return; - } - mCompatUILayout.setCameraCompatHintVisibility(/* show= */ true); - } - int getDisplayId() { return mDisplayId; } @@ -284,8 +213,6 @@ class CompatUIWindowManager extends WindowlessWindowManager { /** Releases the surface control and tears down the view hierarchy. */ void release() { - // Hiding before releasing to avoid flickering when transitioning to the Home screen. - mCompatUILayout.setVisibility(View.GONE); mCompatUILayout = null; if (mViewHost != null) { @@ -356,35 +283,12 @@ class CompatUIWindowManager extends WindowlessWindowManager { mCompatUILayout = inflateCompatUILayout(); mCompatUILayout.inject(this); - updateVisibilityOfViews(); + mCompatUILayout.setSizeCompatHintVisibility(mShouldShowHint); mViewHost.setView(mCompatUILayout, getWindowLayoutParams()); - } - private void updateVisibilityOfViews() { - // Size Compat mode restart button. - mCompatUILayout.setRestartButtonVisibility(mHasSizeCompat); - if (mHasSizeCompat && mShouldShowSizeCompatHint) { - mCompatUILayout.setSizeCompatHintVisibility(/* show= */ true); - // Only show by default for the first time. - mShouldShowSizeCompatHint = false; - } - - // Camera control for stretched issues. - mCompatUILayout.setCameraControlVisibility(shouldShowCameraControl()); - if (shouldShowCameraControl() && mShouldShowCameraCompatHint) { - mCompatUILayout.setCameraCompatHintVisibility(/* show= */ true); - // Only show by default for the first time. - mShouldShowCameraCompatHint = false; - } - if (shouldShowCameraControl()) { - mCompatUILayout.updateCameraTreatmentButton(mCameraCompatControlState); - } - } - - private boolean shouldShowCameraControl() { - return mCameraCompatControlState != CAMERA_COMPAT_CONTROL_HIDDEN - && mCameraCompatControlState != CAMERA_COMPAT_CONTROL_DISMISSED; + // Only show by default for the first time. + mShouldShowHint = false; } @VisibleForTesting 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 825320b4e7840..7c204e636588d 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 @@ -335,7 +335,8 @@ public class ShellTaskOrganizerTests { mOrganizer.onTaskAppeared(taskInfo1, null); // sizeCompatActivity is null if top activity is not in size compat. - verify(mCompatUI).onCompatInfoChanged(taskInfo1, null /* taskListener */); + verify(mCompatUI).onCompatInfoChanged(taskInfo1.displayId, taskInfo1.taskId, + null /* taskConfig */, null /* taskListener */); // sizeCompatActivity is non-null if top activity is in size compat. clearInvocations(mCompatUI); @@ -345,7 +346,8 @@ public class ShellTaskOrganizerTests { taskInfo2.topActivityInSizeCompat = true; taskInfo2.isVisible = true; mOrganizer.onTaskInfoChanged(taskInfo2); - verify(mCompatUI).onCompatInfoChanged(taskInfo2, taskListener); + verify(mCompatUI).onCompatInfoChanged(taskInfo1.displayId, taskInfo1.taskId, + taskInfo1.configuration, taskListener); // Not show size compat UI if task is not visible. clearInvocations(mCompatUI); @@ -355,11 +357,13 @@ public class ShellTaskOrganizerTests { taskInfo3.topActivityInSizeCompat = true; taskInfo3.isVisible = false; mOrganizer.onTaskInfoChanged(taskInfo3); - verify(mCompatUI).onCompatInfoChanged(taskInfo3, null /* taskListener */); + verify(mCompatUI).onCompatInfoChanged(taskInfo1.displayId, taskInfo1.taskId, + null /* taskConfig */, null /* taskListener */); clearInvocations(mCompatUI); mOrganizer.onTaskVanished(taskInfo1); - verify(mCompatUI).onCompatInfoChanged(taskInfo1, null /* taskListener */); + verify(mCompatUI).onCompatInfoChanged(taskInfo1.displayId, taskInfo1.taskId, + null /* taskConfig */, null /* taskListener */); } @Test @@ -373,7 +377,8 @@ public class ShellTaskOrganizerTests { // Task listener sent to compat UI is null if top activity doesn't request a camera // compat control. - verify(mCompatUI).onCompatInfoChanged(taskInfo1, null /* taskListener */); + 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); @@ -383,7 +388,8 @@ public class ShellTaskOrganizerTests { taskInfo2.cameraCompatControlState = TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED; taskInfo2.isVisible = true; mOrganizer.onTaskInfoChanged(taskInfo2); - verify(mCompatUI).onCompatInfoChanged(taskInfo2, taskListener); + 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. @@ -394,7 +400,8 @@ public class ShellTaskOrganizerTests { taskInfo3.cameraCompatControlState = TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED; taskInfo3.isVisible = true; mOrganizer.onTaskInfoChanged(taskInfo3); - verify(mCompatUI).onCompatInfoChanged(taskInfo3, taskListener); + 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. @@ -406,7 +413,8 @@ public class ShellTaskOrganizerTests { taskInfo4.cameraCompatControlState = TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED; taskInfo4.isVisible = true; mOrganizer.onTaskInfoChanged(taskInfo4); - verify(mCompatUI).onCompatInfoChanged(taskInfo4, taskListener); + 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); @@ -416,7 +424,8 @@ public class ShellTaskOrganizerTests { taskInfo5.cameraCompatControlState = TaskInfo.CAMERA_COMPAT_CONTROL_DISMISSED; taskInfo5.isVisible = true; mOrganizer.onTaskInfoChanged(taskInfo5); - verify(mCompatUI).onCompatInfoChanged(taskInfo5, null /* taskListener */); + 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); @@ -426,11 +435,13 @@ public class ShellTaskOrganizerTests { taskInfo6.cameraCompatControlState = TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED; taskInfo6.isVisible = false; mOrganizer.onTaskInfoChanged(taskInfo6); - verify(mCompatUI).onCompatInfoChanged(taskInfo6, null /* taskListener */); + verify(mCompatUI).onCompatInfoChanged(taskInfo1.displayId, taskInfo1.taskId, + null /* taskConfig */, null /* taskListener */); clearInvocations(mCompatUI); mOrganizer.onTaskVanished(taskInfo1); - verify(mCompatUI).onCompatInfoChanged(taskInfo1, null /* taskListener */); + verify(mCompatUI).onCompatInfoChanged(taskInfo1.displayId, taskInfo1.taskId, + null /* taskConfig */, null /* taskListener */); } @Test diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java index 4352fd3d2c277..f622edb7f134d 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java @@ -16,10 +16,6 @@ package com.android.wm.shell.compatui; -import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_DISMISSED; -import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_HIDDEN; -import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED; -import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED; import static android.view.InsetsState.ITYPE_EXTRA_NAVIGATION_BAR; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; @@ -33,9 +29,6 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import android.app.ActivityManager.RunningTaskInfo; -import android.app.TaskInfo; -import android.app.TaskInfo.CameraCompatControlState; import android.content.Context; import android.content.res.Configuration; import android.testing.AndroidTestingRunner; @@ -97,8 +90,8 @@ public class CompatUIControllerTest extends ShellTestCase { mController = new CompatUIController(mContext, mMockDisplayController, mMockDisplayInsetsController, mMockImeController, mMockSyncQueue, mMockExecutor) { @Override - CompatUIWindowManager createLayout(Context context, TaskInfo taskInfo, - ShellTaskOrganizer.TaskListener taskListener) { + CompatUIWindowManager createLayout(Context context, int displayId, int taskId, + Configuration taskConfig, ShellTaskOrganizer.TaskListener taskListener) { return mMockLayout; } }; @@ -113,59 +106,23 @@ public class CompatUIControllerTest extends ShellTestCase { @Test public void testOnCompatInfoChanged() { - TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID, true /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_HIDDEN); + final Configuration taskConfig = new Configuration(); // Verify that the restart button is added with non-null size compat info. - mController.onCompatInfoChanged(taskInfo, mMockTaskListener); + mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig, mMockTaskListener); - verify(mController).createLayout(any(), eq(taskInfo), eq(mMockTaskListener)); + verify(mController).createLayout(any(), eq(DISPLAY_ID), eq(TASK_ID), eq(taskConfig), + eq(mMockTaskListener)); // Verify that the restart button is updated with non-null new size compat info. - mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, - true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN), - mMockTaskListener); + final Configuration newTaskConfig = new Configuration(); + mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, newTaskConfig, mMockTaskListener); - verify(mMockLayout).updateCompatInfo(new Configuration(), mMockTaskListener, - true /* show */, true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN); + verify(mMockLayout).updateCompatInfo(taskConfig, mMockTaskListener, + true /* show */); - // Verify that the restart button is updated with new camera state. - mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, - true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED), - mMockTaskListener); - - verify(mMockLayout).updateCompatInfo(new Configuration(), mMockTaskListener, - true /* show */, true /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED); - - mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, - true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED), - mMockTaskListener); - - verify(mMockLayout).updateCompatInfo(new Configuration(), mMockTaskListener, - true /* show */, true /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED); - - // Verify that compat controls are removed with null compat info. - mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, - false /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN), - null /* taskListener */); - - verify(mMockLayout).release(); - - clearInvocations(mMockLayout); - clearInvocations(mController); - // Verify that compat controls are removed with dismissed camera state. - taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID, - true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED); - - mController.onCompatInfoChanged(taskInfo, mMockTaskListener); - - verify(mController).createLayout(any(), eq(taskInfo), eq(mMockTaskListener)); - - mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, - false /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_DISMISSED), - null /* taskListener */); + // Verify that the restart button is removed with null size compat info. + mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, null, mMockTaskListener); verify(mMockLayout).release(); } @@ -182,8 +139,8 @@ public class CompatUIControllerTest extends ShellTestCase { @Test public void testOnDisplayRemoved() { mController.onDisplayAdded(DISPLAY_ID); - mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, - true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN), + final Configuration taskConfig = new Configuration(); + mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig, mMockTaskListener); mController.onDisplayRemoved(DISPLAY_ID + 1); @@ -200,14 +157,16 @@ public class CompatUIControllerTest extends ShellTestCase { @Test public void testOnDisplayConfigurationChanged() { - mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, - true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener); + final Configuration taskConfig = new Configuration(); + mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig, + mMockTaskListener); - mController.onDisplayConfigurationChanged(DISPLAY_ID + 1, new Configuration()); + final Configuration newTaskConfig = new Configuration(); + mController.onDisplayConfigurationChanged(DISPLAY_ID + 1, newTaskConfig); verify(mMockLayout, never()).updateDisplayLayout(any()); - mController.onDisplayConfigurationChanged(DISPLAY_ID, new Configuration()); + mController.onDisplayConfigurationChanged(DISPLAY_ID, newTaskConfig); verify(mMockLayout).updateDisplayLayout(mMockDisplayLayout); } @@ -215,8 +174,9 @@ public class CompatUIControllerTest extends ShellTestCase { @Test public void testInsetsChanged() { mController.onDisplayAdded(DISPLAY_ID); - mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, - true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener); + final Configuration taskConfig = new Configuration(); + mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig, + mMockTaskListener); InsetsState insetsState = new InsetsState(); InsetsSource insetsSource = new InsetsSource(ITYPE_EXTRA_NAVIGATION_BAR); insetsSource.setFrame(0, 0, 1000, 1000); @@ -236,8 +196,8 @@ public class CompatUIControllerTest extends ShellTestCase { @Test public void testChangeButtonVisibilityOnImeShowHide() { - mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, - true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener); + final Configuration taskConfig = new Configuration(); + mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig, mMockTaskListener); // Verify that the restart button is hidden after IME is showing. mController.onImeVisibilityChanged(DISPLAY_ID, true /* isShowing */); @@ -245,11 +205,10 @@ public class CompatUIControllerTest extends ShellTestCase { verify(mMockLayout).updateVisibility(false); // Verify button remains hidden while IME is showing. - mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, - true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener); + mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig, mMockTaskListener); - verify(mMockLayout).updateCompatInfo(new Configuration(), mMockTaskListener, - false /* show */, true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN); + verify(mMockLayout).updateCompatInfo(taskConfig, mMockTaskListener, + false /* show */); // Verify button is shown after IME is hidden. mController.onImeVisibilityChanged(DISPLAY_ID, false /* isShowing */); @@ -259,8 +218,8 @@ public class CompatUIControllerTest extends ShellTestCase { @Test public void testChangeButtonVisibilityOnKeyguardOccludedChanged() { - mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, - true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener); + final Configuration taskConfig = new Configuration(); + mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig, mMockTaskListener); // Verify that the restart button is hidden after keyguard becomes occluded. mController.onKeyguardOccludedChanged(true); @@ -268,11 +227,10 @@ public class CompatUIControllerTest extends ShellTestCase { verify(mMockLayout).updateVisibility(false); // Verify button remains hidden while keyguard is occluded. - mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, - true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener); + mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig, mMockTaskListener); - verify(mMockLayout).updateCompatInfo(new Configuration(), mMockTaskListener, - false /* show */, true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN); + verify(mMockLayout).updateCompatInfo(taskConfig, mMockTaskListener, + false /* show */); // Verify button is shown after keyguard becomes not occluded. mController.onKeyguardOccludedChanged(false); @@ -282,8 +240,8 @@ public class CompatUIControllerTest extends ShellTestCase { @Test public void testButtonRemainsHiddenOnKeyguardOccludedFalseWhenImeIsShowing() { - mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, - true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener); + final Configuration taskConfig = new Configuration(); + mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig, mMockTaskListener); mController.onImeVisibilityChanged(DISPLAY_ID, true /* isShowing */); mController.onKeyguardOccludedChanged(true); @@ -305,8 +263,8 @@ public class CompatUIControllerTest extends ShellTestCase { @Test public void testButtonRemainsHiddenOnImeHideWhenKeyguardIsOccluded() { - mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, - true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener); + final Configuration taskConfig = new Configuration(); + mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig, mMockTaskListener); mController.onImeVisibilityChanged(DISPLAY_ID, true /* isShowing */); mController.onKeyguardOccludedChanged(true); @@ -325,14 +283,4 @@ public class CompatUIControllerTest extends ShellTestCase { verify(mMockLayout).updateVisibility(true); } - - private static TaskInfo createTaskInfo(int displayId, int taskId, boolean hasSizeCompat, - @CameraCompatControlState int cameraCompatControlState) { - RunningTaskInfo taskInfo = new RunningTaskInfo(); - taskInfo.taskId = taskId; - taskInfo.displayId = displayId; - taskInfo.topActivityInSizeCompat = hasSizeCompat; - taskInfo.cameraCompatControlState = cameraCompatControlState; - return taskInfo; - } } diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUILayoutTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUILayoutTest.java index 353d8fe8bc529..2c3987bc358d5 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUILayoutTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUILayoutTest.java @@ -16,11 +16,6 @@ package com.android.wm.shell.compatui; -import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_DISMISSED; -import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_HIDDEN; -import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED; -import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED; - import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; import static org.mockito.Mockito.doNothing; @@ -74,7 +69,7 @@ public class CompatUILayoutTest extends ShellTestCase { mWindowManager = new CompatUIWindowManager(mContext, new Configuration(), mSyncTransactionQueue, mCallback, TASK_ID, mTaskListener, new DisplayLayout(), - false /* hasShownSizeCompatHint */, false /* hasShownCameraCompatHint */); + false /* hasShownHint */); mCompatUILayout = (CompatUILayout) LayoutInflater.from(mContext).inflate(R.layout.compat_ui_layout, null); @@ -83,7 +78,6 @@ public class CompatUILayoutTest extends ShellTestCase { spyOn(mWindowManager); spyOn(mCompatUILayout); doReturn(mViewHost).when(mWindowManager).createSurfaceViewHost(); - doReturn(mCompatUILayout).when(mWindowManager).inflateCompatUILayout(); } @Test @@ -92,6 +86,7 @@ public class CompatUILayoutTest extends ShellTestCase { button.performClick(); verify(mWindowManager).onRestartButtonClicked(); + doReturn(mCompatUILayout).when(mWindowManager).inflateCompatUILayout(); verify(mCallback).onSizeCompatRestartButtonClicked(TASK_ID); } @@ -107,92 +102,10 @@ public class CompatUILayoutTest extends ShellTestCase { @Test public void testOnClickForSizeCompatHint() { - mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_HIDDEN); + mWindowManager.createLayout(true /* show */); final LinearLayout sizeCompatHint = mCompatUILayout.findViewById(R.id.size_compat_hint); sizeCompatHint.performClick(); verify(mCompatUILayout).setSizeCompatHintVisibility(/* show= */ false); } - - @Test - public void testUpdateCameraTreatmentButton_treatmentAppliedByDefault() { - mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED); - final ImageButton button = - mCompatUILayout.findViewById(R.id.camera_compat_treatment_button); - button.performClick(); - - verify(mWindowManager).onCameraTreatmentButtonClicked(); - verify(mCallback).onCameraControlStateUpdated( - TASK_ID, CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED); - - button.performClick(); - - verify(mCallback).onCameraControlStateUpdated( - TASK_ID, CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED); - } - - @Test - public void testUpdateCameraTreatmentButton_treatmentSuggestedByDefault() { - mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED); - final ImageButton button = - mCompatUILayout.findViewById(R.id.camera_compat_treatment_button); - button.performClick(); - - verify(mWindowManager).onCameraTreatmentButtonClicked(); - verify(mCallback).onCameraControlStateUpdated( - TASK_ID, CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED); - - button.performClick(); - - verify(mCallback).onCameraControlStateUpdated( - TASK_ID, CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED); - } - - @Test - public void testOnCameraDismissButtonClicked() { - mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED); - final ImageButton button = - mCompatUILayout.findViewById(R.id.camera_compat_dismiss_button); - button.performClick(); - - verify(mWindowManager).onCameraDismissButtonClicked(); - verify(mCallback).onCameraControlStateUpdated( - TASK_ID, CAMERA_COMPAT_CONTROL_DISMISSED); - verify(mCompatUILayout).setCameraControlVisibility(/* show */ false); - } - - @Test - public void testOnLongClickForCameraTreatementButton() { - doNothing().when(mWindowManager).onCameraButtonLongClicked(); - - final ImageButton button = - mCompatUILayout.findViewById(R.id.camera_compat_treatment_button); - button.performLongClick(); - - verify(mWindowManager).onCameraButtonLongClicked(); - } - - @Test - public void testOnLongClickForCameraDismissButton() { - doNothing().when(mWindowManager).onCameraButtonLongClicked(); - - final ImageButton button = mCompatUILayout.findViewById(R.id.camera_compat_dismiss_button); - button.performLongClick(); - - verify(mWindowManager).onCameraButtonLongClicked(); - } - - @Test - public void testOnClickForCameraCompatHint() { - mWindowManager.createLayout(true /* show */, false /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED); - final LinearLayout hint = mCompatUILayout.findViewById(R.id.camera_compat_hint); - hint.performClick(); - - verify(mCompatUILayout).setCameraCompatHintVisibility(/* show= */ false); - } } diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java index 11c7973638194..d5dcf2e11a46e 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java @@ -16,10 +16,6 @@ package com.android.wm.shell.compatui; -import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_DISMISSED; -import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_HIDDEN; -import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED; -import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED; import static android.view.InsetsState.ITYPE_EXTRA_NAVIGATION_BAR; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; @@ -27,7 +23,6 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -86,7 +81,7 @@ public class CompatUIWindowManagerTest extends ShellTestCase { mWindowManager = new CompatUIWindowManager(mContext, new Configuration(), mSyncTransactionQueue, mCallback, TASK_ID, mTaskListener, new DisplayLayout(), - false /* hasShownSizeCompatHint */, false /* hasShownSizeCompatHint */); + false /* hasShownHint */); spyOn(mWindowManager); doReturn(mCompatUILayout).when(mWindowManager).inflateCompatUILayout(); @@ -96,35 +91,31 @@ public class CompatUIWindowManagerTest extends ShellTestCase { @Test public void testCreateSizeCompatButton() { // Not create layout if show is false. - mWindowManager.createLayout(false /* show */, true /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_HIDDEN); + mWindowManager.createLayout(false /* show */); verify(mWindowManager, never()).inflateCompatUILayout(); // Not create hint popup. - mWindowManager.mShouldShowSizeCompatHint = false; - mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_HIDDEN); + mWindowManager.mShouldShowHint = false; + mWindowManager.createLayout(true /* show */); verify(mWindowManager).inflateCompatUILayout(); - verify(mCompatUILayout, never()).setSizeCompatHintVisibility(true /* show */); + verify(mCompatUILayout).setSizeCompatHintVisibility(false /* show */); // Create hint popup. mWindowManager.release(); - mWindowManager.mShouldShowSizeCompatHint = true; - mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_HIDDEN); + mWindowManager.mShouldShowHint = true; + mWindowManager.createLayout(true /* show */); verify(mWindowManager, times(2)).inflateCompatUILayout(); assertNotNull(mCompatUILayout); verify(mCompatUILayout).setSizeCompatHintVisibility(true /* show */); - assertFalse(mWindowManager.mShouldShowSizeCompatHint); + assertFalse(mWindowManager.mShouldShowHint); } @Test public void testRelease() { - mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_HIDDEN); + mWindowManager.createLayout(true /* show */); verify(mWindowManager).inflateCompatUILayout(); @@ -135,60 +126,32 @@ public class CompatUIWindowManagerTest extends ShellTestCase { @Test public void testUpdateCompatInfo() { - mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_HIDDEN); + mWindowManager.createLayout(true /* show */); // No diff clearInvocations(mWindowManager); - mWindowManager.updateCompatInfo(mTaskConfig, mTaskListener, true /* show */, - true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN); + mWindowManager.updateCompatInfo(mTaskConfig, mTaskListener, true /* show */); verify(mWindowManager, never()).updateSurfacePosition(); verify(mWindowManager, never()).release(); - verify(mWindowManager, never()).createLayout(anyBoolean(), anyBoolean(), anyInt()); + verify(mWindowManager, never()).createLayout(anyBoolean()); // Change task listener, recreate button. clearInvocations(mWindowManager); final ShellTaskOrganizer.TaskListener newTaskListener = mock( ShellTaskOrganizer.TaskListener.class); mWindowManager.updateCompatInfo(mTaskConfig, newTaskListener, - true /* show */, true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN); + true /* show */); verify(mWindowManager).release(); - verify(mWindowManager).createLayout(anyBoolean(), anyBoolean(), anyInt()); - - // Change Camera Compat state, show a control. - mWindowManager.updateCompatInfo(mTaskConfig, newTaskListener, true /* show */, - true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED); - - verify(mCompatUILayout).setCameraControlVisibility(/* show */ true); - verify(mCompatUILayout).updateCameraTreatmentButton( - CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED); - - clearInvocations(mWindowManager); - clearInvocations(mCompatUILayout); - // Change Camera Compat state, update a control. - mWindowManager.updateCompatInfo(mTaskConfig, newTaskListener, true /* show */, - true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED); - - verify(mCompatUILayout).setCameraControlVisibility(/* show */ true); - verify(mCompatUILayout).updateCameraTreatmentButton( - CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED); - - clearInvocations(mWindowManager); - clearInvocations(mCompatUILayout); - // Change Camera Compat state to hidden, hide a control. - mWindowManager.updateCompatInfo(mTaskConfig, newTaskListener, - true /* show */, true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN); - - verify(mCompatUILayout).setCameraControlVisibility(/* show */ false); + verify(mWindowManager).createLayout(anyBoolean()); // Change task bounds, update position. clearInvocations(mWindowManager); final Configuration newTaskConfiguration = new Configuration(); newTaskConfiguration.windowConfiguration.setBounds(new Rect(0, 1000, 0, 2000)); mWindowManager.updateCompatInfo(newTaskConfiguration, newTaskListener, - true /* show */, true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN); + true /* show */); verify(mWindowManager).updateSurfacePosition(); } @@ -238,25 +201,23 @@ public class CompatUIWindowManagerTest extends ShellTestCase { public void testUpdateVisibility() { // Create button if it is not created. mWindowManager.mCompatUILayout = null; - mWindowManager.mHasSizeCompat = true; mWindowManager.updateVisibility(true /* show */); - verify(mWindowManager).createLayout(true /* show */, true /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_HIDDEN); + verify(mWindowManager).createLayout(true /* show */); // Hide button. clearInvocations(mWindowManager); doReturn(View.VISIBLE).when(mCompatUILayout).getVisibility(); mWindowManager.updateVisibility(false /* show */); - verify(mWindowManager, never()).createLayout(anyBoolean(), anyBoolean(), anyInt()); + verify(mWindowManager, never()).createLayout(anyBoolean()); verify(mCompatUILayout).setVisibility(View.GONE); // Show button. doReturn(View.GONE).when(mCompatUILayout).getVisibility(); mWindowManager.updateVisibility(true /* show */); - verify(mWindowManager, never()).createLayout(anyBoolean(), anyBoolean(), anyInt()); + verify(mWindowManager, never()).createLayout(anyBoolean()); verify(mCompatUILayout).setVisibility(View.VISIBLE); } @@ -268,37 +229,6 @@ public class CompatUIWindowManagerTest extends ShellTestCase { verify(mTaskListener).attachChildSurfaceToTask(TASK_ID, b); } - @Test - public void testOnCameraDismissButtonClicked() { - mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED); - clearInvocations(mCompatUILayout); - mWindowManager.onCameraDismissButtonClicked(); - - verify(mCallback).onCameraControlStateUpdated(TASK_ID, CAMERA_COMPAT_CONTROL_DISMISSED); - verify(mCompatUILayout).setCameraControlVisibility(/* show= */ false); - } - - @Test - public void testOnCameraTreatmentButtonClicked() { - mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED); - clearInvocations(mCompatUILayout); - mWindowManager.onCameraTreatmentButtonClicked(); - - verify(mCallback).onCameraControlStateUpdated( - TASK_ID, CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED); - verify(mCompatUILayout).updateCameraTreatmentButton( - CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED); - - mWindowManager.onCameraTreatmentButtonClicked(); - - verify(mCallback).onCameraControlStateUpdated( - TASK_ID, CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED); - verify(mCompatUILayout).updateCameraTreatmentButton( - CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED); - } - @Test public void testOnRestartButtonClicked() { mWindowManager.onRestartButtonClicked(); @@ -309,60 +239,15 @@ public class CompatUIWindowManagerTest extends ShellTestCase { @Test public void testOnRestartButtonLongClicked_showHint() { // Not create hint popup. - mWindowManager.mShouldShowSizeCompatHint = false; - mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_HIDDEN); + mWindowManager.mShouldShowHint = false; + mWindowManager.createLayout(true /* show */); verify(mWindowManager).inflateCompatUILayout(); - verify(mCompatUILayout, never()).setSizeCompatHintVisibility(true /* show */); + verify(mCompatUILayout).setSizeCompatHintVisibility(false /* show */); mWindowManager.onRestartButtonLongClicked(); verify(mCompatUILayout).setSizeCompatHintVisibility(true /* show */); } - @Test - public void testOnCamerControlLongClicked_showHint() { - // Not create hint popup. - mWindowManager.mShouldShowCameraCompatHint = false; - mWindowManager.createLayout(true /* show */, false /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED); - - verify(mWindowManager).inflateCompatUILayout(); - verify(mCompatUILayout, never()).setCameraCompatHintVisibility(true /* show */); - - mWindowManager.onCameraButtonLongClicked(); - - verify(mCompatUILayout).setCameraCompatHintVisibility(true /* show */); - } - - @Test - public void testCreateCameraCompatControl() { - // Not create layout if show is false. - mWindowManager.createLayout(false /* show */, false /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED); - - verify(mWindowManager, never()).inflateCompatUILayout(); - - // Not create hint popup. - mWindowManager.mShouldShowCameraCompatHint = false; - mWindowManager.createLayout(true /* show */, false /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED); - - verify(mWindowManager).inflateCompatUILayout(); - verify(mCompatUILayout, never()).setCameraCompatHintVisibility(true /* show */); - verify(mCompatUILayout).setCameraControlVisibility(true /* show */); - - // Create hint popup. - mWindowManager.release(); - mWindowManager.mShouldShowCameraCompatHint = true; - mWindowManager.createLayout(true /* show */, false /* hasSizeCompat */, - CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED); - - verify(mWindowManager, times(2)).inflateCompatUILayout(); - assertNotNull(mCompatUILayout); - verify(mCompatUILayout, times(2)).setCameraControlVisibility(true /* show */); - assertFalse(mWindowManager.mShouldShowCameraCompatHint); - } - }