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

Commit 96f41976 authored by Ameer Armaly's avatar Ameer Armaly Committed by Android (Google) Code Review
Browse files

Merge changes from topic "overlay"

* changes:
  Create  display accessibility overlay API.
  Expose SurfacePackage#getSurfaceControl
parents 808daf5e 3a8b1932
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -3087,6 +3087,7 @@ package android.accessibilityservice {
  public abstract class AccessibilityService extends android.app.Service {
    ctor public AccessibilityService();
    method public void attachAccessibilityOverlayToDisplay(int, @NonNull android.view.SurfaceControl);
    method public boolean clearCache();
    method public boolean clearCachedSubtree(@NonNull android.view.accessibility.AccessibilityNodeInfo);
    method public final void disableSelf();
@@ -49980,6 +49981,7 @@ package android.view {
  public static final class SurfaceControlViewHost.SurfacePackage implements android.os.Parcelable {
    ctor public SurfaceControlViewHost.SurfacePackage(@NonNull android.view.SurfaceControlViewHost.SurfacePackage);
    method public int describeContents();
    method @NonNull public android.view.SurfaceControl getSurfaceControl();
    method public void notifyConfigurationChanged(@NonNull android.content.res.Configuration);
    method public void notifyDetachedFromWindow();
    method public void release();
+27 −3
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ import android.util.SparseArray;
import android.view.Display;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.SurfaceView;
import android.view.SurfaceControl;
import android.view.WindowManager;
import android.view.WindowManagerImpl;
import android.view.accessibility.AccessibilityCache;
@@ -2467,8 +2467,8 @@ public abstract class AccessibilityService extends Service {
     * </p>
     * <p>
     * <strong>Note:</strong> If the view with {@link AccessibilityNodeInfo#FOCUS_INPUT}
     * is on an embedded view hierarchy which is embedded in a {@link SurfaceView} via
     * {@link SurfaceView#setChildSurfacePackage}, there is a limitation that this API
     * is on an embedded view hierarchy which is embedded in a {@link android.view.SurfaceView} via
     * {@link android.view.SurfaceView#setChildSurfacePackage}, there is a limitation that this API
     * won't be able to find the node for the view. It's because views don't know about
     * the embedded hierarchies. Instead, you could traverse all the nodes to find the
     * focus.
@@ -3379,4 +3379,28 @@ public abstract class AccessibilityService extends Service {
            controller.onStateChanged(state);
        }
    }

    /**
     * Attaches a {@link android.view.SurfaceControl} containing an accessibility overlay to the
     * specified display. This type of overlay should be used for content that does not need to
     * track the location and size of Views in the currently active app e.g. service configuration
     * or general service UI. To remove this overlay and free the associated resources, use
     * <code> new SurfaceControl.Transaction().reparent(sc, null).apply();</code>.
     *
     * @param displayId the display to which the SurfaceControl should be attached.
     * @param sc the SurfaceControl containing the overlay content
     */
    public void attachAccessibilityOverlayToDisplay(int displayId, @NonNull SurfaceControl sc) {
        Preconditions.checkNotNull(sc, "SurfaceControl cannot be null");
        final IAccessibilityServiceConnection connection =
                AccessibilityInteractionClient.getConnection(mConnectionId);
        if (connection == null) {
            return;
        }
        try {
            connection.attachAccessibilityOverlayToDisplay(displayId, sc);
        } catch (RemoteException re) {
            throw new RuntimeException(re);
        }
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.os.Bundle;
import android.os.RemoteCallback;
import android.view.MagnificationSpec;
import android.view.MotionEvent;
import android.view.SurfaceControl;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import android.view.accessibility.IAccessibilityInteractionConnectionCallback;
@@ -155,4 +156,5 @@ interface IAccessibilityServiceConnection {
    void setInstalledAndEnabledServices(in List<AccessibilityServiceInfo> infos);

    List<AccessibilityServiceInfo> getInstalledAndEnabledServices();
    void attachAccessibilityOverlayToDisplay(int displayId, in SurfaceControl sc);
}
+5 −3
Original line number Diff line number Diff line
@@ -159,9 +159,11 @@ public class SurfaceControlViewHost {
        }

        /**
         * Use {@link SurfaceView#setChildSurfacePackage} or manually fix
         * accessibility (see SurfaceView implementation).
         * @hide
         * Returns the {@link android.view.SurfaceControl} associated with this SurfacePackage for
         * cases where more control is required.
         *
         * @return the SurfaceControl associated with this SurfacePackage and its containing
         *     SurfaceControlViewHost
         */
        public @NonNull SurfaceControl getSurfaceControl() {
            return mSurfaceControl;
+4 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteCallback;
import android.os.RemoteException;
import android.view.SurfaceControl;
import android.window.ScreenCapture;

import java.util.Collections;
@@ -222,4 +223,7 @@ public class AccessibilityServiceConnectionImpl extends IAccessibilityServiceCon
    public List<AccessibilityServiceInfo> getInstalledAndEnabledServices() throws RemoteException {
        return null;
    }

    @Override
    public void attachAccessibilityOverlayToDisplay(int displayId, SurfaceControl sc) {}
}
Loading