Merge "Fix CTS test case failure" into rvc-dev
This commit is contained in:
@@ -45,6 +45,7 @@ import android.os.IBinder;
|
|||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
|
import android.util.IntArray;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
@@ -128,14 +129,13 @@ final class AccessibilityController {
|
|||||||
*/
|
*/
|
||||||
public boolean setWindowsForAccessibilityCallbackLocked(int displayId,
|
public boolean setWindowsForAccessibilityCallbackLocked(int displayId,
|
||||||
WindowsForAccessibilityCallback callback) {
|
WindowsForAccessibilityCallback callback) {
|
||||||
if (callback != null) {
|
final DisplayContent dc = mService.mRoot.getDisplayContentOrCreate(displayId);
|
||||||
final DisplayContent dc = mService.mRoot.getDisplayContentOrCreate(displayId);
|
if (dc == null) {
|
||||||
if (dc == null) {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
final Display display = dc.getDisplay();
|
if (callback != null) {
|
||||||
if (display.getType() == Display.TYPE_VIRTUAL && dc.getParentWindow() != null) {
|
if (isEmbeddedDisplay(dc)) {
|
||||||
// If this display is an embedded one, its window observer should have been set from
|
// If this display is an embedded one, its window observer should have been set from
|
||||||
// window manager after setting its parent window. But if its window observer is
|
// window manager after setting its parent window. But if its window observer is
|
||||||
// empty, that means this mapping didn't be set, and needs to do this again.
|
// empty, that means this mapping didn't be set, and needs to do this again.
|
||||||
@@ -152,13 +152,22 @@ final class AccessibilityController {
|
|||||||
mWindowsForAccessibilityObserver.put(displayId,
|
mWindowsForAccessibilityObserver.put(displayId,
|
||||||
new WindowsForAccessibilityObserver(mService, displayId, callback));
|
new WindowsForAccessibilityObserver(mService, displayId, callback));
|
||||||
} else {
|
} else {
|
||||||
|
if (isEmbeddedDisplay(dc)) {
|
||||||
|
// If this display is an embedded one, its window observer should be removed along
|
||||||
|
// with the window observer of its parent display removed because the window
|
||||||
|
// observer of the embedded display and its parent display is the same, and would
|
||||||
|
// be removed together when stopping the window tracking of its parent display. So
|
||||||
|
// here don't need to do removing window observer of the embedded display again.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
final WindowsForAccessibilityObserver windowsForA11yObserver =
|
final WindowsForAccessibilityObserver windowsForA11yObserver =
|
||||||
mWindowsForAccessibilityObserver.get(displayId);
|
mWindowsForAccessibilityObserver.get(displayId);
|
||||||
if (windowsForA11yObserver == null) {
|
if (windowsForA11yObserver == null) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Windows for accessibility callback of display " + displayId
|
"Windows for accessibility callback of display " + displayId
|
||||||
+ " already cleared!");
|
+ " already cleared!");
|
||||||
}
|
}
|
||||||
|
removeObserverOfEmbeddedDisplay(windowsForA11yObserver);
|
||||||
mWindowsForAccessibilityObserver.remove(displayId);
|
mWindowsForAccessibilityObserver.remove(displayId);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -332,6 +341,7 @@ final class AccessibilityController {
|
|||||||
mWindowsForAccessibilityObserver.get(parentDisplayId);
|
mWindowsForAccessibilityObserver.get(parentDisplayId);
|
||||||
|
|
||||||
if (windowsForA11yObserver != null) {
|
if (windowsForA11yObserver != null) {
|
||||||
|
windowsForA11yObserver.addEmbeddedDisplay(embeddedDisplayId);
|
||||||
// Replaces the observer of embedded display to the one of parent display
|
// Replaces the observer of embedded display to the one of parent display
|
||||||
mWindowsForAccessibilityObserver.put(embeddedDisplayId, windowsForA11yObserver);
|
mWindowsForAccessibilityObserver.put(embeddedDisplayId, windowsForA11yObserver);
|
||||||
}
|
}
|
||||||
@@ -352,6 +362,23 @@ final class AccessibilityController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeObserverOfEmbeddedDisplay(WindowsForAccessibilityObserver
|
||||||
|
observerOfParentDisplay) {
|
||||||
|
final IntArray embeddedDisplayIdList =
|
||||||
|
observerOfParentDisplay.getAndClearEmbeddedDisplayIdList();
|
||||||
|
|
||||||
|
for (int index = 0; index < embeddedDisplayIdList.size(); index++) {
|
||||||
|
final int embeddedDisplayId = embeddedDisplayIdList.get(index);
|
||||||
|
mWindowsForAccessibilityObserver.remove(embeddedDisplayId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isEmbeddedDisplay(DisplayContent dc) {
|
||||||
|
final Display display = dc.getDisplay();
|
||||||
|
|
||||||
|
return display.getType() == Display.TYPE_VIRTUAL && dc.getParentWindow() != null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class encapsulates the functionality related to display magnification.
|
* This class encapsulates the functionality related to display magnification.
|
||||||
*/
|
*/
|
||||||
@@ -1179,6 +1206,8 @@ final class AccessibilityController {
|
|||||||
|
|
||||||
private final long mRecurringAccessibilityEventsIntervalMillis;
|
private final long mRecurringAccessibilityEventsIntervalMillis;
|
||||||
|
|
||||||
|
private final IntArray mEmbeddedDisplayIdList = new IntArray(0);
|
||||||
|
|
||||||
public WindowsForAccessibilityObserver(WindowManagerService windowManagerService,
|
public WindowsForAccessibilityObserver(WindowManagerService windowManagerService,
|
||||||
int displayId,
|
int displayId,
|
||||||
WindowsForAccessibilityCallback callback) {
|
WindowsForAccessibilityCallback callback) {
|
||||||
@@ -1203,6 +1232,21 @@ final class AccessibilityController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IntArray getAndClearEmbeddedDisplayIdList() {
|
||||||
|
final IntArray returnedArray = new IntArray(mEmbeddedDisplayIdList.size());
|
||||||
|
returnedArray.addAll(mEmbeddedDisplayIdList);
|
||||||
|
mEmbeddedDisplayIdList.clear();
|
||||||
|
|
||||||
|
return returnedArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addEmbeddedDisplay(int displayId) {
|
||||||
|
if (displayId == mDisplayId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mEmbeddedDisplayIdList.add(displayId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user