Loading core/java/android/hardware/input/InputSettings.java +33 −0 Original line number Diff line number Diff line Loading @@ -335,6 +335,39 @@ public class InputSettings { return touchpadVisualizer(); } /** * Returns true if the touchpad visualizer is allowed to appear. * * @param context The application context. * @return Whether it is allowed to show touchpad visualizer or not. * * @hide */ public static boolean useTouchpadVisualizer(@NonNull Context context) { if (!isTouchpadVisualizerFeatureFlagEnabled()) { return false; } return Settings.System.getIntForUser(context.getContentResolver(), Settings.System.TOUCHPAD_VISUALIZER, 0, UserHandle.USER_CURRENT) == 1; } /** * Sets the touchpad visualizer behaviour. * * @param context The application context. * @param enabled Will enable touchpad visualizer if true, disable it if false * * @hide */ @RequiresPermission(Manifest.permission.WRITE_SETTINGS) public static void setTouchpadVisualizer(@NonNull Context context, boolean enabled) { if (!isTouchpadVisualizerFeatureFlagEnabled()) { return; } Settings.System.putIntForUser(context.getContentResolver(), Settings.System.TOUCHPAD_VISUALIZER, enabled ? 1 : 0, UserHandle.USER_CURRENT); } /** * Returns true if the touchpad should allow tap dragging. * Loading services/core/java/com/android/server/input/InputSettingsObserver.java +6 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,8 @@ class InputSettingsObserver extends ContentObserver { (reason) -> updateTouchpadTapToClickEnabled()), Map.entry(Settings.System.getUriFor(Settings.System.TOUCHPAD_TAP_DRAGGING), (reason) -> updateTouchpadTapDraggingEnabled()), Map.entry(Settings.System.getUriFor(Settings.System.TOUCHPAD_VISUALIZER), (reason) -> updateTouchpadHardwareStateNotificationsEnabled()), Map.entry(Settings.System.getUriFor(Settings.System.TOUCHPAD_RIGHT_CLICK_ZONE), (reason) -> updateTouchpadRightClickZoneEnabled()), Map.entry(Settings.System.getUriFor(Settings.System.SHOW_TOUCHES), Loading Loading @@ -177,6 +179,10 @@ class InputSettingsObserver extends ContentObserver { mNative.setTouchpadTapDraggingEnabled(InputSettings.useTouchpadTapDragging(mContext)); } private void updateTouchpadHardwareStateNotificationsEnabled() { mNative.setShouldNotifyTouchpadHardwareState(InputSettings.useTouchpadVisualizer(mContext)); } private void updateTouchpadRightClickZoneEnabled() { mNative.setTouchpadRightClickZoneEnabled(InputSettings.useTouchpadRightClickZone(mContext)); } Loading services/core/java/com/android/server/input/NativeInputManagerService.java +5 −0 Original line number Diff line number Diff line Loading @@ -135,6 +135,8 @@ interface NativeInputManagerService { void setTouchpadTapDraggingEnabled(boolean enabled); void setShouldNotifyTouchpadHardwareState(boolean enabled); void setTouchpadRightClickZoneEnabled(boolean enabled); void setShowTouches(boolean enabled); Loading Loading @@ -394,6 +396,9 @@ interface NativeInputManagerService { @Override public native void setTouchpadTapDraggingEnabled(boolean enabled); @Override public native void setShouldNotifyTouchpadHardwareState(boolean enabled); @Override public native void setTouchpadRightClickZoneEnabled(boolean enabled); Loading services/core/jni/com_android_server_input_InputManagerService.cpp +30 −0 Original line number Diff line number Diff line Loading @@ -291,6 +291,7 @@ public: void setTouchpadNaturalScrollingEnabled(bool enabled); void setTouchpadTapToClickEnabled(bool enabled); void setTouchpadTapDraggingEnabled(bool enabled); void setShouldNotifyTouchpadHardwareState(bool enabled); void setTouchpadRightClickZoneEnabled(bool enabled); void setInputDeviceEnabled(uint32_t deviceId, bool enabled); void setShowTouches(bool enabled); Loading Loading @@ -440,6 +441,9 @@ private: // True to enable tap dragging on touchpads. bool touchpadTapDraggingEnabled{false}; // True if hardware state update notifications should be sent to the policy. bool shouldNotifyTouchpadHardwareState{false}; // 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}; Loading Loading @@ -698,6 +702,7 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon outConfig->touchpadNaturalScrollingEnabled = mLocked.touchpadNaturalScrollingEnabled; outConfig->touchpadTapToClickEnabled = mLocked.touchpadTapToClickEnabled; outConfig->touchpadTapDraggingEnabled = mLocked.touchpadTapDraggingEnabled; outConfig->shouldNotifyTouchpadHardwareState = mLocked.shouldNotifyTouchpadHardwareState; outConfig->touchpadRightClickZoneEnabled = mLocked.touchpadRightClickZoneEnabled; outConfig->disabledDevices = mLocked.disabledInputDevices; Loading Loading @@ -1260,6 +1265,22 @@ void NativeInputManager::setTouchpadTapDraggingEnabled(bool enabled) { InputReaderConfiguration::Change::TOUCHPAD_SETTINGS); } void NativeInputManager::setShouldNotifyTouchpadHardwareState(bool enabled) { { // acquire lock std::scoped_lock _l(mLock); if (mLocked.shouldNotifyTouchpadHardwareState == enabled) { return; } ALOGI("Should touchpad hardware state be notified: %s.", toString(enabled)); mLocked.shouldNotifyTouchpadHardwareState = enabled; } // release lock mInputManager->getReader().requestRefreshConfiguration( InputReaderConfiguration::Change::TOUCHPAD_SETTINGS); } void NativeInputManager::setTouchpadRightClickZoneEnabled(bool enabled) { { // acquire lock std::scoped_lock _l(mLock); Loading Loading @@ -2144,6 +2165,13 @@ static void nativeSetTouchpadTapDraggingEnabled(JNIEnv* env, jobject nativeImplO im->setTouchpadTapDraggingEnabled(enabled); } static void nativeSetShouldNotifyTouchpadHardwareState(JNIEnv* env, jobject nativeImplObj, jboolean enabled) { NativeInputManager* im = getNativeInputManager(env, nativeImplObj); im->setShouldNotifyTouchpadHardwareState(enabled); } static void nativeSetTouchpadRightClickZoneEnabled(JNIEnv* env, jobject nativeImplObj, jboolean enabled) { NativeInputManager* im = getNativeInputManager(env, nativeImplObj); Loading Loading @@ -2762,6 +2790,8 @@ static const JNINativeMethod gInputManagerMethods[] = { (void*)nativeSetTouchpadNaturalScrollingEnabled}, {"setTouchpadTapToClickEnabled", "(Z)V", (void*)nativeSetTouchpadTapToClickEnabled}, {"setTouchpadTapDraggingEnabled", "(Z)V", (void*)nativeSetTouchpadTapDraggingEnabled}, {"setShouldNotifyTouchpadHardwareState", "(Z)V", (void*)nativeSetShouldNotifyTouchpadHardwareState}, {"setTouchpadRightClickZoneEnabled", "(Z)V", (void*)nativeSetTouchpadRightClickZoneEnabled}, {"setShowTouches", "(Z)V", (void*)nativeSetShowTouches}, {"setInteractive", "(Z)V", (void*)nativeSetInteractive}, Loading tests/Input/src/com/android/server/input/InputManagerServiceTests.kt +1 −0 Original line number Diff line number Diff line Loading @@ -151,6 +151,7 @@ class InputManagerServiceTests { verify(native).setTouchpadNaturalScrollingEnabled(anyBoolean()) verify(native).setTouchpadTapToClickEnabled(anyBoolean()) verify(native).setTouchpadTapDraggingEnabled(anyBoolean()) verify(native).setShouldNotifyTouchpadHardwareState(anyBoolean()) verify(native).setTouchpadRightClickZoneEnabled(anyBoolean()) verify(native).setShowTouches(anyBoolean()) verify(native).setMotionClassifierEnabled(anyBoolean()) Loading Loading
core/java/android/hardware/input/InputSettings.java +33 −0 Original line number Diff line number Diff line Loading @@ -335,6 +335,39 @@ public class InputSettings { return touchpadVisualizer(); } /** * Returns true if the touchpad visualizer is allowed to appear. * * @param context The application context. * @return Whether it is allowed to show touchpad visualizer or not. * * @hide */ public static boolean useTouchpadVisualizer(@NonNull Context context) { if (!isTouchpadVisualizerFeatureFlagEnabled()) { return false; } return Settings.System.getIntForUser(context.getContentResolver(), Settings.System.TOUCHPAD_VISUALIZER, 0, UserHandle.USER_CURRENT) == 1; } /** * Sets the touchpad visualizer behaviour. * * @param context The application context. * @param enabled Will enable touchpad visualizer if true, disable it if false * * @hide */ @RequiresPermission(Manifest.permission.WRITE_SETTINGS) public static void setTouchpadVisualizer(@NonNull Context context, boolean enabled) { if (!isTouchpadVisualizerFeatureFlagEnabled()) { return; } Settings.System.putIntForUser(context.getContentResolver(), Settings.System.TOUCHPAD_VISUALIZER, enabled ? 1 : 0, UserHandle.USER_CURRENT); } /** * Returns true if the touchpad should allow tap dragging. * Loading
services/core/java/com/android/server/input/InputSettingsObserver.java +6 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,8 @@ class InputSettingsObserver extends ContentObserver { (reason) -> updateTouchpadTapToClickEnabled()), Map.entry(Settings.System.getUriFor(Settings.System.TOUCHPAD_TAP_DRAGGING), (reason) -> updateTouchpadTapDraggingEnabled()), Map.entry(Settings.System.getUriFor(Settings.System.TOUCHPAD_VISUALIZER), (reason) -> updateTouchpadHardwareStateNotificationsEnabled()), Map.entry(Settings.System.getUriFor(Settings.System.TOUCHPAD_RIGHT_CLICK_ZONE), (reason) -> updateTouchpadRightClickZoneEnabled()), Map.entry(Settings.System.getUriFor(Settings.System.SHOW_TOUCHES), Loading Loading @@ -177,6 +179,10 @@ class InputSettingsObserver extends ContentObserver { mNative.setTouchpadTapDraggingEnabled(InputSettings.useTouchpadTapDragging(mContext)); } private void updateTouchpadHardwareStateNotificationsEnabled() { mNative.setShouldNotifyTouchpadHardwareState(InputSettings.useTouchpadVisualizer(mContext)); } private void updateTouchpadRightClickZoneEnabled() { mNative.setTouchpadRightClickZoneEnabled(InputSettings.useTouchpadRightClickZone(mContext)); } Loading
services/core/java/com/android/server/input/NativeInputManagerService.java +5 −0 Original line number Diff line number Diff line Loading @@ -135,6 +135,8 @@ interface NativeInputManagerService { void setTouchpadTapDraggingEnabled(boolean enabled); void setShouldNotifyTouchpadHardwareState(boolean enabled); void setTouchpadRightClickZoneEnabled(boolean enabled); void setShowTouches(boolean enabled); Loading Loading @@ -394,6 +396,9 @@ interface NativeInputManagerService { @Override public native void setTouchpadTapDraggingEnabled(boolean enabled); @Override public native void setShouldNotifyTouchpadHardwareState(boolean enabled); @Override public native void setTouchpadRightClickZoneEnabled(boolean enabled); Loading
services/core/jni/com_android_server_input_InputManagerService.cpp +30 −0 Original line number Diff line number Diff line Loading @@ -291,6 +291,7 @@ public: void setTouchpadNaturalScrollingEnabled(bool enabled); void setTouchpadTapToClickEnabled(bool enabled); void setTouchpadTapDraggingEnabled(bool enabled); void setShouldNotifyTouchpadHardwareState(bool enabled); void setTouchpadRightClickZoneEnabled(bool enabled); void setInputDeviceEnabled(uint32_t deviceId, bool enabled); void setShowTouches(bool enabled); Loading Loading @@ -440,6 +441,9 @@ private: // True to enable tap dragging on touchpads. bool touchpadTapDraggingEnabled{false}; // True if hardware state update notifications should be sent to the policy. bool shouldNotifyTouchpadHardwareState{false}; // 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}; Loading Loading @@ -698,6 +702,7 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon outConfig->touchpadNaturalScrollingEnabled = mLocked.touchpadNaturalScrollingEnabled; outConfig->touchpadTapToClickEnabled = mLocked.touchpadTapToClickEnabled; outConfig->touchpadTapDraggingEnabled = mLocked.touchpadTapDraggingEnabled; outConfig->shouldNotifyTouchpadHardwareState = mLocked.shouldNotifyTouchpadHardwareState; outConfig->touchpadRightClickZoneEnabled = mLocked.touchpadRightClickZoneEnabled; outConfig->disabledDevices = mLocked.disabledInputDevices; Loading Loading @@ -1260,6 +1265,22 @@ void NativeInputManager::setTouchpadTapDraggingEnabled(bool enabled) { InputReaderConfiguration::Change::TOUCHPAD_SETTINGS); } void NativeInputManager::setShouldNotifyTouchpadHardwareState(bool enabled) { { // acquire lock std::scoped_lock _l(mLock); if (mLocked.shouldNotifyTouchpadHardwareState == enabled) { return; } ALOGI("Should touchpad hardware state be notified: %s.", toString(enabled)); mLocked.shouldNotifyTouchpadHardwareState = enabled; } // release lock mInputManager->getReader().requestRefreshConfiguration( InputReaderConfiguration::Change::TOUCHPAD_SETTINGS); } void NativeInputManager::setTouchpadRightClickZoneEnabled(bool enabled) { { // acquire lock std::scoped_lock _l(mLock); Loading Loading @@ -2144,6 +2165,13 @@ static void nativeSetTouchpadTapDraggingEnabled(JNIEnv* env, jobject nativeImplO im->setTouchpadTapDraggingEnabled(enabled); } static void nativeSetShouldNotifyTouchpadHardwareState(JNIEnv* env, jobject nativeImplObj, jboolean enabled) { NativeInputManager* im = getNativeInputManager(env, nativeImplObj); im->setShouldNotifyTouchpadHardwareState(enabled); } static void nativeSetTouchpadRightClickZoneEnabled(JNIEnv* env, jobject nativeImplObj, jboolean enabled) { NativeInputManager* im = getNativeInputManager(env, nativeImplObj); Loading Loading @@ -2762,6 +2790,8 @@ static const JNINativeMethod gInputManagerMethods[] = { (void*)nativeSetTouchpadNaturalScrollingEnabled}, {"setTouchpadTapToClickEnabled", "(Z)V", (void*)nativeSetTouchpadTapToClickEnabled}, {"setTouchpadTapDraggingEnabled", "(Z)V", (void*)nativeSetTouchpadTapDraggingEnabled}, {"setShouldNotifyTouchpadHardwareState", "(Z)V", (void*)nativeSetShouldNotifyTouchpadHardwareState}, {"setTouchpadRightClickZoneEnabled", "(Z)V", (void*)nativeSetTouchpadRightClickZoneEnabled}, {"setShowTouches", "(Z)V", (void*)nativeSetShowTouches}, {"setInteractive", "(Z)V", (void*)nativeSetInteractive}, Loading
tests/Input/src/com/android/server/input/InputManagerServiceTests.kt +1 −0 Original line number Diff line number Diff line Loading @@ -151,6 +151,7 @@ class InputManagerServiceTests { verify(native).setTouchpadNaturalScrollingEnabled(anyBoolean()) verify(native).setTouchpadTapToClickEnabled(anyBoolean()) verify(native).setTouchpadTapDraggingEnabled(anyBoolean()) verify(native).setShouldNotifyTouchpadHardwareState(anyBoolean()) verify(native).setTouchpadRightClickZoneEnabled(anyBoolean()) verify(native).setShowTouches(anyBoolean()) verify(native).setMotionClassifierEnabled(anyBoolean()) Loading