Loading services/core/java/com/android/server/input/InputSettingsObserver.java +23 −1 Original line number Diff line number Diff line Loading @@ -47,6 +47,9 @@ class InputSettingsObserver extends ContentObserver { private final NativeInputManagerService mNative; private final Map<Uri, Consumer<String /* reason*/>> mObservers; // Cache prevent notifying same KeyRepeatInfo data to native code multiple times. private KeyRepeatInfo mLastKeyRepeatInfoSettingsUpdate; InputSettingsObserver(Context context, Handler handler, InputManagerService service, NativeInputManagerService nativeIms) { super(handler); Loading Loading @@ -195,7 +198,11 @@ class InputSettingsObserver extends ContentObserver { final int delayMs = Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.KEY_REPEAT_DELAY_MS, ViewConfiguration.getKeyRepeatDelay(), UserHandle.USER_CURRENT); if (mLastKeyRepeatInfoSettingsUpdate == null || !mLastKeyRepeatInfoSettingsUpdate.isEqualTo( timeoutMs, delayMs)) { mNative.setKeyRepeatConfiguration(timeoutMs, delayMs); mLastKeyRepeatInfoSettingsUpdate = new KeyRepeatInfo(timeoutMs, delayMs); } } // Not using ViewConfiguration.getLongPressTimeout here because it may return a stale value. Loading @@ -214,4 +221,19 @@ class InputSettingsObserver extends ContentObserver { } mNative.setMaximumObscuringOpacityForTouch(opacity); } private static class KeyRepeatInfo { private final int mKeyRepeatTimeoutMs; private final int mKeyRepeatDelayMs; private KeyRepeatInfo(int keyRepeatTimeoutMs, int keyRepeatDelayMs) { this.mKeyRepeatTimeoutMs = keyRepeatTimeoutMs; this.mKeyRepeatDelayMs = keyRepeatDelayMs; } public boolean isEqualTo(int keyRepeatTimeoutMs, int keyRepeatDelayMs) { return mKeyRepeatTimeoutMs == keyRepeatTimeoutMs && mKeyRepeatDelayMs == keyRepeatDelayMs; } } } services/tests/servicestests/src/com/android/server/input/InputManagerServiceTests.kt +1 −2 Original line number Diff line number Diff line Loading @@ -133,8 +133,7 @@ class InputManagerServiceTests { verify(native).setMotionClassifierEnabled(anyBoolean()) verify(native).setMaximumObscuringOpacityForTouch(anyFloat()) verify(native).setStylusPointerIconEnabled(anyBoolean()) // TODO(b/286078544): There is no need to call this more than once. verify(native, times(3)).setKeyRepeatConfiguration(anyInt(), anyInt()) verify(native).setKeyRepeatConfiguration(anyInt(), anyInt()) } @Test Loading Loading
services/core/java/com/android/server/input/InputSettingsObserver.java +23 −1 Original line number Diff line number Diff line Loading @@ -47,6 +47,9 @@ class InputSettingsObserver extends ContentObserver { private final NativeInputManagerService mNative; private final Map<Uri, Consumer<String /* reason*/>> mObservers; // Cache prevent notifying same KeyRepeatInfo data to native code multiple times. private KeyRepeatInfo mLastKeyRepeatInfoSettingsUpdate; InputSettingsObserver(Context context, Handler handler, InputManagerService service, NativeInputManagerService nativeIms) { super(handler); Loading Loading @@ -195,7 +198,11 @@ class InputSettingsObserver extends ContentObserver { final int delayMs = Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.KEY_REPEAT_DELAY_MS, ViewConfiguration.getKeyRepeatDelay(), UserHandle.USER_CURRENT); if (mLastKeyRepeatInfoSettingsUpdate == null || !mLastKeyRepeatInfoSettingsUpdate.isEqualTo( timeoutMs, delayMs)) { mNative.setKeyRepeatConfiguration(timeoutMs, delayMs); mLastKeyRepeatInfoSettingsUpdate = new KeyRepeatInfo(timeoutMs, delayMs); } } // Not using ViewConfiguration.getLongPressTimeout here because it may return a stale value. Loading @@ -214,4 +221,19 @@ class InputSettingsObserver extends ContentObserver { } mNative.setMaximumObscuringOpacityForTouch(opacity); } private static class KeyRepeatInfo { private final int mKeyRepeatTimeoutMs; private final int mKeyRepeatDelayMs; private KeyRepeatInfo(int keyRepeatTimeoutMs, int keyRepeatDelayMs) { this.mKeyRepeatTimeoutMs = keyRepeatTimeoutMs; this.mKeyRepeatDelayMs = keyRepeatDelayMs; } public boolean isEqualTo(int keyRepeatTimeoutMs, int keyRepeatDelayMs) { return mKeyRepeatTimeoutMs == keyRepeatTimeoutMs && mKeyRepeatDelayMs == keyRepeatDelayMs; } } }
services/tests/servicestests/src/com/android/server/input/InputManagerServiceTests.kt +1 −2 Original line number Diff line number Diff line Loading @@ -133,8 +133,7 @@ class InputManagerServiceTests { verify(native).setMotionClassifierEnabled(anyBoolean()) verify(native).setMaximumObscuringOpacityForTouch(anyFloat()) verify(native).setStylusPointerIconEnabled(anyBoolean()) // TODO(b/286078544): There is no need to call this more than once. verify(native, times(3)).setKeyRepeatConfiguration(anyInt(), anyInt()) verify(native).setKeyRepeatConfiguration(anyInt(), anyInt()) } @Test Loading