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

Commit 1b2cf756 authored by mincheli's avatar mincheli
Browse files

Uses windowContext for the MagnificationGestureHandler

ContextImpl checks the incorrect Context usage in S.
If non-ui context access window service, it would throw an
IllegalAccessException.
And the bug happened because the GestureDectectors in
PanningScalingHandler.class don't have the correct context.
So we have to apply using uiContext for the GestureDectectors
and MagnificationGestureHandler.

Bug: 185154435
Test: none
Change-Id: I942192011526d0e4ce68e6121855bd321c499f56
parent 3ed02ffe
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package com.android.server.accessibility;

import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY;

import android.annotation.MainThread;
import android.content.Context;
import android.graphics.Region;
@@ -557,12 +560,16 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
        MagnificationGestureHandler magnificationGestureHandler;
        if (mAms.getMagnificationMode(displayId)
                == Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW) {
            magnificationGestureHandler = new WindowMagnificationGestureHandler(displayContext,
            final Context uiContext = displayContext.createWindowContext(
                    TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY, null /* options */);
            magnificationGestureHandler = new WindowMagnificationGestureHandler(uiContext,
                    mAms.getWindowMagnificationMgr(), mAms.getMagnificationController(),
                    detectControlGestures, triggerable,
                    displayId);
        } else {
            magnificationGestureHandler = new FullScreenMagnificationGestureHandler(displayContext,
            final Context uiContext = displayContext.createWindowContext(
                    TYPE_MAGNIFICATION_OVERLAY, null /* options */);
            magnificationGestureHandler = new FullScreenMagnificationGestureHandler(uiContext,
                    mAms.getFullScreenMagnificationController(), mAms.getMagnificationController(),
                    detectControlGestures, triggerable,
                    new WindowMagnificationPromptController(displayContext, mUserId), displayId);
+2 −1
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import static java.util.Arrays.copyOfRange;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UiContext;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -139,7 +140,7 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
    private PointerCoords[] mTempPointerCoords;
    private PointerProperties[] mTempPointerProperties;

    public FullScreenMagnificationGestureHandler(Context context,
    public FullScreenMagnificationGestureHandler(@UiContext Context context,
            FullScreenMagnificationController fullScreenMagnificationController,
            Callback callback,
            boolean detectTripleTap,
+3 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.accessibility.magnification;
import static java.lang.Math.abs;

import android.annotation.NonNull;
import android.annotation.UiContext;
import android.content.Context;
import android.os.Handler;
import android.util.Log;
@@ -63,8 +64,8 @@ class PanningScalingHandler extends
    private boolean mScaling;
    private boolean mEnable;

    PanningScalingHandler(Context context, float maxScale, float minScale, boolean blockScroll,
            @NonNull MagnificationDelegate magnificationDelegate) {
    PanningScalingHandler(@UiContext Context context, float maxScale, float minScale,
            boolean blockScroll, @NonNull MagnificationDelegate magnificationDelegate) {
        mDisplayId = context.getDisplayId();
        mMaxScale = maxScale;
        mMinScale = minScale;
+3 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static java.util.Arrays.asList;
import static java.util.Arrays.copyOfRange;

import android.annotation.Nullable;
import android.annotation.UiContext;
import android.content.Context;
import android.graphics.Point;
import android.provider.Settings;
@@ -86,7 +87,7 @@ public class WindowMagnificationGestureHandler extends MagnificationGestureHandl
    private final Context mContext;
    private final Point mTempPoint = new Point();

    public WindowMagnificationGestureHandler(Context context,
    public WindowMagnificationGestureHandler(@UiContext Context context,
            WindowMagnificationManager windowMagnificationMgr,
            Callback callback,
            boolean detectTripleTap, boolean detectShortcutTrigger, int displayId) {
@@ -342,7 +343,7 @@ public class WindowMagnificationGestureHandler extends MagnificationGestureHandl
         */
        private final boolean mDetectTripleTap;

        DetectingState(Context context, boolean detectTripleTap) {
        DetectingState(@UiContext Context context, boolean detectTripleTap) {
            mDetectTripleTap = detectTripleTap;
            final MultiTap multiTap = new MultiTap(context, mDetectTripleTap ? 3 : 1,
                    mDetectTripleTap