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

Commit e4b24402 authored by Adrian Roos's avatar Adrian Roos Committed by android-build-merger
Browse files

GestureNav: Log exclusion rect heights am: 5f2c9a14

am: fde134f1

Change-Id: I6b4d05cbd7f9b42dd4e2e340b2abadc791c69f37
parents 38062876 fde134f1
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -337,6 +337,20 @@ public final class DeviceConfig {
        String KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE =
                "system_gestures_excluded_by_pre_q_sticky_immersive";

        /**
         * The minimum duration between gesture exclusion logging for a given window in
         * milliseconds.
         *
         * Events that happen in-between will be silently dropped.
         *
         * A non-positive value disables logging.
         *
         * @see android.provider.DeviceConfig#NAMESPACE_WINDOW_MANAGER
         * @hide
         */
        String KEY_SYSTEM_GESTURE_EXCLUSION_LOG_DEBOUNCE_MILLIS =
                "system_gesture_exclusion_log_debounce_millis";

        /**
         * Key for controlling which packages are explicitly blocked from running at refresh rates
         * higher than 60hz.
+9 −2
Original line number Diff line number Diff line
@@ -28,7 +28,14 @@ oneway interface ISystemGestureExclusionListener {
     * Called when the system gesture exclusion for the given display changed.
     * @param displayId the display whose system gesture exclusion changed
     * @param systemGestureExclusion a {@code Region} where the app would like priority over the
     *                               system gestures, in display coordinates.
     *                               system gestures, in display coordinates. Certain restrictions
     *                               might be applied such that apps don't get all the exclusions
     *                               they request.
     * @param systemGestureExclusionUnrestricted a {@code Region} where the app would like priority
     *                               over the system gestures, in display coordinates, without
     *                               any restrictions applied. Null if no restrictions have been
     *                               applied.
     */
    void onSystemGestureExclusionChanged(int displayId, in Region systemGestureExclusion);
    void onSystemGestureExclusionChanged(int displayId, in Region systemGestureExclusion,
            in Region systemGestureExclusionUnrestricted);
}
 No newline at end of file
+35 −2
Original line number Diff line number Diff line
@@ -53,6 +53,12 @@ public class PointerLocationView extends View implements InputDeviceListener,
    // to plot alongside the default one.  Useful for testing and comparison purposes.
    private static final String ALT_STRATEGY_PROPERY_KEY = "debug.velocitytracker.alt";

    /**
     * If set to a positive value between 1-255, shows an overlay with the approved (red) and
     * rejected (blue) exclusions.
     */
    private static final String GESTURE_EXCLUSION_PROP = "debug.pointerlocation.showexclusion";

    public static class PointerState {
        // Trace of previous points.
        private float[] mTraceX = new float[32];
@@ -138,8 +144,10 @@ public class PointerLocationView extends View implements InputDeviceListener,
    private final PointerCoords mTempCoords = new PointerCoords();

    private final Region mSystemGestureExclusion = new Region();
    private final Region mSystemGestureExclusionRejected = new Region();
    private final Path mSystemGestureExclusionPath = new Path();
    private final Paint mSystemGestureExclusionPaint;
    private final Paint mSystemGestureExclusionRejectedPaint;

    private final VelocityTracker mVelocity;
    private final VelocityTracker mAltVelocity;
@@ -190,6 +198,10 @@ public class PointerLocationView extends View implements InputDeviceListener,
        mSystemGestureExclusionPaint.setARGB(25, 255, 0, 0);
        mSystemGestureExclusionPaint.setStyle(Paint.Style.FILL_AND_STROKE);

        mSystemGestureExclusionRejectedPaint = new Paint();
        mSystemGestureExclusionRejectedPaint.setARGB(25, 0, 0, 255);
        mSystemGestureExclusionRejectedPaint.setStyle(Paint.Style.FILL_AND_STROKE);

        PointerState ps = new PointerState();
        mPointers.add(ps);
        mActivePointerId = 0;
@@ -263,6 +275,12 @@ public class PointerLocationView extends View implements InputDeviceListener,
            canvas.drawPath(mSystemGestureExclusionPath, mSystemGestureExclusionPaint);
        }

        if (!mSystemGestureExclusionRejected.isEmpty()) {
            mSystemGestureExclusionPath.reset();
            mSystemGestureExclusionRejected.getBoundaryPath(mSystemGestureExclusionPath);
            canvas.drawPath(mSystemGestureExclusionPath, mSystemGestureExclusionRejectedPaint);
        }

        // Labels
        if (mActivePointerId >= 0) {
            final PointerState ps = mPointers.get(mActivePointerId);
@@ -754,6 +772,9 @@ public class PointerLocationView extends View implements InputDeviceListener,
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
            final int alpha = systemGestureExclusionOpacity();
            mSystemGestureExclusionPaint.setAlpha(alpha);
            mSystemGestureExclusionRejectedPaint.setAlpha(alpha);
        } else {
            mSystemGestureExclusion.setEmpty();
        }
@@ -805,7 +826,12 @@ public class PointerLocationView extends View implements InputDeviceListener,
    }

    private static boolean shouldShowSystemGestureExclusion() {
        return SystemProperties.getBoolean("debug.pointerlocation.showexclusion", false);
        return systemGestureExclusionOpacity() > 0;
    }

    private static int systemGestureExclusionOpacity() {
        int x = SystemProperties.getInt(GESTURE_EXCLUSION_PROP, 0);
        return x >= 0 && x <= 255 ? x : 0;
    }

    // HACK
@@ -928,12 +954,19 @@ public class PointerLocationView extends View implements InputDeviceListener,
    private ISystemGestureExclusionListener mSystemGestureExclusionListener =
            new ISystemGestureExclusionListener.Stub() {
        @Override
        public void onSystemGestureExclusionChanged(int displayId, Region systemGestureExclusion) {
        public void onSystemGestureExclusionChanged(int displayId, Region systemGestureExclusion,
                Region systemGestureExclusionUnrestricted) {
            Region exclusion = Region.obtain(systemGestureExclusion);
            Region rejected = Region.obtain();
            if (systemGestureExclusionUnrestricted != null) {
                rejected.set(systemGestureExclusionUnrestricted);
                rejected.op(exclusion, Region.Op.DIFFERENCE);
            }
            Handler handler = getHandler();
            if (handler != null) {
                handler.post(() -> {
                    mSystemGestureExclusion.set(exclusion);
                    mSystemGestureExclusionRejected.set(rejected);
                    exclusion.recycle();
                    invalidate();
                });
+23 −3
Original line number Diff line number Diff line
@@ -34,9 +34,11 @@ public abstract class SystemGestureExclusionListenerCompat {
            new ISystemGestureExclusionListener.Stub() {
                @Override
                public void onSystemGestureExclusionChanged(int displayId,
                        Region systemGestureExclusion) {
                        Region systemGestureExclusion, Region unrestrictedOrNull) {
                    if (displayId == mDisplayId) {
                        onExclusionChanged(systemGestureExclusion);
                        Region unrestricted = (unrestrictedOrNull == null)
                                ? systemGestureExclusion : unrestrictedOrNull;
                        onExclusionChanged(systemGestureExclusion, unrestricted);
                    }
                }
            };
@@ -47,10 +49,28 @@ public abstract class SystemGestureExclusionListenerCompat {
    }

    /**
     * Called when the exclusion region has changed
     * Called when the exclusion region has changed.
     *
     * TODO: remove, once all subclasses have migrated to
     *       {@link #onExclusionChanged(Region, Region)}.
     */
    public abstract void onExclusionChanged(Region systemGestureExclusion);

    /**
     * Called when the exclusion region has changed.
     *
     * @param systemGestureExclusion the system gesture exclusion to be applied
     * @param systemGestureExclusionUnrestricted what would be the system gesture exclusion, if
     *           there were no restrictions being applied. For logging purposes only.
     *
     */
    public void onExclusionChanged(Region systemGestureExclusion,
            Region systemGestureExclusionUnrestricted) {
        // TODO: make abstract, once all subclasses have migrated away from
        //       onExclusionChanged(Region)
        onExclusionChanged(systemGestureExclusion);
    }

    /**
     * Registers the listener for getting exclusion rect changes.
     */
+1 −1
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ public class EdgeBackGestureHandler implements DisplayListener {
            new ISystemGestureExclusionListener.Stub() {
                @Override
                public void onSystemGestureExclusionChanged(int displayId,
                        Region systemGestureExclusion) {
                        Region systemGestureExclusion, Region unrestrictedOrNull) {
                    if (displayId == mDisplayId) {
                        mMainExecutor.execute(() -> mExcludeRegion.set(systemGestureExclusion));
                    }
Loading