Merge "Accessibility fix for ShellRoot" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
8f21448a7a
@@ -1542,6 +1542,52 @@ final class AccessibilityController {
|
|||||||
mEmbeddedDisplayIdList.add(displayId);
|
mEmbeddedDisplayIdList.add(displayId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean shellRootIsAbove(WindowState windowState, ShellRoot shellRoot) {
|
||||||
|
int wsLayer = mService.mPolicy.getWindowLayerLw(windowState);
|
||||||
|
int shellLayer = mService.mPolicy.getWindowLayerFromTypeLw(shellRoot.getWindowType(),
|
||||||
|
true);
|
||||||
|
return shellLayer >= wsLayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
int addShellRootsIfAbove(WindowState windowState, ArrayList<ShellRoot> shellRoots,
|
||||||
|
int shellRootIndex, List<WindowInfo> windows, Set<IBinder> addedWindows,
|
||||||
|
Region unaccountedSpace, boolean focusedWindowAdded) {
|
||||||
|
while (shellRootIndex < shellRoots.size()
|
||||||
|
&& shellRootIsAbove(windowState, shellRoots.get(shellRootIndex))) {
|
||||||
|
ShellRoot shellRoot = shellRoots.get(shellRootIndex);
|
||||||
|
shellRootIndex++;
|
||||||
|
final WindowInfo info = shellRoot.getWindowInfo();
|
||||||
|
if (info == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
info.layer = addedWindows.size();
|
||||||
|
windows.add(info);
|
||||||
|
addedWindows.add(info.token);
|
||||||
|
unaccountedSpace.op(info.regionInScreen, unaccountedSpace,
|
||||||
|
Region.Op.REVERSE_DIFFERENCE);
|
||||||
|
if (unaccountedSpace.isEmpty() && focusedWindowAdded) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return shellRootIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArrayList<ShellRoot> getSortedShellRoots(
|
||||||
|
SparseArray<ShellRoot> originalShellRoots) {
|
||||||
|
ArrayList<ShellRoot> sortedShellRoots = new ArrayList<>(originalShellRoots.size());
|
||||||
|
for (int i = originalShellRoots.size() - 1; i >= 0; --i) {
|
||||||
|
sortedShellRoots.add(originalShellRoots.valueAt(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
sortedShellRoots.sort((left, right) ->
|
||||||
|
mService.mPolicy.getWindowLayerFromTypeLw(right.getWindowType(), true)
|
||||||
|
- mService.mPolicy.getWindowLayerFromTypeLw(left.getWindowType(),
|
||||||
|
true));
|
||||||
|
|
||||||
|
return sortedShellRoots;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if windows have changed, and send them to the accessibility subsystem if they have.
|
* Check if windows have changed, and send them to the accessibility subsystem if they have.
|
||||||
*
|
*
|
||||||
@@ -1601,9 +1647,22 @@ final class AccessibilityController {
|
|||||||
final int visibleWindowCount = visibleWindows.size();
|
final int visibleWindowCount = visibleWindows.size();
|
||||||
HashSet<Integer> skipRemainingWindowsForTasks = new HashSet<>();
|
HashSet<Integer> skipRemainingWindowsForTasks = new HashSet<>();
|
||||||
|
|
||||||
|
ArrayList<ShellRoot> shellRoots = getSortedShellRoots(dc.mShellRoots);
|
||||||
|
|
||||||
// Iterate until we figure out what is touchable for the entire screen.
|
// Iterate until we figure out what is touchable for the entire screen.
|
||||||
|
int shellRootIndex = 0;
|
||||||
for (int i = visibleWindowCount - 1; i >= 0; i--) {
|
for (int i = visibleWindowCount - 1; i >= 0; i--) {
|
||||||
final WindowState windowState = visibleWindows.valueAt(i);
|
final WindowState windowState = visibleWindows.valueAt(i);
|
||||||
|
int prevShellRootIndex = shellRootIndex;
|
||||||
|
shellRootIndex = addShellRootsIfAbove(windowState, shellRoots, shellRootIndex,
|
||||||
|
windows, addedWindows, unaccountedSpace, focusedWindowAdded);
|
||||||
|
|
||||||
|
// If a Shell Root was added, it could have accounted for all the space already.
|
||||||
|
if (shellRootIndex > prevShellRootIndex && unaccountedSpace.isEmpty()
|
||||||
|
&& focusedWindowAdded) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
final Region regionInScreen = new Region();
|
final Region regionInScreen = new Region();
|
||||||
computeWindowRegionInScreen(windowState, regionInScreen);
|
computeWindowRegionInScreen(windowState, regionInScreen);
|
||||||
|
|
||||||
@@ -1627,16 +1686,6 @@ final class AccessibilityController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = dc.mShellRoots.size() - 1; i >= 0; --i) {
|
|
||||||
final WindowInfo info = dc.mShellRoots.valueAt(i).getWindowInfo();
|
|
||||||
if (info == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
info.layer = addedWindows.size();
|
|
||||||
windows.add(info);
|
|
||||||
addedWindows.add(info.token);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove child/parent references to windows that were not added.
|
// Remove child/parent references to windows that were not added.
|
||||||
final int windowCount = windows.size();
|
final int windowCount = windows.size();
|
||||||
for (int i = 0; i < windowCount; i++) {
|
for (int i = 0; i < windowCount; i++) {
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public class ShellRoot {
|
|||||||
private SurfaceControl mSurfaceControl = null;
|
private SurfaceControl mSurfaceControl = null;
|
||||||
private IWindow mAccessibilityWindow;
|
private IWindow mAccessibilityWindow;
|
||||||
private IBinder.DeathRecipient mAccessibilityWindowDeath;
|
private IBinder.DeathRecipient mAccessibilityWindowDeath;
|
||||||
|
private int mWindowType;
|
||||||
|
|
||||||
ShellRoot(@NonNull IWindow client, @NonNull DisplayContent dc,
|
ShellRoot(@NonNull IWindow client, @NonNull DisplayContent dc,
|
||||||
@WindowManager.ShellRootLayer final int shellRootLayer) {
|
@WindowManager.ShellRootLayer final int shellRootLayer) {
|
||||||
@@ -64,19 +65,18 @@ public class ShellRoot {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mClient = client;
|
mClient = client;
|
||||||
int windowType;
|
|
||||||
switch (shellRootLayer) {
|
switch (shellRootLayer) {
|
||||||
case SHELL_ROOT_LAYER_DIVIDER:
|
case SHELL_ROOT_LAYER_DIVIDER:
|
||||||
windowType = TYPE_DOCK_DIVIDER;
|
mWindowType = TYPE_DOCK_DIVIDER;
|
||||||
break;
|
break;
|
||||||
case SHELL_ROOT_LAYER_PIP:
|
case SHELL_ROOT_LAYER_PIP:
|
||||||
windowType = TYPE_APPLICATION_OVERLAY;
|
mWindowType = TYPE_APPLICATION_OVERLAY;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException(shellRootLayer
|
throw new IllegalArgumentException(shellRootLayer
|
||||||
+ " is not an acceptable shell root layer.");
|
+ " is not an acceptable shell root layer.");
|
||||||
}
|
}
|
||||||
mToken = new WindowToken.Builder(dc.mWmService, client.asBinder(), windowType)
|
mToken = new WindowToken.Builder(dc.mWmService, client.asBinder(), mWindowType)
|
||||||
.setDisplayContent(dc)
|
.setDisplayContent(dc)
|
||||||
.setPersistOnEmpty(true)
|
.setPersistOnEmpty(true)
|
||||||
.setOwnerCanManageAppTokens(true)
|
.setOwnerCanManageAppTokens(true)
|
||||||
@@ -89,6 +89,10 @@ public class ShellRoot {
|
|||||||
mToken.getPendingTransaction().show(mSurfaceControl);
|
mToken.getPendingTransaction().show(mSurfaceControl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getWindowType() {
|
||||||
|
return mWindowType;
|
||||||
|
}
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
if (mClient != null) {
|
if (mClient != null) {
|
||||||
mClient.asBinder().unlinkToDeath(mDeathRecipient, 0);
|
mClient.asBinder().unlinkToDeath(mDeathRecipient, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user