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

Change-Id: Iffae57e9ad7ccc46633fe1de876486e5b224af8a
This commit is contained in:
Evan Rosky
2020-04-27 22:06:13 +00:00
committed by Automerger Merge Worker
5 changed files with 79 additions and 2 deletions

View File

@@ -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

View File

@@ -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
*/ */

View File

@@ -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) {

View File

@@ -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());
}
}
} }

View File

@@ -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) {