Loading services/core/java/com/android/server/input/InputManagerService.java +5 −4 Original line number Original line Diff line number Diff line Loading @@ -1328,8 +1328,7 @@ public class InputManagerService extends IInputManager.Stub mPointerIconDisplayContext = null; mPointerIconDisplayContext = null; } } updateAdditionalDisplayInputProperties(displayId, updateAdditionalDisplayInputProperties(displayId, AdditionalDisplayInputProperties::reset); AdditionalDisplayInputProperties::reset); // TODO(b/320763728): Rely on WindowInfosListener to determine when a display has been // TODO(b/320763728): Rely on WindowInfosListener to determine when a display has been // removed in InputDispatcher instead of this callback. // removed in InputDispatcher instead of this callback. Loading Loading @@ -1812,8 +1811,6 @@ public class InputManagerService extends IInputManager.Stub mPointerIconType = icon.getType(); mPointerIconType = icon.getType(); mPointerIcon = mPointerIconType == PointerIcon.TYPE_CUSTOM ? icon : null; mPointerIcon = mPointerIconType == PointerIcon.TYPE_CUSTOM ? icon : null; if (!mCurrentDisplayProperties.pointerIconVisible) return false; return mNative.setPointerIcon(icon, displayId, deviceId, pointerId, inputToken); return mNative.setPointerIcon(icon, displayId, deviceId, pointerId, inputToken); } } } } Loading Loading @@ -3509,7 +3506,11 @@ public class InputManagerService extends IInputManager.Stub properties = new AdditionalDisplayInputProperties(); properties = new AdditionalDisplayInputProperties(); mAdditionalDisplayInputProperties.put(displayId, properties); mAdditionalDisplayInputProperties.put(displayId, properties); } } final boolean oldPointerIconVisible = properties.pointerIconVisible; updater.accept(properties); updater.accept(properties); if (oldPointerIconVisible != properties.pointerIconVisible) { mNative.setPointerIconVisibility(displayId, properties.pointerIconVisible); } if (properties.allDefaults()) { if (properties.allDefaults()) { mAdditionalDisplayInputProperties.remove(displayId); mAdditionalDisplayInputProperties.remove(displayId); } } Loading services/core/java/com/android/server/input/NativeInputManagerService.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -190,6 +190,8 @@ interface NativeInputManagerService { boolean setPointerIcon(@NonNull PointerIcon icon, int displayId, int deviceId, int pointerId, boolean setPointerIcon(@NonNull PointerIcon icon, int displayId, int deviceId, int pointerId, @NonNull IBinder inputToken); @NonNull IBinder inputToken); void setPointerIconVisibility(int displayId, boolean visible); void requestPointerCapture(IBinder windowToken, boolean enabled); void requestPointerCapture(IBinder windowToken, boolean enabled); boolean canDispatchToDisplay(int deviceId, int displayId); boolean canDispatchToDisplay(int deviceId, int displayId); Loading Loading @@ -451,6 +453,9 @@ interface NativeInputManagerService { public native boolean setPointerIcon(PointerIcon icon, int displayId, int deviceId, public native boolean setPointerIcon(PointerIcon icon, int displayId, int deviceId, int pointerId, IBinder inputToken); int pointerId, IBinder inputToken); @Override public native void setPointerIconVisibility(int displayId, boolean visible); @Override @Override public native void requestPointerCapture(IBinder windowToken, boolean enabled); public native void requestPointerCapture(IBinder windowToken, boolean enabled); Loading services/core/jni/com_android_server_input_InputManagerService.cpp +16 −0 Original line number Original line Diff line number Diff line Loading @@ -304,6 +304,7 @@ public: bool setPointerIcon(std::variant<std::unique_ptr<SpriteIcon>, PointerIconStyle> icon, bool setPointerIcon(std::variant<std::unique_ptr<SpriteIcon>, PointerIconStyle> icon, int32_t displayId, DeviceId deviceId, int32_t pointerId, int32_t displayId, DeviceId deviceId, int32_t pointerId, const sp<IBinder>& inputToken); const sp<IBinder>& inputToken); void setPointerIconVisibility(int32_t displayId, bool visible); void setMotionClassifierEnabled(bool enabled); void setMotionClassifierEnabled(bool enabled); std::optional<std::string> getBluetoothAddress(int32_t deviceId); std::optional<std::string> getBluetoothAddress(int32_t deviceId); void setStylusButtonMotionEventsEnabled(bool enabled); void setStylusButtonMotionEventsEnabled(bool enabled); Loading Loading @@ -1397,6 +1398,13 @@ bool NativeInputManager::setPointerIcon( return mInputManager->getChoreographer().setPointerIcon(std::move(icon), displayId, deviceId); return mInputManager->getChoreographer().setPointerIcon(std::move(icon), displayId, deviceId); } } void NativeInputManager::setPointerIconVisibility(int32_t displayId, bool visible) { if (!ENABLE_POINTER_CHOREOGRAPHER) { return; } mInputManager->getChoreographer().setPointerIconVisibility(displayId, visible); } TouchAffineTransformation NativeInputManager::getTouchAffineTransformation( TouchAffineTransformation NativeInputManager::getTouchAffineTransformation( JNIEnv *env, jfloatArray matrixArr) { JNIEnv *env, jfloatArray matrixArr) { ATRACE_CALL(); ATRACE_CALL(); Loading Loading @@ -2550,6 +2558,13 @@ static bool nativeSetPointerIcon(JNIEnv* env, jobject nativeImplObj, jobject ico ibinderForJavaObject(env, inputTokenObj)); ibinderForJavaObject(env, inputTokenObj)); } } static void nativeSetPointerIconVisibility(JNIEnv* env, jobject nativeImplObj, jint displayId, jboolean visible) { NativeInputManager* im = getNativeInputManager(env, nativeImplObj); im->setPointerIconVisibility(displayId, visible); } static jboolean nativeCanDispatchToDisplay(JNIEnv* env, jobject nativeImplObj, jint deviceId, static jboolean nativeCanDispatchToDisplay(JNIEnv* env, jobject nativeImplObj, jint deviceId, jint displayId) { jint displayId) { NativeInputManager* im = getNativeInputManager(env, nativeImplObj); NativeInputManager* im = getNativeInputManager(env, nativeImplObj); Loading Loading @@ -2828,6 +2843,7 @@ static const JNINativeMethod gInputManagerMethods[] = { (void*)nativeSetCustomPointerIcon}, (void*)nativeSetCustomPointerIcon}, {"setPointerIcon", "(Landroid/view/PointerIcon;IIILandroid/os/IBinder;)Z", {"setPointerIcon", "(Landroid/view/PointerIcon;IIILandroid/os/IBinder;)Z", (void*)nativeSetPointerIcon}, (void*)nativeSetPointerIcon}, {"setPointerIconVisibility", "(IZ)V", (void*)nativeSetPointerIconVisibility}, {"canDispatchToDisplay", "(II)Z", (void*)nativeCanDispatchToDisplay}, {"canDispatchToDisplay", "(II)Z", (void*)nativeCanDispatchToDisplay}, {"notifyPortAssociationsChanged", "()V", (void*)nativeNotifyPortAssociationsChanged}, {"notifyPortAssociationsChanged", "()V", (void*)nativeNotifyPortAssociationsChanged}, {"changeUniqueIdAssociation", "()V", (void*)nativeChangeUniqueIdAssociation}, {"changeUniqueIdAssociation", "()V", (void*)nativeChangeUniqueIdAssociation}, Loading tests/Input/src/com/android/server/input/InputManagerServiceTests.kt +6 −0 Original line number Original line Diff line number Diff line Loading @@ -292,11 +292,13 @@ class InputManagerServiceTests { setVirtualMousePointerDisplayIdAndVerify(10) setVirtualMousePointerDisplayIdAndVerify(10) localService.setPointerIconVisible(false, 10) localService.setPointerIconVisible(false, 10) verify(native).setPointerIconVisibility(10, false) verify(native).setPointerIconType(eq(PointerIcon.TYPE_NULL)) verify(native).setPointerIconType(eq(PointerIcon.TYPE_NULL)) localService.setMousePointerAccelerationEnabled(false, 10) localService.setMousePointerAccelerationEnabled(false, 10) verify(native).setMousePointerAccelerationEnabled(eq(false)) verify(native).setMousePointerAccelerationEnabled(eq(false)) service.onDisplayRemoved(10) service.onDisplayRemoved(10) verify(native).setPointerIconVisibility(10, true) verify(native).displayRemoved(eq(10)) verify(native).displayRemoved(eq(10)) verify(native).setPointerIconType(eq(PointerIcon.TYPE_NOT_SPECIFIED)) verify(native).setPointerIconType(eq(PointerIcon.TYPE_NOT_SPECIFIED)) verify(native).setMousePointerAccelerationEnabled(true) verify(native).setMousePointerAccelerationEnabled(true) Loading @@ -315,17 +317,20 @@ class InputManagerServiceTests { localService.setPointerIconVisible(false, 10) localService.setPointerIconVisible(false, 10) verify(native).setPointerIconType(eq(PointerIcon.TYPE_NULL)) verify(native).setPointerIconType(eq(PointerIcon.TYPE_NULL)) verify(native).setPointerIconVisibility(10, false) localService.setMousePointerAccelerationEnabled(false, 10) localService.setMousePointerAccelerationEnabled(false, 10) verify(native).setMousePointerAccelerationEnabled(eq(false)) verify(native).setMousePointerAccelerationEnabled(eq(false)) localService.setPointerIconVisible(true, 10) localService.setPointerIconVisible(true, 10) verify(native).setPointerIconType(eq(PointerIcon.TYPE_NOT_SPECIFIED)) verify(native).setPointerIconType(eq(PointerIcon.TYPE_NOT_SPECIFIED)) verify(native).setPointerIconVisibility(10, true) localService.setMousePointerAccelerationEnabled(true, 10) localService.setMousePointerAccelerationEnabled(true, 10) verify(native).setMousePointerAccelerationEnabled(eq(true)) verify(native).setMousePointerAccelerationEnabled(eq(true)) // Verify that setting properties on a different display is not propagated until the // Verify that setting properties on a different display is not propagated until the // pointer is moved to that display. // pointer is moved to that display. localService.setPointerIconVisible(false, 20) localService.setPointerIconVisible(false, 20) verify(native).setPointerIconVisibility(20, false) localService.setMousePointerAccelerationEnabled(false, 20) localService.setMousePointerAccelerationEnabled(false, 20) verifyNoMoreInteractions(native) verifyNoMoreInteractions(native) Loading @@ -341,6 +346,7 @@ class InputManagerServiceTests { localService.setPointerIconVisible(false, 10) localService.setPointerIconVisible(false, 10) localService.setMousePointerAccelerationEnabled(false, 10) localService.setMousePointerAccelerationEnabled(false, 10) verify(native).setPointerIconVisibility(10, false) verifyNoMoreInteractions(native) verifyNoMoreInteractions(native) setVirtualMousePointerDisplayIdAndVerify(10) setVirtualMousePointerDisplayIdAndVerify(10) Loading Loading
services/core/java/com/android/server/input/InputManagerService.java +5 −4 Original line number Original line Diff line number Diff line Loading @@ -1328,8 +1328,7 @@ public class InputManagerService extends IInputManager.Stub mPointerIconDisplayContext = null; mPointerIconDisplayContext = null; } } updateAdditionalDisplayInputProperties(displayId, updateAdditionalDisplayInputProperties(displayId, AdditionalDisplayInputProperties::reset); AdditionalDisplayInputProperties::reset); // TODO(b/320763728): Rely on WindowInfosListener to determine when a display has been // TODO(b/320763728): Rely on WindowInfosListener to determine when a display has been // removed in InputDispatcher instead of this callback. // removed in InputDispatcher instead of this callback. Loading Loading @@ -1812,8 +1811,6 @@ public class InputManagerService extends IInputManager.Stub mPointerIconType = icon.getType(); mPointerIconType = icon.getType(); mPointerIcon = mPointerIconType == PointerIcon.TYPE_CUSTOM ? icon : null; mPointerIcon = mPointerIconType == PointerIcon.TYPE_CUSTOM ? icon : null; if (!mCurrentDisplayProperties.pointerIconVisible) return false; return mNative.setPointerIcon(icon, displayId, deviceId, pointerId, inputToken); return mNative.setPointerIcon(icon, displayId, deviceId, pointerId, inputToken); } } } } Loading Loading @@ -3509,7 +3506,11 @@ public class InputManagerService extends IInputManager.Stub properties = new AdditionalDisplayInputProperties(); properties = new AdditionalDisplayInputProperties(); mAdditionalDisplayInputProperties.put(displayId, properties); mAdditionalDisplayInputProperties.put(displayId, properties); } } final boolean oldPointerIconVisible = properties.pointerIconVisible; updater.accept(properties); updater.accept(properties); if (oldPointerIconVisible != properties.pointerIconVisible) { mNative.setPointerIconVisibility(displayId, properties.pointerIconVisible); } if (properties.allDefaults()) { if (properties.allDefaults()) { mAdditionalDisplayInputProperties.remove(displayId); mAdditionalDisplayInputProperties.remove(displayId); } } Loading
services/core/java/com/android/server/input/NativeInputManagerService.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -190,6 +190,8 @@ interface NativeInputManagerService { boolean setPointerIcon(@NonNull PointerIcon icon, int displayId, int deviceId, int pointerId, boolean setPointerIcon(@NonNull PointerIcon icon, int displayId, int deviceId, int pointerId, @NonNull IBinder inputToken); @NonNull IBinder inputToken); void setPointerIconVisibility(int displayId, boolean visible); void requestPointerCapture(IBinder windowToken, boolean enabled); void requestPointerCapture(IBinder windowToken, boolean enabled); boolean canDispatchToDisplay(int deviceId, int displayId); boolean canDispatchToDisplay(int deviceId, int displayId); Loading Loading @@ -451,6 +453,9 @@ interface NativeInputManagerService { public native boolean setPointerIcon(PointerIcon icon, int displayId, int deviceId, public native boolean setPointerIcon(PointerIcon icon, int displayId, int deviceId, int pointerId, IBinder inputToken); int pointerId, IBinder inputToken); @Override public native void setPointerIconVisibility(int displayId, boolean visible); @Override @Override public native void requestPointerCapture(IBinder windowToken, boolean enabled); public native void requestPointerCapture(IBinder windowToken, boolean enabled); Loading
services/core/jni/com_android_server_input_InputManagerService.cpp +16 −0 Original line number Original line Diff line number Diff line Loading @@ -304,6 +304,7 @@ public: bool setPointerIcon(std::variant<std::unique_ptr<SpriteIcon>, PointerIconStyle> icon, bool setPointerIcon(std::variant<std::unique_ptr<SpriteIcon>, PointerIconStyle> icon, int32_t displayId, DeviceId deviceId, int32_t pointerId, int32_t displayId, DeviceId deviceId, int32_t pointerId, const sp<IBinder>& inputToken); const sp<IBinder>& inputToken); void setPointerIconVisibility(int32_t displayId, bool visible); void setMotionClassifierEnabled(bool enabled); void setMotionClassifierEnabled(bool enabled); std::optional<std::string> getBluetoothAddress(int32_t deviceId); std::optional<std::string> getBluetoothAddress(int32_t deviceId); void setStylusButtonMotionEventsEnabled(bool enabled); void setStylusButtonMotionEventsEnabled(bool enabled); Loading Loading @@ -1397,6 +1398,13 @@ bool NativeInputManager::setPointerIcon( return mInputManager->getChoreographer().setPointerIcon(std::move(icon), displayId, deviceId); return mInputManager->getChoreographer().setPointerIcon(std::move(icon), displayId, deviceId); } } void NativeInputManager::setPointerIconVisibility(int32_t displayId, bool visible) { if (!ENABLE_POINTER_CHOREOGRAPHER) { return; } mInputManager->getChoreographer().setPointerIconVisibility(displayId, visible); } TouchAffineTransformation NativeInputManager::getTouchAffineTransformation( TouchAffineTransformation NativeInputManager::getTouchAffineTransformation( JNIEnv *env, jfloatArray matrixArr) { JNIEnv *env, jfloatArray matrixArr) { ATRACE_CALL(); ATRACE_CALL(); Loading Loading @@ -2550,6 +2558,13 @@ static bool nativeSetPointerIcon(JNIEnv* env, jobject nativeImplObj, jobject ico ibinderForJavaObject(env, inputTokenObj)); ibinderForJavaObject(env, inputTokenObj)); } } static void nativeSetPointerIconVisibility(JNIEnv* env, jobject nativeImplObj, jint displayId, jboolean visible) { NativeInputManager* im = getNativeInputManager(env, nativeImplObj); im->setPointerIconVisibility(displayId, visible); } static jboolean nativeCanDispatchToDisplay(JNIEnv* env, jobject nativeImplObj, jint deviceId, static jboolean nativeCanDispatchToDisplay(JNIEnv* env, jobject nativeImplObj, jint deviceId, jint displayId) { jint displayId) { NativeInputManager* im = getNativeInputManager(env, nativeImplObj); NativeInputManager* im = getNativeInputManager(env, nativeImplObj); Loading Loading @@ -2828,6 +2843,7 @@ static const JNINativeMethod gInputManagerMethods[] = { (void*)nativeSetCustomPointerIcon}, (void*)nativeSetCustomPointerIcon}, {"setPointerIcon", "(Landroid/view/PointerIcon;IIILandroid/os/IBinder;)Z", {"setPointerIcon", "(Landroid/view/PointerIcon;IIILandroid/os/IBinder;)Z", (void*)nativeSetPointerIcon}, (void*)nativeSetPointerIcon}, {"setPointerIconVisibility", "(IZ)V", (void*)nativeSetPointerIconVisibility}, {"canDispatchToDisplay", "(II)Z", (void*)nativeCanDispatchToDisplay}, {"canDispatchToDisplay", "(II)Z", (void*)nativeCanDispatchToDisplay}, {"notifyPortAssociationsChanged", "()V", (void*)nativeNotifyPortAssociationsChanged}, {"notifyPortAssociationsChanged", "()V", (void*)nativeNotifyPortAssociationsChanged}, {"changeUniqueIdAssociation", "()V", (void*)nativeChangeUniqueIdAssociation}, {"changeUniqueIdAssociation", "()V", (void*)nativeChangeUniqueIdAssociation}, Loading
tests/Input/src/com/android/server/input/InputManagerServiceTests.kt +6 −0 Original line number Original line Diff line number Diff line Loading @@ -292,11 +292,13 @@ class InputManagerServiceTests { setVirtualMousePointerDisplayIdAndVerify(10) setVirtualMousePointerDisplayIdAndVerify(10) localService.setPointerIconVisible(false, 10) localService.setPointerIconVisible(false, 10) verify(native).setPointerIconVisibility(10, false) verify(native).setPointerIconType(eq(PointerIcon.TYPE_NULL)) verify(native).setPointerIconType(eq(PointerIcon.TYPE_NULL)) localService.setMousePointerAccelerationEnabled(false, 10) localService.setMousePointerAccelerationEnabled(false, 10) verify(native).setMousePointerAccelerationEnabled(eq(false)) verify(native).setMousePointerAccelerationEnabled(eq(false)) service.onDisplayRemoved(10) service.onDisplayRemoved(10) verify(native).setPointerIconVisibility(10, true) verify(native).displayRemoved(eq(10)) verify(native).displayRemoved(eq(10)) verify(native).setPointerIconType(eq(PointerIcon.TYPE_NOT_SPECIFIED)) verify(native).setPointerIconType(eq(PointerIcon.TYPE_NOT_SPECIFIED)) verify(native).setMousePointerAccelerationEnabled(true) verify(native).setMousePointerAccelerationEnabled(true) Loading @@ -315,17 +317,20 @@ class InputManagerServiceTests { localService.setPointerIconVisible(false, 10) localService.setPointerIconVisible(false, 10) verify(native).setPointerIconType(eq(PointerIcon.TYPE_NULL)) verify(native).setPointerIconType(eq(PointerIcon.TYPE_NULL)) verify(native).setPointerIconVisibility(10, false) localService.setMousePointerAccelerationEnabled(false, 10) localService.setMousePointerAccelerationEnabled(false, 10) verify(native).setMousePointerAccelerationEnabled(eq(false)) verify(native).setMousePointerAccelerationEnabled(eq(false)) localService.setPointerIconVisible(true, 10) localService.setPointerIconVisible(true, 10) verify(native).setPointerIconType(eq(PointerIcon.TYPE_NOT_SPECIFIED)) verify(native).setPointerIconType(eq(PointerIcon.TYPE_NOT_SPECIFIED)) verify(native).setPointerIconVisibility(10, true) localService.setMousePointerAccelerationEnabled(true, 10) localService.setMousePointerAccelerationEnabled(true, 10) verify(native).setMousePointerAccelerationEnabled(eq(true)) verify(native).setMousePointerAccelerationEnabled(eq(true)) // Verify that setting properties on a different display is not propagated until the // Verify that setting properties on a different display is not propagated until the // pointer is moved to that display. // pointer is moved to that display. localService.setPointerIconVisible(false, 20) localService.setPointerIconVisible(false, 20) verify(native).setPointerIconVisibility(20, false) localService.setMousePointerAccelerationEnabled(false, 20) localService.setMousePointerAccelerationEnabled(false, 20) verifyNoMoreInteractions(native) verifyNoMoreInteractions(native) Loading @@ -341,6 +346,7 @@ class InputManagerServiceTests { localService.setPointerIconVisible(false, 10) localService.setPointerIconVisible(false, 10) localService.setMousePointerAccelerationEnabled(false, 10) localService.setMousePointerAccelerationEnabled(false, 10) verify(native).setPointerIconVisibility(10, false) verifyNoMoreInteractions(native) verifyNoMoreInteractions(native) setVirtualMousePointerDisplayIdAndVerify(10) setVirtualMousePointerDisplayIdAndVerify(10) Loading