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

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

Merge "Various minor magnification improvements"

parents 0f2512db 728354b1
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -365,6 +365,11 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
        /* do nothing */
    }

    @Override
    public EventStreamTransformation getNext() {
        return null;
    }

    @Override
    public void clearEvents(int inputSource) {
        /* do nothing */
+7 −29
Original line number Diff line number Diff line
@@ -23,15 +23,12 @@ import android.database.ContentObserver;
import android.net.Uri;
import android.os.Handler;
import android.os.SystemClock;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.Slog;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.MotionEvent.PointerCoords;
import android.view.MotionEvent.PointerProperties;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;

/**
@@ -55,11 +52,10 @@ import android.view.accessibility.AccessibilityManager;
 *
 * Each instance is associated to a single user (and it does not handle user switch itself).
 */
public class AutoclickController implements EventStreamTransformation {
public class AutoclickController extends BaseEventStreamTransformation {

    private static final String LOG_TAG = AutoclickController.class.getSimpleName();

    private EventStreamTransformation mNext;
    private final Context mContext;
    private final int mUserId;

@@ -88,9 +84,7 @@ public class AutoclickController implements EventStreamTransformation {
            mClickScheduler.cancel();
        }

        if (mNext != null) {
            mNext.onMotionEvent(event, rawEvent, policyFlags);
        }
        super.onMotionEvent(event, rawEvent, policyFlags);
    }

    @Override
@@ -103,21 +97,7 @@ public class AutoclickController implements EventStreamTransformation {
            }
        }

        if (mNext != null) {
          mNext.onKeyEvent(event, policyFlags);
        }
    }

    @Override
    public void onAccessibilityEvent(AccessibilityEvent event) {
        if (mNext != null) {
            mNext.onAccessibilityEvent(event);
        }
    }

    @Override
    public void setNext(EventStreamTransformation next) {
        mNext = next;
        super.onKeyEvent(event, policyFlags);
    }

    @Override
@@ -126,9 +106,7 @@ public class AutoclickController implements EventStreamTransformation {
            mClickScheduler.cancel();
        }

        if (mNext != null) {
            mNext.clearEvents(inputSource);
        }
        super.clearEvents(inputSource);
    }

    @Override
@@ -418,7 +396,7 @@ public class AutoclickController implements EventStreamTransformation {
         * Creates and forwards click event sequence.
         */
        private void sendClick() {
            if (mLastMotionEvent == null || mNext == null) {
            if (mLastMotionEvent == null || getNext() == null) {
                return;
            }

@@ -448,10 +426,10 @@ public class AutoclickController implements EventStreamTransformation {
            MotionEvent upEvent = MotionEvent.obtain(downEvent);
            upEvent.setAction(MotionEvent.ACTION_UP);

            mNext.onMotionEvent(downEvent, downEvent, mEventPolicyFlags);
            AutoclickController.super.onMotionEvent(downEvent, downEvent, mEventPolicyFlags);
            downEvent.recycle();

            mNext.onMotionEvent(upEvent, upEvent, mEventPolicyFlags);
            AutoclickController.super.onMotionEvent(upEvent, upEvent, mEventPolicyFlags);
            upEvent.recycle();
        }

+31 −0
Original line number Diff line number Diff line
/*
 ** Copyright 2017, The Android Open Source Project
 **
 ** Licensed under the Apache License, Version 2.0 (the "License");
 ** you may not use this file except in compliance with the License.
 ** You may obtain a copy of the License at
 **
 **     http://www.apache.org/licenses/LICENSE-2.0
 **
 ** Unless required by applicable law or agreed to in writing, software
 ** distributed under the License is distributed on an "AS IS" BASIS,
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ** See the License for the specific language governing permissions and
 ** limitations under the License.
 */

package com.android.server.accessibility;

abstract class BaseEventStreamTransformation implements EventStreamTransformation {
    private EventStreamTransformation mNext;

    @Override
    public void setNext(EventStreamTransformation next) {
        mNext = next;
    }

    @Override
    public EventStreamTransformation getNext() {
        return mNext;
    }
}
 No newline at end of file
+32 −5
Original line number Diff line number Diff line
@@ -65,7 +65,12 @@ interface EventStreamTransformation {
     * @param rawEvent The raw motion event.
     * @param policyFlags Policy flags for the event.
     */
    public void onMotionEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags);
    default void onMotionEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
        EventStreamTransformation next = getNext();
        if (next != null) {
            next.onMotionEvent(event, rawEvent, policyFlags);
        }
    }

    /**
     * Receives a key event.
@@ -73,14 +78,24 @@ interface EventStreamTransformation {
     * @param event The key event.
     * @param policyFlags Policy flags for the event.
     */
    public void onKeyEvent(KeyEvent event, int policyFlags);
    default void onKeyEvent(KeyEvent event, int policyFlags) {
        EventStreamTransformation next = getNext();
        if (next != null) {
            next.onKeyEvent(event, policyFlags);
        }
    }

    /**
     * Receives an accessibility event.
     *
     * @param event The accessibility event.
     */
    public void onAccessibilityEvent(AccessibilityEvent event);
    default void onAccessibilityEvent(AccessibilityEvent event) {
        EventStreamTransformation next = getNext();
        if (next != null) {
            next.onAccessibilityEvent(event);
        }
    };

    /**
     * Sets the next transformation.
@@ -89,15 +104,27 @@ interface EventStreamTransformation {
     */
    public void setNext(EventStreamTransformation next);

    /**
     * Gets the next transformation.
     *
     * @return The next transformation.
     */
    public EventStreamTransformation getNext();

    /**
     * Clears internal state associated with events from specific input source.
     *
     * @param inputSource The input source class for which transformation state should be cleared.
     */
    public void clearEvents(int inputSource);
    default void clearEvents(int inputSource) {
        EventStreamTransformation next = getNext();
        if (next != null) {
            next.clearEvents(inputSource);
        }
    }

    /**
     * Destroys this transformation.
     */
    public void onDestroy();
    default void onDestroy() {}
}
+1 −34
Original line number Diff line number Diff line
@@ -22,14 +22,12 @@ import android.os.SystemClock;
import android.util.Pools;
import android.util.Slog;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.WindowManagerPolicy;
import android.view.accessibility.AccessibilityEvent;

/**
 * Intercepts key events and forwards them to accessibility manager service.
 */
public class KeyboardInterceptor implements EventStreamTransformation, Handler.Callback {
public class KeyboardInterceptor extends BaseEventStreamTransformation implements Handler.Callback {
    private static final int MESSAGE_PROCESS_QUEUED_EVENTS = 1;
    private static final String LOG_TAG = "KeyboardInterceptor";

@@ -37,7 +35,6 @@ public class KeyboardInterceptor implements EventStreamTransformation, Handler.C
    private final WindowManagerPolicy mPolicy;
    private final Handler mHandler;

    private EventStreamTransformation mNext;
    private KeyEventHolder mEventQueueStart;
    private KeyEventHolder mEventQueueEnd;

@@ -64,13 +61,6 @@ public class KeyboardInterceptor implements EventStreamTransformation, Handler.C
        mHandler = handler;
    }

    @Override
    public void onMotionEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
        if (mNext != null) {
            mNext.onMotionEvent(event, rawEvent, policyFlags);
        }
    }

    @Override
    public void onKeyEvent(KeyEvent event, int policyFlags) {
        /*
@@ -89,29 +79,6 @@ public class KeyboardInterceptor implements EventStreamTransformation, Handler.C
        mAms.notifyKeyEvent(event, policyFlags);
    }

    @Override
    public void onAccessibilityEvent(AccessibilityEvent event) {
        if (mNext != null) {
            mNext.onAccessibilityEvent(event);
        }
    }

    @Override
    public void setNext(EventStreamTransformation next) {
        mNext = next;
    }

    @Override
    public void clearEvents(int inputSource) {
        if (mNext != null) {
            mNext.clearEvents(inputSource);
        }
    }

    @Override
    public void onDestroy() {
    }

    @Override
    public boolean handleMessage(Message msg) {
        if (msg.what != MESSAGE_PROCESS_QUEUED_EVENTS) {
Loading