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

Commit 0898b63c authored by mincheli's avatar mincheli
Browse files

Adds interface to show magnification button for System UI

This change just add the interface and the method.
We'll apply this change in the later change.
So that magnification button UI will be updated by
showMagnificationButton() when magnification mode or
capability settings changed.

Bug: 145780606
Test: atest WindowMagnificationConnectionWrapperTest WindowMagnificationManagerTest
Change-Id: I544b03f62a0a67318585620db61caaa6dc213206
parent c522d895
Loading
Loading
Loading
Loading
+15 −1
Original line number Original line Diff line number Diff line
@@ -66,8 +66,22 @@ oneway interface IWindowMagnificationConnection {
    void moveWindowMagnifier(int displayId, float offsetX, float offsetY);
    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.
     * @param callback the interface to be called.
     */
     */
+2 −2
Original line number Original line Diff line number Diff line
@@ -32,7 +32,7 @@ import android.graphics.Rect;
     * @param displayId The logical display id.
     * @param displayId The logical display id.
     * @param bounds The window magnifier bounds in screen coordinates.
     * @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
     * Changes the magnification mode on specified display. It is invoked by System UI when the
     *  switch button is toggled.
     *  switch button is toggled.
@@ -40,5 +40,5 @@ import android.graphics.Rect;
     * @param displayId The logical display id.
     * @param displayId The logical display id.
     * @param magnificationMode new magnification mode.
     * @param magnificationMode new magnification mode.
     */
     */
    void onChangeMagnificationMode(int display, int magnificationMode);
    void onChangeMagnificationMode(int displayId, int magnificationMode);
}
}
+12 −0
Original line number Original line Diff line number Diff line
@@ -192,6 +192,18 @@ public class WindowMagnification extends SystemUI implements WindowMagnifierCall
                    () -> mWindowMagnification.moveWindowMagnifier(displayId, offsetX, offsetY));
                    () -> 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
        @Override
        public void setConnectionCallback(IWindowMagnificationConnectionCallback callback) {
        public void setConnectionCallback(IWindowMagnificationConnectionCallback callback) {
            mConnectionCallback = callback;
            mConnectionCallback = callback;
+29 −5
Original line number Original line Diff line number Diff line
@@ -52,7 +52,7 @@ class WindowMagnificationConnectionWrapper {
            mConnection.enableWindowMagnification(displayId, scale, centerX, centerY);
            mConnection.enableWindowMagnification(displayId, scale, centerX, centerY);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            if (DBG) {
            if (DBG) {
                Slog.e(TAG, "Error calling enableWindowMagnification()");
                Slog.e(TAG, "Error calling enableWindowMagnification()", e);
            }
            }
            return false;
            return false;
        }
        }
@@ -64,7 +64,7 @@ class WindowMagnificationConnectionWrapper {
            mConnection.setScale(displayId, scale);
            mConnection.setScale(displayId, scale);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            if (DBG) {
            if (DBG) {
                Slog.e(TAG, "Error calling setScale()");
                Slog.e(TAG, "Error calling setScale()", e);
            }
            }
            return false;
            return false;
        }
        }
@@ -76,7 +76,7 @@ class WindowMagnificationConnectionWrapper {
            mConnection.disableWindowMagnification(displayId);
            mConnection.disableWindowMagnification(displayId);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            if (DBG) {
            if (DBG) {
                Slog.e(TAG, "Error calling disableWindowMagnification()");
                Slog.e(TAG, "Error calling disableWindowMagnification()", e);
            }
            }
            return false;
            return false;
        }
        }
@@ -88,7 +88,31 @@ class WindowMagnificationConnectionWrapper {
            mConnection.moveWindowMagnifier(displayId, offsetX, offsetY);
            mConnection.moveWindowMagnifier(displayId, offsetX, offsetY);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            if (DBG) {
            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;
            return false;
        }
        }
@@ -100,7 +124,7 @@ class WindowMagnificationConnectionWrapper {
            mConnection.setConnectionCallback(connectionCallback);
            mConnection.setConnectionCallback(connectionCallback);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            if (DBG) {
            if (DBG) {
                Slog.e(TAG, "Error calling setConnectionCallback()");
                Slog.e(TAG, "Error calling setConnectionCallback()", e);
            }
            }
            return false;
            return false;
        }
        }
+27 −4
Original line number Original line 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.
     * Creates the windowMagnifier based on the specified display and stores it.
     * @param displayId logical display id.
     * @param displayId logical display id.
@@ -296,22 +319,22 @@ public final class WindowMagnificationManager implements
        private boolean mExpiredDeathRecipient = false;
        private boolean mExpiredDeathRecipient = false;


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


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