summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Candice Lo <chihtinglo@google.com> 2024-01-31 17:02:37 +0800
committer Candice Lo <chihtinglo@google.com> 2024-02-02 22:58:02 +0800
commited652bd17df53db5f2e2cf57786363de3d8ccda8 (patch)
tree79a32b8c2f52f69ba7595701b35ac3114b6a5504
parenta4ca0a817dbb6f8efb1aa3e5526b98816f0ecf94 (diff)
(refactor) Move non-UI related components out of MagnifiedViewport
Keep the border drawing related methods and fields in the MagnifiedViewport, and move the other logics like computing the magnified region to DisplayMagnifier. Bug: 291891390 Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/accessibility/magnification Flag: N/A Change-Id: Ie629ca85dc17886e254e46afe787422d4b4fa7f2
-rw-r--r--services/core/java/com/android/server/wm/AccessibilityController.java429
1 files changed, 216 insertions, 213 deletions
diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java
index 8566827ee95c..b76352a908e6 100644
--- a/services/core/java/com/android/server/wm/AccessibilityController.java
+++ b/services/core/java/com/android/server/wm/AccessibilityController.java
@@ -532,7 +532,6 @@ final class AccessibilityController {
final DisplayMagnifier displayMagnifier = mDisplayMagnifiers.get(displayId);
if (displayMagnifier != null) {
displayMagnifier.setFullscreenMagnificationActivated(activated);
- displayMagnifier.showMagnificationBoundsIfNeeded();
}
}
@@ -626,9 +625,20 @@ final class AccessibilityController {
private final long mLongAnimationDuration;
private boolean mIsFullscreenMagnificationActivated = false;
+ private final Region mMagnificationRegion = new Region();
+ private final Region mOldMagnificationRegion = new Region();
private final MagnificationSpec mMagnificationSpec = new MagnificationSpec();
+ // Following fields are used for computing magnification region
+ private final Path mCircularPath;
+ private int mTempLayer = 0;
+ private final Point mScreenSize = new Point();
+ private final SparseArray<WindowState> mTempWindowStates =
+ new SparseArray<WindowState>();
+ private final RectF mTempRectF = new RectF();
+ private final Matrix mTempMatrix = new Matrix();
+
DisplayMagnifier(WindowManagerService windowManagerService,
DisplayContent displayContent,
Display display,
@@ -644,6 +654,15 @@ final class AccessibilityController {
AccessibilityController.getAccessibilityControllerInternal(mService);
mLongAnimationDuration = mDisplayContext.getResources().getInteger(
com.android.internal.R.integer.config_longAnimTime);
+ if (mDisplayContext.getResources().getConfiguration().isScreenRound()) {
+ mCircularPath = new Path();
+
+ getDisplaySizeLocked(mScreenSize);
+ final int centerXY = mScreenSize.x / 2;
+ mCircularPath.addCircle(centerXY, centerXY, centerXY, Path.Direction.CW);
+ } else {
+ mCircularPath = null;
+ }
if (mAccessibilityTracing.isTracingEnabled(FLAGS_MAGNIFICATION_CALLBACK)) {
mAccessibilityTracing.logTrace(LOG_TAG + ".DisplayMagnifier.constructor",
FLAGS_MAGNIFICATION_CALLBACK,
@@ -651,6 +670,7 @@ final class AccessibilityController {
+ displayContent + "}; display={" + display + "}; callbacks={"
+ callbacks + "}");
}
+ recomputeBounds();
}
void setMagnificationSpec(MagnificationSpec spec) {
@@ -659,7 +679,7 @@ final class AccessibilityController {
FLAGS_MAGNIFICATION_CALLBACK, "spec={" + spec + "}");
}
updateMagnificationSpec(spec);
- mMagnifedViewport.recomputeBounds();
+ recomputeBounds();
mService.applyMagnificationSpecLocked(mDisplay.getDisplayId(), spec);
mService.scheduleAnimationLocked();
@@ -671,13 +691,8 @@ final class AccessibilityController {
} else {
mMagnificationSpec.clear();
}
- // 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)) {
- mMagnifedViewport.setMagnifiedRegionBorderShown(
- isFullscreenMagnificationActivated(), true);
- }
+
+ mMagnifedViewport.setShowMagnifiedBorderIfNeeded();
}
void setFullscreenMagnificationActivated(boolean activated) {
@@ -687,6 +702,7 @@ final class AccessibilityController {
}
mIsFullscreenMagnificationActivated = activated;
mMagnifedViewport.setMagnifiedRegionBorderShown(activated, true);
+ mMagnifedViewport.showMagnificationBoundsIfNeeded();
}
boolean isFullscreenMagnificationActivated() {
@@ -705,7 +721,7 @@ final class AccessibilityController {
if (DEBUG_LAYERS) {
Slog.i(LOG_TAG, "Layers changed.");
}
- mMagnifedViewport.recomputeBounds();
+ recomputeBounds();
mService.scheduleAnimationLocked();
}
@@ -719,6 +735,8 @@ final class AccessibilityController {
Slog.i(LOG_TAG, "Rotation: " + Surface.rotationToString(rotation)
+ " displayId: " + displayContent.getDisplayId());
}
+
+ recomputeBounds();
mMagnifedViewport.onDisplaySizeChanged();
mHandler.sendEmptyMessage(MyHandler.MESSAGE_NOTIFY_DISPLAY_SIZE_CHANGED);
}
@@ -836,9 +854,7 @@ final class AccessibilityController {
}
void getMagnifiedFrameInContentCoords(Rect rect) {
- Region magnificationRegion = new Region();
- mMagnifedViewport.getMagnificationRegion(magnificationRegion);
- magnificationRegion.getBounds(rect);
+ mMagnificationRegion.getBounds(rect);
rect.offset((int) -mMagnificationSpec.offsetX, (int) -mMagnificationSpec.offsetY);
rect.scale(1.0f / mMagnificationSpec.scale);
}
@@ -873,8 +889,8 @@ final class AccessibilityController {
"outMagnificationRegion={" + outMagnificationRegion + "}");
}
// Make sure we're working with the most current bounds
- mMagnifedViewport.recomputeBounds();
- mMagnifedViewport.getMagnificationRegion(outMagnificationRegion);
+ recomputeBounds();
+ outMagnificationRegion.set(mMagnificationRegion);
}
boolean isMagnifying() {
@@ -888,16 +904,6 @@ final class AccessibilityController {
mMagnifedViewport.destroyWindow();
}
- // 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 drawMagnifiedRegionBorderIfNeeded() {
if (mAccessibilityTracing.isTracingEnabled(FLAGS_MAGNIFICATION_CALLBACK)) {
mAccessibilityTracing.logTrace(LOG_TAG + ".drawMagnifiedRegionBorderIfNeeded",
@@ -906,212 +912,227 @@ final class AccessibilityController {
mMagnifedViewport.drawWindowIfNeeded();
}
- void dump(PrintWriter pw, String prefix) {
- mMagnifedViewport.dump(pw, prefix);
- }
-
- private final class MagnifiedViewport {
+ void recomputeBounds() {
+ getDisplaySizeLocked(mScreenSize);
+ final int screenWidth = mScreenSize.x;
+ final int screenHeight = mScreenSize.y;
- private final SparseArray<WindowState> mTempWindowStates =
- new SparseArray<WindowState>();
+ mMagnificationRegion.set(0, 0, 0, 0);
+ final Region availableBounds = mTempRegion1;
+ availableBounds.set(0, 0, screenWidth, screenHeight);
- private final RectF mTempRectF = new RectF();
+ if (mCircularPath != null) {
+ availableBounds.setPath(mCircularPath, availableBounds);
+ }
- private final Point mScreenSize = new Point();
+ Region nonMagnifiedBounds = mTempRegion4;
+ nonMagnifiedBounds.set(0, 0, 0, 0);
- private final Matrix mTempMatrix = new Matrix();
+ SparseArray<WindowState> visibleWindows = mTempWindowStates;
+ visibleWindows.clear();
+ populateWindowsOnScreen(visibleWindows);
- private final Region mMagnificationRegion = new Region();
- private final Region mOldMagnificationRegion = new Region();
+ final int visibleWindowCount = visibleWindows.size();
+ for (int i = visibleWindowCount - 1; i >= 0; i--) {
+ WindowState windowState = visibleWindows.valueAt(i);
+ final int windowType = windowState.mAttrs.type;
+ if (isExcludedWindowType(windowType)
+ || ((windowState.mAttrs.privateFlags
+ & PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION) != 0)
+ || ((windowState.mAttrs.privateFlags
+ & PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY) != 0)) {
+ continue;
+ }
- private final Path mCircularPath;
+ // Consider the touchable portion of the window
+ Matrix matrix = mTempMatrix;
+ populateTransformationMatrix(windowState, matrix);
+ Region touchableRegion = mTempRegion3;
+ windowState.getTouchableRegion(touchableRegion);
+ Rect touchableFrame = mTempRect1;
+ touchableRegion.getBounds(touchableFrame);
+ RectF windowFrame = mTempRectF;
+ windowFrame.set(touchableFrame);
+ windowFrame.offset(-windowState.getFrame().left,
+ -windowState.getFrame().top);
+ matrix.mapRect(windowFrame);
+ Region windowBounds = mTempRegion2;
+ windowBounds.set((int) windowFrame.left, (int) windowFrame.top,
+ (int) windowFrame.right, (int) windowFrame.bottom);
+ // Only update new regions
+ Region portionOfWindowAlreadyAccountedFor = mTempRegion3;
+ portionOfWindowAlreadyAccountedFor.set(mMagnificationRegion);
+ portionOfWindowAlreadyAccountedFor.op(nonMagnifiedBounds, Region.Op.UNION);
+ windowBounds.op(portionOfWindowAlreadyAccountedFor, Region.Op.DIFFERENCE);
+
+ if (windowState.shouldMagnify()) {
+ mMagnificationRegion.op(windowBounds, Region.Op.UNION);
+ mMagnificationRegion.op(availableBounds, Region.Op.INTERSECT);
+ } else {
+ nonMagnifiedBounds.op(windowBounds, Region.Op.UNION);
+ availableBounds.op(windowBounds, Region.Op.DIFFERENCE);
+ }
- private final float mBorderWidth;
- private final int mHalfBorderWidth;
- private final int mDrawBorderInset;
+ // If the navigation bar window doesn't have touchable region, count
+ // navigation bar insets into nonMagnifiedBounds. It happens when
+ // navigation mode is gestural.
+ if (isUntouchableNavigationBar(windowState, mTempRegion3)) {
+ final Rect navBarInsets = getSystemBarInsetsFrame(windowState);
+ nonMagnifiedBounds.op(navBarInsets, Region.Op.UNION);
+ availableBounds.op(navBarInsets, Region.Op.DIFFERENCE);
+ }
- private final ViewportWindow mWindow;
+ // Count letterbox into nonMagnifiedBounds
+ if (windowState.areAppWindowBoundsLetterboxed()) {
+ Region letterboxBounds = getLetterboxBounds(windowState);
+ nonMagnifiedBounds.op(letterboxBounds, Region.Op.UNION);
+ availableBounds.op(letterboxBounds, Region.Op.DIFFERENCE);
+ }
- private boolean mFullRedrawNeeded;
- private int mTempLayer = 0;
+ // Update accounted bounds
+ Region accountedBounds = mTempRegion2;
+ accountedBounds.set(mMagnificationRegion);
+ accountedBounds.op(nonMagnifiedBounds, Region.Op.UNION);
+ accountedBounds.op(0, 0, screenWidth, screenHeight, Region.Op.INTERSECT);
+
+ if (accountedBounds.isRect()) {
+ Rect accountedFrame = mTempRect1;
+ accountedBounds.getBounds(accountedFrame);
+ if (accountedFrame.width() == screenWidth
+ && accountedFrame.height() == screenHeight) {
+ break;
+ }
+ }
+ }
+ visibleWindows.clear();
- 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);
+ mMagnifedViewport.intersectWithDrawBorderInset(screenWidth, screenHeight);
- if (mDisplayContext.getResources().getConfiguration().isScreenRound()) {
- mCircularPath = new Path();
- getDisplaySizeLocked(mScreenSize);
- final int centerXY = mScreenSize.x / 2;
- mCircularPath.addCircle(centerXY, centerXY, centerXY, Path.Direction.CW);
- } else {
- mCircularPath = null;
- }
+ final boolean magnifiedChanged =
+ !mOldMagnificationRegion.equals(mMagnificationRegion);
+ if (magnifiedChanged) {
+ mMagnifedViewport.updateBorderDrawingStatus(screenWidth, screenHeight);
- recomputeBounds();
+ mOldMagnificationRegion.set(mMagnificationRegion);
+ final SomeArgs args = SomeArgs.obtain();
+ args.arg1 = Region.obtain(mMagnificationRegion);
+ mHandler.obtainMessage(
+ MyHandler.MESSAGE_NOTIFY_MAGNIFICATION_REGION_CHANGED, args)
+ .sendToTarget();
}
+ }
- void getMagnificationRegion(@NonNull Region outMagnificationRegion) {
- outMagnificationRegion.set(mMagnificationRegion);
+ private Region getLetterboxBounds(WindowState windowState) {
+ final ActivityRecord appToken = windowState.mActivityRecord;
+ if (appToken == null) {
+ return new Region();
}
- void recomputeBounds() {
- getDisplaySizeLocked(mScreenSize);
- final int screenWidth = mScreenSize.x;
- final int screenHeight = mScreenSize.y;
+ final Rect boundsWithoutLetterbox = windowState.getBounds();
+ final Rect letterboxInsets = appToken.getLetterboxInsets();
- mMagnificationRegion.set(0, 0, 0, 0);
- final Region availableBounds = mTempRegion1;
- availableBounds.set(0, 0, screenWidth, screenHeight);
+ final Rect boundsIncludingLetterbox = Rect.copyOrNull(boundsWithoutLetterbox);
+ // Letterbox insets from mActivityRecord are positive, so we negate them to grow the
+ // bounds to include the letterbox.
+ boundsIncludingLetterbox.inset(
+ Insets.subtract(Insets.NONE, Insets.of(letterboxInsets)));
- if (mCircularPath != null) {
- availableBounds.setPath(mCircularPath, availableBounds);
- }
+ final Region letterboxBounds = new Region();
+ letterboxBounds.set(boundsIncludingLetterbox);
+ letterboxBounds.op(boundsWithoutLetterbox, Region.Op.DIFFERENCE);
+ return letterboxBounds;
+ }
- Region nonMagnifiedBounds = mTempRegion4;
- nonMagnifiedBounds.set(0, 0, 0, 0);
+ private boolean isExcludedWindowType(int windowType) {
+ return windowType == TYPE_MAGNIFICATION_OVERLAY
+ // Omit the touch region of window magnification to avoid the cut out of the
+ // magnification and the magnified center of window magnification could be
+ // in the bounds
+ || windowType == TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY;
+ }
- SparseArray<WindowState> visibleWindows = mTempWindowStates;
- visibleWindows.clear();
- populateWindowsOnScreen(visibleWindows);
+ private void populateWindowsOnScreen(SparseArray<WindowState> outWindows) {
+ mTempLayer = 0;
+ mDisplayContent.forAllWindows((w) -> {
+ if (w.isOnScreen() && w.isVisible()
+ && (w.mAttrs.alpha != 0)) {
+ mTempLayer++;
+ outWindows.put(mTempLayer, w);
+ }
+ }, /* traverseTopToBottom= */ false);
+ }
- final int visibleWindowCount = visibleWindows.size();
- for (int i = visibleWindowCount - 1; i >= 0; i--) {
- WindowState windowState = visibleWindows.valueAt(i);
- final int windowType = windowState.mAttrs.type;
- if (isExcludedWindowType(windowType)
- || ((windowState.mAttrs.privateFlags
- & PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION) != 0)
- || ((windowState.mAttrs.privateFlags
- & PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY) != 0)) {
- continue;
- }
+ private void getDisplaySizeLocked(Point outSize) {
+ final Rect bounds =
+ mDisplayContent.getConfiguration().windowConfiguration.getBounds();
+ outSize.set(bounds.width(), bounds.height());
+ }
- // Consider the touchable portion of the window
- Matrix matrix = mTempMatrix;
- populateTransformationMatrix(windowState, matrix);
- Region touchableRegion = mTempRegion3;
- windowState.getTouchableRegion(touchableRegion);
- Rect touchableFrame = mTempRect1;
- touchableRegion.getBounds(touchableFrame);
- RectF windowFrame = mTempRectF;
- windowFrame.set(touchableFrame);
- windowFrame.offset(-windowState.getFrame().left,
- -windowState.getFrame().top);
- matrix.mapRect(windowFrame);
- Region windowBounds = mTempRegion2;
- windowBounds.set((int) windowFrame.left, (int) windowFrame.top,
- (int) windowFrame.right, (int) windowFrame.bottom);
- // Only update new regions
- Region portionOfWindowAlreadyAccountedFor = mTempRegion3;
- portionOfWindowAlreadyAccountedFor.set(mMagnificationRegion);
- portionOfWindowAlreadyAccountedFor.op(nonMagnifiedBounds, Region.Op.UNION);
- windowBounds.op(portionOfWindowAlreadyAccountedFor, Region.Op.DIFFERENCE);
-
- if (windowState.shouldMagnify()) {
- mMagnificationRegion.op(windowBounds, Region.Op.UNION);
- mMagnificationRegion.op(availableBounds, Region.Op.INTERSECT);
- } else {
- nonMagnifiedBounds.op(windowBounds, Region.Op.UNION);
- availableBounds.op(windowBounds, Region.Op.DIFFERENCE);
- }
+ void dump(PrintWriter pw, String prefix) {
+ mMagnifedViewport.dump(pw, prefix);
+ }
- // If the navigation bar window doesn't have touchable region, count
- // navigation bar insets into nonMagnifiedBounds. It happens when
- // navigation mode is gestural.
- if (isUntouchableNavigationBar(windowState, mTempRegion3)) {
- final Rect navBarInsets = getSystemBarInsetsFrame(windowState);
- nonMagnifiedBounds.op(navBarInsets, Region.Op.UNION);
- availableBounds.op(navBarInsets, Region.Op.DIFFERENCE);
- }
+ private final class MagnifiedViewport {
- // Count letterbox into nonMagnifiedBounds
- if (windowState.areAppWindowBoundsLetterboxed()) {
- Region letterboxBounds = getLetterboxBounds(windowState);
- nonMagnifiedBounds.op(letterboxBounds, Region.Op.UNION);
- availableBounds.op(letterboxBounds, Region.Op.DIFFERENCE);
- }
+ private final float mBorderWidth;
+ private final int mHalfBorderWidth;
+ private final int mDrawBorderInset;
- // Update accounted bounds
- Region accountedBounds = mTempRegion2;
- accountedBounds.set(mMagnificationRegion);
- accountedBounds.op(nonMagnifiedBounds, Region.Op.UNION);
- accountedBounds.op(0, 0, screenWidth, screenHeight, Region.Op.INTERSECT);
-
- if (accountedBounds.isRect()) {
- Rect accountedFrame = mTempRect1;
- accountedBounds.getBounds(accountedFrame);
- if (accountedFrame.width() == screenWidth
- && accountedFrame.height() == screenHeight) {
- break;
- }
- }
- }
- visibleWindows.clear();
+ private final ViewportWindow mWindow;
- mMagnificationRegion.op(mDrawBorderInset, mDrawBorderInset,
- screenWidth - mDrawBorderInset, screenHeight - mDrawBorderInset,
- Region.Op.INTERSECT);
+ private boolean mFullRedrawNeeded;
- final boolean magnifiedChanged =
- !mOldMagnificationRegion.equals(mMagnificationRegion);
- if (magnifiedChanged) {
- 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);
- }
+ 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);
+ }
- mOldMagnificationRegion.set(mMagnificationRegion);
- final SomeArgs args = SomeArgs.obtain();
- args.arg1 = Region.obtain(mMagnificationRegion);
- mHandler.obtainMessage(
- MyHandler.MESSAGE_NOTIFY_MAGNIFICATION_REGION_CHANGED, args)
- .sendToTarget();
+ 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);
}
}
- private Region getLetterboxBounds(WindowState windowState) {
- final ActivityRecord appToken = windowState.mActivityRecord;
- if (appToken == null) {
- return new Region();
+ 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);
}
+ }
- final Rect boundsWithoutLetterbox = windowState.getBounds();
- final Rect letterboxInsets = appToken.getLetterboxInsets();
-
- final Rect boundsIncludingLetterbox = Rect.copyOrNull(boundsWithoutLetterbox);
- // Letterbox insets from mActivityRecord are positive, so we negate them to grow the
- // bounds to include the letterbox.
- boundsIncludingLetterbox.inset(
- Insets.subtract(Insets.NONE, Insets.of(letterboxInsets)));
-
- final Region letterboxBounds = new Region();
- letterboxBounds.set(boundsIncludingLetterbox);
- letterboxBounds.op(boundsWithoutLetterbox, Region.Op.DIFFERENCE);
- return letterboxBounds;
+ // 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();
}
- private boolean isExcludedWindowType(int windowType) {
- return windowType == TYPE_MAGNIFICATION_OVERLAY
- // Omit the touch region of window magnification to avoid the cut out of the
- // magnification and the magnified center of window magnification could be
- // in the bounds
- || windowType == TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY;
+ void intersectWithDrawBorderInset(int screenWidth, int screenHeight) {
+ mMagnificationRegion.op(mDrawBorderInset, mDrawBorderInset,
+ screenWidth - mDrawBorderInset, screenHeight - mDrawBorderInset,
+ Region.Op.INTERSECT);
}
void onDisplaySizeChanged() {
@@ -1128,7 +1149,6 @@ final class AccessibilityController {
MyHandler.MESSAGE_SHOW_MAGNIFIED_REGION_BOUNDS_IF_NEEDED);
mHandler.sendMessageDelayed(message, delay);
}
- recomputeBounds();
mWindow.updateSize();
}
@@ -1149,23 +1169,6 @@ final class AccessibilityController {
mWindow.releaseSurface();
}
- private void populateWindowsOnScreen(SparseArray<WindowState> outWindows) {
- mTempLayer = 0;
- mDisplayContent.forAllWindows((w) -> {
- if (w.isOnScreen() && w.isVisible()
- && (w.mAttrs.alpha != 0)) {
- mTempLayer++;
- outWindows.put(mTempLayer, w);
- }
- }, false /* traverseTopToBottom */ );
- }
-
- private void getDisplaySizeLocked(Point outSize) {
- final Rect bounds =
- mDisplayContent.getConfiguration().windowConfiguration.getBounds();
- outSize.set(bounds.width(), bounds.height());
- }
-
void dump(PrintWriter pw, String prefix) {
mWindow.dump(pw, prefix);
}