From a5547def07738179d91a60c319039d07c917b0d1 Mon Sep 17 00:00:00 2001 From: "jorgegil@google.com" Date: Tue, 9 Mar 2021 15:13:13 -0800 Subject: [PATCH] Update PIP menu accessiblity bounds when it is moved Bug: 179337864 Test: atest PipHomeTest Change-Id: I37ffbade283861f0013f29a86855146fd2c012de --- .../pip/phone/PhonePipMenuController.java | 18 ++++++++++++++++++ .../wm/shell/flicker/helpers/PipAppHelper.kt | 8 ++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java index 725f87d93e4e1..580861cf49740 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java @@ -121,6 +121,19 @@ public class PhonePipMenuController implements PipMenuController { } }; + private final float[] mTmpValues = new float[9]; + private final Runnable mUpdateEmbeddedMatrix = () -> { + if (mPipMenuView == null || mPipMenuView.getViewRootImpl() == null) { + return; + } + mMoveTransform.getValues(mTmpValues); + try { + mPipMenuView.getViewRootImpl().getAccessibilityEmbeddedConnection() + .setScreenMatrix(mTmpValues); + } catch (RemoteException e) { + } + }; + public PhonePipMenuController(Context context, PipMediaController mediaController, SystemWindows systemWindows, ShellExecutor mainExecutor, Handler mainHandler) { @@ -306,6 +319,11 @@ public class PhonePipMenuController implements PipMenuController { } else { mApplier.scheduleApply(params); } + + if (mPipMenuView.getViewRootImpl() != null) { + mPipMenuView.getHandler().removeCallbacks(mUpdateEmbeddedMatrix); + mPipMenuView.getHandler().post(mUpdateEmbeddedMatrix); + } } /** diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/PipAppHelper.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/PipAppHelper.kt index ecc066be734fc..5a96a7c8cbd97 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/PipAppHelper.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/PipAppHelper.kt @@ -17,7 +17,6 @@ package com.android.wm.shell.flicker.helpers import android.app.Instrumentation -import android.graphics.Point import android.media.session.MediaController import android.media.session.MediaSessionManager import android.os.SystemClock @@ -135,11 +134,8 @@ class PipAppHelper(instrumentation: Instrumentation) : BaseAppHelper( expandPipWindow(wmHelper) val exitPipObject = uiDevice.findObject(By.res(SYSTEMUI_PACKAGE, "dismiss")) requireNotNull(exitPipObject) { "PIP window dismiss button not found" } - val coordinatesInWindow = exitPipObject.visibleBounds - val windowOffset = wmHelper.getWindowRegion(component).bounds - val newCoordinates = Point(windowOffset.left + coordinatesInWindow.centerX(), - windowOffset.top + coordinatesInWindow.centerY()) - uiDevice.click(newCoordinates.x, newCoordinates.y) + val dismissButtonBounds = exitPipObject.visibleBounds + uiDevice.click(dismissButtonBounds.centerX(), dismissButtonBounds.centerY()) } // Wait for animation to complete.