|
67 | 67 | import com.android.internal.os.SomeArgs; |
68 | 68 |
|
69 | 69 | import java.util.ArrayList; |
| 70 | +import java.util.Collections; |
| 71 | +import java.util.Comparator; |
70 | 72 |
|
71 | 73 | /** |
72 | 74 | * This class handles the screen magnification when accessibility is enabled. |
@@ -1020,7 +1022,9 @@ private void handleOnWindowTransition(int transition, WindowInfo info) { |
1020 | 1022 | } |
1021 | 1023 | if (info.type == WindowManager.LayoutParams.TYPE_NAVIGATION_BAR |
1022 | 1024 | || info.type == WindowManager.LayoutParams.TYPE_INPUT_METHOD |
1023 | | - || info.type == WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG) { |
| 1025 | + || info.type == WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG |
| 1026 | + || info.type == WindowManager.LayoutParams.TYPE_KEYGUARD |
| 1027 | + || info.type == WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG) { |
1024 | 1028 | switch (transition) { |
1025 | 1029 | case WindowManagerPolicy.TRANSIT_ENTER: |
1026 | 1030 | case WindowManagerPolicy.TRANSIT_SHOW: |
@@ -1473,7 +1477,9 @@ private static final class Viewport { |
1473 | 1477 |
|
1474 | 1478 | private final ArrayList<WindowInfo> mTempWindowInfoList = new ArrayList<WindowInfo>(); |
1475 | 1479 |
|
1476 | | - private final Rect mTempRect = new Rect(); |
| 1480 | + private final Rect mTempRect1 = new Rect(); |
| 1481 | + private final Rect mTempRect2 = new Rect(); |
| 1482 | + private final Rect mTempRect3 = new Rect(); |
1477 | 1483 |
|
1478 | 1484 | private final IWindowManager mWindowManagerService; |
1479 | 1485 | private final DisplayProvider mDisplayProvider; |
@@ -1542,31 +1548,83 @@ public Rect evaluate(float fraction, Rect fromFrame, Rect toFrame) { |
1542 | 1548 | recomputeBounds(false); |
1543 | 1549 | } |
1544 | 1550 |
|
| 1551 | + private final Comparator<WindowInfo> mWindowInfoInverseComparator = |
| 1552 | + new Comparator<WindowInfo>() { |
| 1553 | + @Override |
| 1554 | + public int compare(WindowInfo lhs, WindowInfo rhs) { |
| 1555 | + if (lhs.layer != rhs.layer) { |
| 1556 | + return rhs.layer - lhs.layer; |
| 1557 | + } |
| 1558 | + if (lhs.touchableRegion.top != rhs.touchableRegion.top) { |
| 1559 | + return rhs.touchableRegion.top - lhs.touchableRegion.top; |
| 1560 | + } |
| 1561 | + if (lhs.touchableRegion.left != rhs.touchableRegion.left) { |
| 1562 | + return rhs.touchableRegion.left - lhs.touchableRegion.left; |
| 1563 | + } |
| 1564 | + if (lhs.touchableRegion.right != rhs.touchableRegion.right) { |
| 1565 | + return rhs.touchableRegion.right - lhs.touchableRegion.right; |
| 1566 | + } |
| 1567 | + if (lhs.touchableRegion.bottom != rhs.touchableRegion.bottom) { |
| 1568 | + return rhs.touchableRegion.bottom - lhs.touchableRegion.bottom; |
| 1569 | + } |
| 1570 | + return 0; |
| 1571 | + } |
| 1572 | + }; |
| 1573 | + |
1545 | 1574 | public void recomputeBounds(boolean animate) { |
1546 | | - Rect frame = mTempRect; |
1547 | | - frame.set(0, 0, mDisplayProvider.getDisplayInfo().logicalWidth, |
1548 | | - mDisplayProvider.getDisplayInfo().logicalHeight); |
| 1575 | + Rect magnifiedFrame = mTempRect1; |
| 1576 | + magnifiedFrame.set(0, 0, 0, 0); |
| 1577 | + |
| 1578 | + Rect notMagnifiedFrame = mTempRect2; |
| 1579 | + notMagnifiedFrame.set(0, 0, 0, 0); |
| 1580 | + |
1549 | 1581 | ArrayList<WindowInfo> infos = mTempWindowInfoList; |
1550 | 1582 | infos.clear(); |
| 1583 | + int windowCount = 0; |
1551 | 1584 | try { |
1552 | 1585 | mWindowManagerService.getVisibleWindowsForDisplay( |
1553 | 1586 | mDisplayProvider.getDisplay().getDisplayId(), infos); |
1554 | | - final int windowCount = infos.size(); |
| 1587 | + Collections.sort(infos, mWindowInfoInverseComparator); |
| 1588 | + windowCount = infos.size(); |
1555 | 1589 | for (int i = 0; i < windowCount; i++) { |
1556 | 1590 | WindowInfo info = infos.get(i); |
1557 | | - if (info.type == WindowManager.LayoutParams.TYPE_NAVIGATION_BAR |
1558 | | - || info.type == WindowManager.LayoutParams.TYPE_INPUT_METHOD |
1559 | | - || info.type == WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG) { |
1560 | | - subtract(frame, info.touchableRegion); |
| 1591 | + if (info.type == WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY) { |
| 1592 | + continue; |
| 1593 | + } |
| 1594 | + if (isWindowMagnified(info.type)) { |
| 1595 | + Rect clippedFrame = mTempRect3; |
| 1596 | + clippedFrame.set(info.touchableRegion); |
| 1597 | + subtract(clippedFrame, notMagnifiedFrame); |
| 1598 | + magnifiedFrame.union(clippedFrame); |
| 1599 | + } else { |
| 1600 | + Rect clippedFrame = mTempRect3; |
| 1601 | + clippedFrame.set(info.touchableRegion); |
| 1602 | + subtract(clippedFrame, magnifiedFrame); |
| 1603 | + notMagnifiedFrame.union(clippedFrame); |
| 1604 | + } |
| 1605 | + if (magnifiedFrame.bottom >= notMagnifiedFrame.top) { |
| 1606 | + break; |
1561 | 1607 | } |
1562 | | - info.recycle(); |
1563 | 1608 | } |
1564 | 1609 | } catch (RemoteException re) { |
1565 | 1610 | /* ignore */ |
1566 | 1611 | } finally { |
1567 | | - infos.clear(); |
| 1612 | + for (int i = windowCount - 1; i >= 0; i--) { |
| 1613 | + infos.remove(i).recycle(); |
| 1614 | + } |
1568 | 1615 | } |
1569 | | - resize(frame, animate); |
| 1616 | + |
| 1617 | + final int displayWidth = mDisplayProvider.getDisplayInfo().logicalWidth; |
| 1618 | + final int displayHeight = mDisplayProvider.getDisplayInfo().logicalHeight; |
| 1619 | + magnifiedFrame.intersect(0, 0, displayWidth, displayHeight); |
| 1620 | + |
| 1621 | + resize(magnifiedFrame, animate); |
| 1622 | + } |
| 1623 | + |
| 1624 | + private boolean isWindowMagnified(int type) { |
| 1625 | + return (type != WindowManager.LayoutParams.TYPE_NAVIGATION_BAR |
| 1626 | + && type != WindowManager.LayoutParams.TYPE_INPUT_METHOD |
| 1627 | + && type != WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG); |
1570 | 1628 | } |
1571 | 1629 |
|
1572 | 1630 | public void rotationChanged() { |
|
0 commit comments