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

Commit 34a2cd24 authored by Josep del Río's avatar Josep del Río Committed by Automerger Merge Worker
Browse files

Merge "Remove InputManager and DisplayManager from ViewRootImpl" into udc-dev am: 4ceed60b

parents 3e4503a0 4ceed60b
Loading
Loading
Loading
Loading
+1 −4
Original line number Original line Diff line number Diff line
@@ -39,7 +39,6 @@ import android.os.InputEventInjectionSync;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemClock;
import android.os.Vibrator;
import android.os.Vibrator;
import android.sysprop.InputProperties;
import android.util.Log;
import android.util.Log;
import android.view.Display;
import android.view.Display;
import android.view.InputDevice;
import android.view.InputDevice;
@@ -1038,9 +1037,7 @@ public final class InputManager {
     */
     */
    public boolean isStylusPointerIconEnabled() {
    public boolean isStylusPointerIconEnabled() {
        if (mIsStylusPointerIconEnabled == null) {
        if (mIsStylusPointerIconEnabled == null) {
            mIsStylusPointerIconEnabled = mContext.getResources()
            mIsStylusPointerIconEnabled = InputSettings.isStylusPointerIconEnabled(mContext);
                    .getBoolean(com.android.internal.R.bool.config_enableStylusPointerIcon)
                    || InputProperties.force_enable_stylus_pointer_icon().orElse(false);
        }
        }
        return mIsStylusPointerIconEnabled;
        return mIsStylusPointerIconEnabled;
    }
    }
+1 −1
Original line number Original line Diff line number Diff line
@@ -1252,7 +1252,7 @@ public final class InputManagerGlobal {
    /**
    /**
     * @see InputManager#requestPointerCapture(IBinder, boolean)
     * @see InputManager#requestPointerCapture(IBinder, boolean)
     */
     */
    void requestPointerCapture(IBinder windowToken, boolean enable) {
    public void requestPointerCapture(IBinder windowToken, boolean enable) {
        try {
        try {
            mIm.requestPointerCapture(windowToken, enable);
            mIm.requestPointerCapture(windowToken, enable);
        } catch (RemoteException ex) {
        } catch (RemoteException ex) {
+12 −0
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ import android.annotation.TestApi;
import android.content.Context;
import android.content.Context;
import android.os.UserHandle;
import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Settings;
import android.sysprop.InputProperties;


/**
/**
 * InputSettings encapsulates reading and writing settings related to input
 * InputSettings encapsulates reading and writing settings related to input
@@ -316,4 +317,15 @@ public class InputSettings {
                Settings.System.TOUCHPAD_RIGHT_CLICK_ZONE, enabled ? 1 : 0,
                Settings.System.TOUCHPAD_RIGHT_CLICK_ZONE, enabled ? 1 : 0,
                UserHandle.USER_CURRENT);
                UserHandle.USER_CURRENT);
    }
    }

    /**
     * Whether a pointer icon will be shown over the location of a
     * stylus pointer.
     * @hide
     */
    public static boolean isStylusPointerIconEnabled(@NonNull Context context) {
        return context.getResources()
                       .getBoolean(com.android.internal.R.bool.config_enableStylusPointerIcon)
               || InputProperties.force_enable_stylus_pointer_icon().orElse(false);
    }
}
}
+30 −13
Original line number Original line Diff line number Diff line
@@ -133,7 +133,9 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.GradientDrawable;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager.DisplayListener;
import android.hardware.display.DisplayManager.DisplayListener;
import android.hardware.input.InputManager;
import android.hardware.display.DisplayManagerGlobal;
import android.hardware.input.InputManagerGlobal;
import android.hardware.input.InputSettings;
import android.media.AudioManager;
import android.media.AudioManager;
import android.os.Binder;
import android.os.Binder;
import android.os.Build;
import android.os.Build;
@@ -443,9 +445,7 @@ public final class ViewRootImpl implements ViewParent,
    @UnsupportedAppUsage
    @UnsupportedAppUsage
    final IWindowSession mWindowSession;
    final IWindowSession mWindowSession;
    @NonNull Display mDisplay;
    @NonNull Display mDisplay;
    final DisplayManager mDisplayManager;
    final String mBasePackageName;
    final String mBasePackageName;
    final InputManager mInputManager;


    final int[] mTmpLocation = new int[2];
    final int[] mTmpLocation = new int[2];


@@ -550,6 +550,9 @@ public final class ViewRootImpl implements ViewParent,
    // Whether to draw this surface as DISPLAY_DECORATION.
    // Whether to draw this surface as DISPLAY_DECORATION.
    boolean mDisplayDecorationCached = false;
    boolean mDisplayDecorationCached = false;


    // Is the stylus pointer icon enabled
    private final boolean mIsStylusPointerIconEnabled;

    /**
    /**
     * Update the Choreographer's FrameInfo object with the timing information for the current
     * Update the Choreographer's FrameInfo object with the timing information for the current
     * ViewRootImpl instance. Erase the data in the current ViewFrameInfo to prepare for the next
     * ViewRootImpl instance. Erase the data in the current ViewFrameInfo to prepare for the next
@@ -994,14 +997,14 @@ public final class ViewRootImpl implements ViewParent,
        mFallbackEventHandler = new PhoneFallbackEventHandler(context);
        mFallbackEventHandler = new PhoneFallbackEventHandler(context);
        // TODO(b/222696368): remove getSfInstance usage and use vsyncId for transactions
        // TODO(b/222696368): remove getSfInstance usage and use vsyncId for transactions
        mChoreographer = Choreographer.getInstance();
        mChoreographer = Choreographer.getInstance();
        mDisplayManager = (DisplayManager)context.getSystemService(Context.DISPLAY_SERVICE);
        mInputManager = context.getSystemService(InputManager.class);
        mInsetsController = new InsetsController(new ViewRootInsetsControllerHost(this));
        mInsetsController = new InsetsController(new ViewRootInsetsControllerHost(this));
        mHandwritingInitiator = new HandwritingInitiator(
        mHandwritingInitiator = new HandwritingInitiator(
                mViewConfiguration,
                mViewConfiguration,
                mContext.getSystemService(InputMethodManager.class));
                mContext.getSystemService(InputMethodManager.class));


        mViewBoundsSandboxingEnabled = getViewBoundsSandboxingEnabled();
        mViewBoundsSandboxingEnabled = getViewBoundsSandboxingEnabled();
        mIsStylusPointerIconEnabled =
                InputSettings.isStylusPointerIconEnabled(mContext);


        String processorOverrideName = context.getResources().getString(
        String processorOverrideName = context.getResources().getString(
                                    R.string.config_inputEventCompatProcessorOverrideClassName);
                                    R.string.config_inputEventCompatProcessorOverrideClassName);
@@ -1488,7 +1491,14 @@ public final class ViewRootImpl implements ViewParent,
                mAccessibilityInteractionConnectionManager, mHandler);
                mAccessibilityInteractionConnectionManager, mHandler);
        mAccessibilityManager.addHighTextContrastStateChangeListener(
        mAccessibilityManager.addHighTextContrastStateChangeListener(
                mHighContrastTextManager, mHandler);
                mHighContrastTextManager, mHandler);
        mDisplayManager.registerDisplayListener(mDisplayListener, mHandler);
        DisplayManagerGlobal
                .getInstance()
                .registerDisplayListener(
                        mDisplayListener,
                        mHandler,
                        DisplayManager.EVENT_FLAG_DISPLAY_ADDED
                        | DisplayManager.EVENT_FLAG_DISPLAY_CHANGED
                        | DisplayManager.EVENT_FLAG_DISPLAY_REMOVED);
    }
    }


    /**
    /**
@@ -1499,7 +1509,9 @@ public final class ViewRootImpl implements ViewParent,
                mAccessibilityInteractionConnectionManager);
                mAccessibilityInteractionConnectionManager);
        mAccessibilityManager.removeHighTextContrastStateChangeListener(
        mAccessibilityManager.removeHighTextContrastStateChangeListener(
                mHighContrastTextManager);
                mHighContrastTextManager);
        mDisplayManager.unregisterDisplayListener(mDisplayListener);
        DisplayManagerGlobal
                .getInstance()
                .unregisterDisplayListener(mDisplayListener);
    }
    }


    private void setTag() {
    private void setTag() {
@@ -5382,7 +5394,9 @@ public final class ViewRootImpl implements ViewParent,
            Log.e(mTag, "No input channel to request Pointer Capture.");
            Log.e(mTag, "No input channel to request Pointer Capture.");
            return;
            return;
        }
        }
        mInputManager.requestPointerCapture(inputToken, enabled);
        InputManagerGlobal
                .getInstance()
                .requestPointerCapture(inputToken, enabled);
    }
    }


    private void handlePointerCaptureChanged(boolean hasCapture) {
    private void handlePointerCaptureChanged(boolean hasCapture) {
@@ -6947,7 +6961,7 @@ public final class ViewRootImpl implements ViewParent,
            }
            }
            final boolean needsStylusPointerIcon = event.isStylusPointer()
            final boolean needsStylusPointerIcon = event.isStylusPointer()
                    && event.isHoverEvent()
                    && event.isHoverEvent()
                    && mInputManager.isStylusPointerIconEnabled();
                    && mIsStylusPointerIconEnabled;
            if (needsStylusPointerIcon || event.isFromSource(InputDevice.SOURCE_MOUSE)) {
            if (needsStylusPointerIcon || event.isFromSource(InputDevice.SOURCE_MOUSE)) {
                if (event.getActionMasked() == MotionEvent.ACTION_HOVER_ENTER
                if (event.getActionMasked() == MotionEvent.ACTION_HOVER_ENTER
                        || event.getActionMasked() == MotionEvent.ACTION_HOVER_EXIT) {
                        || event.getActionMasked() == MotionEvent.ACTION_HOVER_EXIT) {
@@ -7018,8 +7032,7 @@ public final class ViewRootImpl implements ViewParent,
        }
        }


        PointerIcon pointerIcon = null;
        PointerIcon pointerIcon = null;

        if (event.isStylusPointer() && mIsStylusPointerIconEnabled) {
        if (event.isStylusPointer() && mInputManager.isStylusPointerIconEnabled()) {
            pointerIcon = mHandwritingInitiator.onResolvePointerIcon(mContext, event);
            pointerIcon = mHandwritingInitiator.onResolvePointerIcon(mContext, event);
        }
        }


@@ -7034,14 +7047,18 @@ public final class ViewRootImpl implements ViewParent,
            mPointerIconType = pointerType;
            mPointerIconType = pointerType;
            mCustomPointerIcon = null;
            mCustomPointerIcon = null;
            if (mPointerIconType != PointerIcon.TYPE_CUSTOM) {
            if (mPointerIconType != PointerIcon.TYPE_CUSTOM) {
                mInputManager.setPointerIconType(pointerType);
                InputManagerGlobal
                    .getInstance()
                    .setPointerIconType(pointerType);
                return true;
                return true;
            }
            }
        }
        }
        if (mPointerIconType == PointerIcon.TYPE_CUSTOM &&
        if (mPointerIconType == PointerIcon.TYPE_CUSTOM &&
                !pointerIcon.equals(mCustomPointerIcon)) {
                !pointerIcon.equals(mCustomPointerIcon)) {
            mCustomPointerIcon = pointerIcon;
            mCustomPointerIcon = pointerIcon;
            mInputManager.setCustomPointerIcon(mCustomPointerIcon);
            InputManagerGlobal
                    .getInstance()
                    .setCustomPointerIcon(mCustomPointerIcon);
        }
        }
        return true;
        return true;
    }
    }
+0 −7
Original line number Original line Diff line number Diff line
@@ -82,13 +82,6 @@ public class DecorContext extends ContextThemeWrapper {
            }
            }
            return mContentCaptureManager;
            return mContentCaptureManager;
        }
        }
        // TODO(b/154191411): Try to revisit this issue in S.
        // We use application to get DisplayManager here because ViewRootImpl holds reference of
        // DisplayManager and implicitly holds reference of mContext, which makes activity cannot
        // be GC'd even after destroyed if mContext is an activity object.
        if (Context.DISPLAY_SERVICE.equals(name)) {
            return super.getSystemService(name);
        }
        // LayoutInflater and WallpaperManagerService should also be obtained from visual context
        // LayoutInflater and WallpaperManagerService should also be obtained from visual context
        // instead of base context.
        // instead of base context.
        return (context != null) ? context.getSystemService(name) : super.getSystemService(name);
        return (context != null) ? context.getSystemService(name) : super.getSystemService(name);