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

Commit dc6d1a9c authored by Svetoslav's avatar Svetoslav
Browse files

Fix the global gesture to enable accessibility.

1. There was a bug in the touch explorer which was crashing almost
   every time after accessibility was enabled via the gesture. The
   problem was that in dragging state when a finger goes up we were
   not transitioning to touch exploring state.

2. The global actions dialog was not going away after enabling
   accessibility while it should as the user brought it up to
   turn accessibility on rather to interact with global actions.

bug:15254250

Change-Id: Iaa45f758e09566822775b53e87d2980138e85ef9
parent 6a6a8f00
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ public class EnableAccessibilityController {


    private final Context mContext;
    private final Runnable mOnAccessibilityEnabledCallback;
    private final UserManager mUserManager;
    private final TextToSpeech mTts;
    private final Ringtone mTone;
@@ -97,8 +98,9 @@ public class EnableAccessibilityController {
    private float mSecondPointerDownX;
    private float mSecondPointerDownY;

    public EnableAccessibilityController(Context context) {
    public EnableAccessibilityController(Context context, Runnable onAccessibilityEnabledCallback) {
        mContext = context;
        mOnAccessibilityEnabledCallback = onAccessibilityEnabledCallback;
        mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
        mTts = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
            @Override
@@ -275,5 +277,7 @@ public class EnableAccessibilityController {
                /* ignore */
            }
        }

        mOnAccessibilityEnabledCallback.run();
    }
}
+7 −1
Original line number Diff line number Diff line
@@ -1073,7 +1073,13 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
            // is dismissed on the first down while the global gesture is a long press
            // with two fingers anywhere on the screen.
            if (EnableAccessibilityController.canEnableAccessibilityViaGesture(mContext)) {
                mEnableAccessibilityController = new EnableAccessibilityController(mContext);
                mEnableAccessibilityController = new EnableAccessibilityController(mContext,
                        new Runnable() {
                    @Override
                    public void run() {
                        dismiss();
                    }
                });
                super.setCanceledOnTouchOutside(false);
            } else {
                mEnableAccessibilityController = null;
+1 −0
Original line number Diff line number Diff line
@@ -708,6 +708,7 @@ class TouchExplorer implements EventStreamTransformation {
                     // Send an event to the end of the drag gesture.
                     sendMotionEvent(event, MotionEvent.ACTION_UP, pointerIdBits, policyFlags);
                 }
                 mCurrentState = STATE_TOUCH_EXPLORING;
            } break;
            case MotionEvent.ACTION_UP: {
                mAms.onTouchInteractionEnd();