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

Commit 0f08a151 authored by Anna Galusza's avatar Anna Galusza Committed by Android (Google) Code Review
Browse files

Merge "Revert "Create a new input filter to handle touch input for Software...

Merge "Revert "Create a new input filter to handle touch input for Software Cursor. Logic will be added in follow-up CLs. Software Cursor is a new accessibility feature that enables the user to control an on-screen mouse using swipes and taps on the touch screen.""
parents 0ec0ceb9 77da1c0e
Loading
Loading
Loading
Loading
+2 −32
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ import android.view.MotionEvent;
import android.view.accessibility.AccessibilityEvent;

import com.android.server.LocalServices;
import com.android.server.accessibility.cursor.SoftwareCursorGestureHandler;
import com.android.server.accessibility.gestures.TouchExplorer;
import com.android.server.accessibility.magnification.FullScreenMagnificationGestureHandler;
import com.android.server.accessibility.magnification.MagnificationGestureHandler;
@@ -142,13 +141,6 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
     */
    static final int FLAG_SEND_MOTION_EVENTS = 0x00000400;

    /**
     * Flag for enabling the Software Cursor accessibility feature.
     *
     * @see setUserAndEnabledFeatures(int, int)
     */
    static final int FLAG_FEATURE_SOFTWARE_CURSOR = 0x00000800;

    static final int FEATURES_AFFECTING_MOTION_EVENTS =
            FLAG_FEATURE_INJECT_MOTION_EVENTS
                    | FLAG_FEATURE_AUTOCLICK
@@ -157,8 +149,7 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
                    | FLAG_FEATURE_TRIGGERED_SCREEN_MAGNIFIER
                    | FLAG_SERVICE_HANDLES_DOUBLE_TAP
                    | FLAG_REQUEST_MULTI_FINGER_GESTURES
                    | FLAG_REQUEST_2_FINGER_PASSTHROUGH
                    | FLAG_FEATURE_SOFTWARE_CURSOR;
                    | FLAG_REQUEST_2_FINGER_PASSTHROUGH;

    private final Context mContext;

@@ -179,9 +170,6 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo

    private KeyboardInterceptor mKeyboardInterceptor;

    private SparseArray<SoftwareCursorGestureHandler> mSoftwareCursorGestureHandler =
            new SparseArray<>(0);

    private boolean mInstalled;

    private int mUserId;
@@ -507,16 +495,6 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
            mMagnificationGestureHandler.put(displayId, magnificationGestureHandler);
        }

        if ((mEnabledFeatures & FLAG_FEATURE_SOFTWARE_CURSOR) != 0) {
            // TODO: Add full support for multiple displays.
            final SoftwareCursorGestureHandler softwareCursorGestureHandler =
                    new SoftwareCursorGestureHandler(displayContext,
                        mAms.getSoftwareCursorManager(),
                        mAms.getTraceManager());
            addFirstEventHandler(displayId, softwareCursorGestureHandler);
            mSoftwareCursorGestureHandler.put(displayId, softwareCursorGestureHandler);
        }

        if ((mEnabledFeatures & FLAG_FEATURE_INJECT_MOTION_EVENTS) != 0) {
            MotionEventInjector injector = new MotionEventInjector(
                    mContext.getMainLooper(), mAms.getTraceManager());
@@ -587,20 +565,12 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
            mTouchExplorer.remove(displayId);
        }

        final MagnificationGestureHandler handler =
                mMagnificationGestureHandler.get(displayId);
        final MagnificationGestureHandler handler = mMagnificationGestureHandler.get(displayId);
        if (handler != null) {
            handler.onDestroy();
            mMagnificationGestureHandler.remove(displayId);
        }

        final SoftwareCursorGestureHandler softwareCursorHandler =
                mSoftwareCursorGestureHandler.get(displayId);
        if (softwareCursorHandler != null) {
            softwareCursorHandler.onDestroy();
            mSoftwareCursorGestureHandler.remove(displayId);
        }

        final EventStreamTransformation eventStreamTransformation = mEventHandler.get(displayId);
        if (eventStreamTransformation != null) {
            mEventHandler.remove(displayId);
+0 −17
Original line number Diff line number Diff line
@@ -140,7 +140,6 @@ import com.android.internal.util.IntPair;
import com.android.server.AccessibilityManagerInternal;
import com.android.server.LocalServices;
import com.android.server.SystemService;
import com.android.server.accessibility.cursor.SoftwareCursorManager;
import com.android.server.accessibility.magnification.MagnificationController;
import com.android.server.accessibility.magnification.MagnificationProcessor;
import com.android.server.accessibility.magnification.MagnificationScaleProvider;
@@ -245,8 +244,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
    private final MagnificationController mMagnificationController;
    private final MagnificationProcessor mMagnificationProcessor;

    private final SoftwareCursorManager mSoftwareCursorManager;

    private final MainHandler mMainHandler;

    // Lazily initialized - access through getSystemActionPerformer()
@@ -415,7 +412,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
        mMagnificationController = magnificationController;
        mMagnificationProcessor = new MagnificationProcessor(mMagnificationController);
        mCaptioningManagerImpl = new CaptioningManagerImpl(mContext);
        mSoftwareCursorManager = new SoftwareCursorManager();
        if (inputFilter != null) {
            mInputFilter = inputFilter;
            mHasInputFilter = true;
@@ -449,7 +445,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
                new MagnificationScaleProvider(mContext));
        mMagnificationProcessor = new MagnificationProcessor(mMagnificationController);
        mCaptioningManagerImpl = new CaptioningManagerImpl(mContext);
        mSoftwareCursorManager = new SoftwareCursorManager();
        init();
    }

@@ -2287,9 +2282,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
            if (userState.isPerformGesturesEnabledLocked()) {
                flags |= AccessibilityInputFilter.FLAG_FEATURE_INJECT_MOTION_EVENTS;
            }
            if (userState.isSoftwareCursorEnabledLocked()) {
                flags |= AccessibilityInputFilter.FLAG_FEATURE_SOFTWARE_CURSOR;
            }
            if (flags != 0) {
                if (!mHasInputFilter) {
                    mHasInputFilter = true;
@@ -3491,15 +3483,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
        return mMagnificationController;
    }

    /**
     * Getter of {@link SoftwareCursorManager}.
     *
     * @return SoftwareCursorManager
     */
    SoftwareCursorManager getSoftwareCursorManager() {
        return mSoftwareCursorManager;
    }

    @Override
    public void associateEmbeddedHierarchy(@NonNull IBinder host, @NonNull IBinder embedded) {
        if (mTraceManager.isA11yTracingEnabledForTypes(FLAGS_ACCESSIBILITY_MANAGER)) {
+0 −12
Original line number Diff line number Diff line
@@ -109,7 +109,6 @@ class AccessibilityUserState {
    private boolean mIsAudioDescriptionByDefaultRequested;
    private boolean mIsAutoclickEnabled;
    private boolean mIsDisplayMagnificationEnabled;
    private boolean mIsSoftwareCursorEnabled;
    private boolean mIsFilterKeyEventsEnabled;
    private boolean mIsPerformGesturesEnabled;
    private boolean mAccessibilityFocusOnlyInActiveWindow;
@@ -209,7 +208,6 @@ class AccessibilityUserState {
        mRequestTwoFingerPassthrough = false;
        mSendMotionEventsEnabled = false;
        mIsDisplayMagnificationEnabled = false;
        mIsSoftwareCursorEnabled = false;
        mIsAutoclickEnabled = false;
        mUserNonInteractiveUiTimeout = 0;
        mUserInteractiveUiTimeout = 0;
@@ -511,8 +509,6 @@ class AccessibilityUserState {
        pw.append(", sendMotionEventsEnabled").append(String.valueOf(mSendMotionEventsEnabled));
        pw.append(", displayMagnificationEnabled=").append(String.valueOf(
                mIsDisplayMagnificationEnabled));
        pw.append(", softwareCursorEnabled=").append(String.valueOf(
                mIsSoftwareCursorEnabled));
        pw.append(", autoclickEnabled=").append(String.valueOf(mIsAutoclickEnabled));
        pw.append(", nonInteractiveUiTimeout=").append(String.valueOf(mNonInteractiveUiTimeout));
        pw.append(", interactiveUiTimeout=").append(String.valueOf(mInteractiveUiTimeout));
@@ -623,14 +619,6 @@ class AccessibilityUserState {
        mIsDisplayMagnificationEnabled = enabled;
    }

    public boolean isSoftwareCursorEnabledLocked() {
        return mIsSoftwareCursorEnabled;
    }

    public void setSoftwareCursorEnabledLocked(boolean enabled) {
        mIsSoftwareCursorEnabled = enabled;
    }

    public boolean isFilterKeyEventsEnabledLocked() {
        return mIsFilterKeyEventsEnabled;
    }
+0 −71
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.cursor;

import android.content.Context;
import android.util.Log;
import android.util.Slog;
import android.view.MotionEvent;

import com.android.server.accessibility.AccessibilityTraceManager;
import com.android.server.accessibility.BaseEventStreamTransformation;

/**
 * Handles touch input for the Software Cursor accessibility feature.
 *
 * The behavior is as follows:
 *
 * <ol>
 *   <li> 1. Enable Software Cursor by swiping from the trigger zone on the edge of the screen.
 *   <li> 2. Move the cursor by swiping anywhere on the touch screen. Select by tapping anywhere on
 *   the touch screen.
 *   <li> 3. Put the cursor away by swiping it past either edge of the screen.
 * </ol>
 *
 * TODO(b/243552818): Determine how to handle multi-display.
 */
public final class SoftwareCursorGestureHandler extends BaseEventStreamTransformation {


    private static final String LOG_TAG = "SWCursorGestureHandler";
    private static final boolean DEBUG_ALL = Log.isLoggable("SWCursorGestureHandler",
            Log.DEBUG);

    Context mContext;
    SoftwareCursorManager mSoftwareCursorManager;
    AccessibilityTraceManager mTraceManager;

    public SoftwareCursorGestureHandler(Context context,
                          SoftwareCursorManager softwareCursorManager,
                          AccessibilityTraceManager traceManager) {
        mContext = context;
        mSoftwareCursorManager = softwareCursorManager;
        mTraceManager = traceManager;
    }

    @Override
    public void onMotionEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
        if (DEBUG_ALL) {
            Slog.i(LOG_TAG, "onMotionEvent(" + event + ")");
        }
        // TODO: Add logic.
        // TODO: Prevent users from enabling this filter in conjuntion with TouchExplorer.
        super.onMotionEvent(event, rawEvent, policyFlags);
    }


}
+0 −28
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.cursor;

/**
 * Allows the Software Cursor feature to interface with its corresponding code in the SystemUI
 * process.
 */
public final class SoftwareCursorManager {

    public SoftwareCursorManager() {
      // TODO: Add behavior in a future CL.
    }
}
Loading