Skip to content

Commit a7bcb54

Browse files
committed
Screen magnification cannot be engaged in landscape on a phone.
1. The reason is that the screen magnifier computes that the whole screen is not magnifiable. The miscalculation was caused due to an incorrect assumption that the non-magnified area is only at the bottom. In fact, on a phone in landscape the non-magnified area is both on the right and at the bottom. This change adds a correct algorithm for computing the magnified region. 2. Increasing the delay for computing the magnified area when the keyguard goes away to allow all windows hidden by the keyguard to be shown. In rare occasions the previous delay was not long enough resulting in a state where the keyboard is considered a part of the magnified region. 3. Removed some dead code. bug:7293097 Change-Id: Ic5ff91977df8bcf4afd77071685c3eb20555d4f3
1 parent 7ef38ea commit a7bcb54

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

services/java/com/android/server/accessibility/ScreenMagnifier.java

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,6 @@ && isScreenMagnificationAutoUpdateEnabled(mContext)) {
846846
private static final class DisplayContentObserver {
847847

848848
private static final int MESSAGE_SHOW_VIEWPORT_FRAME = 1;
849-
private static final int MESSAGE_RECOMPUTE_VIEWPORT_BOUNDS = 2;
850849
private static final int MESSAGE_ON_RECTANGLE_ON_SCREEN_REQUESTED = 3;
851850
private static final int MESSAGE_ON_WINDOW_TRANSITION = 4;
852851
private static final int MESSAGE_ON_ROTATION_CHANGED = 5;
@@ -892,7 +891,9 @@ public void onWindowTransition(int displayId, int transition, WindowInfo info) {
892891
|| info.type == WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG
893892
&& (transition == WindowManagerPolicy.TRANSIT_EXIT
894893
|| transition == WindowManagerPolicy.TRANSIT_HIDE)) {
895-
mHandler.sendMessageDelayed(message, mLongAnimationDuration);
894+
final long delay = (long) (2 * mLongAnimationDuration
895+
* mWindowAnimationScale);
896+
mHandler.sendMessageDelayed(message, delay);
896897
} else {
897898
message.sendToTarget();
898899
}
@@ -1169,10 +1170,6 @@ public void handleMessage(Message message) {
11691170
case MESSAGE_SHOW_VIEWPORT_FRAME: {
11701171
mViewport.setFrameShown(true, true);
11711172
} break;
1172-
case MESSAGE_RECOMPUTE_VIEWPORT_BOUNDS: {
1173-
final boolean animate = message.arg1 == 1;
1174-
mViewport.recomputeBounds(animate);
1175-
} break;
11761173
case MESSAGE_ON_RECTANGLE_ON_SCREEN_REQUESTED: {
11771174
SomeArgs args = (SomeArgs) message.obj;
11781175
try {
@@ -1525,8 +1522,10 @@ public void recomputeBounds(boolean animate) {
15251522
Rect magnifiedFrame = mTempRect1;
15261523
magnifiedFrame.set(0, 0, 0, 0);
15271524

1528-
Rect notMagnifiedFrame = mTempRect2;
1529-
notMagnifiedFrame.set(0, 0, 0, 0);
1525+
DisplayInfo displayInfo = mDisplayProvider.getDisplayInfo();
1526+
1527+
Rect availableFrame = mTempRect2;
1528+
availableFrame.set(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight);
15301529

15311530
ArrayList<WindowInfo> infos = mTempWindowInfoList;
15321531
infos.clear();
@@ -1541,18 +1540,16 @@ public void recomputeBounds(boolean animate) {
15411540
if (info.type == WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY) {
15421541
continue;
15431542
}
1543+
Rect windowFrame = mTempRect3;
1544+
windowFrame.set(info.touchableRegion);
15441545
if (isWindowMagnified(info.type)) {
1545-
Rect clippedFrame = mTempRect3;
1546-
clippedFrame.set(info.touchableRegion);
1547-
subtract(clippedFrame, notMagnifiedFrame);
1548-
magnifiedFrame.union(clippedFrame);
1546+
magnifiedFrame.union(windowFrame);
1547+
magnifiedFrame.intersect(availableFrame);
15491548
} else {
1550-
Rect clippedFrame = mTempRect3;
1551-
clippedFrame.set(info.touchableRegion);
1552-
subtract(clippedFrame, magnifiedFrame);
1553-
notMagnifiedFrame.union(clippedFrame);
1549+
subtract(windowFrame, magnifiedFrame);
1550+
subtract(availableFrame, windowFrame);
15541551
}
1555-
if (magnifiedFrame.bottom >= notMagnifiedFrame.top) {
1552+
if (availableFrame.equals(magnifiedFrame)) {
15561553
break;
15571554
}
15581555
}

0 commit comments

Comments
 (0)