Loading core/java/android/view/ViewConfiguration.java +23 −4 Original line number Diff line number Diff line Loading @@ -74,10 +74,15 @@ public class ViewConfiguration { private static final int PRESSED_STATE_DURATION = 125; /** * Defines the duration in milliseconds before a press turns into * Defines the default duration in milliseconds before a press turns into * a long press */ private static final int DEFAULTLONG_PRESS_TIMEOUT = 500; private static final int DEFAULT_LONG_PRESS_TIMEOUT = 500; /** * Defines the time between successive key repeats in milliseconds. */ private static final int KEY_REPEAT_DELAY = 50; /** * Defines the duration in milliseconds a user needs to hold down the Loading Loading @@ -330,7 +335,21 @@ public class ViewConfiguration { */ public static int getLongPressTimeout() { return AppGlobals.getIntCoreSetting(Settings.Secure.LONG_PRESS_TIMEOUT, DEFAULTLONG_PRESS_TIMEOUT); DEFAULT_LONG_PRESS_TIMEOUT); } /** * @return the time before the first key repeat in milliseconds. */ public static int getKeyRepeatTimeout() { return getLongPressTimeout(); } /** * @return the time between successive key repeats in milliseconds. */ public static int getKeyRepeatDelay() { return KEY_REPEAT_DELAY; } /** Loading services/java/com/android/server/wm/InputManager.java +12 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.view.InputDevice; import android.view.InputEvent; import android.view.KeyEvent; import android.view.Surface; import android.view.ViewConfiguration; import android.view.WindowManager; import java.io.File; Loading Loading @@ -530,6 +531,16 @@ public class InputManager { return names.toArray(new String[names.size()]); } @SuppressWarnings("unused") public int getKeyRepeatTimeout() { return ViewConfiguration.getKeyRepeatTimeout(); } @SuppressWarnings("unused") public int getKeyRepeatDelay() { return ViewConfiguration.getKeyRepeatDelay(); } @SuppressWarnings("unused") public int getMaxEventsPerSecond() { int result = 0; Loading services/jni/com_android_server_InputManager.cpp +37 −3 Original line number Diff line number Diff line Loading @@ -67,6 +67,8 @@ static struct { jmethodID filterJumpyTouchEvents; jmethodID getVirtualKeyQuietTimeMillis; jmethodID getExcludedDeviceNames; jmethodID getKeyRepeatTimeout; jmethodID getKeyRepeatDelay; jmethodID getMaxEventsPerSecond; jmethodID getPointerLayer; jmethodID getPointerIcon; Loading Loading @@ -199,6 +201,10 @@ private: int32_t mFilterJumpyTouchEvents; nsecs_t mVirtualKeyQuietTime; // Cached key repeat policy. nsecs_t mKeyRepeatTimeout; nsecs_t mKeyRepeatDelay; // Cached throttling policy. int32_t mMaxEventsPerSecond; Loading Loading @@ -234,6 +240,7 @@ private: NativeInputManager::NativeInputManager(jobject callbacksObj, const sp<Looper>& looper) : mLooper(looper), mFilterTouchEvents(-1), mFilterJumpyTouchEvents(-1), mVirtualKeyQuietTime(-1), mKeyRepeatTimeout(-1), mKeyRepeatDelay(-1), mMaxEventsPerSecond(-1) { JNIEnv* env = jniEnv(); Loading Loading @@ -526,13 +533,34 @@ nsecs_t NativeInputManager::getKeyRepeatTimeout() { // Disable key repeat when the screen is off. return -1; } else { // TODO use ViewConfiguration.getLongPressTimeout() return milliseconds_to_nanoseconds(500); if (mKeyRepeatTimeout < 0) { JNIEnv* env = jniEnv(); jint result = env->CallIntMethod(mCallbacksObj, gCallbacksClassInfo.getKeyRepeatTimeout); if (checkAndClearExceptionFromCallback(env, "getKeyRepeatTimeout")) { result = 500; } mKeyRepeatTimeout = milliseconds_to_nanoseconds(result); } return mKeyRepeatTimeout; } } nsecs_t NativeInputManager::getKeyRepeatDelay() { return milliseconds_to_nanoseconds(50); if (mKeyRepeatDelay < 0) { JNIEnv* env = jniEnv(); jint result = env->CallIntMethod(mCallbacksObj, gCallbacksClassInfo.getKeyRepeatDelay); if (checkAndClearExceptionFromCallback(env, "getKeyRepeatDelay")) { result = 50; } mKeyRepeatDelay = milliseconds_to_nanoseconds(result); } return mKeyRepeatDelay; } int32_t NativeInputManager::getMaxEventsPerSecond() { Loading Loading @@ -1262,6 +1290,12 @@ int register_android_server_InputManager(JNIEnv* env) { GET_METHOD_ID(gCallbacksClassInfo.getExcludedDeviceNames, gCallbacksClassInfo.clazz, "getExcludedDeviceNames", "()[Ljava/lang/String;"); GET_METHOD_ID(gCallbacksClassInfo.getKeyRepeatTimeout, gCallbacksClassInfo.clazz, "getKeyRepeatTimeout", "()I"); GET_METHOD_ID(gCallbacksClassInfo.getKeyRepeatDelay, gCallbacksClassInfo.clazz, "getKeyRepeatDelay", "()I"); GET_METHOD_ID(gCallbacksClassInfo.getMaxEventsPerSecond, gCallbacksClassInfo.clazz, "getMaxEventsPerSecond", "()I"); Loading Loading
core/java/android/view/ViewConfiguration.java +23 −4 Original line number Diff line number Diff line Loading @@ -74,10 +74,15 @@ public class ViewConfiguration { private static final int PRESSED_STATE_DURATION = 125; /** * Defines the duration in milliseconds before a press turns into * Defines the default duration in milliseconds before a press turns into * a long press */ private static final int DEFAULTLONG_PRESS_TIMEOUT = 500; private static final int DEFAULT_LONG_PRESS_TIMEOUT = 500; /** * Defines the time between successive key repeats in milliseconds. */ private static final int KEY_REPEAT_DELAY = 50; /** * Defines the duration in milliseconds a user needs to hold down the Loading Loading @@ -330,7 +335,21 @@ public class ViewConfiguration { */ public static int getLongPressTimeout() { return AppGlobals.getIntCoreSetting(Settings.Secure.LONG_PRESS_TIMEOUT, DEFAULTLONG_PRESS_TIMEOUT); DEFAULT_LONG_PRESS_TIMEOUT); } /** * @return the time before the first key repeat in milliseconds. */ public static int getKeyRepeatTimeout() { return getLongPressTimeout(); } /** * @return the time between successive key repeats in milliseconds. */ public static int getKeyRepeatDelay() { return KEY_REPEAT_DELAY; } /** Loading
services/java/com/android/server/wm/InputManager.java +12 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.view.InputDevice; import android.view.InputEvent; import android.view.KeyEvent; import android.view.Surface; import android.view.ViewConfiguration; import android.view.WindowManager; import java.io.File; Loading Loading @@ -530,6 +531,16 @@ public class InputManager { return names.toArray(new String[names.size()]); } @SuppressWarnings("unused") public int getKeyRepeatTimeout() { return ViewConfiguration.getKeyRepeatTimeout(); } @SuppressWarnings("unused") public int getKeyRepeatDelay() { return ViewConfiguration.getKeyRepeatDelay(); } @SuppressWarnings("unused") public int getMaxEventsPerSecond() { int result = 0; Loading
services/jni/com_android_server_InputManager.cpp +37 −3 Original line number Diff line number Diff line Loading @@ -67,6 +67,8 @@ static struct { jmethodID filterJumpyTouchEvents; jmethodID getVirtualKeyQuietTimeMillis; jmethodID getExcludedDeviceNames; jmethodID getKeyRepeatTimeout; jmethodID getKeyRepeatDelay; jmethodID getMaxEventsPerSecond; jmethodID getPointerLayer; jmethodID getPointerIcon; Loading Loading @@ -199,6 +201,10 @@ private: int32_t mFilterJumpyTouchEvents; nsecs_t mVirtualKeyQuietTime; // Cached key repeat policy. nsecs_t mKeyRepeatTimeout; nsecs_t mKeyRepeatDelay; // Cached throttling policy. int32_t mMaxEventsPerSecond; Loading Loading @@ -234,6 +240,7 @@ private: NativeInputManager::NativeInputManager(jobject callbacksObj, const sp<Looper>& looper) : mLooper(looper), mFilterTouchEvents(-1), mFilterJumpyTouchEvents(-1), mVirtualKeyQuietTime(-1), mKeyRepeatTimeout(-1), mKeyRepeatDelay(-1), mMaxEventsPerSecond(-1) { JNIEnv* env = jniEnv(); Loading Loading @@ -526,13 +533,34 @@ nsecs_t NativeInputManager::getKeyRepeatTimeout() { // Disable key repeat when the screen is off. return -1; } else { // TODO use ViewConfiguration.getLongPressTimeout() return milliseconds_to_nanoseconds(500); if (mKeyRepeatTimeout < 0) { JNIEnv* env = jniEnv(); jint result = env->CallIntMethod(mCallbacksObj, gCallbacksClassInfo.getKeyRepeatTimeout); if (checkAndClearExceptionFromCallback(env, "getKeyRepeatTimeout")) { result = 500; } mKeyRepeatTimeout = milliseconds_to_nanoseconds(result); } return mKeyRepeatTimeout; } } nsecs_t NativeInputManager::getKeyRepeatDelay() { return milliseconds_to_nanoseconds(50); if (mKeyRepeatDelay < 0) { JNIEnv* env = jniEnv(); jint result = env->CallIntMethod(mCallbacksObj, gCallbacksClassInfo.getKeyRepeatDelay); if (checkAndClearExceptionFromCallback(env, "getKeyRepeatDelay")) { result = 50; } mKeyRepeatDelay = milliseconds_to_nanoseconds(result); } return mKeyRepeatDelay; } int32_t NativeInputManager::getMaxEventsPerSecond() { Loading Loading @@ -1262,6 +1290,12 @@ int register_android_server_InputManager(JNIEnv* env) { GET_METHOD_ID(gCallbacksClassInfo.getExcludedDeviceNames, gCallbacksClassInfo.clazz, "getExcludedDeviceNames", "()[Ljava/lang/String;"); GET_METHOD_ID(gCallbacksClassInfo.getKeyRepeatTimeout, gCallbacksClassInfo.clazz, "getKeyRepeatTimeout", "()I"); GET_METHOD_ID(gCallbacksClassInfo.getKeyRepeatDelay, gCallbacksClassInfo.clazz, "getKeyRepeatDelay", "()I"); GET_METHOD_ID(gCallbacksClassInfo.getMaxEventsPerSecond, gCallbacksClassInfo.clazz, "getMaxEventsPerSecond", "()I"); Loading