Loading services/core/java/com/android/server/input/InputManagerInternal.java +7 −0 Original line number Diff line number Diff line Loading @@ -206,4 +206,11 @@ public abstract class InputManagerInternal { * @param inputPort The port of the input device. */ public abstract void removeKeyboardLayoutAssociation(@NonNull String inputPort); /** * Set whether stylus button reporting through motion events should be enabled. * * @param enabled When true, stylus buttons will not be reported through motion events. */ public abstract void setStylusButtonMotionEventsEnabled(boolean enabled); } services/core/java/com/android/server/input/InputManagerService.java +5 −0 Original line number Diff line number Diff line Loading @@ -3383,6 +3383,11 @@ public class InputManagerService extends IInputManager.Stub public void removeKeyboardLayoutAssociation(@NonNull String inputPort) { InputManagerService.this.removeKeyboardLayoutAssociation(inputPort); } @Override public void setStylusButtonMotionEventsEnabled(boolean enabled) { mNative.setStylusButtonMotionEventsEnabled(enabled); } } @Override Loading services/core/java/com/android/server/input/NativeInputManagerService.java +6 −0 Original line number Diff line number Diff line Loading @@ -213,6 +213,9 @@ interface NativeInputManagerService { /** Get the bluetooth address of an input device if known, otherwise return null. */ String getBluetoothAddress(int deviceId); /** Set whether stylus button reporting through motion events should be enabled. */ void setStylusButtonMotionEventsEnabled(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 @@ -439,5 +442,8 @@ interface NativeInputManagerService { @Override public native String getBluetoothAddress(int deviceId); @Override public native void setStylusButtonMotionEventsEnabled(boolean enabled); } } services/core/java/com/android/server/policy/PhoneWindowManager.java +1 −0 Original line number Diff line number Diff line Loading @@ -2577,6 +2577,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { mStylusButtonsDisabled = Settings.Secure.getIntForUser(resolver, Secure.STYLUS_BUTTONS_DISABLED, 0, UserHandle.USER_CURRENT) == 1; mInputManagerInternal.setStylusButtonMotionEventsEnabled(!mStylusButtonsDisabled); } if (updateRotation) { updateRotation(true); Loading services/core/jni/com_android_server_input_InputManagerService.cpp +29 −0 Original line number Diff line number Diff line Loading @@ -302,6 +302,7 @@ public: void setCustomPointerIcon(const SpriteIcon& icon); void setMotionClassifierEnabled(bool enabled); std::optional<std::string> getBluetoothAddress(int32_t deviceId); void setStylusButtonMotionEventsEnabled(bool enabled); /* --- InputReaderPolicyInterface implementation --- */ Loading Loading @@ -405,6 +406,9 @@ private: // Associated Pointer controller display. int32_t pointerDisplayId{ADISPLAY_ID_DEFAULT}; // True if stylus button reporting through motion events is enabled. bool stylusButtonMotionEventsEnabled{true}; } mLocked GUARDED_BY(mLock); std::atomic<bool> mInteractive; Loading Loading @@ -654,6 +658,8 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon outConfig->defaultPointerDisplayId = mLocked.pointerDisplayId; outConfig->disabledDevices = mLocked.disabledInputDevices; outConfig->stylusButtonMotionEventsEnabled = mLocked.stylusButtonMotionEventsEnabled; } // release lock } Loading Loading @@ -1524,6 +1530,21 @@ std::optional<std::string> NativeInputManager::getBluetoothAddress(int32_t devic return mInputManager->getReader().getBluetoothAddress(deviceId); } void NativeInputManager::setStylusButtonMotionEventsEnabled(bool enabled) { { // acquire lock AutoMutex _l(mLock); if (mLocked.stylusButtonMotionEventsEnabled == enabled) { return; } mLocked.stylusButtonMotionEventsEnabled = enabled; } // release lock mInputManager->getReader().requestRefreshConfiguration( InputReaderConfiguration::CHANGE_STYLUS_BUTTON_REPORTING); } bool NativeInputManager::isPerDisplayTouchModeEnabled() { JNIEnv* env = jniEnv(); jboolean enabled = Loading Loading @@ -2393,6 +2414,12 @@ static jstring nativeGetBluetoothAddress(JNIEnv* env, jobject nativeImplObj, jin return address ? env->NewStringUTF(address->c_str()) : nullptr; } static void nativeSetStylusButtonMotionEventsEnabled(JNIEnv* env, jobject nativeImplObj, jboolean enabled) { NativeInputManager* im = getNativeInputManager(env, nativeImplObj); im->setStylusButtonMotionEventsEnabled(enabled); } // ---------------------------------------------------------------------------- static const JNINativeMethod gInputManagerMethods[] = { Loading Loading @@ -2479,6 +2506,8 @@ static const JNINativeMethod gInputManagerMethods[] = { {"cancelCurrentTouch", "()V", (void*)nativeCancelCurrentTouch}, {"setPointerDisplayId", "(I)V", (void*)nativeSetPointerDisplayId}, {"getBluetoothAddress", "(I)Ljava/lang/String;", (void*)nativeGetBluetoothAddress}, {"setStylusButtonMotionEventsEnabled", "(Z)V", (void*)nativeSetStylusButtonMotionEventsEnabled}, }; #define FIND_CLASS(var, className) \ Loading Loading
services/core/java/com/android/server/input/InputManagerInternal.java +7 −0 Original line number Diff line number Diff line Loading @@ -206,4 +206,11 @@ public abstract class InputManagerInternal { * @param inputPort The port of the input device. */ public abstract void removeKeyboardLayoutAssociation(@NonNull String inputPort); /** * Set whether stylus button reporting through motion events should be enabled. * * @param enabled When true, stylus buttons will not be reported through motion events. */ public abstract void setStylusButtonMotionEventsEnabled(boolean enabled); }
services/core/java/com/android/server/input/InputManagerService.java +5 −0 Original line number Diff line number Diff line Loading @@ -3383,6 +3383,11 @@ public class InputManagerService extends IInputManager.Stub public void removeKeyboardLayoutAssociation(@NonNull String inputPort) { InputManagerService.this.removeKeyboardLayoutAssociation(inputPort); } @Override public void setStylusButtonMotionEventsEnabled(boolean enabled) { mNative.setStylusButtonMotionEventsEnabled(enabled); } } @Override Loading
services/core/java/com/android/server/input/NativeInputManagerService.java +6 −0 Original line number Diff line number Diff line Loading @@ -213,6 +213,9 @@ interface NativeInputManagerService { /** Get the bluetooth address of an input device if known, otherwise return null. */ String getBluetoothAddress(int deviceId); /** Set whether stylus button reporting through motion events should be enabled. */ void setStylusButtonMotionEventsEnabled(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 @@ -439,5 +442,8 @@ interface NativeInputManagerService { @Override public native String getBluetoothAddress(int deviceId); @Override public native void setStylusButtonMotionEventsEnabled(boolean enabled); } }
services/core/java/com/android/server/policy/PhoneWindowManager.java +1 −0 Original line number Diff line number Diff line Loading @@ -2577,6 +2577,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { mStylusButtonsDisabled = Settings.Secure.getIntForUser(resolver, Secure.STYLUS_BUTTONS_DISABLED, 0, UserHandle.USER_CURRENT) == 1; mInputManagerInternal.setStylusButtonMotionEventsEnabled(!mStylusButtonsDisabled); } if (updateRotation) { updateRotation(true); Loading
services/core/jni/com_android_server_input_InputManagerService.cpp +29 −0 Original line number Diff line number Diff line Loading @@ -302,6 +302,7 @@ public: void setCustomPointerIcon(const SpriteIcon& icon); void setMotionClassifierEnabled(bool enabled); std::optional<std::string> getBluetoothAddress(int32_t deviceId); void setStylusButtonMotionEventsEnabled(bool enabled); /* --- InputReaderPolicyInterface implementation --- */ Loading Loading @@ -405,6 +406,9 @@ private: // Associated Pointer controller display. int32_t pointerDisplayId{ADISPLAY_ID_DEFAULT}; // True if stylus button reporting through motion events is enabled. bool stylusButtonMotionEventsEnabled{true}; } mLocked GUARDED_BY(mLock); std::atomic<bool> mInteractive; Loading Loading @@ -654,6 +658,8 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon outConfig->defaultPointerDisplayId = mLocked.pointerDisplayId; outConfig->disabledDevices = mLocked.disabledInputDevices; outConfig->stylusButtonMotionEventsEnabled = mLocked.stylusButtonMotionEventsEnabled; } // release lock } Loading Loading @@ -1524,6 +1530,21 @@ std::optional<std::string> NativeInputManager::getBluetoothAddress(int32_t devic return mInputManager->getReader().getBluetoothAddress(deviceId); } void NativeInputManager::setStylusButtonMotionEventsEnabled(bool enabled) { { // acquire lock AutoMutex _l(mLock); if (mLocked.stylusButtonMotionEventsEnabled == enabled) { return; } mLocked.stylusButtonMotionEventsEnabled = enabled; } // release lock mInputManager->getReader().requestRefreshConfiguration( InputReaderConfiguration::CHANGE_STYLUS_BUTTON_REPORTING); } bool NativeInputManager::isPerDisplayTouchModeEnabled() { JNIEnv* env = jniEnv(); jboolean enabled = Loading Loading @@ -2393,6 +2414,12 @@ static jstring nativeGetBluetoothAddress(JNIEnv* env, jobject nativeImplObj, jin return address ? env->NewStringUTF(address->c_str()) : nullptr; } static void nativeSetStylusButtonMotionEventsEnabled(JNIEnv* env, jobject nativeImplObj, jboolean enabled) { NativeInputManager* im = getNativeInputManager(env, nativeImplObj); im->setStylusButtonMotionEventsEnabled(enabled); } // ---------------------------------------------------------------------------- static const JNINativeMethod gInputManagerMethods[] = { Loading Loading @@ -2479,6 +2506,8 @@ static const JNINativeMethod gInputManagerMethods[] = { {"cancelCurrentTouch", "()V", (void*)nativeCancelCurrentTouch}, {"setPointerDisplayId", "(I)V", (void*)nativeSetPointerDisplayId}, {"getBluetoothAddress", "(I)Ljava/lang/String;", (void*)nativeGetBluetoothAddress}, {"setStylusButtonMotionEventsEnabled", "(Z)V", (void*)nativeSetStylusButtonMotionEventsEnabled}, }; #define FIND_CLASS(var, className) \ Loading