Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define LOG_TAG "MotionEvent-JNI" |
| 18 | |
| 19 | #include "JNIHelp.h" |
| 20 | |
| 21 | #include <android_runtime/AndroidRuntime.h> |
| 22 | #include <utils/Log.h> |
Mathias Agopian | b93a03f8 | 2012-02-17 15:34:57 -0800 | [diff] [blame] | 23 | #include <androidfw/Input.h> |
Jeff Sharkey | d84e1ce | 2012-03-06 18:26:19 -0800 | [diff] [blame] | 24 | #include "android_os_Parcel.h" |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 25 | #include "android_view_MotionEvent.h" |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 26 | #include "android_util_Binder.h" |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 27 | #include "android/graphics/Matrix.h" |
| 28 | |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 29 | #include "SkMatrix.h" |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 30 | |
| 31 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 32 | namespace android { |
| 33 | |
| 34 | // ---------------------------------------------------------------------------- |
| 35 | |
| 36 | static struct { |
| 37 | jclass clazz; |
| 38 | |
| 39 | jmethodID obtain; |
| 40 | jmethodID recycle; |
| 41 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 42 | jfieldID mNativePtr; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 43 | } gMotionEventClassInfo; |
| 44 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 45 | static struct { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 46 | jfieldID mPackedAxisBits; |
| 47 | jfieldID mPackedAxisValues; |
| 48 | jfieldID x; |
| 49 | jfieldID y; |
| 50 | jfieldID pressure; |
| 51 | jfieldID size; |
| 52 | jfieldID touchMajor; |
| 53 | jfieldID touchMinor; |
| 54 | jfieldID toolMajor; |
| 55 | jfieldID toolMinor; |
| 56 | jfieldID orientation; |
| 57 | } gPointerCoordsClassInfo; |
| 58 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 59 | static struct { |
| 60 | jfieldID id; |
| 61 | jfieldID toolType; |
| 62 | } gPointerPropertiesClassInfo; |
| 63 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 64 | // ---------------------------------------------------------------------------- |
| 65 | |
Jeff Brown | 2ed2462 | 2011-03-14 19:39:54 -0700 | [diff] [blame] | 66 | MotionEvent* android_view_MotionEvent_getNativePtr(JNIEnv* env, jobject eventObj) { |
| 67 | if (!eventObj) { |
| 68 | return NULL; |
| 69 | } |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 70 | return reinterpret_cast<MotionEvent*>( |
| 71 | env->GetIntField(eventObj, gMotionEventClassInfo.mNativePtr)); |
| 72 | } |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 73 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 74 | static void android_view_MotionEvent_setNativePtr(JNIEnv* env, jobject eventObj, |
| 75 | MotionEvent* event) { |
| 76 | env->SetIntField(eventObj, gMotionEventClassInfo.mNativePtr, |
| 77 | reinterpret_cast<int>(event)); |
| 78 | } |
| 79 | |
Jeff Brown | 2ed2462 | 2011-03-14 19:39:54 -0700 | [diff] [blame] | 80 | jobject android_view_MotionEvent_obtainAsCopy(JNIEnv* env, const MotionEvent* event) { |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 81 | jobject eventObj = env->CallStaticObjectMethod(gMotionEventClassInfo.clazz, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 82 | gMotionEventClassInfo.obtain); |
Jeff Brown | 2ed2462 | 2011-03-14 19:39:54 -0700 | [diff] [blame] | 83 | if (env->ExceptionCheck() || !eventObj) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 84 | ALOGE("An exception occurred while obtaining a motion event."); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 85 | LOGE_EX(env); |
| 86 | env->ExceptionClear(); |
| 87 | return NULL; |
| 88 | } |
| 89 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 90 | MotionEvent* destEvent = android_view_MotionEvent_getNativePtr(env, eventObj); |
| 91 | if (!destEvent) { |
| 92 | destEvent = new MotionEvent(); |
| 93 | android_view_MotionEvent_setNativePtr(env, eventObj, destEvent); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 94 | } |
| 95 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 96 | destEvent->copyFrom(event, true); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 97 | return eventObj; |
| 98 | } |
| 99 | |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 100 | status_t android_view_MotionEvent_recycle(JNIEnv* env, jobject eventObj) { |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 101 | env->CallVoidMethod(eventObj, gMotionEventClassInfo.recycle); |
| 102 | if (env->ExceptionCheck()) { |
Steve Block | 8564c8d | 2012-01-05 23:22:43 +0000 | [diff] [blame] | 103 | ALOGW("An exception occurred while recycling a motion event."); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 104 | LOGW_EX(env); |
| 105 | env->ExceptionClear(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 106 | return UNKNOWN_ERROR; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 107 | } |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 108 | return OK; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 109 | } |
| 110 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 111 | // ---------------------------------------------------------------------------- |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 112 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 113 | static const jint HISTORY_CURRENT = -0x80000000; |
| 114 | |
| 115 | static bool validatePointerCount(JNIEnv* env, jint pointerCount) { |
| 116 | if (pointerCount < 1) { |
| 117 | jniThrowException(env, "java/lang/IllegalArgumentException", |
| 118 | "pointerCount must be at least 1"); |
| 119 | return false; |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 120 | } |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 121 | return true; |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 122 | } |
| 123 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 124 | static bool validatePointerPropertiesArray(JNIEnv* env, jobjectArray pointerPropertiesObjArray, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 125 | size_t pointerCount) { |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 126 | if (!pointerPropertiesObjArray) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 127 | jniThrowException(env, "java/lang/IllegalArgumentException", |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 128 | "pointerProperties array must not be null"); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 129 | return false; |
| 130 | } |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 131 | size_t length = size_t(env->GetArrayLength(pointerPropertiesObjArray)); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 132 | if (length < pointerCount) { |
| 133 | jniThrowException(env, "java/lang/IllegalArgumentException", |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 134 | "pointerProperties array must be large enough to hold all pointers"); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 135 | return false; |
| 136 | } |
| 137 | return true; |
| 138 | } |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 139 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 140 | static bool validatePointerCoordsObjArray(JNIEnv* env, jobjectArray pointerCoordsObjArray, |
| 141 | size_t pointerCount) { |
| 142 | if (!pointerCoordsObjArray) { |
| 143 | jniThrowException(env, "java/lang/IllegalArgumentException", |
| 144 | "pointerCoords array must not be null"); |
| 145 | return false; |
| 146 | } |
| 147 | size_t length = size_t(env->GetArrayLength(pointerCoordsObjArray)); |
| 148 | if (length < pointerCount) { |
| 149 | jniThrowException(env, "java/lang/IllegalArgumentException", |
| 150 | "pointerCoords array must be large enough to hold all pointers"); |
| 151 | return false; |
| 152 | } |
| 153 | return true; |
| 154 | } |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 155 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 156 | static bool validatePointerIndex(JNIEnv* env, jint pointerIndex, size_t pointerCount) { |
| 157 | if (pointerIndex < 0 || size_t(pointerIndex) >= pointerCount) { |
| 158 | jniThrowException(env, "java/lang/IllegalArgumentException", |
| 159 | "pointerIndex out of range"); |
| 160 | return false; |
| 161 | } |
| 162 | return true; |
| 163 | } |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 164 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 165 | static bool validateHistoryPos(JNIEnv* env, jint historyPos, size_t historySize) { |
| 166 | if (historyPos < 0 || size_t(historyPos) >= historySize) { |
| 167 | jniThrowException(env, "java/lang/IllegalArgumentException", |
| 168 | "historyPos out of range"); |
| 169 | return false; |
| 170 | } |
| 171 | return true; |
| 172 | } |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 173 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 174 | static bool validatePointerCoords(JNIEnv* env, jobject pointerCoordsObj) { |
| 175 | if (!pointerCoordsObj) { |
| 176 | jniThrowException(env, "java/lang/IllegalArgumentException", |
| 177 | "pointerCoords must not be null"); |
| 178 | return false; |
| 179 | } |
| 180 | return true; |
| 181 | } |
| 182 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 183 | static bool validatePointerProperties(JNIEnv* env, jobject pointerPropertiesObj) { |
| 184 | if (!pointerPropertiesObj) { |
| 185 | jniThrowException(env, "java/lang/IllegalArgumentException", |
| 186 | "pointerProperties must not be null"); |
| 187 | return false; |
| 188 | } |
| 189 | return true; |
| 190 | } |
| 191 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 192 | static void pointerCoordsToNative(JNIEnv* env, jobject pointerCoordsObj, |
| 193 | float xOffset, float yOffset, PointerCoords* outRawPointerCoords) { |
| 194 | outRawPointerCoords->clear(); |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 195 | outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_X, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 196 | env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.x) - xOffset); |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 197 | outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_Y, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 198 | env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.y) - yOffset); |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 199 | outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 200 | env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.pressure)); |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 201 | outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_SIZE, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 202 | env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.size)); |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 203 | outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 204 | env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.touchMajor)); |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 205 | outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 206 | env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.touchMinor)); |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 207 | outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 208 | env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.toolMajor)); |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 209 | outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 210 | env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.toolMinor)); |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 211 | outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 212 | env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.orientation)); |
| 213 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 214 | uint64_t bits = env->GetLongField(pointerCoordsObj, gPointerCoordsClassInfo.mPackedAxisBits); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 215 | if (bits) { |
| 216 | jfloatArray valuesArray = jfloatArray(env->GetObjectField(pointerCoordsObj, |
| 217 | gPointerCoordsClassInfo.mPackedAxisValues)); |
| 218 | if (valuesArray) { |
| 219 | jfloat* values = static_cast<jfloat*>( |
| 220 | env->GetPrimitiveArrayCritical(valuesArray, NULL)); |
| 221 | |
| 222 | uint32_t index = 0; |
| 223 | do { |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 224 | uint32_t axis = __builtin_ctzll(bits); |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 225 | uint64_t axisBit = 1LL << axis; |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 226 | bits &= ~axisBit; |
| 227 | outRawPointerCoords->setAxisValue(axis, values[index++]); |
| 228 | } while (bits); |
| 229 | |
| 230 | env->ReleasePrimitiveArrayCritical(valuesArray, values, JNI_ABORT); |
| 231 | env->DeleteLocalRef(valuesArray); |
| 232 | } |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | static jfloatArray obtainPackedAxisValuesArray(JNIEnv* env, uint32_t minSize, |
| 237 | jobject outPointerCoordsObj) { |
| 238 | jfloatArray outValuesArray = jfloatArray(env->GetObjectField(outPointerCoordsObj, |
| 239 | gPointerCoordsClassInfo.mPackedAxisValues)); |
| 240 | if (outValuesArray) { |
| 241 | uint32_t size = env->GetArrayLength(outValuesArray); |
| 242 | if (minSize <= size) { |
| 243 | return outValuesArray; |
| 244 | } |
| 245 | env->DeleteLocalRef(outValuesArray); |
| 246 | } |
| 247 | uint32_t size = 8; |
| 248 | while (size < minSize) { |
| 249 | size *= 2; |
| 250 | } |
| 251 | outValuesArray = env->NewFloatArray(size); |
| 252 | env->SetObjectField(outPointerCoordsObj, |
| 253 | gPointerCoordsClassInfo.mPackedAxisValues, outValuesArray); |
| 254 | return outValuesArray; |
| 255 | } |
| 256 | |
| 257 | static void pointerCoordsFromNative(JNIEnv* env, const PointerCoords* rawPointerCoords, |
| 258 | float xOffset, float yOffset, jobject outPointerCoordsObj) { |
| 259 | env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.x, |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 260 | rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_X) + xOffset); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 261 | env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.y, |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 262 | rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_Y) + yOffset); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 263 | env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.pressure, |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 264 | rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_PRESSURE)); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 265 | env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.size, |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 266 | rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_SIZE)); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 267 | env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.touchMajor, |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 268 | rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR)); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 269 | env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.touchMinor, |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 270 | rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR)); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 271 | env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.toolMajor, |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 272 | rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR)); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 273 | env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.toolMinor, |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 274 | rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR)); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 275 | env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.orientation, |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 276 | rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION)); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 277 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 278 | const uint64_t unpackedAxisBits = 0 |
| 279 | | (1LL << AMOTION_EVENT_AXIS_X) |
| 280 | | (1LL << AMOTION_EVENT_AXIS_Y) |
| 281 | | (1LL << AMOTION_EVENT_AXIS_PRESSURE) |
| 282 | | (1LL << AMOTION_EVENT_AXIS_SIZE) |
| 283 | | (1LL << AMOTION_EVENT_AXIS_TOUCH_MAJOR) |
| 284 | | (1LL << AMOTION_EVENT_AXIS_TOUCH_MINOR) |
| 285 | | (1LL << AMOTION_EVENT_AXIS_TOOL_MAJOR) |
| 286 | | (1LL << AMOTION_EVENT_AXIS_TOOL_MINOR) |
| 287 | | (1LL << AMOTION_EVENT_AXIS_ORIENTATION); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 288 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 289 | uint64_t outBits = 0; |
| 290 | uint64_t remainingBits = rawPointerCoords->bits & ~unpackedAxisBits; |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 291 | if (remainingBits) { |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 292 | uint32_t packedAxesCount = __builtin_popcountll(remainingBits); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 293 | jfloatArray outValuesArray = obtainPackedAxisValuesArray(env, packedAxesCount, |
| 294 | outPointerCoordsObj); |
| 295 | if (!outValuesArray) { |
| 296 | return; // OOM |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 297 | } |
| 298 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 299 | jfloat* outValues = static_cast<jfloat*>(env->GetPrimitiveArrayCritical( |
| 300 | outValuesArray, NULL)); |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 301 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 302 | const float* values = rawPointerCoords->values; |
| 303 | uint32_t index = 0; |
| 304 | do { |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 305 | uint32_t axis = __builtin_ctzll(remainingBits); |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 306 | uint64_t axisBit = 1LL << axis; |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 307 | remainingBits &= ~axisBit; |
| 308 | outBits |= axisBit; |
| 309 | outValues[index++] = rawPointerCoords->getAxisValue(axis); |
| 310 | } while (remainingBits); |
| 311 | |
| 312 | env->ReleasePrimitiveArrayCritical(outValuesArray, outValues, 0); |
| 313 | env->DeleteLocalRef(outValuesArray); |
| 314 | } |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 315 | env->SetLongField(outPointerCoordsObj, gPointerCoordsClassInfo.mPackedAxisBits, outBits); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 316 | } |
| 317 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 318 | static void pointerPropertiesToNative(JNIEnv* env, jobject pointerPropertiesObj, |
| 319 | PointerProperties* outPointerProperties) { |
| 320 | outPointerProperties->clear(); |
| 321 | outPointerProperties->id = env->GetIntField(pointerPropertiesObj, |
| 322 | gPointerPropertiesClassInfo.id); |
| 323 | outPointerProperties->toolType = env->GetIntField(pointerPropertiesObj, |
| 324 | gPointerPropertiesClassInfo.toolType); |
| 325 | } |
| 326 | |
| 327 | static void pointerPropertiesFromNative(JNIEnv* env, const PointerProperties* pointerProperties, |
| 328 | jobject outPointerPropertiesObj) { |
| 329 | env->SetIntField(outPointerPropertiesObj, gPointerPropertiesClassInfo.id, |
| 330 | pointerProperties->id); |
| 331 | env->SetIntField(outPointerPropertiesObj, gPointerPropertiesClassInfo.toolType, |
| 332 | pointerProperties->toolType); |
| 333 | } |
| 334 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 335 | |
| 336 | // ---------------------------------------------------------------------------- |
| 337 | |
| 338 | static jint android_view_MotionEvent_nativeInitialize(JNIEnv* env, jclass clazz, |
| 339 | jint nativePtr, |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 340 | jint deviceId, jint source, jint action, jint flags, jint edgeFlags, |
| 341 | jint metaState, jint buttonState, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 342 | jfloat xOffset, jfloat yOffset, jfloat xPrecision, jfloat yPrecision, |
| 343 | jlong downTimeNanos, jlong eventTimeNanos, |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 344 | jint pointerCount, jobjectArray pointerPropertiesObjArray, |
| 345 | jobjectArray pointerCoordsObjArray) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 346 | if (!validatePointerCount(env, pointerCount) |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 347 | || !validatePointerPropertiesArray(env, pointerPropertiesObjArray, pointerCount) |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 348 | || !validatePointerCoordsObjArray(env, pointerCoordsObjArray, pointerCount)) { |
| 349 | return 0; |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 350 | } |
| 351 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 352 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 353 | if (!event) { |
| 354 | event = new MotionEvent(); |
| 355 | } |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 356 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 357 | PointerProperties pointerProperties[pointerCount]; |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 358 | PointerCoords rawPointerCoords[pointerCount]; |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 359 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 360 | for (jint i = 0; i < pointerCount; i++) { |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 361 | jobject pointerPropertiesObj = env->GetObjectArrayElement(pointerPropertiesObjArray, i); |
| 362 | if (!pointerPropertiesObj) { |
| 363 | goto Error; |
| 364 | } |
| 365 | pointerPropertiesToNative(env, pointerPropertiesObj, &pointerProperties[i]); |
| 366 | env->DeleteLocalRef(pointerPropertiesObj); |
| 367 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 368 | jobject pointerCoordsObj = env->GetObjectArrayElement(pointerCoordsObjArray, i); |
| 369 | if (!pointerCoordsObj) { |
| 370 | jniThrowNullPointerException(env, "pointerCoords"); |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 371 | goto Error; |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 372 | } |
| 373 | pointerCoordsToNative(env, pointerCoordsObj, xOffset, yOffset, &rawPointerCoords[i]); |
| 374 | env->DeleteLocalRef(pointerCoordsObj); |
| 375 | } |
| 376 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 377 | event->initialize(deviceId, source, action, flags, edgeFlags, metaState, buttonState, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 378 | xOffset, yOffset, xPrecision, yPrecision, |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 379 | downTimeNanos, eventTimeNanos, pointerCount, pointerProperties, rawPointerCoords); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 380 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 381 | return reinterpret_cast<jint>(event); |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 382 | |
| 383 | Error: |
| 384 | if (!nativePtr) { |
| 385 | delete event; |
| 386 | } |
| 387 | return 0; |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | static jint android_view_MotionEvent_nativeCopy(JNIEnv* env, jclass clazz, |
| 391 | jint destNativePtr, jint sourceNativePtr, jboolean keepHistory) { |
| 392 | MotionEvent* destEvent = reinterpret_cast<MotionEvent*>(destNativePtr); |
| 393 | if (!destEvent) { |
| 394 | destEvent = new MotionEvent(); |
| 395 | } |
| 396 | MotionEvent* sourceEvent = reinterpret_cast<MotionEvent*>(sourceNativePtr); |
| 397 | destEvent->copyFrom(sourceEvent, keepHistory); |
| 398 | return reinterpret_cast<jint>(destEvent); |
| 399 | } |
| 400 | |
| 401 | static void android_view_MotionEvent_nativeDispose(JNIEnv* env, jclass clazz, |
| 402 | jint nativePtr) { |
| 403 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 404 | delete event; |
| 405 | } |
| 406 | |
| 407 | static void android_view_MotionEvent_nativeAddBatch(JNIEnv* env, jclass clazz, |
| 408 | jint nativePtr, jlong eventTimeNanos, jobjectArray pointerCoordsObjArray, |
| 409 | jint metaState) { |
| 410 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 411 | size_t pointerCount = event->getPointerCount(); |
| 412 | if (!validatePointerCoordsObjArray(env, pointerCoordsObjArray, pointerCount)) { |
| 413 | return; |
| 414 | } |
| 415 | |
| 416 | PointerCoords rawPointerCoords[pointerCount]; |
| 417 | |
| 418 | for (size_t i = 0; i < pointerCount; i++) { |
| 419 | jobject pointerCoordsObj = env->GetObjectArrayElement(pointerCoordsObjArray, i); |
| 420 | if (!pointerCoordsObj) { |
| 421 | jniThrowNullPointerException(env, "pointerCoords"); |
| 422 | return; |
| 423 | } |
| 424 | pointerCoordsToNative(env, pointerCoordsObj, |
| 425 | event->getXOffset(), event->getYOffset(), &rawPointerCoords[i]); |
| 426 | env->DeleteLocalRef(pointerCoordsObj); |
| 427 | } |
| 428 | |
| 429 | event->addSample(eventTimeNanos, rawPointerCoords); |
| 430 | event->setMetaState(event->getMetaState() | metaState); |
| 431 | } |
| 432 | |
| 433 | static jint android_view_MotionEvent_nativeGetDeviceId(JNIEnv* env, jclass clazz, |
| 434 | jint nativePtr) { |
| 435 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 436 | return event->getDeviceId(); |
| 437 | } |
| 438 | |
| 439 | static jint android_view_MotionEvent_nativeGetSource(JNIEnv* env, jclass clazz, |
| 440 | jint nativePtr) { |
| 441 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 442 | return event->getSource(); |
| 443 | } |
| 444 | |
| 445 | static void android_view_MotionEvent_nativeSetSource(JNIEnv* env, jclass clazz, |
| 446 | jint nativePtr, jint source) { |
| 447 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 448 | event->setSource(source); |
| 449 | } |
| 450 | |
| 451 | static jint android_view_MotionEvent_nativeGetAction(JNIEnv* env, jclass clazz, |
| 452 | jint nativePtr) { |
| 453 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 454 | return event->getAction(); |
| 455 | } |
| 456 | |
| 457 | static void android_view_MotionEvent_nativeSetAction(JNIEnv* env, jclass clazz, |
| 458 | jint nativePtr, jint action) { |
| 459 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 460 | event->setAction(action); |
| 461 | } |
| 462 | |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 463 | static jboolean android_view_MotionEvent_nativeIsTouchEvent(JNIEnv* env, jclass clazz, |
| 464 | jint nativePtr) { |
| 465 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 466 | return event->isTouchEvent(); |
| 467 | } |
| 468 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 469 | static jint android_view_MotionEvent_nativeGetFlags(JNIEnv* env, jclass clazz, |
| 470 | jint nativePtr) { |
| 471 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 472 | return event->getFlags(); |
| 473 | } |
| 474 | |
Jeff Brown | 21bc5c9 | 2011-02-28 18:27:14 -0800 | [diff] [blame] | 475 | static void android_view_MotionEvent_nativeSetFlags(JNIEnv* env, jclass clazz, |
| 476 | jint nativePtr, jint flags) { |
| 477 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 478 | event->setFlags(flags); |
| 479 | } |
| 480 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 481 | static jint android_view_MotionEvent_nativeGetEdgeFlags(JNIEnv* env, jclass clazz, |
| 482 | jint nativePtr) { |
| 483 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 484 | return event->getEdgeFlags(); |
| 485 | } |
| 486 | |
| 487 | static void android_view_MotionEvent_nativeSetEdgeFlags(JNIEnv* env, jclass clazz, |
| 488 | jint nativePtr, jint edgeFlags) { |
| 489 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 490 | event->setEdgeFlags(edgeFlags); |
| 491 | } |
| 492 | |
| 493 | static jint android_view_MotionEvent_nativeGetMetaState(JNIEnv* env, jclass clazz, |
| 494 | jint nativePtr) { |
| 495 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 496 | return event->getMetaState(); |
| 497 | } |
| 498 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 499 | static jint android_view_MotionEvent_nativeGetButtonState(JNIEnv* env, jclass clazz, |
| 500 | jint nativePtr) { |
| 501 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 502 | return event->getButtonState(); |
| 503 | } |
| 504 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 505 | static void android_view_MotionEvent_nativeOffsetLocation(JNIEnv* env, jclass clazz, |
| 506 | jint nativePtr, jfloat deltaX, jfloat deltaY) { |
| 507 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 508 | return event->offsetLocation(deltaX, deltaY); |
| 509 | } |
| 510 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 511 | static jfloat android_view_MotionEvent_nativeGetXOffset(JNIEnv* env, jclass clazz, |
| 512 | jint nativePtr) { |
| 513 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 514 | return event->getXOffset(); |
| 515 | } |
| 516 | |
| 517 | static jfloat android_view_MotionEvent_nativeGetYOffset(JNIEnv* env, jclass clazz, |
| 518 | jint nativePtr) { |
| 519 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 520 | return event->getYOffset(); |
| 521 | } |
| 522 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 523 | static jfloat android_view_MotionEvent_nativeGetXPrecision(JNIEnv* env, jclass clazz, |
| 524 | jint nativePtr) { |
| 525 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 526 | return event->getXPrecision(); |
| 527 | } |
| 528 | |
| 529 | static jfloat android_view_MotionEvent_nativeGetYPrecision(JNIEnv* env, jclass clazz, |
| 530 | jint nativePtr) { |
| 531 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 532 | return event->getYPrecision(); |
| 533 | } |
| 534 | |
| 535 | static jlong android_view_MotionEvent_nativeGetDownTimeNanos(JNIEnv* env, jclass clazz, |
| 536 | jint nativePtr) { |
| 537 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 538 | return event->getDownTime(); |
| 539 | } |
| 540 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 541 | static void android_view_MotionEvent_nativeSetDownTimeNanos(JNIEnv* env, jclass clazz, |
| 542 | jint nativePtr, jlong downTimeNanos) { |
| 543 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 544 | event->setDownTime(downTimeNanos); |
| 545 | } |
| 546 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 547 | static jint android_view_MotionEvent_nativeGetPointerCount(JNIEnv* env, jclass clazz, |
| 548 | jint nativePtr) { |
| 549 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 550 | return jint(event->getPointerCount()); |
| 551 | } |
| 552 | |
| 553 | static jint android_view_MotionEvent_nativeGetPointerId(JNIEnv* env, jclass clazz, |
| 554 | jint nativePtr, jint pointerIndex) { |
| 555 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 556 | size_t pointerCount = event->getPointerCount(); |
| 557 | if (!validatePointerIndex(env, pointerIndex, pointerCount)) { |
| 558 | return -1; |
| 559 | } |
| 560 | return event->getPointerId(pointerIndex); |
| 561 | } |
| 562 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 563 | static jint android_view_MotionEvent_nativeGetToolType(JNIEnv* env, jclass clazz, |
| 564 | jint nativePtr, jint pointerIndex) { |
| 565 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 566 | size_t pointerCount = event->getPointerCount(); |
| 567 | if (!validatePointerIndex(env, pointerIndex, pointerCount)) { |
| 568 | return -1; |
| 569 | } |
| 570 | return event->getToolType(pointerIndex); |
| 571 | } |
| 572 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 573 | static jint android_view_MotionEvent_nativeFindPointerIndex(JNIEnv* env, jclass clazz, |
| 574 | jint nativePtr, jint pointerId) { |
| 575 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
Jeff Brown | 2ed2462 | 2011-03-14 19:39:54 -0700 | [diff] [blame] | 576 | return jint(event->findPointerIndex(pointerId)); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | static jint android_view_MotionEvent_nativeGetHistorySize(JNIEnv* env, jclass clazz, |
| 580 | jint nativePtr) { |
| 581 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 582 | return jint(event->getHistorySize()); |
| 583 | } |
| 584 | |
| 585 | static jlong android_view_MotionEvent_nativeGetEventTimeNanos(JNIEnv* env, jclass clazz, |
| 586 | jint nativePtr, jint historyPos) { |
| 587 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 588 | if (historyPos == HISTORY_CURRENT) { |
| 589 | return event->getEventTime(); |
| 590 | } else { |
| 591 | size_t historySize = event->getHistorySize(); |
| 592 | if (!validateHistoryPos(env, historyPos, historySize)) { |
| 593 | return 0; |
| 594 | } |
| 595 | return event->getHistoricalEventTime(historyPos); |
| 596 | } |
| 597 | } |
| 598 | |
| 599 | static jfloat android_view_MotionEvent_nativeGetRawAxisValue(JNIEnv* env, jclass clazz, |
| 600 | jint nativePtr, jint axis, jint pointerIndex, jint historyPos) { |
| 601 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 602 | size_t pointerCount = event->getPointerCount(); |
| 603 | if (!validatePointerIndex(env, pointerIndex, pointerCount)) { |
| 604 | return 0; |
| 605 | } |
| 606 | |
| 607 | if (historyPos == HISTORY_CURRENT) { |
| 608 | return event->getRawAxisValue(axis, pointerIndex); |
| 609 | } else { |
| 610 | size_t historySize = event->getHistorySize(); |
| 611 | if (!validateHistoryPos(env, historyPos, historySize)) { |
| 612 | return 0; |
| 613 | } |
| 614 | return event->getHistoricalRawAxisValue(axis, pointerIndex, historyPos); |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | static jfloat android_view_MotionEvent_nativeGetAxisValue(JNIEnv* env, jclass clazz, |
| 619 | jint nativePtr, jint axis, jint pointerIndex, jint historyPos) { |
| 620 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 621 | size_t pointerCount = event->getPointerCount(); |
| 622 | if (!validatePointerIndex(env, pointerIndex, pointerCount)) { |
| 623 | return 0; |
| 624 | } |
| 625 | |
| 626 | if (historyPos == HISTORY_CURRENT) { |
| 627 | return event->getAxisValue(axis, pointerIndex); |
| 628 | } else { |
| 629 | size_t historySize = event->getHistorySize(); |
| 630 | if (!validateHistoryPos(env, historyPos, historySize)) { |
| 631 | return 0; |
| 632 | } |
| 633 | return event->getHistoricalAxisValue(axis, pointerIndex, historyPos); |
| 634 | } |
| 635 | } |
| 636 | |
| 637 | static void android_view_MotionEvent_nativeGetPointerCoords(JNIEnv* env, jclass clazz, |
| 638 | jint nativePtr, jint pointerIndex, jint historyPos, jobject outPointerCoordsObj) { |
| 639 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 640 | size_t pointerCount = event->getPointerCount(); |
| 641 | if (!validatePointerIndex(env, pointerIndex, pointerCount) |
| 642 | || !validatePointerCoords(env, outPointerCoordsObj)) { |
| 643 | return; |
| 644 | } |
| 645 | |
| 646 | const PointerCoords* rawPointerCoords; |
| 647 | if (historyPos == HISTORY_CURRENT) { |
| 648 | rawPointerCoords = event->getRawPointerCoords(pointerIndex); |
| 649 | } else { |
| 650 | size_t historySize = event->getHistorySize(); |
| 651 | if (!validateHistoryPos(env, historyPos, historySize)) { |
| 652 | return; |
| 653 | } |
| 654 | rawPointerCoords = event->getHistoricalRawPointerCoords(pointerIndex, historyPos); |
| 655 | } |
| 656 | pointerCoordsFromNative(env, rawPointerCoords, event->getXOffset(), event->getYOffset(), |
| 657 | outPointerCoordsObj); |
| 658 | } |
| 659 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 660 | static void android_view_MotionEvent_nativeGetPointerProperties(JNIEnv* env, jclass clazz, |
| 661 | jint nativePtr, jint pointerIndex, jobject outPointerPropertiesObj) { |
| 662 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 663 | size_t pointerCount = event->getPointerCount(); |
| 664 | if (!validatePointerIndex(env, pointerIndex, pointerCount) |
| 665 | || !validatePointerProperties(env, outPointerPropertiesObj)) { |
| 666 | return; |
| 667 | } |
| 668 | |
| 669 | const PointerProperties* pointerProperties = event->getPointerProperties(pointerIndex); |
| 670 | pointerPropertiesFromNative(env, pointerProperties, outPointerPropertiesObj); |
| 671 | } |
| 672 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 673 | static void android_view_MotionEvent_nativeScale(JNIEnv* env, jclass clazz, |
| 674 | jint nativePtr, jfloat scale) { |
| 675 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 676 | event->scale(scale); |
| 677 | } |
| 678 | |
| 679 | static void android_view_MotionEvent_nativeTransform(JNIEnv* env, jclass clazz, |
| 680 | jint nativePtr, jobject matrixObj) { |
| 681 | SkMatrix* matrix = android_graphics_Matrix_getSkMatrix(env, matrixObj); |
| 682 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 683 | event->transform(matrix); |
| 684 | } |
| 685 | |
| 686 | static jint android_view_MotionEvent_nativeReadFromParcel(JNIEnv* env, jclass clazz, |
| 687 | jint nativePtr, jobject parcelObj) { |
| 688 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 689 | if (!event) { |
| 690 | event = new MotionEvent(); |
| 691 | } |
| 692 | |
| 693 | Parcel* parcel = parcelForJavaObject(env, parcelObj); |
| 694 | |
| 695 | status_t status = event->readFromParcel(parcel); |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 696 | if (status) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 697 | if (!nativePtr) { |
| 698 | delete event; |
| 699 | } |
| 700 | jniThrowRuntimeException(env, "Failed to read MotionEvent parcel."); |
| 701 | return 0; |
| 702 | } |
| 703 | return reinterpret_cast<jint>(event); |
| 704 | } |
| 705 | |
| 706 | static void android_view_MotionEvent_nativeWriteToParcel(JNIEnv* env, jclass clazz, |
| 707 | jint nativePtr, jobject parcelObj) { |
| 708 | MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); |
| 709 | Parcel* parcel = parcelForJavaObject(env, parcelObj); |
| 710 | |
| 711 | status_t status = event->writeToParcel(parcel); |
Jeff Brown | ebbd5d1 | 2011-02-17 13:01:34 -0800 | [diff] [blame] | 712 | if (status) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 713 | jniThrowRuntimeException(env, "Failed to write MotionEvent parcel."); |
| 714 | } |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 715 | } |
| 716 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 717 | // ---------------------------------------------------------------------------- |
| 718 | |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 719 | static JNINativeMethod gMotionEventMethods[] = { |
| 720 | /* name, signature, funcPtr */ |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 721 | { "nativeInitialize", |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 722 | "(IIIIIIIIFFFFJJI[Landroid/view/MotionEvent$PointerProperties;" |
| 723 | "[Landroid/view/MotionEvent$PointerCoords;)I", |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 724 | (void*)android_view_MotionEvent_nativeInitialize }, |
| 725 | { "nativeCopy", |
| 726 | "(IIZ)I", |
| 727 | (void*)android_view_MotionEvent_nativeCopy }, |
| 728 | { "nativeDispose", |
| 729 | "(I)V", |
| 730 | (void*)android_view_MotionEvent_nativeDispose }, |
| 731 | { "nativeAddBatch", |
| 732 | "(IJ[Landroid/view/MotionEvent$PointerCoords;I)V", |
| 733 | (void*)android_view_MotionEvent_nativeAddBatch }, |
| 734 | { "nativeGetDeviceId", |
| 735 | "(I)I", |
| 736 | (void*)android_view_MotionEvent_nativeGetDeviceId }, |
| 737 | { "nativeGetSource", |
| 738 | "(I)I", |
| 739 | (void*)android_view_MotionEvent_nativeGetSource }, |
| 740 | { "nativeSetSource", |
| 741 | "(II)I", |
| 742 | (void*)android_view_MotionEvent_nativeSetSource }, |
| 743 | { "nativeGetAction", |
| 744 | "(I)I", |
| 745 | (void*)android_view_MotionEvent_nativeGetAction }, |
| 746 | { "nativeSetAction", |
| 747 | "(II)V", |
| 748 | (void*)android_view_MotionEvent_nativeSetAction }, |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 749 | { "nativeIsTouchEvent", |
| 750 | "(I)Z", |
| 751 | (void*)android_view_MotionEvent_nativeIsTouchEvent }, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 752 | { "nativeGetFlags", |
| 753 | "(I)I", |
| 754 | (void*)android_view_MotionEvent_nativeGetFlags }, |
Jeff Brown | 21bc5c9 | 2011-02-28 18:27:14 -0800 | [diff] [blame] | 755 | { "nativeSetFlags", |
| 756 | "(II)V", |
| 757 | (void*)android_view_MotionEvent_nativeSetFlags }, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 758 | { "nativeGetEdgeFlags", |
| 759 | "(I)I", |
| 760 | (void*)android_view_MotionEvent_nativeGetEdgeFlags }, |
| 761 | { "nativeSetEdgeFlags", |
| 762 | "(II)V", |
| 763 | (void*)android_view_MotionEvent_nativeSetEdgeFlags }, |
| 764 | { "nativeGetMetaState", |
| 765 | "(I)I", |
| 766 | (void*)android_view_MotionEvent_nativeGetMetaState }, |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 767 | { "nativeGetButtonState", |
| 768 | "(I)I", |
| 769 | (void*)android_view_MotionEvent_nativeGetButtonState }, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 770 | { "nativeOffsetLocation", |
| 771 | "(IFF)V", |
| 772 | (void*)android_view_MotionEvent_nativeOffsetLocation }, |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 773 | { "nativeGetXOffset", |
| 774 | "(I)F", |
| 775 | (void*)android_view_MotionEvent_nativeGetXOffset }, |
| 776 | { "nativeGetYOffset", |
| 777 | "(I)F", |
| 778 | (void*)android_view_MotionEvent_nativeGetYOffset }, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 779 | { "nativeGetXPrecision", |
| 780 | "(I)F", |
| 781 | (void*)android_view_MotionEvent_nativeGetXPrecision }, |
| 782 | { "nativeGetYPrecision", |
| 783 | "(I)F", |
| 784 | (void*)android_view_MotionEvent_nativeGetYPrecision }, |
| 785 | { "nativeGetDownTimeNanos", |
| 786 | "(I)J", |
| 787 | (void*)android_view_MotionEvent_nativeGetDownTimeNanos }, |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 788 | { "nativeSetDownTimeNanos", |
| 789 | "(IJ)V", |
| 790 | (void*)android_view_MotionEvent_nativeSetDownTimeNanos }, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 791 | { "nativeGetPointerCount", |
| 792 | "(I)I", |
| 793 | (void*)android_view_MotionEvent_nativeGetPointerCount }, |
| 794 | { "nativeGetPointerId", |
| 795 | "(II)I", |
| 796 | (void*)android_view_MotionEvent_nativeGetPointerId }, |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 797 | { "nativeGetToolType", |
| 798 | "(II)I", |
| 799 | (void*)android_view_MotionEvent_nativeGetToolType }, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 800 | { "nativeFindPointerIndex", |
| 801 | "(II)I", |
| 802 | (void*)android_view_MotionEvent_nativeFindPointerIndex }, |
| 803 | { "nativeGetHistorySize", |
| 804 | "(I)I", |
| 805 | (void*)android_view_MotionEvent_nativeGetHistorySize }, |
| 806 | { "nativeGetEventTimeNanos", |
| 807 | "(II)J", |
| 808 | (void*)android_view_MotionEvent_nativeGetEventTimeNanos }, |
| 809 | { "nativeGetRawAxisValue", |
| 810 | "(IIII)F", |
| 811 | (void*)android_view_MotionEvent_nativeGetRawAxisValue }, |
| 812 | { "nativeGetAxisValue", |
| 813 | "(IIII)F", |
| 814 | (void*)android_view_MotionEvent_nativeGetAxisValue }, |
| 815 | { "nativeGetPointerCoords", |
| 816 | "(IIILandroid/view/MotionEvent$PointerCoords;)V", |
| 817 | (void*)android_view_MotionEvent_nativeGetPointerCoords }, |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 818 | { "nativeGetPointerProperties", |
| 819 | "(IILandroid/view/MotionEvent$PointerProperties;)V", |
| 820 | (void*)android_view_MotionEvent_nativeGetPointerProperties }, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 821 | { "nativeScale", |
| 822 | "(IF)V", |
| 823 | (void*)android_view_MotionEvent_nativeScale }, |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 824 | { "nativeTransform", |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 825 | "(ILandroid/graphics/Matrix;)V", |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 826 | (void*)android_view_MotionEvent_nativeTransform }, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 827 | { "nativeReadFromParcel", |
| 828 | "(ILandroid/os/Parcel;)I", |
| 829 | (void*)android_view_MotionEvent_nativeReadFromParcel }, |
| 830 | { "nativeWriteToParcel", |
| 831 | "(ILandroid/os/Parcel;)V", |
| 832 | (void*)android_view_MotionEvent_nativeWriteToParcel }, |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 833 | }; |
| 834 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 835 | #define FIND_CLASS(var, className) \ |
| 836 | var = env->FindClass(className); \ |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 837 | LOG_FATAL_IF(! var, "Unable to find class " className); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 838 | |
| 839 | #define GET_STATIC_METHOD_ID(var, clazz, methodName, fieldDescriptor) \ |
| 840 | var = env->GetStaticMethodID(clazz, methodName, fieldDescriptor); \ |
| 841 | LOG_FATAL_IF(! var, "Unable to find static method" methodName); |
| 842 | |
| 843 | #define GET_METHOD_ID(var, clazz, methodName, fieldDescriptor) \ |
| 844 | var = env->GetMethodID(clazz, methodName, fieldDescriptor); \ |
| 845 | LOG_FATAL_IF(! var, "Unable to find method" methodName); |
| 846 | |
| 847 | #define GET_FIELD_ID(var, clazz, fieldName, fieldDescriptor) \ |
| 848 | var = env->GetFieldID(clazz, fieldName, fieldDescriptor); \ |
| 849 | LOG_FATAL_IF(! var, "Unable to find field " fieldName); |
| 850 | |
| 851 | int register_android_view_MotionEvent(JNIEnv* env) { |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 852 | int res = jniRegisterNativeMethods(env, "android/view/MotionEvent", |
| 853 | gMotionEventMethods, NELEM(gMotionEventMethods)); |
| 854 | LOG_FATAL_IF(res < 0, "Unable to register native methods."); |
| 855 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 856 | FIND_CLASS(gMotionEventClassInfo.clazz, "android/view/MotionEvent"); |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 857 | gMotionEventClassInfo.clazz = jclass(env->NewGlobalRef(gMotionEventClassInfo.clazz)); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 858 | |
| 859 | GET_STATIC_METHOD_ID(gMotionEventClassInfo.obtain, gMotionEventClassInfo.clazz, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 860 | "obtain", "()Landroid/view/MotionEvent;"); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 861 | GET_METHOD_ID(gMotionEventClassInfo.recycle, gMotionEventClassInfo.clazz, |
| 862 | "recycle", "()V"); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 863 | GET_FIELD_ID(gMotionEventClassInfo.mNativePtr, gMotionEventClassInfo.clazz, |
| 864 | "mNativePtr", "I"); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 865 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 866 | jclass clazz; |
| 867 | FIND_CLASS(clazz, "android/view/MotionEvent$PointerCoords"); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 868 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 869 | GET_FIELD_ID(gPointerCoordsClassInfo.mPackedAxisBits, clazz, |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 870 | "mPackedAxisBits", "J"); |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 871 | GET_FIELD_ID(gPointerCoordsClassInfo.mPackedAxisValues, clazz, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 872 | "mPackedAxisValues", "[F"); |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 873 | GET_FIELD_ID(gPointerCoordsClassInfo.x, clazz, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 874 | "x", "F"); |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 875 | GET_FIELD_ID(gPointerCoordsClassInfo.y, clazz, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 876 | "y", "F"); |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 877 | GET_FIELD_ID(gPointerCoordsClassInfo.pressure, clazz, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 878 | "pressure", "F"); |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 879 | GET_FIELD_ID(gPointerCoordsClassInfo.size, clazz, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 880 | "size", "F"); |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 881 | GET_FIELD_ID(gPointerCoordsClassInfo.touchMajor, clazz, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 882 | "touchMajor", "F"); |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 883 | GET_FIELD_ID(gPointerCoordsClassInfo.touchMinor, clazz, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 884 | "touchMinor", "F"); |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 885 | GET_FIELD_ID(gPointerCoordsClassInfo.toolMajor, clazz, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 886 | "toolMajor", "F"); |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 887 | GET_FIELD_ID(gPointerCoordsClassInfo.toolMinor, clazz, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 888 | "toolMinor", "F"); |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 889 | GET_FIELD_ID(gPointerCoordsClassInfo.orientation, clazz, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 890 | "orientation", "F"); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 891 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 892 | FIND_CLASS(clazz, "android/view/MotionEvent$PointerProperties"); |
| 893 | |
| 894 | GET_FIELD_ID(gPointerPropertiesClassInfo.id, clazz, |
| 895 | "id", "I"); |
| 896 | GET_FIELD_ID(gPointerPropertiesClassInfo.toolType, clazz, |
| 897 | "toolType", "I"); |
| 898 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 899 | return 0; |
| 900 | } |
| 901 | |
| 902 | } // namespace android |