Merge "Add getAccessibilityWindowId system process API"
diff --git a/api/system-current.txt b/api/system-current.txt
index 56cda7b..09dca1e 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -7240,6 +7240,7 @@
package android.view.accessibility {
public final class AccessibilityManager {
+ method public int getAccessibilityWindowId(android.os.IBinder);
method public void performAccessibilityShortcut();
}
diff --git a/core/java/android/view/accessibility/AccessibilityManager.java b/core/java/android/view/accessibility/AccessibilityManager.java
index 88b9c80..c5c1bca 100644
--- a/core/java/android/view/accessibility/AccessibilityManager.java
+++ b/core/java/android/view/accessibility/AccessibilityManager.java
@@ -1004,6 +1004,36 @@
}
/**
+ * Returns accessibility window id from window token. Accessibility window id is the one
+ * returned from AccessibilityWindowInfo.getId(). Only available for the system process.
+ *
+ * @param windowToken Window token to find accessibility window id.
+ * @return Accessibility window id for the window token.
+ * AccessibilityWindowInfo.UNDEFINED_WINDOW_ID if accessibility window id not available for
+ * the token.
+ * @hide
+ */
+ @SystemApi
+ public int getAccessibilityWindowId(IBinder windowToken) {
+ if (windowToken == null) {
+ return AccessibilityWindowInfo.UNDEFINED_WINDOW_ID;
+ }
+
+ final IAccessibilityManager service;
+ synchronized (mLock) {
+ service = getServiceLocked();
+ if (service == null) {
+ return AccessibilityWindowInfo.UNDEFINED_WINDOW_ID;
+ }
+ }
+ try {
+ return service.getAccessibilityWindowId(windowToken);
+ } catch (RemoteException e) {
+ return AccessibilityWindowInfo.UNDEFINED_WINDOW_ID;
+ }
+ }
+
+ /**
* Sets the current state and notifies listeners, if necessary.
*
* @param stateFlags The state flags.
diff --git a/core/java/android/view/accessibility/IAccessibilityManager.aidl b/core/java/android/view/accessibility/IAccessibilityManager.aidl
index 2767a82..38dac94 100644
--- a/core/java/android/view/accessibility/IAccessibilityManager.aidl
+++ b/core/java/android/view/accessibility/IAccessibilityManager.aidl
@@ -76,5 +76,8 @@
// System process only
boolean sendFingerprintGesture(int gestureKeyCode);
+ // System process only
+ int getAccessibilityWindowId(IBinder windowToken);
+
long getRecommendedTimeoutMillis();
}
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
index d5decce..36ca52a 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -2466,6 +2466,25 @@
}
/**
+ * AIDL-exposed method. System only.
+ * Gets accessibility window id from window token.
+ *
+ * @param windowToken Window token to get accessibility window id.
+ * @return Accessibility window id for the window token. Returns -1 if no such token is
+ * registered.
+ */
+ @Override
+ public int getAccessibilityWindowId(IBinder windowToken) {
+ synchronized (mLock) {
+ if (UserHandle.getAppId(Binder.getCallingUid()) != Process.SYSTEM_UID) {
+ throw new SecurityException("Only SYSTEM can call getAccessibilityWindowId");
+ }
+
+ return findWindowIdLocked(windowToken);
+ }
+ }
+
+ /**
* Get the recommended timeout of interactive controls and non-interactive controls.
*
* @return A long for pair of {@code int}s. First integer for interactive one, and second