Loading core/java/android/hardware/input/InputManager.java +1 −4 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading core/java/android/hardware/input/InputManagerGlobal.java +1 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading core/java/android/hardware/input/InputSettings.java +12 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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); } } core/java/android/view/ViewRootImpl.java +30 −13 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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]; Loading Loading @@ -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 Loading Loading @@ -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); Loading Loading @@ -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); } /** Loading @@ -1499,7 +1509,9 @@ public final class ViewRootImpl implements ViewParent, mAccessibilityInteractionConnectionManager); mAccessibilityManager.removeHighTextContrastStateChangeListener( mHighContrastTextManager); mDisplayManager.unregisterDisplayListener(mDisplayListener); DisplayManagerGlobal .getInstance() .unregisterDisplayListener(mDisplayListener); } private void setTag() { Loading Loading @@ -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) { Loading Loading @@ -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) { Loading Loading @@ -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); } Loading @@ -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; } Loading core/java/com/android/internal/policy/DecorContext.java +0 −7 Original line number Diff line number Diff line Loading @@ -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); Loading Loading
core/java/android/hardware/input/InputManager.java +1 −4 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading
core/java/android/hardware/input/InputManagerGlobal.java +1 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading
core/java/android/hardware/input/InputSettings.java +12 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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); } }
core/java/android/view/ViewRootImpl.java +30 −13 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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]; Loading Loading @@ -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 Loading Loading @@ -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); Loading Loading @@ -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); } /** Loading @@ -1499,7 +1509,9 @@ public final class ViewRootImpl implements ViewParent, mAccessibilityInteractionConnectionManager); mAccessibilityManager.removeHighTextContrastStateChangeListener( mHighContrastTextManager); mDisplayManager.unregisterDisplayListener(mDisplayListener); DisplayManagerGlobal .getInstance() .unregisterDisplayListener(mDisplayListener); } private void setTag() { Loading Loading @@ -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) { Loading Loading @@ -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) { Loading Loading @@ -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); } Loading @@ -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; } Loading
core/java/com/android/internal/policy/DecorContext.java +0 −7 Original line number Diff line number Diff line Loading @@ -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); Loading