diff options
| -rw-r--r-- | services/core/java/com/android/server/wm/AccessibilityController.java | 515 | ||||
| -rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java | 52 |
2 files changed, 1 insertions, 566 deletions
diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java index 7cbacd6b0b82..57f361491764 100644 --- a/services/core/java/com/android/server/wm/AccessibilityController.java +++ b/services/core/java/com/android/server/wm/AccessibilityController.java @@ -26,7 +26,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER; import static android.view.WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY; import static android.view.WindowManager.TRANSIT_FLAG_IS_RECENTS; -import static com.android.internal.util.DumpUtils.dumpSparseArray; import static com.android.internal.util.DumpUtils.dumpSparseArrayValues; import static com.android.server.accessibility.AccessibilityTraceFileProto.ENTRY; import static com.android.server.accessibility.AccessibilityTraceFileProto.MAGIC_NUMBER; @@ -50,23 +49,15 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import static com.android.server.wm.WindowTracingLegacy.WINSCOPE_EXT; import android.accessibilityservice.AccessibilityTrace; -import android.animation.ObjectAnimator; -import android.animation.ValueAnimator; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.Application; import android.content.Context; import android.content.pm.PackageManagerInternal; -import android.graphics.BLASTBufferQueue; -import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.Insets; import android.graphics.Matrix; -import android.graphics.Paint; import android.graphics.Path; -import android.graphics.PixelFormat; import android.graphics.Point; -import android.graphics.PorterDuff.Mode; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Region; @@ -84,25 +75,16 @@ import android.util.Pair; import android.util.Slog; import android.util.SparseArray; import android.util.SparseBooleanArray; -import android.util.TypedValue; import android.util.proto.ProtoOutputStream; import android.view.Display; import android.view.MagnificationSpec; import android.view.Surface; -import android.view.Surface.OutOfResourcesException; -import android.view.SurfaceControl; import android.view.ViewConfiguration; import android.view.WindowInfo; import android.view.WindowManager; import android.view.WindowManager.TransitionFlags; import android.view.WindowManager.TransitionType; -import android.view.WindowManagerPolicyConstants; -import android.view.animation.DecelerateInterpolator; -import android.view.animation.Interpolator; -import com.android.internal.R; -import com.android.internal.annotations.GuardedBy; -import com.android.internal.annotations.VisibleForTesting; import com.android.internal.os.SomeArgs; import com.android.internal.util.TraceBuffer; import com.android.internal.util.function.pooled.PooledLambda; @@ -112,7 +94,6 @@ import com.android.server.wm.AccessibilityWindowsPopulator.AccessibilityWindow; import com.android.server.wm.WindowManagerInternal.AccessibilityControllerInternal; import com.android.server.wm.WindowManagerInternal.MagnificationCallbacks; import com.android.server.wm.WindowManagerInternal.WindowsForAccessibilityCallback; -import com.android.window.flags.Flags; import java.io.File; import java.io.IOException; @@ -302,36 +283,6 @@ final class AccessibilityController { } } - /** It is only used by unit test. */ - @VisibleForTesting - Surface forceShowMagnifierSurface(int displayId) { - final DisplayMagnifier displayMagnifier = mDisplayMagnifiers.get(displayId); - if (displayMagnifier != null) { - displayMagnifier.mMagnifiedViewport.mWindow.setAlpha(DisplayMagnifier.MagnifiedViewport - .ViewportWindow.AnimationController.MAX_ALPHA); - return displayMagnifier.mMagnifiedViewport.mWindow.mSurface; - } - return null; - } - - void onWindowLayersChanged(int displayId) { - if (mAccessibilityTracing.isTracingEnabled(FLAGS_MAGNIFICATION_CALLBACK - | FLAGS_WINDOWS_FOR_ACCESSIBILITY_CALLBACK)) { - mAccessibilityTracing.logTrace(TAG + ".onWindowLayersChanged", - FLAGS_MAGNIFICATION_CALLBACK | FLAGS_WINDOWS_FOR_ACCESSIBILITY_CALLBACK, - "displayId=" + displayId); - } - final DisplayMagnifier displayMagnifier = mDisplayMagnifiers.get(displayId); - if (displayMagnifier != null) { - displayMagnifier.onWindowLayersChanged(); - } - final WindowsForAccessibilityObserver windowsForA11yObserver = - mWindowsForAccessibilityObserver.get(displayId); - if (windowsForA11yObserver != null) { - windowsForA11yObserver.scheduleComputeChangedWindows(); - } - } - void onDisplaySizeChanged(DisplayContent displayContent) { if (mAccessibilityTracing.isTracingEnabled(FLAGS_MAGNIFICATION_CALLBACK @@ -564,9 +515,6 @@ final class AccessibilityController { } void dump(PrintWriter pw, String prefix) { - dumpSparseArray(pw, prefix, mDisplayMagnifiers, "magnification display", - (index, key) -> pw.printf("%sDisplay #%d:", prefix + " ", key), - dm -> dm.dump(pw, "")); dumpSparseArrayValues(pw, prefix, mWindowsForAccessibilityObserver, "windows for accessibility observer"); mAccessibilityWindowsPopulator.dump(pw, prefix); @@ -624,7 +572,6 @@ final class AccessibilityController { private final Context mDisplayContext; private final WindowManagerService mService; - private final MagnifiedViewport mMagnifiedViewport; private final Handler mHandler; private final DisplayContent mDisplayContent; private final Display mDisplay; @@ -661,8 +608,6 @@ final class AccessibilityController { mDisplay = display; mHandler = new MyHandler(mService.mH.getLooper()); mUserContextChangedNotifier = new UserContextChangedNotifier(mHandler); - mMagnifiedViewport = Flags.alwaysDrawMagnificationFullscreenBorder() - ? null : new MagnifiedViewport(); mAccessibilityTracing = AccessibilityController.getAccessibilityControllerInternal(mService); mLongAnimationDuration = mDisplayContext.getResources().getInteger( @@ -704,10 +649,6 @@ final class AccessibilityController { } else { mMagnificationSpec.clear(); } - - if (!Flags.alwaysDrawMagnificationFullscreenBorder()) { - mMagnifiedViewport.setShowMagnifiedBorderIfNeeded(); - } } void setFullscreenMagnificationActivated(boolean activated) { @@ -716,10 +657,6 @@ final class AccessibilityController { FLAGS_MAGNIFICATION_CALLBACK, "activated=" + activated); } mIsFullscreenMagnificationActivated = activated; - if (!Flags.alwaysDrawMagnificationFullscreenBorder()) { - mMagnifiedViewport.setMagnifiedRegionBorderShown(activated, true); - mMagnifiedViewport.showMagnificationBoundsIfNeeded(); - } } boolean isFullscreenMagnificationActivated() { @@ -730,18 +667,6 @@ final class AccessibilityController { return mIsFullscreenMagnificationActivated; } - void onWindowLayersChanged() { - if (mAccessibilityTracing.isTracingEnabled(FLAGS_MAGNIFICATION_CALLBACK)) { - mAccessibilityTracing.logTrace( - LOG_TAG + ".onWindowLayersChanged", FLAGS_MAGNIFICATION_CALLBACK); - } - if (DEBUG_LAYERS) { - Slog.i(LOG_TAG, "Layers changed."); - } - recomputeBounds(); - mService.scheduleAnimationLocked(); - } - void onDisplaySizeChanged(DisplayContent displayContent) { if (mAccessibilityTracing.isTracingEnabled(FLAGS_MAGNIFICATION_CALLBACK)) { mAccessibilityTracing.logTrace(LOG_TAG + ".onDisplaySizeChanged", @@ -754,9 +679,6 @@ final class AccessibilityController { } recomputeBounds(); - if (!Flags.alwaysDrawMagnificationFullscreenBorder()) { - mMagnifiedViewport.onDisplaySizeChanged(); - } mHandler.sendEmptyMessage(MyHandler.MESSAGE_NOTIFY_DISPLAY_SIZE_CHANGED); } @@ -927,10 +849,6 @@ final class AccessibilityController { if (mAccessibilityTracing.isTracingEnabled(FLAGS_MAGNIFICATION_CALLBACK)) { mAccessibilityTracing.logTrace(LOG_TAG + ".destroy", FLAGS_MAGNIFICATION_CALLBACK); } - - if (!Flags.alwaysDrawMagnificationFullscreenBorder()) { - mMagnifiedViewport.destroyWindow(); - } } void recomputeMagnifiedRegionAndDrawMagnifiedRegionBorderIfNeeded() { @@ -940,10 +858,6 @@ final class AccessibilityController { FLAGS_MAGNIFICATION_CALLBACK); } recomputeBounds(); - - if (!Flags.alwaysDrawMagnificationFullscreenBorder()) { - mMagnifiedViewport.drawWindowIfNeeded(); - } } void recomputeBounds() { @@ -1051,16 +965,9 @@ final class AccessibilityController { } visibleWindows.clear(); - if (!Flags.alwaysDrawMagnificationFullscreenBorder()) { - mMagnifiedViewport.intersectWithDrawBorderInset(screenWidth, screenHeight); - } - final boolean magnifiedChanged = !mOldMagnificationRegion.equals(mMagnificationRegion); if (magnifiedChanged) { - if (!Flags.alwaysDrawMagnificationFullscreenBorder()) { - mMagnifiedViewport.updateBorderDrawingStatus(screenWidth, screenHeight); - } mOldMagnificationRegion.set(mMagnificationRegion); final SomeArgs args = SomeArgs.obtain(); args.arg1 = Region.obtain(mMagnificationRegion); @@ -1140,420 +1047,11 @@ final class AccessibilityController { outSize.set(bounds.width(), bounds.height()); } - void dump(PrintWriter pw, String prefix) { - if (!Flags.alwaysDrawMagnificationFullscreenBorder()) { - mMagnifiedViewport.dump(pw, prefix); - } - } - - private final class MagnifiedViewport { - - private final float mBorderWidth; - private final int mHalfBorderWidth; - private final int mDrawBorderInset; - - @Nullable private final ViewportWindow mWindow; - - private boolean mFullRedrawNeeded; - - MagnifiedViewport() { - mBorderWidth = mDisplayContext.getResources().getDimension( - com.android.internal.R.dimen.accessibility_magnification_indicator_width); - mHalfBorderWidth = (int) Math.ceil(mBorderWidth / 2); - mDrawBorderInset = (int) mBorderWidth / 2; - mWindow = new ViewportWindow(mDisplayContext); - } - - void updateBorderDrawingStatus(int screenWidth, int screenHeight) { - mWindow.setBounds(mMagnificationRegion); - final Rect dirtyRect = mTempRect1; - if (mFullRedrawNeeded) { - mFullRedrawNeeded = false; - dirtyRect.set(mDrawBorderInset, mDrawBorderInset, - screenWidth - mDrawBorderInset, - screenHeight - mDrawBorderInset); - mWindow.invalidate(dirtyRect); - } else { - final Region dirtyRegion = mTempRegion3; - dirtyRegion.set(mMagnificationRegion); - dirtyRegion.op(mOldMagnificationRegion, Region.Op.XOR); - dirtyRegion.getBounds(dirtyRect); - mWindow.invalidate(dirtyRect); - } - } - - void setShowMagnifiedBorderIfNeeded() { - // If this message is pending, we are in a rotation animation and do not want - // to show the border. We will do so when the pending message is handled. - if (!mHandler.hasMessages( - MyHandler.MESSAGE_SHOW_MAGNIFIED_REGION_BOUNDS_IF_NEEDED)) { - setMagnifiedRegionBorderShown( - isFullscreenMagnificationActivated(), true); - } - } - - // Can be called outside of a surface transaction - void showMagnificationBoundsIfNeeded() { - if (mAccessibilityTracing.isTracingEnabled(FLAGS_MAGNIFICATION_CALLBACK)) { - mAccessibilityTracing.logTrace(LOG_TAG + ".showMagnificationBoundsIfNeeded", - FLAGS_MAGNIFICATION_CALLBACK); - } - mHandler.obtainMessage(MyHandler.MESSAGE_SHOW_MAGNIFIED_REGION_BOUNDS_IF_NEEDED) - .sendToTarget(); - } - - void intersectWithDrawBorderInset(int screenWidth, int screenHeight) { - mMagnificationRegion.op(mDrawBorderInset, mDrawBorderInset, - screenWidth - mDrawBorderInset, screenHeight - mDrawBorderInset, - Region.Op.INTERSECT); - } - - void onDisplaySizeChanged() { - // If fullscreen magnification is activated, hide the border immediately so - // the user does not see strange artifacts during display size changed caused by - // rotation or folding/unfolding the device. In the rotation case, the - // screenshot used for rotation already has the border. After the rotation is - // completed we will show the border. - if (isFullscreenMagnificationActivated()) { - setMagnifiedRegionBorderShown(false, false); - final long delay = (long) (mLongAnimationDuration - * mService.getWindowAnimationScaleLocked()); - Message message = mHandler.obtainMessage( - MyHandler.MESSAGE_SHOW_MAGNIFIED_REGION_BOUNDS_IF_NEEDED); - mHandler.sendMessageDelayed(message, delay); - } - mWindow.updateSize(); - } - - void setMagnifiedRegionBorderShown(boolean shown, boolean animate) { - if (mWindow.setShown(shown, animate)) { - mFullRedrawNeeded = true; - // Clear the old region, so recomputeBounds will refresh the current region. - mOldMagnificationRegion.set(0, 0, 0, 0); - } - } - - void drawWindowIfNeeded() { - mWindow.postDrawIfNeeded(); - } - - void destroyWindow() { - mWindow.releaseSurface(); - } - - void dump(PrintWriter pw, String prefix) { - mWindow.dump(pw, prefix); - } - - // TODO(291891390): Remove this class when we clean up the flag - // alwaysDrawMagnificationFullscreenBorder - private final class ViewportWindow implements Runnable { - private static final String SURFACE_TITLE = "Magnification Overlay"; - - private final Region mBounds = new Region(); - private final Rect mDirtyRect = new Rect(); - private final Paint mPaint = new Paint(); - - private final SurfaceControl mSurfaceControl; - /** After initialization, it should only be accessed from animation thread. */ - private final SurfaceControl.Transaction mTransaction; - private final BLASTBufferQueue mBlastBufferQueue; - private final Surface mSurface; - - private final AnimationController mAnimationController; - - private boolean mShown; - private boolean mLastSurfaceShown; - private int mAlpha; - private int mPreviousAlpha; - - private volatile boolean mInvalidated; - - ViewportWindow(Context context) { - SurfaceControl surfaceControl = null; - try { - surfaceControl = mDisplayContent - .makeOverlay() - .setName(SURFACE_TITLE) - .setBLASTLayer() - .setFormat(PixelFormat.TRANSLUCENT) - .setCallsite("ViewportWindow") - .build(); - } catch (OutOfResourcesException oore) { - /* ignore */ - } - mSurfaceControl = surfaceControl; - mDisplay.getRealSize(mScreenSize); - mBlastBufferQueue = new BLASTBufferQueue(SURFACE_TITLE, mSurfaceControl, - mScreenSize.x, mScreenSize.y, PixelFormat.RGBA_8888); - - final SurfaceControl.Transaction t = mService.mTransactionFactory.get(); - final int layer = - mService.mPolicy.getWindowLayerFromTypeLw(TYPE_MAGNIFICATION_OVERLAY) * - WindowManagerPolicyConstants.TYPE_LAYER_MULTIPLIER; - t.setLayer(mSurfaceControl, layer).setPosition(mSurfaceControl, 0, 0); - InputMonitor.setTrustedOverlayInputInfo(mSurfaceControl, t, - mDisplayContent.getDisplayId(), "Magnification Overlay"); - t.apply(); - mTransaction = t; - mSurface = mBlastBufferQueue.createSurface(); - - mAnimationController = new AnimationController(context, - mService.mH.getLooper()); - - TypedValue typedValue = new TypedValue(); - context.getTheme().resolveAttribute(R.attr.colorActivatedHighlight, - typedValue, true); - final int borderColor = context.getColor(typedValue.resourceId); - - mPaint.setStyle(Paint.Style.STROKE); - mPaint.setStrokeWidth(mBorderWidth); - mPaint.setColor(borderColor); - - mInvalidated = true; - } - - /** Returns {@code true} if the state is changed to shown. */ - boolean setShown(boolean shown, boolean animate) { - synchronized (mService.mGlobalLock) { - if (mShown == shown) { - return false; - } - mShown = shown; - mAnimationController.onFrameShownStateChanged(shown, animate); - if (DEBUG_VIEWPORT_WINDOW) { - Slog.i(LOG_TAG, "ViewportWindow shown: " + mShown); - } - } - return shown; - } - - @SuppressWarnings("unused") - // Called reflectively from an animator. - int getAlpha() { - synchronized (mService.mGlobalLock) { - return mAlpha; - } - } - - void setAlpha(int alpha) { - synchronized (mService.mGlobalLock) { - if (mAlpha == alpha) { - return; - } - mAlpha = alpha; - invalidate(null); - if (DEBUG_VIEWPORT_WINDOW) { - Slog.i(LOG_TAG, "ViewportWindow set alpha: " + alpha); - } - } - } - - void setBounds(Region bounds) { - synchronized (mService.mGlobalLock) { - if (mBounds.equals(bounds)) { - return; - } - mBounds.set(bounds); - invalidate(mDirtyRect); - if (DEBUG_VIEWPORT_WINDOW) { - Slog.i(LOG_TAG, "ViewportWindow set bounds: " + bounds); - } - } - } - - void updateSize() { - synchronized (mService.mGlobalLock) { - getDisplaySizeLocked(mScreenSize); - mBlastBufferQueue.update(mSurfaceControl, mScreenSize.x, mScreenSize.y, - PixelFormat.RGBA_8888); - invalidate(mDirtyRect); - } - } - - void invalidate(Rect dirtyRect) { - if (dirtyRect != null) { - mDirtyRect.set(dirtyRect); - } else { - mDirtyRect.setEmpty(); - } - mInvalidated = true; - mService.scheduleAnimationLocked(); - } - - void postDrawIfNeeded() { - if (mInvalidated) { - mService.mAnimationHandler.post(this); - } - } - - @Override - public void run() { - drawOrRemoveIfNeeded(); - } - - /** - * This method must only be called by animation handler directly to make sure - * thread safe and there is no lock held outside. - */ - private void drawOrRemoveIfNeeded() { - // Drawing variables (alpha, dirty rect, and bounds) access is synchronized - // using WindowManagerGlobalLock. Grab copies of these values before - // drawing on the canvas so that drawing can be performed outside of the lock. - int alpha; - boolean redrawBounds; - Rect drawingRect = null; - Region drawingBounds = null; - synchronized (mService.mGlobalLock) { - if (mBlastBufferQueue.mNativeObject == 0) { - // Complete removal since releaseSurface has been called. - if (mSurface.isValid()) { - mTransaction.remove(mSurfaceControl).apply(); - mSurface.release(); - } - return; - } - if (!mInvalidated) { - return; - } - mInvalidated = false; - - alpha = mAlpha; - // For b/325863281, we should ensure the drawn border path is cleared when - // alpha = 0. Therefore, we cache the last used alpha when drawing as - // mPreviousAlpha and check it here. If mPreviousAlpha > 0, which means - // the border is showing now, then we should still redraw the clear path - // on the canvas so the border is cleared. - redrawBounds = mAlpha > 0 || mPreviousAlpha > 0; - if (redrawBounds) { - drawingBounds = new Region(mBounds); - // Empty dirty rectangle means unspecified. - if (mDirtyRect.isEmpty()) { - mBounds.getBounds(mDirtyRect); - } - mDirtyRect.inset(-mHalfBorderWidth, -mHalfBorderWidth); - drawingRect = new Rect(mDirtyRect); - if (DEBUG_VIEWPORT_WINDOW) { - Slog.i(LOG_TAG, "ViewportWindow bounds: " + mBounds); - Slog.i(LOG_TAG, "ViewportWindow dirty rect: " + mDirtyRect); - } - } - } - - final boolean showSurface; - // Draw without holding WindowManagerGlobalLock. - if (redrawBounds) { - Canvas canvas = null; - try { - canvas = mSurface.lockCanvas(drawingRect); - } catch (IllegalArgumentException | OutOfResourcesException e) { - /* ignore */ - } - if (canvas == null) { - return; - } - canvas.drawColor(Color.TRANSPARENT, Mode.CLEAR); - mPaint.setAlpha(alpha); - canvas.drawPath(drawingBounds.getBoundaryPath(), mPaint); - mSurface.unlockCanvasAndPost(canvas); - mPreviousAlpha = alpha; - } - - showSurface = alpha > 0; - - if (showSurface && !mLastSurfaceShown) { - mTransaction.show(mSurfaceControl).apply(); - mLastSurfaceShown = true; - } else if (!showSurface && mLastSurfaceShown) { - mTransaction.hide(mSurfaceControl).apply(); - mLastSurfaceShown = false; - } - } - - @GuardedBy("mService.mGlobalLock") - void releaseSurface() { - mBlastBufferQueue.destroy(); - // Post to perform cleanup on the thread which handles mSurface. - mService.mAnimationHandler.post(this); - } - - void dump(PrintWriter pw, String prefix) { - pw.println(prefix - + " mBounds= " + mBounds - + " mDirtyRect= " + mDirtyRect - + " mWidth= " + mScreenSize.x - + " mHeight= " + mScreenSize.y); - } - - private final class AnimationController extends Handler { - private static final String PROPERTY_NAME_ALPHA = "alpha"; - - private static final int MIN_ALPHA = 0; - private static final int MAX_ALPHA = 255; - - private static final int MSG_FRAME_SHOWN_STATE_CHANGED = 1; - - private final ValueAnimator mShowHideFrameAnimator; - - AnimationController(Context context, Looper looper) { - super(looper); - mShowHideFrameAnimator = ObjectAnimator.ofInt(ViewportWindow.this, - PROPERTY_NAME_ALPHA, MIN_ALPHA, MAX_ALPHA); - - Interpolator interpolator = new DecelerateInterpolator(2.5f); - final long longAnimationDuration = context.getResources().getInteger( - com.android.internal.R.integer.config_longAnimTime); - - mShowHideFrameAnimator.setInterpolator(interpolator); - mShowHideFrameAnimator.setDuration(longAnimationDuration); - } - - void onFrameShownStateChanged(boolean shown, boolean animate) { - obtainMessage(MSG_FRAME_SHOWN_STATE_CHANGED, - shown ? 1 : 0, animate ? 1 : 0).sendToTarget(); - } - - @Override - public void handleMessage(Message message) { - switch (message.what) { - case MSG_FRAME_SHOWN_STATE_CHANGED: { - final boolean shown = message.arg1 == 1; - final boolean animate = message.arg2 == 1; - - if (animate) { - if (mShowHideFrameAnimator.isRunning()) { - mShowHideFrameAnimator.reverse(); - } else { - if (shown) { - mShowHideFrameAnimator.start(); - } else { - mShowHideFrameAnimator.reverse(); - } - } - } else { - mShowHideFrameAnimator.cancel(); - if (shown) { - setAlpha(MAX_ALPHA); - } else { - setAlpha(MIN_ALPHA); - } - } - } break; - } - } - } - } - } - private class MyHandler extends Handler { public static final int MESSAGE_NOTIFY_MAGNIFICATION_REGION_CHANGED = 1; public static final int MESSAGE_NOTIFY_USER_CONTEXT_CHANGED = 3; public static final int MESSAGE_NOTIFY_DISPLAY_SIZE_CHANGED = 4; - - // TODO(291891390): Remove this field when we clean up the flag - // alwaysDrawMagnificationFullscreenBorder - public static final int MESSAGE_SHOW_MAGNIFIED_REGION_BOUNDS_IF_NEEDED = 5; - public static final int MESSAGE_NOTIFY_IME_WINDOW_VISIBILITY_CHANGED = 6; + public static final int MESSAGE_NOTIFY_IME_WINDOW_VISIBILITY_CHANGED = 5; MyHandler(Looper looper) { super(looper); @@ -1577,17 +1075,6 @@ final class AccessibilityController { mCallbacks.onDisplaySizeChanged(); } break; - case MESSAGE_SHOW_MAGNIFIED_REGION_BOUNDS_IF_NEEDED : { - synchronized (mService.mGlobalLock) { - if (isFullscreenMagnificationActivated()) { - if (!Flags.alwaysDrawMagnificationFullscreenBorder()) { - mMagnifiedViewport.setMagnifiedRegionBorderShown(true, true); - } - mService.scheduleAnimationLocked(); - } - } - } break; - case MESSAGE_NOTIFY_IME_WINDOW_VISIBILITY_CHANGED: { final boolean shown = message.arg1 == 1; mCallbacks.onImeWindowVisibilityChanged(shown); diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java index 8bbba1b17240..a425401c6238 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java @@ -42,7 +42,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_TOAST; import static android.view.flags.Flags.FLAG_SENSITIVE_CONTENT_APP_PROTECTION; import static android.window.DisplayAreaOrganizer.FEATURE_VENDOR_FIRST; -import static com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.never; @@ -85,7 +84,6 @@ import android.os.RemoteException; import android.os.UserHandle; import android.os.UserManager; import android.platform.test.annotations.Presubmit; -import android.platform.test.annotations.RequiresFlagsDisabled; import android.platform.test.annotations.RequiresFlagsEnabled; import android.platform.test.flag.junit.CheckFlagsRule; import android.platform.test.flag.junit.DeviceFlagsValueProvider; @@ -97,7 +95,6 @@ import android.view.InputChannel; import android.view.InputDevice; import android.view.InsetsSourceControl; import android.view.InsetsState; -import android.view.Surface; import android.view.SurfaceControl; import android.view.View; import android.view.WindowInsets; @@ -1192,55 +1189,6 @@ public class WindowManagerServiceTests extends WindowTestsBase { argThat(h -> (h.inputConfig & InputConfig.SENSITIVE_FOR_PRIVACY) != 0)); } - @RequiresFlagsDisabled(Flags.FLAG_ALWAYS_DRAW_MAGNIFICATION_FULLSCREEN_BORDER) - @Test - public void testDrawMagnifiedViewport() { - final int displayId = mDisplayContent.mDisplayId; - // Use real surface, so ViewportWindow's BlastBufferQueue can be created. - final ArrayList<SurfaceControl> surfaceControls = new ArrayList<>(); - mWm.mSurfaceControlFactory = () -> new SurfaceControl.Builder() { - @Override - public SurfaceControl build() { - final SurfaceControl sc = super.build(); - surfaceControls.add(sc); - return sc; - } - }; - mWm.mAccessibilityController.setMagnificationCallbacks(displayId, - mock(WindowManagerInternal.MagnificationCallbacks.class)); - final boolean[] lockCanvasInWmLock = { false }; - final Surface surface = mWm.mAccessibilityController.forceShowMagnifierSurface(displayId); - spyOn(surface); - doAnswer(invocationOnMock -> { - lockCanvasInWmLock[0] |= Thread.holdsLock(mWm.mGlobalLock); - invocationOnMock.callRealMethod(); - return null; - }).when(surface).lockCanvas(any()); - mWm.mAccessibilityController - .recomputeMagnifiedRegionAndDrawMagnifiedRegionBorderIfNeeded(displayId); - waitUntilHandlersIdle(); - try { - verify(surface).lockCanvas(any()); - - clearInvocations(surface); - // Invalidate and redraw. - mWm.mAccessibilityController.onDisplaySizeChanged(mDisplayContent); - mWm.mAccessibilityController - .recomputeMagnifiedRegionAndDrawMagnifiedRegionBorderIfNeeded(displayId); - // Turn off magnification to release surface. - mWm.mAccessibilityController.setMagnificationCallbacks(displayId, null); - waitUntilHandlersIdle(); - // lockCanvas must not be called after releasing. - verify(surface, never()).lockCanvas(any()); - verify(surface).release(); - assertFalse(lockCanvasInWmLock[0]); - } finally { - for (int i = surfaceControls.size() - 1; i >= 0; --i) { - surfaceControls.get(i).release(); - } - } - } - @Test public void testRequestKeyboardShortcuts_noWindow() { doNothing().when(mWm.mContext).enforceCallingOrSelfPermission(anyString(), anyString()); |