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

Commit 7ec98fad authored by Evan Rosky's avatar Evan Rosky Committed by Automerger Merge Worker
Browse files

Merge "Connect systemwindow root with accessibility" into rvc-dev am:...

Merge "Connect systemwindow root with accessibility" into rvc-dev am: db49a262 am: bfdaff3d am: fcacba52

Change-Id: Ic566a2a54280de2afd9190d2a4851cdf08b82dd8
parents 8c54498c fcacba52
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -160,6 +160,14 @@ interface IWindowManager
     */
     */
    SurfaceControl addShellRoot(int displayId, IWindow client, int windowType);
    SurfaceControl addShellRoot(int displayId, IWindow client, int windowType);


    /**
     * Sets the window token sent to accessibility for a particular shell root. The
     * displayId and windowType identify which shell-root to update.
     *
     * @param target The IWindow that accessibility service interfaces with.
     */
    void setShellRootAccessibilityWindow(int displayId, int windowType, IWindow target);

    /**
    /**
     * Like overridePendingAppTransitionMultiThumb, but uses a future to supply the specs. This is
     * Like overridePendingAppTransitionMultiThumb, but uses a future to supply the specs. This is
     * used for recents, where generating the thumbnails of the specs takes a non-trivial amount of
     * used for recents, where generating the thumbnails of the specs takes a non-trivial amount of
+9 −1
Original line number Original line Diff line number Diff line
@@ -39,7 +39,7 @@ import java.util.Objects;
 * {@link SurfaceView#setChildSurfacePackage}.
 * {@link SurfaceView#setChildSurfacePackage}.
 */
 */
public class SurfaceControlViewHost {
public class SurfaceControlViewHost {
    private ViewRootImpl mViewRoot;
    private final ViewRootImpl mViewRoot;
    private WindowlessWindowManager mWm;
    private WindowlessWindowManager mWm;


    private SurfaceControl mSurfaceControl;
    private SurfaceControl mSurfaceControl;
@@ -225,6 +225,14 @@ public class SurfaceControlViewHost {
        return mViewRoot.getView();
        return mViewRoot.getView();
    }
    }


    /**
     * @return the ViewRootImpl wrapped by this host.
     * @hide
     */
    public IWindow getWindowToken() {
        return mViewRoot.mWindow;
    }

    /**
    /**
     * @hide
     * @hide
     */
     */
+8 −0
Original line number Original line Diff line number Diff line
@@ -201,6 +201,14 @@ public class SystemWindows {
            attrs.flags |= FLAG_HARDWARE_ACCELERATED;
            attrs.flags |= FLAG_HARDWARE_ACCELERATED;
            viewRoot.setView(view, attrs);
            viewRoot.setView(view, attrs);
            mViewRoots.put(view, viewRoot);
            mViewRoots.put(view, viewRoot);

            try {
                mWmService.setShellRootAccessibilityWindow(mDisplayId, windowType,
                        viewRoot.getWindowToken());
            } catch (RemoteException e) {
                Slog.e(TAG, "Error setting accessibility window for " + mDisplayId + ":"
                        + windowType, e);
            }
        }
        }


        SysUiWindowManager addRoot(int windowType) {
        SysUiWindowManager addRoot(int windowType) {
+30 −1
Original line number Original line Diff line number Diff line
@@ -43,6 +43,8 @@ public class ShellRoot {
    private WindowToken mToken;
    private WindowToken mToken;
    private final IBinder.DeathRecipient mDeathRecipient;
    private final IBinder.DeathRecipient mDeathRecipient;
    private SurfaceControl mSurfaceControl = null;
    private SurfaceControl mSurfaceControl = null;
    private IWindow mAccessibilityWindow;
    private IBinder.DeathRecipient mAccessibilityWindowDeath;


    ShellRoot(@NonNull IWindow client, @NonNull DisplayContent dc, final int windowType) {
    ShellRoot(@NonNull IWindow client, @NonNull DisplayContent dc, final int windowType) {
        mDisplayContent = dc;
        mDisplayContent = dc;
@@ -112,11 +114,14 @@ public class ShellRoot {
        if (!mDisplayContent.getDefaultTaskDisplayArea().isSplitScreenModeActivated()) {
        if (!mDisplayContent.getDefaultTaskDisplayArea().isSplitScreenModeActivated()) {
            return null;
            return null;
        }
        }
        if (mAccessibilityWindow == null) {
            return null;
        }
        WindowInfo windowInfo = WindowInfo.obtain();
        WindowInfo windowInfo = WindowInfo.obtain();
        windowInfo.displayId = mToken.getDisplayArea().getDisplayContent().mDisplayId;
        windowInfo.displayId = mToken.getDisplayArea().getDisplayContent().mDisplayId;
        windowInfo.type = mToken.windowType;
        windowInfo.type = mToken.windowType;
        windowInfo.layer = mToken.getWindowLayerFromType();
        windowInfo.layer = mToken.getWindowLayerFromType();
        windowInfo.token = mClient.asBinder();
        windowInfo.token = mAccessibilityWindow.asBinder();
        windowInfo.title = "Splitscreen Divider";
        windowInfo.title = "Splitscreen Divider";
        windowInfo.focused = false;
        windowInfo.focused = false;
        windowInfo.inPictureInPicture = false;
        windowInfo.inPictureInPicture = false;
@@ -126,5 +131,29 @@ public class ShellRoot {
        windowInfo.regionInScreen.set(regionRect);
        windowInfo.regionInScreen.set(regionRect);
        return windowInfo;
        return windowInfo;
    }
    }

    void setAccessibilityWindow(IWindow window) {
        if (mAccessibilityWindow != null) {
            mAccessibilityWindow.asBinder().unlinkToDeath(mAccessibilityWindowDeath, 0);
        }
        mAccessibilityWindow = window;
        if (mAccessibilityWindow != null) {
            try {
                mAccessibilityWindowDeath = () -> {
                    synchronized (mDisplayContent.mWmService.mGlobalLock) {
                        mAccessibilityWindow = null;
                        setAccessibilityWindow(null);
                    }
                };
                mAccessibilityWindow.asBinder().linkToDeath(mAccessibilityWindowDeath, 0);
            } catch (RemoteException e) {
                mAccessibilityWindow = null;
            }
        }
        if (mDisplayContent.mWmService.mAccessibilityController != null) {
            mDisplayContent.mWmService.mAccessibilityController.onSomeWindowResizedOrMovedLocked(
                    mDisplayContent.getDisplayId());
        }
    }
}
}
+24 −0
Original line number Original line Diff line number Diff line
@@ -3910,6 +3910,30 @@ public class WindowManagerService extends IWindowManager.Stub
        }
        }
    }
    }


    @Override
    public void setShellRootAccessibilityWindow(int displayId, int windowType, IWindow target) {
        if (mContext.checkCallingOrSelfPermission(MANAGE_APP_TOKENS)
                != PackageManager.PERMISSION_GRANTED) {
            throw new SecurityException("Must hold permission " + MANAGE_APP_TOKENS);
        }
        final long origId = Binder.clearCallingIdentity();
        try {
            synchronized (mGlobalLock) {
                final DisplayContent dc = mRoot.getDisplayContent(displayId);
                if (dc == null) {
                    return;
                }
                ShellRoot root = dc.mShellRoots.get(windowType);
                if (root == null) {
                    return;
                }
                root.setAccessibilityWindow(target);
            }
        } finally {
            Binder.restoreCallingIdentity(origId);
        }
    }

    @Override
    @Override
    public void setDisplayWindowInsetsController(
    public void setDisplayWindowInsetsController(
            int displayId, IDisplayWindowInsetsController insetsController) {
            int displayId, IDisplayWindowInsetsController insetsController) {