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

Change-Id: Ic566a2a54280de2afd9190d2a4851cdf08b82dd8
This commit is contained in:
Evan Rosky
2020-04-27 22:14:23 +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);
/**
* 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
* 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}.
*/
public class SurfaceControlViewHost {
private ViewRootImpl mViewRoot;
private final ViewRootImpl mViewRoot;
private WindowlessWindowManager mWm;
private SurfaceControl mSurfaceControl;
@@ -225,6 +225,14 @@ public class SurfaceControlViewHost {
return mViewRoot.getView();
}
/**
* @return the ViewRootImpl wrapped by this host.
* @hide
*/
public IWindow getWindowToken() {
return mViewRoot.mWindow;
}
/**
* @hide
*/

View File

@@ -201,6 +201,14 @@ public class SystemWindows {
attrs.flags |= FLAG_HARDWARE_ACCELERATED;
viewRoot.setView(view, attrs);
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) {

View File

@@ -43,6 +43,8 @@ public class ShellRoot {
private WindowToken mToken;
private final IBinder.DeathRecipient mDeathRecipient;
private SurfaceControl mSurfaceControl = null;
private IWindow mAccessibilityWindow;
private IBinder.DeathRecipient mAccessibilityWindowDeath;
ShellRoot(@NonNull IWindow client, @NonNull DisplayContent dc, final int windowType) {
mDisplayContent = dc;
@@ -112,11 +114,14 @@ public class ShellRoot {
if (!mDisplayContent.getDefaultTaskDisplayArea().isSplitScreenModeActivated()) {
return null;
}
if (mAccessibilityWindow == null) {
return null;
}
WindowInfo windowInfo = WindowInfo.obtain();
windowInfo.displayId = mToken.getDisplayArea().getDisplayContent().mDisplayId;
windowInfo.type = mToken.windowType;
windowInfo.layer = mToken.getWindowLayerFromType();
windowInfo.token = mClient.asBinder();
windowInfo.token = mAccessibilityWindow.asBinder();
windowInfo.title = "Splitscreen Divider";
windowInfo.focused = false;
windowInfo.inPictureInPicture = false;
@@ -126,5 +131,29 @@ public class ShellRoot {
windowInfo.regionInScreen.set(regionRect);
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
public void setDisplayWindowInsetsController(
int displayId, IDisplayWindowInsetsController insetsController) {