From 492922a6e815faa2da02bc27883f4195aceb2b8a Mon Sep 17 00:00:00 2001 From: Seunghwan Choi Date: Tue, 17 Jan 2023 20:47:47 +0900 Subject: [PATCH] check config for showing a stylus pointer (frameworks/base part) On InputReader, get the configuration from config.xml to decide whether to show a stylus pointer. Test: Manual Test(hover pointer on handwriting area) Bug: b/215436642 Change-Id: Ia08052f97e027c48d3bbc76ad03988722a7d9e2f --- .../com/android/server/input/InputManagerService.java | 7 +++++++ .../com_android_server_input_InputManagerService.cpp | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java index e2caeec114d0a..a752c15921832 100644 --- a/services/core/java/com/android/server/input/InputManagerService.java +++ b/services/core/java/com/android/server/input/InputManagerService.java @@ -2974,6 +2974,13 @@ public class InputManagerService extends IInputManager.Stub return null; } + // Native callback. + @SuppressWarnings("unused") + private boolean isStylusPointerIconEnabled() { + return Objects.requireNonNull(mContext.getSystemService(InputManager.class)) + .isStylusPointerIconEnabled(); + } + private static class PointerDisplayIdChangedArgs { final int mPointerDisplayId; final float mXPosition; diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp index 56ccf872d2f63..b4e2fb6ca3e3f 100644 --- a/services/core/jni/com_android_server_input_InputManagerService.cpp +++ b/services/core/jni/com_android_server_input_InputManagerService.cpp @@ -137,6 +137,7 @@ static struct { jmethodID notifyDropWindow; jmethodID getParentSurfaceForPointers; jmethodID isPerDisplayTouchModeEnabled; + jmethodID isStylusPointerIconEnabled; } gServiceClassInfo; static struct { @@ -660,6 +661,12 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon outConfig->pointerGestureTapSlop = hoverTapSlop; } + jboolean stylusPointerIconEnabled = + env->CallBooleanMethod(mServiceObj, gServiceClassInfo.isStylusPointerIconEnabled); + if (!checkAndClearExceptionFromCallback(env, "isStylusPointerIconEnabled")) { + outConfig->stylusPointerIconEnabled = stylusPointerIconEnabled; + } + { // acquire lock AutoMutex _l(mLock); @@ -2793,6 +2800,9 @@ int register_android_server_InputManager(JNIEnv* env) { GET_METHOD_ID(gServiceClassInfo.isPerDisplayTouchModeEnabled, clazz, "isPerDisplayTouchModeEnabled", "()Z"); + GET_METHOD_ID(gServiceClassInfo.isStylusPointerIconEnabled, clazz, "isStylusPointerIconEnabled", + "()Z"); + // InputDevice FIND_CLASS(gInputDeviceClassInfo.clazz, "android/view/InputDevice");