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

Commit d3488971 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add getAccessibilityWindowId system process API"

parents 4510b444 ca4c5743
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7240,6 +7240,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.
     *