Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ca4c5743 authored by Yuki Awano's avatar Yuki Awano
Browse files

Add getAccessibilityWindowId system process API

- Add an API to get accessibility window id from window token. This API
  can be called only from a system process.

Bug: 119794051
Test: None
Change-Id: I37db50209efeb81f3e3502d84fd53fedec695f99
parent 441ca70d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7310,6 +7310,7 @@ package android.view {
package android.view.accessibility {

  public final class AccessibilityManager {
    method public int getAccessibilityWindowId(android.os.IBinder);
    method public void performAccessibilityShortcut();
  }

+30 −0
Original line number Diff line number Diff line
@@ -1003,6 +1003,36 @@ public final class AccessibilityManager {
        }
    }

    /**
     * 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.
     *
+3 −0
Original line number Diff line number Diff line
@@ -76,5 +76,8 @@ interface IAccessibilityManager {
    // System process only
    boolean sendFingerprintGesture(int gestureKeyCode);

    // System process only
    int getAccessibilityWindowId(IBinder windowToken);

    long getRecommendedTimeoutMillis();
}
+19 −0
Original line number Diff line number Diff line
@@ -2465,6 +2465,25 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
        return mFingerprintGestureDispatcher.onFingerprintGesture(gestureKeyCode);
    }

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