summaryrefslogtreecommitdiffstats
path: root/core/jni
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-06-03 21:19:13 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-06-03 21:19:13 -0700
commit7d3fa093bbd34e19f6b580b6258c8ea4e138c777 (patch)
tree33ed4f33968d5cfabad258135588f9c3aa1e7e71 /core/jni
parent66a10964b0aa56e07263005e6a41a87ecd2dd2d7 (diff)
parentf47e76e2c78e78e26110786e99548d718d177c32 (diff)
downloadframeworks_base-7d3fa093bbd34e19f6b580b6258c8ea4e138c777.zip
frameworks_base-7d3fa093bbd34e19f6b580b6258c8ea4e138c777.tar.gz
frameworks_base-7d3fa093bbd34e19f6b580b6258c8ea4e138c777.tar.bz2
am f47e76e2: Merge "Make velocity tracker strategy configurable." into jb-dev
* commit 'f47e76e2c78e78e26110786e99548d718d177c32': Make velocity tracker strategy configurable.
Diffstat (limited to 'core/jni')
-rw-r--r--core/jni/android_view_VelocityTracker.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/core/jni/android_view_VelocityTracker.cpp b/core/jni/android_view_VelocityTracker.cpp
index 0180e0a..c2fa3be 100644
--- a/core/jni/android_view_VelocityTracker.cpp
+++ b/core/jni/android_view_VelocityTracker.cpp
@@ -24,6 +24,8 @@
#include <androidfw/VelocityTracker.h>
#include "android_view_MotionEvent.h"
+#include <ScopedUtfChars.h>
+
namespace android {
@@ -42,7 +44,7 @@ static struct {
class VelocityTrackerState {
public:
- VelocityTrackerState();
+ VelocityTrackerState(const char* strategy);
void clear();
void addMovement(const MotionEvent* event);
@@ -61,7 +63,8 @@ private:
Velocity mCalculatedVelocity[MAX_POINTERS];
};
-VelocityTrackerState::VelocityTrackerState() : mActivePointerId(-1) {
+VelocityTrackerState::VelocityTrackerState(const char* strategy) :
+ mVelocityTracker(strategy), mActivePointerId(-1) {
}
void VelocityTrackerState::clear() {
@@ -135,8 +138,13 @@ bool VelocityTrackerState::getEstimator(int32_t id, VelocityTracker::Estimator*
// --- JNI Methods ---
-static jint android_view_VelocityTracker_nativeInitialize(JNIEnv* env, jclass clazz) {
- return reinterpret_cast<jint>(new VelocityTrackerState());
+static jint android_view_VelocityTracker_nativeInitialize(JNIEnv* env, jclass clazz,
+ jstring strategyStr) {
+ if (strategyStr) {
+ ScopedUtfChars strategy(env, strategyStr);
+ return reinterpret_cast<jint>(new VelocityTrackerState(strategy.c_str()));
+ }
+ return reinterpret_cast<jint>(new VelocityTrackerState(NULL));
}
static void android_view_VelocityTracker_nativeDispose(JNIEnv* env, jclass clazz, jint ptr) {
@@ -209,7 +217,7 @@ static jboolean android_view_VelocityTracker_nativeGetEstimator(JNIEnv* env, jcl
static JNINativeMethod gVelocityTrackerMethods[] = {
/* name, signature, funcPtr */
{ "nativeInitialize",
- "()I",
+ "(Ljava/lang/String;)I",
(void*)android_view_VelocityTracker_nativeInitialize },
{ "nativeDispose",
"(I)V",