Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [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_NDEBUG 0 |
| 18 | |
| 19 | #define LOG_TAG "MtpDeviceJNI" |
| 20 | #include "utils/Log.h" |
| 21 | |
| 22 | #include <stdio.h> |
| 23 | #include <assert.h> |
| 24 | #include <limits.h> |
| 25 | #include <unistd.h> |
| 26 | #include <fcntl.h> |
| 27 | |
| 28 | #include "jni.h" |
| 29 | #include "JNIHelp.h" |
| 30 | #include "android_runtime/AndroidRuntime.h" |
Ruben Brunk | 87eac99 | 2013-09-09 17:44:59 -0700 | [diff] [blame] | 31 | #include "android_runtime/Log.h" |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 32 | #include "private/android_filesystem_config.h" |
| 33 | |
| 34 | #include "MtpTypes.h" |
| 35 | #include "MtpDevice.h" |
| 36 | #include "MtpDeviceInfo.h" |
| 37 | #include "MtpStorageInfo.h" |
| 38 | #include "MtpObjectInfo.h" |
| 39 | |
| 40 | using namespace android; |
| 41 | |
| 42 | // ---------------------------------------------------------------------------- |
| 43 | |
| 44 | static jfieldID field_context; |
| 45 | |
| 46 | jclass clazz_deviceInfo; |
| 47 | jclass clazz_storageInfo; |
| 48 | jclass clazz_objectInfo; |
| 49 | |
| 50 | jmethodID constructor_deviceInfo; |
| 51 | jmethodID constructor_storageInfo; |
| 52 | jmethodID constructor_objectInfo; |
| 53 | |
| 54 | // MtpDeviceInfo fields |
| 55 | static jfieldID field_deviceInfo_manufacturer; |
| 56 | static jfieldID field_deviceInfo_model; |
| 57 | static jfieldID field_deviceInfo_version; |
| 58 | static jfieldID field_deviceInfo_serialNumber; |
| 59 | |
| 60 | // MtpStorageInfo fields |
| 61 | static jfieldID field_storageInfo_storageId; |
| 62 | static jfieldID field_storageInfo_maxCapacity; |
| 63 | static jfieldID field_storageInfo_freeSpace; |
| 64 | static jfieldID field_storageInfo_description; |
| 65 | static jfieldID field_storageInfo_volumeIdentifier; |
| 66 | |
| 67 | // MtpObjectInfo fields |
| 68 | static jfieldID field_objectInfo_handle; |
| 69 | static jfieldID field_objectInfo_storageId; |
| 70 | static jfieldID field_objectInfo_format; |
| 71 | static jfieldID field_objectInfo_protectionStatus; |
| 72 | static jfieldID field_objectInfo_compressedSize; |
| 73 | static jfieldID field_objectInfo_thumbFormat; |
| 74 | static jfieldID field_objectInfo_thumbCompressedSize; |
| 75 | static jfieldID field_objectInfo_thumbPixWidth; |
| 76 | static jfieldID field_objectInfo_thumbPixHeight; |
| 77 | static jfieldID field_objectInfo_imagePixWidth; |
| 78 | static jfieldID field_objectInfo_imagePixHeight; |
| 79 | static jfieldID field_objectInfo_imagePixDepth; |
| 80 | static jfieldID field_objectInfo_parent; |
| 81 | static jfieldID field_objectInfo_associationType; |
| 82 | static jfieldID field_objectInfo_associationDesc; |
| 83 | static jfieldID field_objectInfo_sequenceNumber; |
| 84 | static jfieldID field_objectInfo_name; |
| 85 | static jfieldID field_objectInfo_dateCreated; |
| 86 | static jfieldID field_objectInfo_dateModified; |
| 87 | static jfieldID field_objectInfo_keywords; |
| 88 | |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 89 | MtpDevice* get_device_from_object(JNIEnv* env, jobject javaDevice) |
| 90 | { |
Ashok Bhat | e2e5932 | 2013-12-17 19:04:19 +0000 | [diff] [blame] | 91 | return (MtpDevice*)env->GetLongField(javaDevice, field_context); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | static void checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodName) { |
| 95 | if (env->ExceptionCheck()) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 96 | ALOGE("An exception was thrown by callback '%s'.", methodName); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 97 | LOGE_EX(env); |
| 98 | env->ExceptionClear(); |
| 99 | } |
| 100 | } |
| 101 | |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 102 | // ---------------------------------------------------------------------------- |
| 103 | |
| 104 | static jboolean |
| 105 | android_mtp_MtpDevice_open(JNIEnv *env, jobject thiz, jstring deviceName, jint fd) |
| 106 | { |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 107 | const char *deviceNameStr = env->GetStringUTFChars(deviceName, NULL); |
James Dong | 3977472 | 2011-04-06 11:57:48 -0700 | [diff] [blame] | 108 | if (deviceNameStr == NULL) { |
Ashok Bhat | e2e5932 | 2013-12-17 19:04:19 +0000 | [diff] [blame] | 109 | return JNI_FALSE; |
James Dong | 3977472 | 2011-04-06 11:57:48 -0700 | [diff] [blame] | 110 | } |
| 111 | |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 112 | MtpDevice* device = MtpDevice::open(deviceNameStr, fd); |
| 113 | env->ReleaseStringUTFChars(deviceName, deviceNameStr); |
| 114 | |
| 115 | if (device) |
Ashok Bhat | e2e5932 | 2013-12-17 19:04:19 +0000 | [diff] [blame] | 116 | env->SetLongField(thiz, field_context, (jlong)device); |
| 117 | return (jboolean)(device != NULL); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | static void |
| 121 | android_mtp_MtpDevice_close(JNIEnv *env, jobject thiz) |
| 122 | { |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 123 | MtpDevice* device = get_device_from_object(env, thiz); |
| 124 | if (device) { |
| 125 | device->close(); |
| 126 | delete device; |
Ashok Bhat | e2e5932 | 2013-12-17 19:04:19 +0000 | [diff] [blame] | 127 | env->SetLongField(thiz, field_context, 0); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 128 | } |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | static jobject |
| 132 | android_mtp_MtpDevice_get_device_info(JNIEnv *env, jobject thiz) |
| 133 | { |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 134 | MtpDevice* device = get_device_from_object(env, thiz); |
| 135 | if (!device) { |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 136 | ALOGD("android_mtp_MtpDevice_get_device_info device is null"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 137 | return NULL; |
| 138 | } |
| 139 | MtpDeviceInfo* deviceInfo = device->getDeviceInfo(); |
| 140 | if (!deviceInfo) { |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 141 | ALOGD("android_mtp_MtpDevice_get_device_info deviceInfo is null"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 142 | return NULL; |
| 143 | } |
| 144 | jobject info = env->NewObject(clazz_deviceInfo, constructor_deviceInfo); |
| 145 | if (info == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 146 | ALOGE("Could not create a MtpDeviceInfo object"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 147 | delete deviceInfo; |
| 148 | return NULL; |
| 149 | } |
| 150 | |
| 151 | if (deviceInfo->mManufacturer) |
| 152 | env->SetObjectField(info, field_deviceInfo_manufacturer, |
| 153 | env->NewStringUTF(deviceInfo->mManufacturer)); |
| 154 | if (deviceInfo->mModel) |
| 155 | env->SetObjectField(info, field_deviceInfo_model, |
| 156 | env->NewStringUTF(deviceInfo->mModel)); |
| 157 | if (deviceInfo->mVersion) |
| 158 | env->SetObjectField(info, field_deviceInfo_version, |
| 159 | env->NewStringUTF(deviceInfo->mVersion)); |
| 160 | if (deviceInfo->mSerial) |
| 161 | env->SetObjectField(info, field_deviceInfo_serialNumber, |
| 162 | env->NewStringUTF(deviceInfo->mSerial)); |
| 163 | |
| 164 | delete deviceInfo; |
| 165 | return info; |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | static jintArray |
| 169 | android_mtp_MtpDevice_get_storage_ids(JNIEnv *env, jobject thiz) |
| 170 | { |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 171 | MtpDevice* device = get_device_from_object(env, thiz); |
| 172 | if (!device) |
| 173 | return NULL; |
| 174 | MtpStorageIDList* storageIDs = device->getStorageIDs(); |
| 175 | if (!storageIDs) |
| 176 | return NULL; |
| 177 | |
| 178 | int length = storageIDs->size(); |
| 179 | jintArray array = env->NewIntArray(length); |
| 180 | // FIXME is this cast safe? |
| 181 | env->SetIntArrayRegion(array, 0, length, (const jint *)storageIDs->array()); |
| 182 | |
| 183 | delete storageIDs; |
| 184 | return array; |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | static jobject |
| 188 | android_mtp_MtpDevice_get_storage_info(JNIEnv *env, jobject thiz, jint storageID) |
| 189 | { |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 190 | MtpDevice* device = get_device_from_object(env, thiz); |
| 191 | if (!device) |
| 192 | return NULL; |
| 193 | MtpStorageInfo* storageInfo = device->getStorageInfo(storageID); |
| 194 | if (!storageInfo) |
| 195 | return NULL; |
| 196 | |
| 197 | jobject info = env->NewObject(clazz_storageInfo, constructor_storageInfo); |
| 198 | if (info == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 199 | ALOGE("Could not create a MtpStorageInfo object"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 200 | delete storageInfo; |
| 201 | return NULL; |
| 202 | } |
| 203 | |
| 204 | if (storageInfo->mStorageID) |
| 205 | env->SetIntField(info, field_storageInfo_storageId, storageInfo->mStorageID); |
| 206 | if (storageInfo->mMaxCapacity) |
| 207 | env->SetLongField(info, field_storageInfo_maxCapacity, storageInfo->mMaxCapacity); |
| 208 | if (storageInfo->mFreeSpaceBytes) |
| 209 | env->SetLongField(info, field_storageInfo_freeSpace, storageInfo->mFreeSpaceBytes); |
| 210 | if (storageInfo->mStorageDescription) |
| 211 | env->SetObjectField(info, field_storageInfo_description, |
| 212 | env->NewStringUTF(storageInfo->mStorageDescription)); |
| 213 | if (storageInfo->mVolumeIdentifier) |
| 214 | env->SetObjectField(info, field_storageInfo_volumeIdentifier, |
| 215 | env->NewStringUTF(storageInfo->mVolumeIdentifier)); |
| 216 | |
| 217 | delete storageInfo; |
| 218 | return info; |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | static jintArray |
| 222 | android_mtp_MtpDevice_get_object_handles(JNIEnv *env, jobject thiz, |
| 223 | jint storageID, jint format, jint objectID) |
| 224 | { |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 225 | MtpDevice* device = get_device_from_object(env, thiz); |
| 226 | if (!device) |
| 227 | return NULL; |
| 228 | MtpObjectHandleList* handles = device->getObjectHandles(storageID, format, objectID); |
| 229 | if (!handles) |
| 230 | return NULL; |
| 231 | |
| 232 | int length = handles->size(); |
| 233 | jintArray array = env->NewIntArray(length); |
| 234 | // FIXME is this cast safe? |
| 235 | env->SetIntArrayRegion(array, 0, length, (const jint *)handles->array()); |
| 236 | |
| 237 | delete handles; |
| 238 | return array; |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | static jobject |
| 242 | android_mtp_MtpDevice_get_object_info(JNIEnv *env, jobject thiz, jint objectID) |
| 243 | { |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 244 | MtpDevice* device = get_device_from_object(env, thiz); |
| 245 | if (!device) |
| 246 | return NULL; |
| 247 | MtpObjectInfo* objectInfo = device->getObjectInfo(objectID); |
| 248 | if (!objectInfo) |
| 249 | return NULL; |
| 250 | jobject info = env->NewObject(clazz_objectInfo, constructor_objectInfo); |
| 251 | if (info == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 252 | ALOGE("Could not create a MtpObjectInfo object"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 253 | delete objectInfo; |
| 254 | return NULL; |
| 255 | } |
| 256 | |
| 257 | if (objectInfo->mHandle) |
| 258 | env->SetIntField(info, field_objectInfo_handle, objectInfo->mHandle); |
| 259 | if (objectInfo->mStorageID) |
| 260 | env->SetIntField(info, field_objectInfo_storageId, objectInfo->mStorageID); |
| 261 | if (objectInfo->mFormat) |
| 262 | env->SetIntField(info, field_objectInfo_format, objectInfo->mFormat); |
| 263 | if (objectInfo->mProtectionStatus) |
| 264 | env->SetIntField(info, field_objectInfo_protectionStatus, objectInfo->mProtectionStatus); |
| 265 | if (objectInfo->mCompressedSize) |
| 266 | env->SetIntField(info, field_objectInfo_compressedSize, objectInfo->mCompressedSize); |
| 267 | if (objectInfo->mThumbFormat) |
| 268 | env->SetIntField(info, field_objectInfo_thumbFormat, objectInfo->mThumbFormat); |
| 269 | if (objectInfo->mThumbCompressedSize) |
| 270 | env->SetIntField(info, field_objectInfo_thumbCompressedSize, objectInfo->mThumbCompressedSize); |
| 271 | if (objectInfo->mThumbPixWidth) |
| 272 | env->SetIntField(info, field_objectInfo_thumbPixWidth, objectInfo->mThumbPixWidth); |
| 273 | if (objectInfo->mThumbPixHeight) |
| 274 | env->SetIntField(info, field_objectInfo_thumbPixHeight, objectInfo->mThumbPixHeight); |
| 275 | if (objectInfo->mImagePixWidth) |
| 276 | env->SetIntField(info, field_objectInfo_imagePixWidth, objectInfo->mImagePixWidth); |
| 277 | if (objectInfo->mImagePixHeight) |
| 278 | env->SetIntField(info, field_objectInfo_imagePixHeight, objectInfo->mImagePixHeight); |
| 279 | if (objectInfo->mImagePixDepth) |
| 280 | env->SetIntField(info, field_objectInfo_imagePixDepth, objectInfo->mImagePixDepth); |
| 281 | if (objectInfo->mParent) |
| 282 | env->SetIntField(info, field_objectInfo_parent, objectInfo->mParent); |
| 283 | if (objectInfo->mAssociationType) |
| 284 | env->SetIntField(info, field_objectInfo_associationType, objectInfo->mAssociationType); |
| 285 | if (objectInfo->mAssociationDesc) |
| 286 | env->SetIntField(info, field_objectInfo_associationDesc, objectInfo->mAssociationDesc); |
| 287 | if (objectInfo->mSequenceNumber) |
| 288 | env->SetIntField(info, field_objectInfo_sequenceNumber, objectInfo->mSequenceNumber); |
| 289 | if (objectInfo->mName) |
| 290 | env->SetObjectField(info, field_objectInfo_name, env->NewStringUTF(objectInfo->mName)); |
| 291 | if (objectInfo->mDateCreated) |
Mike Lockwood | b966b9d | 2011-03-09 17:28:33 -0500 | [diff] [blame] | 292 | env->SetLongField(info, field_objectInfo_dateCreated, objectInfo->mDateCreated * 1000LL); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 293 | if (objectInfo->mDateModified) |
Mike Lockwood | b966b9d | 2011-03-09 17:28:33 -0500 | [diff] [blame] | 294 | env->SetLongField(info, field_objectInfo_dateModified, objectInfo->mDateModified * 1000LL); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 295 | if (objectInfo->mKeywords) |
| 296 | env->SetObjectField(info, field_objectInfo_keywords, |
| 297 | env->NewStringUTF(objectInfo->mKeywords)); |
| 298 | |
| 299 | delete objectInfo; |
| 300 | return info; |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | struct get_object_callback_data { |
| 304 | JNIEnv *env; |
| 305 | jbyteArray array; |
| 306 | }; |
| 307 | |
| 308 | static bool get_object_callback(void* data, int offset, int length, void* clientData) |
| 309 | { |
| 310 | get_object_callback_data* cbData = (get_object_callback_data *)clientData; |
| 311 | cbData->env->SetByteArrayRegion(cbData->array, offset, length, (jbyte *)data); |
| 312 | return true; |
| 313 | } |
| 314 | |
| 315 | static jbyteArray |
| 316 | android_mtp_MtpDevice_get_object(JNIEnv *env, jobject thiz, jint objectID, jint objectSize) |
| 317 | { |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 318 | MtpDevice* device = get_device_from_object(env, thiz); |
| 319 | if (!device) |
| 320 | return NULL; |
| 321 | |
| 322 | jbyteArray array = env->NewByteArray(objectSize); |
| 323 | if (!array) { |
| 324 | jniThrowException(env, "java/lang/OutOfMemoryError", NULL); |
| 325 | return NULL; |
| 326 | } |
| 327 | |
| 328 | get_object_callback_data data; |
| 329 | data.env = env; |
| 330 | data.array = array; |
| 331 | |
| 332 | if (device->readObject(objectID, get_object_callback, objectSize, &data)) |
| 333 | return array; |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 334 | return NULL; |
| 335 | } |
| 336 | |
| 337 | static jbyteArray |
| 338 | android_mtp_MtpDevice_get_thumbnail(JNIEnv *env, jobject thiz, jint objectID) |
| 339 | { |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 340 | MtpDevice* device = get_device_from_object(env, thiz); |
| 341 | if (!device) |
| 342 | return NULL; |
| 343 | |
| 344 | int length; |
| 345 | void* thumbnail = device->getThumbnail(objectID, length); |
| 346 | if (! thumbnail) |
| 347 | return NULL; |
| 348 | jbyteArray array = env->NewByteArray(length); |
| 349 | env->SetByteArrayRegion(array, 0, length, (const jbyte *)thumbnail); |
| 350 | |
| 351 | free(thumbnail); |
| 352 | return array; |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | static jboolean |
| 356 | android_mtp_MtpDevice_delete_object(JNIEnv *env, jobject thiz, jint object_id) |
| 357 | { |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 358 | MtpDevice* device = get_device_from_object(env, thiz); |
Ashok Bhat | e2e5932 | 2013-12-17 19:04:19 +0000 | [diff] [blame] | 359 | if (device && device->deleteObject(object_id)) { |
| 360 | return JNI_TRUE; |
| 361 | } else { |
| 362 | return JNI_FALSE; |
| 363 | } |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | static jlong |
| 367 | android_mtp_MtpDevice_get_parent(JNIEnv *env, jobject thiz, jint object_id) |
| 368 | { |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 369 | MtpDevice* device = get_device_from_object(env, thiz); |
| 370 | if (device) |
Ashok Bhat | e2e5932 | 2013-12-17 19:04:19 +0000 | [diff] [blame] | 371 | return (jlong)device->getParent(object_id); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 372 | else |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 373 | return -1; |
| 374 | } |
| 375 | |
| 376 | static jlong |
| 377 | android_mtp_MtpDevice_get_storage_id(JNIEnv *env, jobject thiz, jint object_id) |
| 378 | { |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 379 | MtpDevice* device = get_device_from_object(env, thiz); |
| 380 | if (device) |
Ashok Bhat | e2e5932 | 2013-12-17 19:04:19 +0000 | [diff] [blame] | 381 | return (jlong)device->getStorageID(object_id); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 382 | else |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 383 | return -1; |
| 384 | } |
| 385 | |
| 386 | static jboolean |
| 387 | android_mtp_MtpDevice_import_file(JNIEnv *env, jobject thiz, jint object_id, jstring dest_path) |
| 388 | { |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 389 | MtpDevice* device = get_device_from_object(env, thiz); |
| 390 | if (device) { |
| 391 | const char *destPathStr = env->GetStringUTFChars(dest_path, NULL); |
James Dong | 3977472 | 2011-04-06 11:57:48 -0700 | [diff] [blame] | 392 | if (destPathStr == NULL) { |
Ashok Bhat | e2e5932 | 2013-12-17 19:04:19 +0000 | [diff] [blame] | 393 | return JNI_FALSE; |
James Dong | 3977472 | 2011-04-06 11:57:48 -0700 | [diff] [blame] | 394 | } |
| 395 | |
Ashok Bhat | e2e5932 | 2013-12-17 19:04:19 +0000 | [diff] [blame] | 396 | jboolean result = device->readObject(object_id, destPathStr, AID_SDCARD_RW, 0664); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 397 | env->ReleaseStringUTFChars(dest_path, destPathStr); |
| 398 | return result; |
| 399 | } |
Mike Lockwood | c1b9bbb | 2011-07-13 11:06:57 -0400 | [diff] [blame] | 400 | |
Ashok Bhat | e2e5932 | 2013-12-17 19:04:19 +0000 | [diff] [blame] | 401 | return JNI_FALSE; |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | // ---------------------------------------------------------------------------- |
| 405 | |
| 406 | static JNINativeMethod gMethods[] = { |
| 407 | {"native_open", "(Ljava/lang/String;I)Z", |
| 408 | (void *)android_mtp_MtpDevice_open}, |
| 409 | {"native_close", "()V", (void *)android_mtp_MtpDevice_close}, |
| 410 | {"native_get_device_info", "()Landroid/mtp/MtpDeviceInfo;", |
| 411 | (void *)android_mtp_MtpDevice_get_device_info}, |
| 412 | {"native_get_storage_ids", "()[I", (void *)android_mtp_MtpDevice_get_storage_ids}, |
| 413 | {"native_get_storage_info", "(I)Landroid/mtp/MtpStorageInfo;", |
| 414 | (void *)android_mtp_MtpDevice_get_storage_info}, |
| 415 | {"native_get_object_handles","(III)[I", |
| 416 | (void *)android_mtp_MtpDevice_get_object_handles}, |
| 417 | {"native_get_object_info", "(I)Landroid/mtp/MtpObjectInfo;", |
| 418 | (void *)android_mtp_MtpDevice_get_object_info}, |
| 419 | {"native_get_object", "(II)[B",(void *)android_mtp_MtpDevice_get_object}, |
| 420 | {"native_get_thumbnail", "(I)[B",(void *)android_mtp_MtpDevice_get_thumbnail}, |
| 421 | {"native_delete_object", "(I)Z", (void *)android_mtp_MtpDevice_delete_object}, |
| 422 | {"native_get_parent", "(I)J", (void *)android_mtp_MtpDevice_get_parent}, |
| 423 | {"native_get_storage_id", "(I)J", (void *)android_mtp_MtpDevice_get_storage_id}, |
| 424 | {"native_import_file", "(ILjava/lang/String;)Z", |
| 425 | (void *)android_mtp_MtpDevice_import_file}, |
| 426 | }; |
| 427 | |
| 428 | static const char* const kClassPathName = "android/mtp/MtpDevice"; |
| 429 | |
| 430 | int register_android_mtp_MtpDevice(JNIEnv *env) |
| 431 | { |
| 432 | jclass clazz; |
| 433 | |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 434 | ALOGD("register_android_mtp_MtpDevice\n"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 435 | |
| 436 | clazz = env->FindClass("android/mtp/MtpDeviceInfo"); |
| 437 | if (clazz == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 438 | ALOGE("Can't find android/mtp/MtpDeviceInfo"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 439 | return -1; |
| 440 | } |
| 441 | constructor_deviceInfo = env->GetMethodID(clazz, "<init>", "()V"); |
| 442 | if (constructor_deviceInfo == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 443 | ALOGE("Can't find android/mtp/MtpDeviceInfo constructor"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 444 | return -1; |
| 445 | } |
| 446 | field_deviceInfo_manufacturer = env->GetFieldID(clazz, "mManufacturer", "Ljava/lang/String;"); |
| 447 | if (field_deviceInfo_manufacturer == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 448 | ALOGE("Can't find MtpDeviceInfo.mManufacturer"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 449 | return -1; |
| 450 | } |
| 451 | field_deviceInfo_model = env->GetFieldID(clazz, "mModel", "Ljava/lang/String;"); |
| 452 | if (field_deviceInfo_model == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 453 | ALOGE("Can't find MtpDeviceInfo.mModel"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 454 | return -1; |
| 455 | } |
| 456 | field_deviceInfo_version = env->GetFieldID(clazz, "mVersion", "Ljava/lang/String;"); |
| 457 | if (field_deviceInfo_version == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 458 | ALOGE("Can't find MtpDeviceInfo.mVersion"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 459 | return -1; |
| 460 | } |
| 461 | field_deviceInfo_serialNumber = env->GetFieldID(clazz, "mSerialNumber", "Ljava/lang/String;"); |
| 462 | if (field_deviceInfo_serialNumber == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 463 | ALOGE("Can't find MtpDeviceInfo.mSerialNumber"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 464 | return -1; |
| 465 | } |
Mike Lockwood | 40304e2 | 2011-02-11 08:19:11 -0500 | [diff] [blame] | 466 | clazz_deviceInfo = (jclass)env->NewGlobalRef(clazz); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 467 | |
| 468 | clazz = env->FindClass("android/mtp/MtpStorageInfo"); |
| 469 | if (clazz == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 470 | ALOGE("Can't find android/mtp/MtpStorageInfo"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 471 | return -1; |
| 472 | } |
| 473 | constructor_storageInfo = env->GetMethodID(clazz, "<init>", "()V"); |
| 474 | if (constructor_storageInfo == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 475 | ALOGE("Can't find android/mtp/MtpStorageInfo constructor"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 476 | return -1; |
| 477 | } |
| 478 | field_storageInfo_storageId = env->GetFieldID(clazz, "mStorageId", "I"); |
| 479 | if (field_storageInfo_storageId == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 480 | ALOGE("Can't find MtpStorageInfo.mStorageId"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 481 | return -1; |
| 482 | } |
| 483 | field_storageInfo_maxCapacity = env->GetFieldID(clazz, "mMaxCapacity", "J"); |
| 484 | if (field_storageInfo_maxCapacity == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 485 | ALOGE("Can't find MtpStorageInfo.mMaxCapacity"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 486 | return -1; |
| 487 | } |
| 488 | field_storageInfo_freeSpace = env->GetFieldID(clazz, "mFreeSpace", "J"); |
| 489 | if (field_storageInfo_freeSpace == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 490 | ALOGE("Can't find MtpStorageInfo.mFreeSpace"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 491 | return -1; |
| 492 | } |
| 493 | field_storageInfo_description = env->GetFieldID(clazz, "mDescription", "Ljava/lang/String;"); |
| 494 | if (field_storageInfo_description == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 495 | ALOGE("Can't find MtpStorageInfo.mDescription"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 496 | return -1; |
| 497 | } |
| 498 | field_storageInfo_volumeIdentifier = env->GetFieldID(clazz, "mVolumeIdentifier", "Ljava/lang/String;"); |
| 499 | if (field_storageInfo_volumeIdentifier == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 500 | ALOGE("Can't find MtpStorageInfo.mVolumeIdentifier"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 501 | return -1; |
| 502 | } |
Mike Lockwood | 40304e2 | 2011-02-11 08:19:11 -0500 | [diff] [blame] | 503 | clazz_storageInfo = (jclass)env->NewGlobalRef(clazz); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 504 | |
| 505 | clazz = env->FindClass("android/mtp/MtpObjectInfo"); |
| 506 | if (clazz == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 507 | ALOGE("Can't find android/mtp/MtpObjectInfo"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 508 | return -1; |
| 509 | } |
| 510 | constructor_objectInfo = env->GetMethodID(clazz, "<init>", "()V"); |
| 511 | if (constructor_objectInfo == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 512 | ALOGE("Can't find android/mtp/MtpObjectInfo constructor"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 513 | return -1; |
| 514 | } |
| 515 | field_objectInfo_handle = env->GetFieldID(clazz, "mHandle", "I"); |
| 516 | if (field_objectInfo_handle == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 517 | ALOGE("Can't find MtpObjectInfo.mHandle"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 518 | return -1; |
| 519 | } |
| 520 | field_objectInfo_storageId = env->GetFieldID(clazz, "mStorageId", "I"); |
| 521 | if (field_objectInfo_storageId == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 522 | ALOGE("Can't find MtpObjectInfo.mStorageId"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 523 | return -1; |
| 524 | } |
| 525 | field_objectInfo_format = env->GetFieldID(clazz, "mFormat", "I"); |
| 526 | if (field_objectInfo_format == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 527 | ALOGE("Can't find MtpObjectInfo.mFormat"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 528 | return -1; |
| 529 | } |
| 530 | field_objectInfo_protectionStatus = env->GetFieldID(clazz, "mProtectionStatus", "I"); |
| 531 | if (field_objectInfo_protectionStatus == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 532 | ALOGE("Can't find MtpObjectInfo.mProtectionStatus"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 533 | return -1; |
| 534 | } |
| 535 | field_objectInfo_compressedSize = env->GetFieldID(clazz, "mCompressedSize", "I"); |
| 536 | if (field_objectInfo_compressedSize == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 537 | ALOGE("Can't find MtpObjectInfo.mCompressedSize"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 538 | return -1; |
| 539 | } |
| 540 | field_objectInfo_thumbFormat = env->GetFieldID(clazz, "mThumbFormat", "I"); |
| 541 | if (field_objectInfo_thumbFormat == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 542 | ALOGE("Can't find MtpObjectInfo.mThumbFormat"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 543 | return -1; |
| 544 | } |
| 545 | field_objectInfo_thumbCompressedSize = env->GetFieldID(clazz, "mThumbCompressedSize", "I"); |
| 546 | if (field_objectInfo_thumbCompressedSize == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 547 | ALOGE("Can't find MtpObjectInfo.mThumbCompressedSize"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 548 | return -1; |
| 549 | } |
| 550 | field_objectInfo_thumbPixWidth = env->GetFieldID(clazz, "mThumbPixWidth", "I"); |
| 551 | if (field_objectInfo_thumbPixWidth == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 552 | ALOGE("Can't find MtpObjectInfo.mThumbPixWidth"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 553 | return -1; |
| 554 | } |
| 555 | field_objectInfo_thumbPixHeight = env->GetFieldID(clazz, "mThumbPixHeight", "I"); |
| 556 | if (field_objectInfo_thumbPixHeight == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 557 | ALOGE("Can't find MtpObjectInfo.mThumbPixHeight"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 558 | return -1; |
| 559 | } |
| 560 | field_objectInfo_imagePixWidth = env->GetFieldID(clazz, "mImagePixWidth", "I"); |
| 561 | if (field_objectInfo_imagePixWidth == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 562 | ALOGE("Can't find MtpObjectInfo.mImagePixWidth"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 563 | return -1; |
| 564 | } |
| 565 | field_objectInfo_imagePixHeight = env->GetFieldID(clazz, "mImagePixHeight", "I"); |
| 566 | if (field_objectInfo_imagePixHeight == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 567 | ALOGE("Can't find MtpObjectInfo.mImagePixHeight"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 568 | return -1; |
| 569 | } |
| 570 | field_objectInfo_imagePixDepth = env->GetFieldID(clazz, "mImagePixDepth", "I"); |
| 571 | if (field_objectInfo_imagePixDepth == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 572 | ALOGE("Can't find MtpObjectInfo.mImagePixDepth"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 573 | return -1; |
| 574 | } |
| 575 | field_objectInfo_parent = env->GetFieldID(clazz, "mParent", "I"); |
| 576 | if (field_objectInfo_parent == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 577 | ALOGE("Can't find MtpObjectInfo.mParent"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 578 | return -1; |
| 579 | } |
| 580 | field_objectInfo_associationType = env->GetFieldID(clazz, "mAssociationType", "I"); |
| 581 | if (field_objectInfo_associationType == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 582 | ALOGE("Can't find MtpObjectInfo.mAssociationType"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 583 | return -1; |
| 584 | } |
| 585 | field_objectInfo_associationDesc = env->GetFieldID(clazz, "mAssociationDesc", "I"); |
| 586 | if (field_objectInfo_associationDesc == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 587 | ALOGE("Can't find MtpObjectInfo.mAssociationDesc"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 588 | return -1; |
| 589 | } |
| 590 | field_objectInfo_sequenceNumber = env->GetFieldID(clazz, "mSequenceNumber", "I"); |
| 591 | if (field_objectInfo_sequenceNumber == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 592 | ALOGE("Can't find MtpObjectInfo.mSequenceNumber"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 593 | return -1; |
| 594 | } |
| 595 | field_objectInfo_name = env->GetFieldID(clazz, "mName", "Ljava/lang/String;"); |
| 596 | if (field_objectInfo_name == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 597 | ALOGE("Can't find MtpObjectInfo.mName"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 598 | return -1; |
| 599 | } |
| 600 | field_objectInfo_dateCreated = env->GetFieldID(clazz, "mDateCreated", "J"); |
| 601 | if (field_objectInfo_dateCreated == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 602 | ALOGE("Can't find MtpObjectInfo.mDateCreated"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 603 | return -1; |
| 604 | } |
| 605 | field_objectInfo_dateModified = env->GetFieldID(clazz, "mDateModified", "J"); |
| 606 | if (field_objectInfo_dateModified == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 607 | ALOGE("Can't find MtpObjectInfo.mDateModified"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 608 | return -1; |
| 609 | } |
| 610 | field_objectInfo_keywords = env->GetFieldID(clazz, "mKeywords", "Ljava/lang/String;"); |
| 611 | if (field_objectInfo_keywords == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 612 | ALOGE("Can't find MtpObjectInfo.mKeywords"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 613 | return -1; |
| 614 | } |
Mike Lockwood | 40304e2 | 2011-02-11 08:19:11 -0500 | [diff] [blame] | 615 | clazz_objectInfo = (jclass)env->NewGlobalRef(clazz); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 616 | |
| 617 | clazz = env->FindClass("android/mtp/MtpDevice"); |
| 618 | if (clazz == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 619 | ALOGE("Can't find android/mtp/MtpDevice"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 620 | return -1; |
| 621 | } |
Ashok Bhat | e2e5932 | 2013-12-17 19:04:19 +0000 | [diff] [blame] | 622 | field_context = env->GetFieldID(clazz, "mNativeContext", "J"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 623 | if (field_context == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 624 | ALOGE("Can't find MtpDevice.mNativeContext"); |
Mike Lockwood | 8182e72 | 2010-12-30 15:38:45 -0500 | [diff] [blame] | 625 | return -1; |
| 626 | } |
| 627 | |
| 628 | return AndroidRuntime::registerNativeMethods(env, |
| 629 | "android/mtp/MtpDevice", gMethods, NELEM(gMethods)); |
| 630 | } |