Loading core/java/android/view/IWindowManager.aidl +8 −0 Original line number Original line Diff line number Diff line Loading @@ -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 Loading core/java/android/view/SurfaceControlViewHost.java +9 −1 Original line number Original line Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 */ */ Loading packages/SystemUI/src/com/android/systemui/wm/SystemWindows.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -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) { Loading services/core/java/com/android/server/wm/ShellRoot.java +30 −1 Original line number Original line Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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()); } } } } services/core/java/com/android/server/wm/WindowManagerService.java +24 −0 Original line number Original line Diff line number Diff line Loading @@ -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) { Loading Loading
core/java/android/view/IWindowManager.aidl +8 −0 Original line number Original line Diff line number Diff line Loading @@ -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 Loading
core/java/android/view/SurfaceControlViewHost.java +9 −1 Original line number Original line Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 */ */ Loading
packages/SystemUI/src/com/android/systemui/wm/SystemWindows.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -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) { Loading
services/core/java/com/android/server/wm/ShellRoot.java +30 −1 Original line number Original line Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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()); } } } }
services/core/java/com/android/server/wm/WindowManagerService.java +24 −0 Original line number Original line Diff line number Diff line Loading @@ -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) { Loading