diff options
author | Jeff Brown <jeffbrown@google.com> | 2010-08-21 09:35:13 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-08-21 09:35:13 -0700 |
commit | feb02e7695c99d6eab0884f2424cff5bf48f4df4 (patch) | |
tree | ea768208836244e89363d14d13a1c88aab5274f3 /services/jni | |
parent | 37444f4239b26944d24f039c537d411ac7004243 (diff) | |
parent | d25f0aea1cebe93aff55a75374e172f87115f1b3 (diff) | |
download | frameworks_base-feb02e7695c99d6eab0884f2424cff5bf48f4df4.zip frameworks_base-feb02e7695c99d6eab0884f2424cff5bf48f4df4.tar.gz frameworks_base-feb02e7695c99d6eab0884f2424cff5bf48f4df4.tar.bz2 |
am d25f0aea: am 99401b29: Merge "Add support for throttling motion events." into gingerbread
Merge commit 'd25f0aea1cebe93aff55a75374e172f87115f1b3'
* commit 'd25f0aea1cebe93aff55a75374e172f87115f1b3':
Add support for throttling motion events.
Diffstat (limited to 'services/jni')
-rw-r--r-- | services/jni/com_android_server_InputManager.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/services/jni/com_android_server_InputManager.cpp b/services/jni/com_android_server_InputManager.cpp index ba58b43..59528db 100644 --- a/services/jni/com_android_server_InputManager.cpp +++ b/services/jni/com_android_server_InputManager.cpp @@ -139,6 +139,7 @@ static struct { jmethodID filterJumpyTouchEvents; jmethodID getVirtualKeyDefinitions; jmethodID getExcludedDeviceNames; + jmethodID getMaxEventsPerSecond; } gCallbacksClassInfo; static struct { @@ -249,6 +250,7 @@ public: int32_t injectorPid, int32_t injectorUid, Vector<InputTarget>& outTargets); virtual int32_t waitForMotionEventTargets(MotionEvent* motionEvent, uint32_t policyFlags, int32_t injectorPid, int32_t injectorUid, Vector<InputTarget>& outTargets); + virtual int32_t getMaxEventsPerSecond(); private: struct InputWindow { @@ -310,6 +312,9 @@ private: int32_t mFilterTouchEvents; int32_t mFilterJumpyTouchEvents; + // Cached throttling policy. + int32_t mMaxEventsPerSecond; + // Cached display state. (lock mDisplayLock) Mutex mDisplayLock; int32_t mDisplayWidth, mDisplayHeight; @@ -400,6 +405,7 @@ private: NativeInputManager::NativeInputManager(jobject callbacksObj) : mFilterTouchEvents(-1), mFilterJumpyTouchEvents(-1), + mMaxEventsPerSecond(-1), mDisplayWidth(-1), mDisplayHeight(-1), mDisplayOrientation(ROTATION_0), mDispatchEnabled(true), mDispatchFrozen(false), mWindowsReady(true), mFocusedWindow(NULL), mTouchDown(false), mTouchedWindow(NULL), @@ -921,6 +927,21 @@ nsecs_t NativeInputManager::getKeyRepeatTimeout() { } } +int32_t NativeInputManager::getMaxEventsPerSecond() { + if (mMaxEventsPerSecond < 0) { + JNIEnv* env = jniEnv(); + + jint result = env->CallIntMethod(mCallbacksObj, + gCallbacksClassInfo.getMaxEventsPerSecond); + if (checkAndClearExceptionFromCallback(env, "getMaxEventsPerSecond")) { + result = 35; + } + + mMaxEventsPerSecond = result; + } + return mMaxEventsPerSecond; +} + void NativeInputManager::setInputWindows(JNIEnv* env, jobjectArray windowObjArray) { #if DEBUG_FOCUS LOGD("setInputWindows"); @@ -2293,6 +2314,9 @@ int register_android_server_InputManager(JNIEnv* env) { GET_METHOD_ID(gCallbacksClassInfo.getExcludedDeviceNames, gCallbacksClassInfo.clazz, "getExcludedDeviceNames", "()[Ljava/lang/String;"); + GET_METHOD_ID(gCallbacksClassInfo.getMaxEventsPerSecond, gCallbacksClassInfo.clazz, + "getMaxEventsPerSecond", "()I"); + // VirtualKeyDefinition FIND_CLASS(gVirtualKeyDefinitionClassInfo.clazz, |