diff options
author | Jeff Brown <jeffbrown@google.com> | 2011-03-02 21:38:11 -0800 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2011-03-02 21:38:11 -0800 |
commit | a454767b09ecb7d25d00beae0e5a1fdd48605c63 (patch) | |
tree | 21bd62830a3bacf4776aafa631ba60e45441b116 /services/jni | |
parent | e2e012683d6f35f5eedfd0c39167ea78e32e2650 (diff) | |
download | frameworks_base-a454767b09ecb7d25d00beae0e5a1fdd48605c63.zip frameworks_base-a454767b09ecb7d25d00beae0e5a1fdd48605c63.tar.gz frameworks_base-a454767b09ecb7d25d00beae0e5a1fdd48605c63.tar.bz2 |
Get key repeat timeout and delay from ViewConfiguration.
Replaces previously hardcoded values. This ensures that key repeat
takes the accessibility long press timeout setting into account.
Unfortunately the system must be rebooted for the change to take
effect. We will fix that later.
Change-Id: I3ab70bb037331620b7e532170c1727287b5c6f91
Diffstat (limited to 'services/jni')
-rw-r--r-- | services/jni/com_android_server_InputManager.cpp | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/services/jni/com_android_server_InputManager.cpp b/services/jni/com_android_server_InputManager.cpp index 00d0af1..3be3b1b 100644 --- a/services/jni/com_android_server_InputManager.cpp +++ b/services/jni/com_android_server_InputManager.cpp @@ -67,6 +67,8 @@ static struct { jmethodID filterJumpyTouchEvents; jmethodID getVirtualKeyQuietTimeMillis; jmethodID getExcludedDeviceNames; + jmethodID getKeyRepeatTimeout; + jmethodID getKeyRepeatDelay; jmethodID getMaxEventsPerSecond; jmethodID getPointerLayer; jmethodID getPointerIcon; @@ -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; @@ -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(); @@ -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() { @@ -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"); |