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

Commit e1e3273b authored by Ryan Lin's avatar Ryan Lin Committed by Android (Google) Code Review
Browse files

Merge "added setDisplayId in GestureDesicption.Builder to support multi-display"

parents 89d954c3 80788131
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2966,6 +2966,7 @@ package android.accessibilityservice {
  }
  public final class GestureDescription {
    method public int getDisplayId();
    method public static long getMaxGestureDuration();
    method public static int getMaxStrokeCount();
    method public android.accessibilityservice.GestureDescription.StrokeDescription getStroke(@IntRange(from=0) int);
@@ -2976,6 +2977,7 @@ package android.accessibilityservice {
    ctor public GestureDescription.Builder();
    method public android.accessibilityservice.GestureDescription.Builder addStroke(@NonNull android.accessibilityservice.GestureDescription.StrokeDescription);
    method public android.accessibilityservice.GestureDescription build();
    method @NonNull public android.accessibilityservice.GestureDescription.Builder setDisplayId(int);
  }
  public static class GestureDescription.StrokeDescription {
+2 −2
Original line number Diff line number Diff line
@@ -777,8 +777,8 @@ public abstract class AccessibilityService extends Service {
                            callback, handler);
                    mGestureStatusCallbackInfos.put(mGestureStatusCallbackSequence, callbackInfo);
                }
                connection.sendGesture(mGestureStatusCallbackSequence,
                        new ParceledListSlice<>(steps));
                connection.dispatchGesture(mGestureStatusCallbackSequence,
                        new ParceledListSlice<>(steps), gesture.getDisplayId());
            }
        } catch (RemoteException re) {
            throw new RuntimeException(re);
+36 −4
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.graphics.PathMeasure;
import android.graphics.RectF;
import android.os.Parcel;
import android.os.Parcelable;
import android.view.Display;

import com.android.internal.util.Preconditions;

@@ -33,7 +34,7 @@ import java.util.List;
 * Accessibility services with the
 * {@link android.R.styleable#AccessibilityService_canPerformGestures} property can dispatch
 * gestures. This class describes those gestures. Gestures are made up of one or more strokes.
 * Gestures are immutable once built.
 * Gestures are immutable once built and will be dispatched to the specified display.
 * <p>
 * Spatial dimensions throughout are in screen pixels. Time is measured in milliseconds.
 */
@@ -48,6 +49,7 @@ public final class GestureDescription {

    private final List<StrokeDescription> mStrokes = new ArrayList<>();
    private final float[] mTempPos = new float[2];
    private final int mDisplayId;

    /**
     * Get the upper limit for the number of strokes a gesture may contain.
@@ -67,10 +69,17 @@ public final class GestureDescription {
        return MAX_GESTURE_DURATION_MS;
    }

    private GestureDescription() {}
    private GestureDescription() {
       this(new ArrayList<>());
    }

    private GestureDescription(List<StrokeDescription> strokes) {
        this(strokes, Display.DEFAULT_DISPLAY);
    }

    private GestureDescription(List<StrokeDescription> strokes, int displayId) {
        mStrokes.addAll(strokes);
        mDisplayId = displayId;
    }

    /**
@@ -93,6 +102,16 @@ public final class GestureDescription {
        return mStrokes.get(index);
    }

    /**
     * Returns the ID of the display this gesture is sent on, for use with
     * {@link android.hardware.display.DisplayManager#getDisplay(int)}.
     *
     * @return The logical display id.
     */
    public int getDisplayId() {
        return mDisplayId;
    }

    /**
     * Return the smallest key point (where a path starts or ends) that is at least a specified
     * offset
@@ -160,9 +179,10 @@ public final class GestureDescription {
    public static class Builder {

        private final List<StrokeDescription> mStrokes = new ArrayList<>();
        private int mDisplayId = Display.DEFAULT_DISPLAY;

        /**
         * Add a stroke to the gesture description. Up to
         * Adds a stroke to the gesture description. Up to
         * {@link GestureDescription#getMaxStrokeCount()} paths may be
         * added to a gesture, and the total gesture duration (earliest path start time to latest
         * path end time) may not exceed {@link GestureDescription#getMaxGestureDuration()}.
@@ -187,11 +207,23 @@ public final class GestureDescription {
            return this;
        }

        /**
         * Sets the id of the display to dispatch gestures.
         *
         * @param displayId The logical display id
         *
         * @return this
         */
        public @NonNull Builder setDisplayId(int displayId) {
            mDisplayId = displayId;
            return this;
        }

        public GestureDescription build() {
            if (mStrokes.size() == 0) {
                throw new IllegalStateException("Gestures must have at least one stroke");
            }
            return new GestureDescription(mStrokes);
            return new GestureDescription(mStrokes, mDisplayId);
        }
    }

+2 −0
Original line number Diff line number Diff line
@@ -95,6 +95,8 @@ interface IAccessibilityServiceConnection {

    void sendGesture(int sequence, in ParceledListSlice gestureSteps);

    void dispatchGesture(int sequence, in ParceledListSlice gestureSteps, int displayId);

    boolean isFingerprintGestureDetectionAvailable();

    IBinder getOverlayWindowToken(int displayid);
+2 −0
Original line number Diff line number Diff line
@@ -132,6 +132,8 @@ public class AccessibilityServiceConnectionImpl extends IAccessibilityServiceCon

    public void sendGesture(int sequence, ParceledListSlice gestureSteps) {}

    public void dispatchGesture(int sequence, ParceledListSlice gestureSteps, int displayId) {}

    public boolean isFingerprintGestureDetectionAvailable() {
        return false;
    }
Loading