Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 964629ac authored by Svetoslav Ganov's avatar Svetoslav Ganov Committed by Android (Google) Code Review
Browse files

Merge "Occasionally triple tap on the keyboard toggles screen magnification." into jb-mr1-dev

parents 8db45f0b 55468c64
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -28,5 +28,6 @@ import android.graphics.Rect;
oneway interface IDisplayContentChangeListener {
    void onWindowTransition(int displayId, int transition, in WindowInfo info);
    void onRectangleOnScreenRequested(int displayId, in Rect rectangle, boolean immediate);
    void onWindowLayersChanged(int displayId);
    void onRotationChanged(int rotation);
}
+11 −18
Original line number Diff line number Diff line
@@ -850,6 +850,7 @@ public final class ScreenMagnifier implements EventStreamTransformation {
        private static final int MESSAGE_ON_RECTANGLE_ON_SCREEN_REQUESTED = 3;
        private static final int MESSAGE_ON_WINDOW_TRANSITION = 4;
        private static final int MESSAGE_ON_ROTATION_CHANGED = 5;
        private static final int MESSAGE_ON_WINDOW_LAYERS_CHANGED = 6;

        private final Handler mHandler = new MyHandler();

@@ -880,24 +881,8 @@ public final class ScreenMagnifier implements EventStreamTransformation {
            mDisplayContentChangeListener = new IDisplayContentChangeListener.Stub() {
                @Override
                public void onWindowTransition(int displayId, int transition, WindowInfo info) {
                    Message message = mHandler.obtainMessage(MESSAGE_ON_WINDOW_TRANSITION,
                            transition, 0, WindowInfo.obtain(info));
                    // TODO: This makes me quite unhappy but for the time being the
                    //       least risky fix for cases where the keyguard is removed but
                    //       the windows it force hides are not made visible yet. Hence,
                    //       we would compute the magnified frame before we have a stable
                    //       state. One more reason to move the magnified frame computation
                    //       in the window manager!
                    if (info.type == WindowManager.LayoutParams.TYPE_KEYGUARD
                                || info.type == WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG
                            && (transition == WindowManagerPolicy.TRANSIT_EXIT
                                || transition == WindowManagerPolicy.TRANSIT_HIDE)) {
                        final long delay = (long) (2 * mLongAnimationDuration
                                * mWindowAnimationScale);
                        mHandler.sendMessageDelayed(message, delay);
                    } else {
                        message.sendToTarget();
                    }
                    mHandler.obtainMessage(MESSAGE_ON_WINDOW_TRANSITION,
                            transition, 0, WindowInfo.obtain(info)).sendToTarget();
                }

                @Override
@@ -917,6 +902,11 @@ public final class ScreenMagnifier implements EventStreamTransformation {
                    mHandler.obtainMessage(MESSAGE_ON_ROTATION_CHANGED, rotation, 0)
                            .sendToTarget();
                }

                @Override
                public void onWindowLayersChanged(int displayId) throws RemoteException {
                    mHandler.sendEmptyMessage(MESSAGE_ON_WINDOW_LAYERS_CHANGED);
                }
            };

            try {
@@ -1192,6 +1182,9 @@ public final class ScreenMagnifier implements EventStreamTransformation {
                        final int rotation = message.arg1;
                        handleOnRotationChanged(rotation);
                    } break;
                    case MESSAGE_ON_WINDOW_LAYERS_CHANGED: {
                        mViewport.recomputeBounds(mMagnificationController.isMagnifying());
                    } break;
                    default: {
                        throw new IllegalArgumentException("Unknown message: " + action);
                    }
+49 −4
Original line number Diff line number Diff line
@@ -6569,6 +6569,36 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    private void scheduleNotifyWindowLayersChangedIfNeededLocked(DisplayContent displayContent) {
        if (displayContent.mDisplayContentChangeListeners != null
                && displayContent.mDisplayContentChangeListeners.getRegisteredCallbackCount() > 0) {
            mH.obtainMessage(H.NOTIFY_WINDOW_LAYERS_CHANGED, displayContent) .sendToTarget();
        }
    }

    private void handleNotifyWindowLayersChanged(DisplayContent displayContent) {
        RemoteCallbackList<IDisplayContentChangeListener> callbacks = null;
        synchronized (mWindowMap) {
            callbacks = displayContent.mDisplayContentChangeListeners;
            if (callbacks == null) {
                return;
            }
        }
        try {
            final int watcherCount = callbacks.beginBroadcast();
            for (int i = 0; i < watcherCount; i++) {
                try {
                    callbacks.getBroadcastItem(i).onWindowLayersChanged(
                            displayContent.getDisplayId());
                } catch (RemoteException re) {
                    /* ignore */
                }
            }
        } finally {
            callbacks.finishBroadcast();
        }
    }

    public void addWindowChangeListener(WindowChangeListener listener) {
        synchronized(mWindowMap) {
            mWindowChangeListeners.add(listener);
@@ -7215,12 +7245,13 @@ public class WindowManagerService extends IWindowManager.Stub
        public static final int NOTIFY_ROTATION_CHANGED = 28;
        public static final int NOTIFY_WINDOW_TRANSITION = 29;
        public static final int NOTIFY_RECTANGLE_ON_SCREEN_REQUESTED = 30;
        public static final int NOTIFY_WINDOW_LAYERS_CHANGED = 31;

        public static final int DO_DISPLAY_ADDED = 31;
        public static final int DO_DISPLAY_REMOVED = 32;
        public static final int DO_DISPLAY_CHANGED = 33;
        public static final int DO_DISPLAY_ADDED = 32;
        public static final int DO_DISPLAY_REMOVED = 33;
        public static final int DO_DISPLAY_CHANGED = 34;

        public static final int CLIENT_FREEZE_TIMEOUT = 34;
        public static final int CLIENT_FREEZE_TIMEOUT = 35;

        public static final int ANIMATOR_WHAT_OFFSET = 100000;
        public static final int SET_TRANSPARENT_REGION = ANIMATOR_WHAT_OFFSET + 1;
@@ -7692,6 +7723,12 @@ public class WindowManagerService extends IWindowManager.Stub
                    break;
                }

                case NOTIFY_WINDOW_LAYERS_CHANGED: {
                    DisplayContent displayContent = (DisplayContent) msg.obj;
                    handleNotifyWindowLayersChanged(displayContent);
                    break;
                }

                case DO_DISPLAY_ADDED:
                    synchronized (mWindowMap) {
                        handleDisplayAddedLocked(msg.arg1);
@@ -8068,6 +8105,8 @@ public class WindowManagerService extends IWindowManager.Stub
            Slog.v(TAG, "Assigning layers", here);
        }

        boolean anyLayerChanged = false;

        for (i=0; i<N; i++) {
            final WindowState w = windows.get(i);
            final WindowStateAnimator winAnimator = w.mWinAnimator;
@@ -8083,6 +8122,7 @@ public class WindowManagerService extends IWindowManager.Stub
            }
            if (w.mLayer != oldLayer) {
                layerChanged = true;
                anyLayerChanged = true;
            }
            oldLayer = winAnimator.mAnimLayer;
            if (w.mTargetAppToken != null) {
@@ -8101,6 +8141,7 @@ public class WindowManagerService extends IWindowManager.Stub
            }
            if (winAnimator.mAnimLayer != oldLayer) {
                layerChanged = true;
                anyLayerChanged = true;
            }
            if (layerChanged && mAnimator.isDimmingLocked(winAnimator)) {
                // Force an animation pass just to update the mDimAnimator layer.
@@ -8115,6 +8156,10 @@ public class WindowManagerService extends IWindowManager.Stub
            //System.out.println(
            //    "Assigned layer " + curLayer + " to " + w.mClient.asBinder());
        }

        if (anyLayerChanged) {
            scheduleNotifyWindowLayersChangedIfNeededLocked(getDefaultDisplayContentLocked());
        }
    }

    private final void performLayoutAndPlaceSurfacesLocked() {