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

Commit 35e113b5 authored by Minche Li's avatar Minche Li Committed by Android (Google) Code Review
Browse files

Merge "Adds interface to show magnification button for System UI"

parents fc74b545 0898b63c
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -66,8 +66,22 @@ oneway interface IWindowMagnificationConnection {
    void moveWindowMagnifier(int displayId, float offsetX, float offsetY);

    /**
     * Sets {@link IWindowMagnificationConnectionCallback} to receive the request or the callback.
     * Requests System UI show magnification mode button UI on the specified display.
     *
     * @param displayId The logical display id.
     * @param magnificationMode the current magnification mode.
     */
    void showMagnificationButton(int displayId, int magnificationMode);

    /**
     * Requests System UI remove magnification mode button UI on the specified display.
     *
     * @param displayId The logical display id.
     */
    void removeMagnificationButton(int displayId);

    /**
     * Sets {@link IWindowMagnificationConnectionCallback} to receive the request or the callback.
     *
     * @param callback the interface to be called.
     */
+2 −2
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ import android.graphics.Rect;
     * @param displayId The logical display id.
     * @param bounds The window magnifier bounds in screen coordinates.
     */
    void onWindowMagnifierBoundsChanged(int display, in Rect bounds);
    void onWindowMagnifierBoundsChanged(int displayId, in Rect bounds);
    /**
     * Changes the magnification mode on specified display. It is invoked by System UI when the
     *  switch button is toggled.
@@ -40,5 +40,5 @@ import android.graphics.Rect;
     * @param displayId The logical display id.
     * @param magnificationMode new magnification mode.
     */
    void onChangeMagnificationMode(int display, int magnificationMode);
    void onChangeMagnificationMode(int displayId, int magnificationMode);
}
+12 −0
Original line number Diff line number Diff line
@@ -192,6 +192,18 @@ public class WindowMagnification extends SystemUI implements WindowMagnifierCall
                    () -> mWindowMagnification.moveWindowMagnifier(displayId, offsetX, offsetY));
        }

        @Override
        public void showMagnificationButton(int displayId, int magnificationMode) {
            // TODO(b/145780606): show magnification button UI when the magnification capability
            //  or scale changed.
        }

        @Override
        public void removeMagnificationButton(int displayId) {
            // TODO(b/145780606): remove magnification button UI when the magnification
            //  capability changed.
        }

        @Override
        public void setConnectionCallback(IWindowMagnificationConnectionCallback callback) {
            mConnectionCallback = callback;
+29 −5
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ class WindowMagnificationConnectionWrapper {
            mConnection.enableWindowMagnification(displayId, scale, centerX, centerY);
        } catch (RemoteException e) {
            if (DBG) {
                Slog.e(TAG, "Error calling enableWindowMagnification()");
                Slog.e(TAG, "Error calling enableWindowMagnification()", e);
            }
            return false;
        }
@@ -64,7 +64,7 @@ class WindowMagnificationConnectionWrapper {
            mConnection.setScale(displayId, scale);
        } catch (RemoteException e) {
            if (DBG) {
                Slog.e(TAG, "Error calling setScale()");
                Slog.e(TAG, "Error calling setScale()", e);
            }
            return false;
        }
@@ -76,7 +76,7 @@ class WindowMagnificationConnectionWrapper {
            mConnection.disableWindowMagnification(displayId);
        } catch (RemoteException e) {
            if (DBG) {
                Slog.e(TAG, "Error calling disableWindowMagnification()");
                Slog.e(TAG, "Error calling disableWindowMagnification()", e);
            }
            return false;
        }
@@ -88,7 +88,31 @@ class WindowMagnificationConnectionWrapper {
            mConnection.moveWindowMagnifier(displayId, offsetX, offsetY);
        } catch (RemoteException e) {
            if (DBG) {
                Slog.e(TAG, "Error calling moveWindowMagnifier()");
                Slog.e(TAG, "Error calling moveWindowMagnifier()", e);
            }
            return false;
        }
        return true;
    }

    boolean showMagnificationButton(int displayId, int magnificationMode) {
        try {
            mConnection.showMagnificationButton(displayId, magnificationMode);
        } catch (RemoteException e) {
            if (DBG) {
                Slog.e(TAG, "Error calling showMagnificationButton()", e);
            }
            return false;
        }
        return true;
    }

    boolean removeMagnificationButton(int displayId) {
        try {
            mConnection.removeMagnificationButton(displayId);
        } catch (RemoteException e) {
            if (DBG) {
                Slog.e(TAG, "Error calling removeMagnificationButton()", e);
            }
            return false;
        }
@@ -100,7 +124,7 @@ class WindowMagnificationConnectionWrapper {
            mConnection.setConnectionCallback(connectionCallback);
        } catch (RemoteException e) {
            if (DBG) {
                Slog.e(TAG, "Error calling setConnectionCallback()");
                Slog.e(TAG, "Error calling setConnectionCallback()", e);
            }
            return false;
        }
+27 −4
Original line number Diff line number Diff line
@@ -280,6 +280,29 @@ public final class WindowMagnificationManager implements
        }
    }

    /**
     * Requests System UI show magnification mode button UI on the specified display.
     *
     * @param displayId The logical display id.
     * @param magnificationMode the current magnification mode.
     * @return {@code true} if the event was handled, {@code false} otherwise
     */
    public boolean showMagnificationButton(int displayId, int magnificationMode) {
        return mConnectionWrapper != null && mConnectionWrapper.showMagnificationButton(
                displayId, magnificationMode);
    }

    /**
     * Requests System UI remove magnification mode button UI on the specified display.
     *
     * @param displayId The logical display id.
     * @return {@code true} if the event was handled, {@code false} otherwise
     */
    public boolean removeMagnificationButton(int displayId) {
        return mConnectionWrapper != null && mConnectionWrapper.removeMagnificationButton(
                displayId);
    }

    /**
     * Creates the windowMagnifier based on the specified display and stores it.
     * @param displayId logical display id.
@@ -296,22 +319,22 @@ public final class WindowMagnificationManager implements
        private boolean mExpiredDeathRecipient = false;

        @Override
        public void onWindowMagnifierBoundsChanged(int display, Rect bounds) {
        public void onWindowMagnifierBoundsChanged(int displayId, Rect bounds) {
            synchronized (mLock) {
                WindowMagnifier magnifier = mWindowMagnifiers.get(display);
                WindowMagnifier magnifier = mWindowMagnifiers.get(displayId);
                if (magnifier == null) {
                    return;
                }
                if (DBG) {
                    Slog.i(TAG,
                            "onWindowMagnifierBoundsChanged -" + display + " bounds = " + bounds);
                            "onWindowMagnifierBoundsChanged -" + displayId + " bounds = " + bounds);
                }
                magnifier.setMagnifierLocation(bounds);
            }
        }

        @Override
        public void onChangeMagnificationMode(int display, int magnificationMode)
        public void onChangeMagnificationMode(int displayId, int magnificationMode)
                throws RemoteException {
            //TODO: Uses this method to change the magnification mode on non-default display.
        }
Loading