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

Commit 6c7e8863 authored by tomnatan's avatar tomnatan Committed by Tom Natan
Browse files

[4/n] Letterbox Education: Create a superclass for compat UI window managers.

This super class will hold common logic and be used for the letterbox
education window manager in a follow up cl.

Bug: 207010227
Test: atest WMShellUnitTests:CompatUILayoutTest
Test: atest WMShellUnitTests:CompatUIWindowManagerTest
Test: atest WMShellUnitTests:CompatUIControllerTest
Change-Id: If6a1a5d1325e1fd4245b138e255000fa71273472
parent 1483f4d6
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ import java.util.function.Consumer;
import java.util.function.Predicate;

/**
 * Controls to show/update restart-activity buttons on Tasks based on whether the foreground
 * Controller to show/update compat UI components on Tasks based on whether the foreground
 * activities are in compatibility mode.
 */
public class CompatUIController implements OnDisplaysChangedListener,
@@ -228,8 +228,7 @@ public class CompatUIController implements OnDisplaysChangedListener,
        final CompatUIWindowManager compatUIWindowManager =
                createLayout(context, taskInfo, taskListener);
        mActiveLayouts.put(taskInfo.taskId, compatUIWindowManager);
        compatUIWindowManager.createLayout(showOnDisplay(taskInfo.displayId),
                taskInfo.topActivityInSizeCompat, taskInfo.cameraCompatControlState);
        compatUIWindowManager.createLayout(showOnDisplay(taskInfo.displayId), taskInfo);
    }

    @VisibleForTesting
@@ -254,9 +253,7 @@ public class CompatUIController implements OnDisplaysChangedListener,
        if (layout == null) {
            return;
        }
        layout.updateCompatInfo(taskInfo.configuration, taskListener,
                showOnDisplay(layout.getDisplayId()), taskInfo.topActivityInSizeCompat,
                taskInfo.cameraCompatControlState);
        layout.updateCompatInfo(taskInfo, taskListener, showOnDisplay(layout.getDisplayId()));
    }

    private void removeLayout(int taskId) {
+76 −256
Original line number Diff line number Diff line
@@ -20,28 +20,16 @@ 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;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;

import android.annotation.Nullable;
import android.app.TaskInfo;
import android.app.TaskInfo.CameraCompatControlState;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.os.Binder;
import android.util.Log;
import android.view.IWindow;
import android.view.LayoutInflater;
import android.view.SurfaceControl;
import android.view.SurfaceControlViewHost;
import android.view.SurfaceSession;
import android.view.View;
import android.view.WindowManager;
import android.view.WindowlessWindowManager;

import com.android.internal.annotations.VisibleForTesting;
import com.android.wm.shell.R;
@@ -50,26 +38,19 @@ import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.common.SyncTransactionQueue;

/**
 * Holds view hierarchy of a root surface and helps to inflate and manage layout for compat
 * controls.
 * Window manager for the Size Compat restart button and Camera Compat control.
 */
class CompatUIWindowManager extends WindowlessWindowManager {
class CompatUIWindowManager extends CompatUIWindowManagerAbstract {

    private static final String TAG = "CompatUIWindowManager";
    /**
     * The Compat UI should be the topmost child of the Task in case there can be more than one
     * child.
     */
    private static final int Z_ORDER = Integer.MAX_VALUE;

    private final SyncTransactionQueue mSyncQueue;
    private final CompatUIController.CompatUICallback mCallback;
    private final int mDisplayId;
    private final int mTaskId;
    private final Rect mStableBounds;

    private Context mContext;
    private Configuration mTaskConfig;
    private ShellTaskOrganizer.TaskListener mTaskListener;
    private DisplayLayout mDisplayLayout;

    // Remember the last reported states in case visibility changes due to keyguard or
    // IME updates.
    // Remember the last reported states in case visibility changes due to keyguard or IME updates.
    @VisibleForTesting
    boolean mHasSizeCompat;
    @CameraCompatControlState
@@ -82,147 +63,83 @@ class CompatUIWindowManager extends WindowlessWindowManager {

    @Nullable
    @VisibleForTesting
    CompatUILayout mCompatUILayout;

    @Nullable
    private SurfaceControlViewHost mViewHost;
    @Nullable
    private SurfaceControl mLeash;
    CompatUILayout mLayout;

    CompatUIWindowManager(Context context, Configuration taskConfig,
            SyncTransactionQueue syncQueue, CompatUIController.CompatUICallback callback,
            int taskId, ShellTaskOrganizer.TaskListener taskListener, DisplayLayout displayLayout,
            boolean hasShownSizeCompatHint, boolean hasShownCameraCompatHint) {
        super(taskConfig, null /* rootSurface */, null /* hostInputToken */);
        mContext = context;
        mSyncQueue = syncQueue;
        super(context, taskConfig, syncQueue, taskId, taskListener, displayLayout);
        mCallback = callback;
        mTaskConfig = taskConfig;
        mDisplayId = mContext.getDisplayId();
        mTaskId = taskId;
        mTaskListener = taskListener;
        mDisplayLayout = displayLayout;
        mShouldShowSizeCompatHint = !hasShownSizeCompatHint;
        mShouldShowCameraCompatHint = !hasShownCameraCompatHint;
        mStableBounds = new Rect();
        mDisplayLayout.getStableBounds(mStableBounds);
    }

    @Override
    public void setConfiguration(Configuration configuration) {
        super.setConfiguration(configuration);
        mContext = mContext.createConfigurationContext(configuration);
    protected int getZOrder() {
        return Z_ORDER;
    }


    @Override
    protected void attachToParentSurface(IWindow window, SurfaceControl.Builder b) {
        // Can't set position for the ViewRootImpl SC directly. Create a leash to manipulate later.
        final SurfaceControl.Builder builder = new SurfaceControl.Builder(new SurfaceSession())
                .setContainerLayer()
                .setName("CompatUILeash")
                .setHidden(false)
                .setCallsite("CompatUIWindowManager#attachToParentSurface");
        attachToParentSurface(builder);
        mLeash = builder.build();
        b.setParent(mLeash);
    protected @Nullable View getLayout() {
        return mLayout;
    }

    /** Creates the layout for compat controls. */
    void createLayout(boolean show, boolean hasSizeCompat,
            @CameraCompatControlState int cameraCompatControlState) {
        mHasSizeCompat = hasSizeCompat;
        mCameraCompatControlState = cameraCompatControlState;
        if (!show || mCompatUILayout != null) {
            // Wait until compat controls should be visible.
            return;
    @Override
    protected void removeLayout() {
        mLayout = null;
    }

        initCompatUi();
        updateSurfacePosition();

        if (hasSizeCompat) {
            mCallback.onSizeCompatRestartButtonAppeared(mTaskId);
        }
    @Override
    protected boolean eligibleToShowLayout() {
        return mHasSizeCompat || shouldShowCameraControl();
    }

    private void createLayout(boolean show) {
        createLayout(show, mHasSizeCompat, mCameraCompatControlState);
    /**
     * Updates the internal state with respect to {@code taskInfo} and calls {@link
     * #createLayout(boolean)}.
     */
    void createLayout(boolean canShow, TaskInfo taskInfo) {
        mHasSizeCompat = taskInfo.topActivityInSizeCompat;
        mCameraCompatControlState = taskInfo.cameraCompatControlState;
        createLayout(canShow);
    }

    /** Called when compat info changed. */
    void updateCompatInfo(Configuration taskConfig,
            ShellTaskOrganizer.TaskListener taskListener, boolean show, boolean hasSizeCompat,
            @CameraCompatControlState int cameraCompatControlState) {
        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);
        setConfiguration(taskConfig);

        if (mCompatUILayout == null || prevTaskListener != taskListener) {
            // TaskListener changed, recreate the layout for new surface parent.
            release();
            createLayout(show);
            return;
        }
    @Override
    protected View createLayout() {
        mLayout = inflateLayout();
        mLayout.inject(this);

        if (prevHasSizeCompat != mHasSizeCompat
                || prevCameraCompatControlState != mCameraCompatControlState) {
        updateVisibilityOfViews();
        }

        if (!taskConfig.windowConfiguration.getBounds()
                .equals(prevTaskConfig.windowConfiguration.getBounds())) {
            // Reposition the UI surfaces.
            updateSurfacePosition();
        if (mHasSizeCompat) {
            mCallback.onSizeCompatRestartButtonAppeared(mTaskId);
        }

        if (taskConfig.getLayoutDirection() != prevTaskConfig.getLayoutDirection()) {
            // Update layout for RTL.
            mCompatUILayout.setLayoutDirection(taskConfig.getLayoutDirection());
            updateSurfacePosition();
        return mLayout;
    }

    @VisibleForTesting
    CompatUILayout inflateLayout() {
        return (CompatUILayout) LayoutInflater.from(mContext).inflate(R.layout.compat_ui_layout,
                null);
    }

    /** Called when the visibility of the UI should change. */
    void updateVisibility(boolean show) {
        if (mCompatUILayout == null) {
            // Layout may not have been created because it was hidden previously.
            createLayout(show);
            return;
        }
    @Override
    public void updateCompatInfo(TaskInfo taskInfo, ShellTaskOrganizer.TaskListener taskListener,
            boolean canShow) {
        final boolean prevHasSizeCompat = mHasSizeCompat;
        final int prevCameraCompatControlState = mCameraCompatControlState;
        mHasSizeCompat = taskInfo.topActivityInSizeCompat;
        mCameraCompatControlState = taskInfo.cameraCompatControlState;

        // Hide compat UIs when IME is showing.
        final int newVisibility = show ? View.VISIBLE : View.GONE;
        if (mCompatUILayout.getVisibility() != newVisibility) {
            mCompatUILayout.setVisibility(newVisibility);
        }
    }
        super.updateCompatInfo(taskInfo, taskListener, canShow);

    /** Called when display layout changed. */
    void updateDisplayLayout(DisplayLayout displayLayout) {
        final Rect prevStableBounds = mStableBounds;
        final Rect curStableBounds = new Rect();
        displayLayout.getStableBounds(curStableBounds);
        mDisplayLayout = displayLayout;
        if (!prevStableBounds.equals(curStableBounds)) {
            // Stable bounds changed, update UI surface positions.
            updateSurfacePosition();
            mStableBounds.set(curStableBounds);
        }
        if (prevHasSizeCompat != mHasSizeCompat
                || prevCameraCompatControlState != mCameraCompatControlState) {
            updateVisibilityOfViews();
        }

    /** Called when it is ready to be placed compat UI surface. */
    void attachToParentSurface(SurfaceControl.Builder b) {
        mTaskListener.attachChildSurfaceToTask(mTaskId, b);
    }

    /** Called when the restart button is clicked. */
@@ -233,7 +150,7 @@ class CompatUIWindowManager extends WindowlessWindowManager {
    /** 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.");
            Log.w(getTag(), "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
@@ -244,141 +161,72 @@ class CompatUIWindowManager extends WindowlessWindowManager {
                        ? CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED
                        : CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED;
        mCallback.onCameraControlStateUpdated(mTaskId, mCameraCompatControlState);
        mCompatUILayout.updateCameraTreatmentButton(mCameraCompatControlState);
        mLayout.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.");
            Log.w(getTag(), "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);
        mLayout.setCameraControlVisibility(/* show= */ false);
    }

    /** Called when the restart button is long clicked. */
    void onRestartButtonLongClicked() {
        if (mCompatUILayout == null) {
        if (mLayout == null) {
            return;
        }
        mCompatUILayout.setSizeCompatHintVisibility(/* show= */ true);
        mLayout.setSizeCompatHintVisibility(/* show= */ true);
    }

    /** Called when either dismiss or treatment camera buttons is long clicked. */
    void onCameraButtonLongClicked() {
        if (mCompatUILayout == null) {
        if (mLayout == null) {
            return;
        }
        mCompatUILayout.setCameraCompatHintVisibility(/* show= */ true);
        mLayout.setCameraCompatHintVisibility(/* show= */ true);
    }

    int getDisplayId() {
        return mDisplayId;
    }

    int getTaskId() {
        return mTaskId;
    }

    /** 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) {
            mViewHost.release();
            mViewHost = null;
        }

        if (mLeash != null) {
            final SurfaceControl leash = mLeash;
            mSyncQueue.runInSync(t -> t.remove(leash));
            mLeash = null;
        }
    }

    void relayout() {
        mViewHost.relayout(getWindowLayoutParams());
        updateSurfacePosition();
    }

    @VisibleForTesting
    void updateSurfacePosition() {
        if (mCompatUILayout == null || mLeash == null) {
    @Override
    protected void updateSurfacePosition(Rect taskBounds, Rect stableBounds) {
        if (mLayout == null) {
            return;
        }

        // Use stable bounds to prevent controls from overlapping with system bars.
        final Rect taskBounds = mTaskConfig.windowConfiguration.getBounds();
        final Rect stableBounds = new Rect();
        mDisplayLayout.getStableBounds(stableBounds);
        stableBounds.intersect(taskBounds);

        // Position of the button in the container coordinate.
        final int positionX = getLayoutDirection() == View.LAYOUT_DIRECTION_RTL
                ? stableBounds.left - taskBounds.left
                : stableBounds.right - taskBounds.left - mCompatUILayout.getMeasuredWidth();
                : stableBounds.right - taskBounds.left - mLayout.getMeasuredWidth();
        final int positionY = stableBounds.bottom - taskBounds.top
                - mCompatUILayout.getMeasuredHeight();
                - mLayout.getMeasuredHeight();

        updateSurfacePosition(positionX, positionY);
    }

    private int getLayoutDirection() {
        return mContext.getResources().getConfiguration().getLayoutDirection();
    }

    private void updateSurfacePosition(int positionX, int positionY) {
        mSyncQueue.runInSync(t -> {
            if (mLeash == null || !mLeash.isValid()) {
                Log.w(TAG, "The leash has been released.");
    private void updateVisibilityOfViews() {
        if (mLayout == null) {
            return;
        }
            t.setPosition(mLeash, positionX, positionY);
            // The compat UI should be the topmost child of the Task in case there can be more
            // than one children.
            t.setLayer(mLeash, Integer.MAX_VALUE);
        });
    }

    /** Inflates {@link CompatUILayout} on to the root surface. */
    private void initCompatUi() {
        if (mViewHost != null) {
            throw new IllegalStateException(
                    "A UI has already been created with this window manager.");
        }

        // Construction extracted into the separate methods to allow injection for tests.
        mViewHost = createSurfaceViewHost();
        mCompatUILayout = inflateCompatUILayout();
        mCompatUILayout.inject(this);

        updateVisibilityOfViews();

        mViewHost.setView(mCompatUILayout, getWindowLayoutParams());
    }

    private void updateVisibilityOfViews() {
        // Size Compat mode restart button.
        mCompatUILayout.setRestartButtonVisibility(mHasSizeCompat);
        mLayout.setRestartButtonVisibility(mHasSizeCompat);
        if (mHasSizeCompat && mShouldShowSizeCompatHint) {
            mCompatUILayout.setSizeCompatHintVisibility(/* show= */ true);
            mLayout.setSizeCompatHintVisibility(/* show= */ true);
            // Only show by default for the first time.
            mShouldShowSizeCompatHint = false;
        }

        // Camera control for stretched issues.
        mCompatUILayout.setCameraControlVisibility(shouldShowCameraControl());
        mLayout.setCameraControlVisibility(shouldShowCameraControl());
        if (shouldShowCameraControl() && mShouldShowCameraCompatHint) {
            mCompatUILayout.setCameraCompatHintVisibility(/* show= */ true);
            mLayout.setCameraCompatHintVisibility(/* show= */ true);
            // Only show by default for the first time.
            mShouldShowCameraCompatHint = false;
        }
        if (shouldShowCameraControl()) {
            mCompatUILayout.updateCameraTreatmentButton(mCameraCompatControlState);
            mLayout.updateCameraTreatmentButton(mCameraCompatControlState);
        }
    }

@@ -386,32 +234,4 @@ class CompatUIWindowManager extends WindowlessWindowManager {
        return mCameraCompatControlState != CAMERA_COMPAT_CONTROL_HIDDEN
                && mCameraCompatControlState != CAMERA_COMPAT_CONTROL_DISMISSED;
    }

    @VisibleForTesting
    CompatUILayout inflateCompatUILayout() {
        return (CompatUILayout) LayoutInflater.from(mContext)
                .inflate(R.layout.compat_ui_layout, null);
    }

    @VisibleForTesting
    SurfaceControlViewHost createSurfaceViewHost() {
        return new SurfaceControlViewHost(mContext, mContext.getDisplay(), this);
    }

    /** Gets the layout params. */
    private WindowManager.LayoutParams getWindowLayoutParams() {
        // Measure how big the hint is since its size depends on the text size.
        mCompatUILayout.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
        final WindowManager.LayoutParams winParams = new WindowManager.LayoutParams(
                // Cannot be wrap_content as this determines the actual window size
                mCompatUILayout.getMeasuredWidth(), mCompatUILayout.getMeasuredHeight(),
                TYPE_APPLICATION_OVERLAY,
                FLAG_NOT_FOCUSABLE | FLAG_NOT_TOUCH_MODAL,
                PixelFormat.TRANSLUCENT);
        winParams.token = new Binder();
        winParams.setTitle(CompatUILayout.class.getSimpleName() + mTaskId);
        winParams.privateFlags |= PRIVATE_FLAG_NO_MOVE_ANIMATION | PRIVATE_FLAG_TRUSTED_OVERLAY;
        return winParams;
    }

}
+364 −0

File added.

Preview size limit exceeded, changes collapsed.

+14 −32
Original line number Diff line number Diff line
@@ -116,35 +116,17 @@ public class CompatUIControllerTest extends ShellTestCase {
        TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID, true /* hasSizeCompat */,
                CAMERA_COMPAT_CONTROL_HIDDEN);

        // Verify that the restart button is added with non-null size compat info.
        // Verify that the compat controls are added with non-null size compat info.
        mController.onCompatInfoChanged(taskInfo, mMockTaskListener);

        verify(mController).createLayout(any(), eq(taskInfo), 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);

        verify(mMockLayout).updateCompatInfo(new Configuration(), mMockTaskListener,
                true /* show */, true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN);

        // 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 */,
        // Verify that the compat controls are updated with non-null new size compat info.
        taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID, true /* hasSizeCompat */,
                CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED);
        mController.onCompatInfoChanged(taskInfo, mMockTaskListener);

        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(mMockLayout).updateCompatInfo(taskInfo, mMockTaskListener, true /* canShow */);

        // Verify that compat controls are removed with null compat info.
        mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID,
@@ -155,7 +137,7 @@ public class CompatUIControllerTest extends ShellTestCase {

        clearInvocations(mMockLayout);
        clearInvocations(mController);
        // Verify that compat controls are removed with dismissed camera state.
        // Verify that compat controls are removed with no size compat and dismissed camera state.
        taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID,
                true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);

@@ -245,11 +227,11 @@ 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);
        TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID, true /* hasSizeCompat */,
                CAMERA_COMPAT_CONTROL_HIDDEN);
        mController.onCompatInfoChanged(taskInfo, mMockTaskListener);

        verify(mMockLayout).updateCompatInfo(new Configuration(), mMockTaskListener,
                false /* show */, true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN);
        verify(mMockLayout).updateCompatInfo(taskInfo, mMockTaskListener, false /* canShow */);

        // Verify button is shown after IME is hidden.
        mController.onImeVisibilityChanged(DISPLAY_ID, false /* isShowing */);
@@ -268,11 +250,11 @@ 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);
        TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID, true /* hasSizeCompat */,
                CAMERA_COMPAT_CONTROL_HIDDEN);
        mController.onCompatInfoChanged(taskInfo, mMockTaskListener);

        verify(mMockLayout).updateCompatInfo(new Configuration(), mMockTaskListener,
                false /* show */,  true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN);
        verify(mMockLayout).updateCompatInfo(taskInfo, mMockTaskListener, false /* canShow */);

        // Verify button is shown after keyguard becomes not occluded.
        mController.onKeyguardOccludedChanged(false);
+22 −11

File changed.

Preview size limit exceeded, changes collapsed.

Loading