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

Commit 4ceed60b authored by Josep del Río's avatar Josep del Río Committed by Android (Google) Code Review
Browse files

Merge "Remove InputManager and DisplayManager from ViewRootImpl" into udc-dev

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

/**
 * 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,
                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 Diff line number Diff line
@@ -133,7 +133,9 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.hardware.display.DisplayManager;
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.os.Binder;
import android.os.Build;
@@ -443,9 +445,7 @@ public final class ViewRootImpl implements ViewParent,
    @UnsupportedAppUsage
    final IWindowSession mWindowSession;
    @NonNull Display mDisplay;
    final DisplayManager mDisplayManager;
    final String mBasePackageName;
    final InputManager mInputManager;

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

@@ -550,6 +550,9 @@ public final class ViewRootImpl implements ViewParent,
    // Whether to draw this surface as DISPLAY_DECORATION.
    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
     * 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);
        // TODO(b/222696368): remove getSfInstance usage and use vsyncId for transactions
        mChoreographer = Choreographer.getInstance();
        mDisplayManager = (DisplayManager)context.getSystemService(Context.DISPLAY_SERVICE);
        mInputManager = context.getSystemService(InputManager.class);
        mInsetsController = new InsetsController(new ViewRootInsetsControllerHost(this));
        mHandwritingInitiator = new HandwritingInitiator(
                mViewConfiguration,
                mContext.getSystemService(InputMethodManager.class));

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

        String processorOverrideName = context.getResources().getString(
                                    R.string.config_inputEventCompatProcessorOverrideClassName);
@@ -1488,7 +1491,14 @@ public final class ViewRootImpl implements ViewParent,
                mAccessibilityInteractionConnectionManager, mHandler);
        mAccessibilityManager.addHighTextContrastStateChangeListener(
                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);
        mAccessibilityManager.removeHighTextContrastStateChangeListener(
                mHighContrastTextManager);
        mDisplayManager.unregisterDisplayListener(mDisplayListener);
        DisplayManagerGlobal
                .getInstance()
                .unregisterDisplayListener(mDisplayListener);
    }

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

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

        PointerIcon pointerIcon = null;

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

@@ -7034,14 +7047,18 @@ public final class ViewRootImpl implements ViewParent,
            mPointerIconType = pointerType;
            mCustomPointerIcon = null;
            if (mPointerIconType != PointerIcon.TYPE_CUSTOM) {
                mInputManager.setPointerIconType(pointerType);
                InputManagerGlobal
                    .getInstance()
                    .setPointerIconType(pointerType);
                return true;
            }
        }
        if (mPointerIconType == PointerIcon.TYPE_CUSTOM &&
                !pointerIcon.equals(mCustomPointerIcon)) {
            mCustomPointerIcon = pointerIcon;
            mInputManager.setCustomPointerIcon(mCustomPointerIcon);
            InputManagerGlobal
                    .getInstance()
                    .setCustomPointerIcon(mCustomPointerIcon);
        }
        return true;
    }
+0 −7
Original line number Diff line number Diff line
@@ -82,13 +82,6 @@ public class DecorContext extends ContextThemeWrapper {
            }
            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
        // instead of base context.
        return (context != null) ? context.getSystemService(name) : super.getSystemService(name);