Lines Matching refs:env

112     JavaArrayWriter(JNIEnv* env, jbyteArray array) :
113 mEnv(env), mArray(array), mSize(mEnv->GetArrayLength(mArray)) {}
133 MtpDevice* get_device_from_object(JNIEnv* env, jobject javaDevice)
135 return (MtpDevice*)env->GetLongField(javaDevice, field_context);
138 void fill_jobject_from_object_info(JNIEnv* env, jobject object, MtpObjectInfo* objectInfo) {
140 env->SetIntField(object, field_objectInfo_handle, objectInfo->mHandle);
142 env->SetIntField(object, field_objectInfo_storageId, objectInfo->mStorageID);
144 env->SetIntField(object, field_objectInfo_format, objectInfo->mFormat);
146 env->SetIntField(object, field_objectInfo_protectionStatus, objectInfo->mProtectionStatus);
148 env->SetIntField(object, field_objectInfo_compressedSize, objectInfo->mCompressedSize);
150 env->SetIntField(object, field_objectInfo_thumbFormat, objectInfo->mThumbFormat);
152 env->SetIntField(object, field_objectInfo_thumbCompressedSize,
156 env->SetIntField(object, field_objectInfo_thumbPixWidth, objectInfo->mThumbPixWidth);
158 env->SetIntField(object, field_objectInfo_thumbPixHeight, objectInfo->mThumbPixHeight);
160 env->SetIntField(object, field_objectInfo_imagePixWidth, objectInfo->mImagePixWidth);
162 env->SetIntField(object, field_objectInfo_imagePixHeight, objectInfo->mImagePixHeight);
164 env->SetIntField(object, field_objectInfo_imagePixDepth, objectInfo->mImagePixDepth);
166 env->SetIntField(object, field_objectInfo_parent, objectInfo->mParent);
168 env->SetIntField(object, field_objectInfo_associationType, objectInfo->mAssociationType);
170 env->SetIntField(object, field_objectInfo_associationDesc, objectInfo->mAssociationDesc);
172 env->SetIntField(object, field_objectInfo_sequenceNumber, objectInfo->mSequenceNumber);
174 env->SetObjectField(object, field_objectInfo_name, env->NewStringUTF(objectInfo->mName));
176 env->SetLongField(object, field_objectInfo_dateCreated, objectInfo->mDateCreated * 1000LL);
178 env->SetLongField(object, field_objectInfo_dateModified,
182 env->SetObjectField(object, field_objectInfo_keywords,
183 env->NewStringUTF(objectInfo->mKeywords));
190 android_mtp_MtpDevice_open(JNIEnv *env, jobject thiz, jstring deviceName, jint fd)
192 const char *deviceNameStr = env->GetStringUTFChars(deviceName, NULL);
198 env->ReleaseStringUTFChars(deviceName, deviceNameStr);
201 env->SetLongField(thiz, field_context, (jlong)device);
206 android_mtp_MtpDevice_close(JNIEnv *env, jobject thiz)
208 MtpDevice* device = get_device_from_object(env, thiz);
212 env->SetLongField(thiz, field_context, 0);
217 android_mtp_MtpDevice_get_device_info(JNIEnv *env, jobject thiz)
219 MtpDevice* device = get_device_from_object(env, thiz);
229 jobject info = env->NewObject(clazz_deviceInfo, constructor_deviceInfo);
236 env->SetObjectField(info, field_deviceInfo_manufacturer,
237 env->NewStringUTF(deviceInfo->mManufacturer));
239 env->SetObjectField(info, field_deviceInfo_model,
240 env->NewStringUTF(deviceInfo->mModel));
242 env->SetObjectField(info, field_deviceInfo_version,
243 env->NewStringUTF(deviceInfo->mVersion));
245 env->SetObjectField(info, field_deviceInfo_serialNumber,
246 env->NewStringUTF(deviceInfo->mSerial));
250 ScopedLocalRef<jintArray> operations(env, static_cast<jintArray>(env->NewIntArray(size)));
252 ScopedIntArrayRW elements(env, operations.get());
260 env->SetObjectField(info, field_deviceInfo_operationsSupported, operations.get());
266 ScopedLocalRef<jintArray> events(env, static_cast<jintArray>(env->NewIntArray(size)));
268 ScopedIntArrayRW elements(env, events.get());
276 env->SetObjectField(info, field_deviceInfo_eventsSupported, events.get());
284 android_mtp_MtpDevice_get_storage_ids(JNIEnv *env, jobject thiz)
286 MtpDevice* device = get_device_from_object(env, thiz);
294 jintArray array = env->NewIntArray(length);
296 env->SetIntArrayRegion(array, 0, length, (const jint *)storageIDs->array());
303 android_mtp_MtpDevice_get_storage_info(JNIEnv *env, jobject thiz, jint storageID)
305 MtpDevice* device = get_device_from_object(env, thiz);
312 jobject info = env->NewObject(clazz_storageInfo, constructor_storageInfo);
320 env->SetIntField(info, field_storageInfo_storageId, storageInfo->mStorageID);
322 env->SetLongField(info, field_storageInfo_maxCapacity, storageInfo->mMaxCapacity);
324 env->SetLongField(info, field_storageInfo_freeSpace, storageInfo->mFreeSpaceBytes);
326 env->SetObjectField(info, field_storageInfo_description,
327 env->NewStringUTF(storageInfo->mStorageDescription));
329 env->SetObjectField(info, field_storageInfo_volumeIdentifier,
330 env->NewStringUTF(storageInfo->mVolumeIdentifier));
337 android_mtp_MtpDevice_get_object_handles(JNIEnv *env, jobject thiz,
340 MtpDevice* device = get_device_from_object(env, thiz);
348 jintArray array = env->NewIntArray(length);
350 env->SetIntArrayRegion(array, 0, length, (const jint *)handles->array());
357 android_mtp_MtpDevice_get_object_info(JNIEnv *env, jobject thiz, jint objectID)
359 MtpDevice* device = get_device_from_object(env, thiz);
365 jobject info = env->NewObject(clazz_objectInfo, constructor_objectInfo);
372 fill_jobject_from_object_info(env, info, objectInfo);
377 bool check_uint32_arg(JNIEnv *env, const char* name, jlong value, uint32_t* out) {
380 env,
390 android_mtp_MtpDevice_get_object(JNIEnv *env, jobject thiz, jint objectID, jlong objectSizeLong)
393 if (!check_uint32_arg(env, "objectSize", objectSizeLong, &objectSize)) {
397 MtpDevice* device = get_device_from_object(env, thiz);
402 ScopedLocalRef<jbyteArray> array(env, env->NewByteArray(objectSize));
404 jniThrowException(env, "java/lang/OutOfMemoryError", NULL);
408 JavaArrayWriter writer(env, array.get());
417 android_mtp_MtpDevice_get_partial_object(JNIEnv *env,
425 jniThrowException(env, "java/lang/IllegalArgumentException", "Array must not be null.");
431 if (!check_uint32_arg(env, "offset", offsetLong, &offset) ||
432 !check_uint32_arg(env, "size", sizeLong, &size)) {
436 MtpDevice* const device = get_device_from_object(env, thiz);
438 jniThrowException(env, "java/io/IOException", "Failed to obtain MtpDevice.");
442 JavaArrayWriter writer(env, array);
447 jniThrowException(env, "java/io/IOException", "Failed to read data.");
454 android_mtp_MtpDevice_get_partial_object_64(JNIEnv *env,
461 jniThrowException(env, "java/lang/IllegalArgumentException", "Array must not be null.");
467 env,
475 env,
481 MtpDevice* const device = get_device_from_object(env, thiz);
483 jniThrowException(env, "java/io/IOException", "Failed to obtain MtpDevice.");
491 JavaArrayWriter writer(env, array);
501 jniThrowException(env, "java/io/IOException", "Failed to read data.");
508 android_mtp_MtpDevice_get_thumbnail(JNIEnv *env, jobject thiz, jint objectID)
510 MtpDevice* device = get_device_from_object(env, thiz);
518 jbyteArray array = env->NewByteArray(length);
519 env->SetByteArrayRegion(array, 0, length, (const jbyte *)thumbnail);
526 android_mtp_MtpDevice_delete_object(JNIEnv *env, jobject thiz, jint object_id)
528 MtpDevice* device = get_device_from_object(env, thiz);
537 android_mtp_MtpDevice_get_parent(JNIEnv *env, jobject thiz, jint object_id)
539 MtpDevice* device = get_device_from_object(env, thiz);
547 android_mtp_MtpDevice_get_storage_id(JNIEnv *env, jobject thiz, jint object_id)
549 MtpDevice* device = get_device_from_object(env, thiz);
557 android_mtp_MtpDevice_import_file(JNIEnv *env, jobject thiz, jint object_id, jstring dest_path)
559 MtpDevice* device = get_device_from_object(env, thiz);
561 const char *destPathStr = env->GetStringUTFChars(dest_path, NULL);
567 env->ReleaseStringUTFChars(dest_path, destPathStr);
575 android_mtp_MtpDevice_import_file_to_fd(JNIEnv *env, jobject thiz, jint object_id, jint fd)
577 MtpDevice* device = get_device_from_object(env, thiz);
586 JNIEnv *env, jobject thiz, jint object_id, jlong sizeLong, jint fd)
589 if (!check_uint32_arg(env, "size", sizeLong, &size))
592 MtpDevice* device = get_device_from_object(env, thiz);
600 android_mtp_MtpDevice_send_object_info(JNIEnv *env, jobject thiz, jobject info)
602 MtpDevice* device = get_device_from_object(env, thiz);
608 if (env->GetIntField(info, field_objectInfo_handle) != -1) {
613 object_info->mStorageID = env->GetIntField(info, field_objectInfo_storageId);
614 object_info->mFormat = env->GetIntField(info, field_objectInfo_format);
615 object_info->mProtectionStatus = env->GetIntField(info, field_objectInfo_protectionStatus);
616 object_info->mCompressedSize = env->GetIntField(info, field_objectInfo_compressedSize);
617 object_info->mThumbFormat = env->GetIntField(info, field_objectInfo_thumbFormat);
619 env->GetIntField(info, field_objectInfo_thumbCompressedSize);
620 object_info->mThumbPixWidth = env->GetIntField(info, field_objectInfo_thumbPixWidth);
621 object_info->mThumbPixHeight = env->GetIntField(info, field_objectInfo_thumbPixHeight);
622 object_info->mImagePixWidth = env->GetIntField(info, field_objectInfo_imagePixWidth);
623 object_info->mImagePixHeight = env->GetIntField(info, field_objectInfo_imagePixHeight);
624 object_info->mImagePixDepth = env->GetIntField(info, field_objectInfo_imagePixDepth);
625 object_info->mParent = env->GetIntField(info, field_objectInfo_parent);
626 object_info->mAssociationType = env->GetIntField(info, field_objectInfo_associationType);
627 object_info->mAssociationDesc = env->GetIntField(info, field_objectInfo_associationDesc);
628 object_info->mSequenceNumber = env->GetIntField(info, field_objectInfo_sequenceNumber);
630 jstring name_jstring = (jstring) env->GetObjectField(info, field_objectInfo_name);
632 const char* name_string = env->GetStringUTFChars(name_jstring, NULL);
634 env->ReleaseStringUTFChars(name_jstring, name_string);
637 object_info->mDateCreated = env->GetLongField(info, field_objectInfo_dateCreated) / 1000LL;
638 object_info->mDateModified = env->GetLongField(info, field_objectInfo_dateModified) / 1000LL;
640 jstring keywords_jstring = (jstring) env->GetObjectField(info, field_objectInfo_keywords);
642 const char* keywords_string = env->GetStringUTFChars(keywords_jstring, NULL);
644 env->ReleaseStringUTFChars(keywords_jstring, keywords_string);
654 jobject result = env->NewObject(clazz_objectInfo, constructor_objectInfo);
661 fill_jobject_from_object_info(env, result, object_info);
666 static jint android_mtp_MtpDevice_submit_event_request(JNIEnv *env, jobject thiz)
668 MtpDevice* const device = get_device_from_object(env, thiz);
670 env->ThrowNew(clazz_io_exception, "");
676 static jobject android_mtp_MtpDevice_reap_event_request(JNIEnv *env, jobject thiz, jint seq)
678 MtpDevice* const device = get_device_from_object(env, thiz);
680 env->ThrowNew(clazz_io_exception, "");
686 env->ThrowNew(clazz_operation_canceled_exception, "");
689 jobject result = env->NewObject(clazz_event, constructor_event);
690 env->SetIntField(result, field_event_eventCode, eventCode);
691 env->SetIntField(result, field_event_parameter1, static_cast<jint>(parameters[0]));
692 env->SetIntField(result, field_event_parameter2, static_cast<jint>(parameters[1]));
693 env->SetIntField(result, field_event_parameter3, static_cast<jint>(parameters[2]));
697 static void android_mtp_MtpDevice_discard_event_request(JNIEnv *env, jobject thiz, jint seq)
699 MtpDevice* const device = get_device_from_object(env, thiz);
709 JNIEnv *env, jobject thiz, jint handle, jint format) {
710 MtpDevice* const device = get_device_from_object(env, thiz);
712 env->ThrowNew(clazz_io_exception, "Failed to obtain MtpDevice.");
719 env->ThrowNew(clazz_io_exception, "Failed to obtain property desc.");
724 env->ThrowNew(clazz_io_exception, "Unexpected property data type.");
729 env->ThrowNew(clazz_io_exception, "Failed to obtain property value.");
735 env->ThrowNew(clazz_io_exception, "Object size is too large to express as jlong.");
779 int register_android_mtp_MtpDevice(JNIEnv *env)
785 clazz = env->FindClass("android/mtp/MtpDeviceInfo");
790 constructor_deviceInfo = env->GetMethodID(clazz, "<init>", "()V");
795 field_deviceInfo_manufacturer = env->GetFieldID(clazz, "mManufacturer", "Ljava/lang/String;");
800 field_deviceInfo_model = env->GetFieldID(clazz, "mModel", "Ljava/lang/String;");
805 field_deviceInfo_version = env->GetFieldID(clazz, "mVersion", "Ljava/lang/String;");
810 field_deviceInfo_serialNumber = env->GetFieldID(clazz, "mSerialNumber", "Ljava/lang/String;");
815 field_deviceInfo_operationsSupported = env->GetFieldID(clazz, "mOperationsSupported", "[I");
820 field_deviceInfo_eventsSupported = env->GetFieldID(clazz, "mEventsSupported", "[I");
825 clazz_deviceInfo = (jclass)env->NewGlobalRef(clazz);
827 clazz = env->FindClass("android/mtp/MtpStorageInfo");
832 constructor_storageInfo = env->GetMethodID(clazz, "<init>", "()V");
837 field_storageInfo_storageId = env->GetFieldID(clazz, "mStorageId", "I");
842 field_storageInfo_maxCapacity = env->GetFieldID(clazz, "mMaxCapacity", "J");
847 field_storageInfo_freeSpace = env->GetFieldID(clazz, "mFreeSpace", "J");
852 field_storageInfo_description = env->GetFieldID(clazz, "mDescription", "Ljava/lang/String;");
857 field_storageInfo_volumeIdentifier = env->GetFieldID(clazz, "mVolumeIdentifier", "Ljava/lang/String;");
862 clazz_storageInfo = (jclass)env->NewGlobalRef(clazz);
864 clazz = env->FindClass("android/mtp/MtpObjectInfo");
869 constructor_objectInfo = env->GetMethodID(clazz, "<init>", "()V");
874 field_objectInfo_handle = env->GetFieldID(clazz, "mHandle", "I");
879 field_objectInfo_storageId = env->GetFieldID(clazz, "mStorageId", "I");
884 field_objectInfo_format = env->GetFieldID(clazz, "mFormat", "I");
889 field_objectInfo_protectionStatus = env->GetFieldID(clazz, "mProtectionStatus", "I");
894 field_objectInfo_compressedSize = env->GetFieldID(clazz, "mCompressedSize", "I");
899 field_objectInfo_thumbFormat = env->GetFieldID(clazz, "mThumbFormat", "I");
904 field_objectInfo_thumbCompressedSize = env->GetFieldID(clazz, "mThumbCompressedSize", "I");
909 field_objectInfo_thumbPixWidth = env->GetFieldID(clazz, "mThumbPixWidth", "I");
914 field_objectInfo_thumbPixHeight = env->GetFieldID(clazz, "mThumbPixHeight", "I");
919 field_objectInfo_imagePixWidth = env->GetFieldID(clazz, "mImagePixWidth", "I");
924 field_objectInfo_imagePixHeight = env->GetFieldID(clazz, "mImagePixHeight", "I");
929 field_objectInfo_imagePixDepth = env->GetFieldID(clazz, "mImagePixDepth", "I");
934 field_objectInfo_parent = env->GetFieldID(clazz, "mParent", "I");
939 field_objectInfo_associationType = env->GetFieldID(clazz, "mAssociationType", "I");
944 field_objectInfo_associationDesc = env->GetFieldID(clazz, "mAssociationDesc", "I");
949 field_objectInfo_sequenceNumber = env->GetFieldID(clazz, "mSequenceNumber", "I");
954 field_objectInfo_name = env->GetFieldID(clazz, "mName", "Ljava/lang/String;");
959 field_objectInfo_dateCreated = env->GetFieldID(clazz, "mDateCreated", "J");
964 field_objectInfo_dateModified = env->GetFieldID(clazz, "mDateModified", "J");
969 field_objectInfo_keywords = env->GetFieldID(clazz, "mKeywords", "Ljava/lang/String;");
974 clazz_objectInfo = (jclass)env->NewGlobalRef(clazz);
976 clazz = env->FindClass("android/mtp/MtpEvent");
981 constructor_event = env->GetMethodID(clazz, "<init>", "()V");
986 field_event_eventCode = env->GetFieldID(clazz, "mEventCode", "I");
991 field_event_parameter1 = env->GetFieldID(clazz, "mParameter1", "I");
996 field_event_parameter2 = env->GetFieldID(clazz, "mParameter2", "I");
1001 field_event_parameter3 = env->GetFieldID(clazz, "mParameter3", "I");
1006 clazz_event = (jclass)env->NewGlobalRef(clazz);
1008 clazz = env->FindClass("android/mtp/MtpDevice");
1013 field_context = env->GetFieldID(clazz, "mNativeContext", "J");
1018 clazz = env->FindClass("java/io/IOException");
1023 clazz_io_exception = (jclass)env->NewGlobalRef(clazz);
1024 clazz = env->FindClass("android/os/OperationCanceledException");
1029 clazz_operation_canceled_exception = (jclass)env->NewGlobalRef(clazz);
1031 return AndroidRuntime::registerNativeMethods(env,