Loading services/core/java/com/android/server/input/InputManagerService.java +4 −7 Original line number Diff line number Diff line Loading @@ -547,6 +547,10 @@ public class InputManagerService extends IInputManager.Stub mBatteryController.systemRunning(); mKeyboardBacklightController.systemRunning(); mKeyRemapper.systemRunning(); mNative.setStylusPointerIconEnabled( Objects.requireNonNull(mContext.getSystemService(InputManager.class)) .isStylusPointerIconEnabled()); } private void reloadDeviceAliases() { Loading Loading @@ -2749,13 +2753,6 @@ 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; Loading services/core/java/com/android/server/input/NativeInputManagerService.java +6 −0 Original line number Diff line number Diff line Loading @@ -234,6 +234,9 @@ interface NativeInputManagerService { */ float[] getMouseCursorPosition(); /** Set whether showing a pointer icon for styluses is enabled. */ void setStylusPointerIconEnabled(boolean enabled); /** The native implementation of InputManagerService methods. */ class NativeImpl implements NativeInputManagerService { /** Pointer to native input manager service object, used by native code. */ Loading Loading @@ -478,5 +481,8 @@ interface NativeInputManagerService { @Override public native float[] getMouseCursorPosition(); @Override public native void setStylusPointerIconEnabled(boolean enabled); } } services/core/jni/com_android_server_input_InputManagerService.cpp +28 −10 Original line number Diff line number Diff line Loading @@ -137,7 +137,6 @@ static struct { jmethodID notifyDropWindow; jmethodID getParentSurfaceForPointers; jmethodID isPerDisplayTouchModeEnabled; jmethodID isStylusPointerIconEnabled; } gServiceClassInfo; static struct { Loading Loading @@ -309,6 +308,7 @@ public: std::optional<std::string> getBluetoothAddress(int32_t deviceId); void setStylusButtonMotionEventsEnabled(bool enabled); FloatPoint getMouseCursorPosition(); void setStylusPointerIconEnabled(bool enabled); /* --- InputReaderPolicyInterface implementation --- */ Loading Loading @@ -430,6 +430,9 @@ private: // True to enable a zone on the right-hand side of touchpads where clicks will be turned // into context (a.k.a. "right") clicks. bool touchpadRightClickZoneEnabled{false}; // True if a pointer icon should be shown for stylus pointers. bool stylusPointerIconEnabled{false}; } mLocked GUARDED_BY(mLock); std::atomic<bool> mInteractive; Loading Loading @@ -662,12 +665,6 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon outConfig->pointerGestureTapSlop = hoverTapSlop; } jboolean stylusPointerIconEnabled = env->CallBooleanMethod(mServiceObj, gServiceClassInfo.isStylusPointerIconEnabled); if (!checkAndClearExceptionFromCallback(env, "isStylusPointerIconEnabled")) { outConfig->stylusPointerIconEnabled = stylusPointerIconEnabled; } { // acquire lock std::scoped_lock _l(mLock); Loading @@ -692,6 +689,8 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon outConfig->disabledDevices = mLocked.disabledInputDevices; outConfig->stylusButtonMotionEventsEnabled = mLocked.stylusButtonMotionEventsEnabled; outConfig->stylusPointerIconEnabled = mLocked.stylusPointerIconEnabled; } // release lock } Loading Loading @@ -1664,6 +1663,21 @@ FloatPoint NativeInputManager::getMouseCursorPosition() { return pc->getPosition(); } void NativeInputManager::setStylusPointerIconEnabled(bool enabled) { { // acquire lock std::scoped_lock _l(mLock); if (mLocked.stylusPointerIconEnabled == enabled) { return; } mLocked.stylusPointerIconEnabled = enabled; } // release lock mInputManager->getReader().requestRefreshConfiguration( InputReaderConfiguration::CHANGE_DISPLAY_INFO); } // ---------------------------------------------------------------------------- static NativeInputManager* getNativeInputManager(JNIEnv* env, jobject clazz) { Loading Loading @@ -2565,6 +2579,12 @@ static jfloatArray nativeGetMouseCursorPosition(JNIEnv* env, jobject nativeImplO return outArr; } static void nativeSetStylusPointerIconEnabled(JNIEnv* env, jobject nativeImplObj, jboolean enabled) { NativeInputManager* im = getNativeInputManager(env, nativeImplObj); im->setStylusPointerIconEnabled(enabled); } // ---------------------------------------------------------------------------- static const JNINativeMethod gInputManagerMethods[] = { Loading Loading @@ -2659,6 +2679,7 @@ static const JNINativeMethod gInputManagerMethods[] = { {"setStylusButtonMotionEventsEnabled", "(Z)V", (void*)nativeSetStylusButtonMotionEventsEnabled}, {"getMouseCursorPosition", "()[F", (void*)nativeGetMouseCursorPosition}, {"setStylusPointerIconEnabled", "(Z)V", (void*)nativeSetStylusPointerIconEnabled}, }; #define FIND_CLASS(var, className) \ Loading Loading @@ -2819,9 +2840,6 @@ 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"); Loading Loading
services/core/java/com/android/server/input/InputManagerService.java +4 −7 Original line number Diff line number Diff line Loading @@ -547,6 +547,10 @@ public class InputManagerService extends IInputManager.Stub mBatteryController.systemRunning(); mKeyboardBacklightController.systemRunning(); mKeyRemapper.systemRunning(); mNative.setStylusPointerIconEnabled( Objects.requireNonNull(mContext.getSystemService(InputManager.class)) .isStylusPointerIconEnabled()); } private void reloadDeviceAliases() { Loading Loading @@ -2749,13 +2753,6 @@ 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; Loading
services/core/java/com/android/server/input/NativeInputManagerService.java +6 −0 Original line number Diff line number Diff line Loading @@ -234,6 +234,9 @@ interface NativeInputManagerService { */ float[] getMouseCursorPosition(); /** Set whether showing a pointer icon for styluses is enabled. */ void setStylusPointerIconEnabled(boolean enabled); /** The native implementation of InputManagerService methods. */ class NativeImpl implements NativeInputManagerService { /** Pointer to native input manager service object, used by native code. */ Loading Loading @@ -478,5 +481,8 @@ interface NativeInputManagerService { @Override public native float[] getMouseCursorPosition(); @Override public native void setStylusPointerIconEnabled(boolean enabled); } }
services/core/jni/com_android_server_input_InputManagerService.cpp +28 −10 Original line number Diff line number Diff line Loading @@ -137,7 +137,6 @@ static struct { jmethodID notifyDropWindow; jmethodID getParentSurfaceForPointers; jmethodID isPerDisplayTouchModeEnabled; jmethodID isStylusPointerIconEnabled; } gServiceClassInfo; static struct { Loading Loading @@ -309,6 +308,7 @@ public: std::optional<std::string> getBluetoothAddress(int32_t deviceId); void setStylusButtonMotionEventsEnabled(bool enabled); FloatPoint getMouseCursorPosition(); void setStylusPointerIconEnabled(bool enabled); /* --- InputReaderPolicyInterface implementation --- */ Loading Loading @@ -430,6 +430,9 @@ private: // True to enable a zone on the right-hand side of touchpads where clicks will be turned // into context (a.k.a. "right") clicks. bool touchpadRightClickZoneEnabled{false}; // True if a pointer icon should be shown for stylus pointers. bool stylusPointerIconEnabled{false}; } mLocked GUARDED_BY(mLock); std::atomic<bool> mInteractive; Loading Loading @@ -662,12 +665,6 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon outConfig->pointerGestureTapSlop = hoverTapSlop; } jboolean stylusPointerIconEnabled = env->CallBooleanMethod(mServiceObj, gServiceClassInfo.isStylusPointerIconEnabled); if (!checkAndClearExceptionFromCallback(env, "isStylusPointerIconEnabled")) { outConfig->stylusPointerIconEnabled = stylusPointerIconEnabled; } { // acquire lock std::scoped_lock _l(mLock); Loading @@ -692,6 +689,8 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon outConfig->disabledDevices = mLocked.disabledInputDevices; outConfig->stylusButtonMotionEventsEnabled = mLocked.stylusButtonMotionEventsEnabled; outConfig->stylusPointerIconEnabled = mLocked.stylusPointerIconEnabled; } // release lock } Loading Loading @@ -1664,6 +1663,21 @@ FloatPoint NativeInputManager::getMouseCursorPosition() { return pc->getPosition(); } void NativeInputManager::setStylusPointerIconEnabled(bool enabled) { { // acquire lock std::scoped_lock _l(mLock); if (mLocked.stylusPointerIconEnabled == enabled) { return; } mLocked.stylusPointerIconEnabled = enabled; } // release lock mInputManager->getReader().requestRefreshConfiguration( InputReaderConfiguration::CHANGE_DISPLAY_INFO); } // ---------------------------------------------------------------------------- static NativeInputManager* getNativeInputManager(JNIEnv* env, jobject clazz) { Loading Loading @@ -2565,6 +2579,12 @@ static jfloatArray nativeGetMouseCursorPosition(JNIEnv* env, jobject nativeImplO return outArr; } static void nativeSetStylusPointerIconEnabled(JNIEnv* env, jobject nativeImplObj, jboolean enabled) { NativeInputManager* im = getNativeInputManager(env, nativeImplObj); im->setStylusPointerIconEnabled(enabled); } // ---------------------------------------------------------------------------- static const JNINativeMethod gInputManagerMethods[] = { Loading Loading @@ -2659,6 +2679,7 @@ static const JNINativeMethod gInputManagerMethods[] = { {"setStylusButtonMotionEventsEnabled", "(Z)V", (void*)nativeSetStylusButtonMotionEventsEnabled}, {"getMouseCursorPosition", "()[F", (void*)nativeGetMouseCursorPosition}, {"setStylusPointerIconEnabled", "(Z)V", (void*)nativeSetStylusPointerIconEnabled}, }; #define FIND_CLASS(var, className) \ Loading Loading @@ -2819,9 +2840,6 @@ 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"); Loading