Lines Matching defs: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);
201 env->ReleaseStringUTFChars(deviceName, deviceNameStr);
204 env->SetLongField(thiz, field_context, (jlong)device);
209 android_mtp_MtpDevice_close(JNIEnv *env, jobject thiz)
211 MtpDevice* device = get_device_from_object(env, thiz);
215 env->SetLongField(thiz, field_context, 0);
220 android_mtp_MtpDevice_get_device_info(JNIEnv *env, jobject thiz)
222 MtpDevice* device = get_device_from_object(env, thiz);
232 jobject info = env->NewObject(clazz_deviceInfo, constructor_deviceInfo);
239 env->SetObjectField(info, field_deviceInfo_manufacturer,
240 env->NewStringUTF(deviceInfo->mManufacturer));
242 env->SetObjectField(info, field_deviceInfo_model,
243 env->NewStringUTF(deviceInfo->mModel));
245 env->SetObjectField(info, field_deviceInfo_version,
246 env->NewStringUTF(deviceInfo->mVersion));
248 env->SetObjectField(info, field_deviceInfo_serialNumber,
249 env->NewStringUTF(deviceInfo->mSerial));
253 ScopedLocalRef<jintArray> operations(env, static_cast<jintArray>(env->NewIntArray(size)));
255 ScopedIntArrayRW elements(env, operations.get());
263 env->SetObjectField(info, field_deviceInfo_operationsSupported, operations.get());
269 ScopedLocalRef<jintArray> events(env, static_cast<jintArray>(env->NewIntArray(size)));
271 ScopedIntArrayRW elements(env, events.get());
279 env->SetObjectField(info, field_deviceInfo_eventsSupported, events.get());
287 android_mtp_MtpDevice_get_storage_ids(JNIEnv *env, jobject thiz)
289 MtpDevice* device = get_device_from_object(env, thiz);
297 jintArray array = env->NewIntArray(length);
299 env->SetIntArrayRegion(array, 0, length, (const jint *)storageIDs->data());
306 android_mtp_MtpDevice_get_storage_info(JNIEnv *env, jobject thiz, jint storageID)
308 MtpDevice* device = get_device_from_object(env, thiz);
315 jobject info = env->NewObject(clazz_storageInfo, constructor_storageInfo);
323 env->SetIntField(info, field_storageInfo_storageId, storageInfo->mStorageID);
325 env->SetLongField(info, field_storageInfo_maxCapacity, storageInfo->mMaxCapacity);
327 env->SetLongField(info, field_storageInfo_freeSpace, storageInfo->mFreeSpaceBytes);
329 env->SetObjectField(info, field_storageInfo_description,
330 env->NewStringUTF(storageInfo->mStorageDescription));
332 env->SetObjectField(info, field_storageInfo_volumeIdentifier,
333 env->NewStringUTF(storageInfo->mVolumeIdentifier));
340 android_mtp_MtpDevice_get_object_handles(JNIEnv *env, jobject thiz,
343 MtpDevice* device = get_device_from_object(env, thiz);
351 jintArray array = env->NewIntArray(length);
353 env->SetIntArrayRegion(array, 0, length, (const jint *)handles->data());
360 android_mtp_MtpDevice_get_object_info(JNIEnv *env, jobject thiz, jint objectID)
362 MtpDevice* device = get_device_from_object(env, thiz);
368 jobject info = env->NewObject(clazz_objectInfo, constructor_objectInfo);
375 fill_jobject_from_object_info(env, info, objectInfo);
380 bool check_uint32_arg(JNIEnv *env, const char* name, jlong value, uint32_t* out) {
383 env,
393 android_mtp_MtpDevice_get_object(JNIEnv *env, jobject thiz, jint objectID, jlong objectSizeLong)
396 if (!check_uint32_arg(env, "objectSize", objectSizeLong, &objectSize)) {
400 MtpDevice* device = get_device_from_object(env, thiz);
405 ScopedLocalRef<jbyteArray> array(env, env->NewByteArray(objectSize));
407 jniThrowException(env, "java/lang/OutOfMemoryError", NULL);
411 JavaArrayWriter writer(env, array.get());
420 android_mtp_MtpDevice_get_partial_object(JNIEnv *env,
428 jniThrowException(env, "java/lang/IllegalArgumentException", "Array must not be null.");
434 if (!check_uint32_arg(env, "offset", offsetLong, &offset) ||
435 !check_uint32_arg(env, "size", sizeLong, &size)) {
439 MtpDevice* const device = get_device_from_object(env, thiz);
441 jniThrowException(env, "java/io/IOException", "Failed to obtain MtpDevice.");
445 JavaArrayWriter writer(env, array);
450 jniThrowException(env, "java/io/IOException", "Failed to read data.");
457 android_mtp_MtpDevice_get_partial_object_64(JNIEnv *env,
464 jniThrowException(env, "java/lang/IllegalArgumentException", "Array must not be null.");
470 env,
478 env,
484 MtpDevice* const device = get_device_from_object(env, thiz);
486 jniThrowException(env, "java/io/IOException", "Failed to obtain MtpDevice.");
494 JavaArrayWriter writer(env, array);
504 jniThrowException(env, "java/io/IOException", "Failed to read data.");
511 android_mtp_MtpDevice_get_thumbnail(JNIEnv *env, jobject thiz, jint objectID)
513 MtpDevice* device = get_device_from_object(env, thiz);
521 jbyteArray array = env->NewByteArray(length);
522 env->SetByteArrayRegion(array, 0, length, (const jbyte *)thumbnail);
529 android_mtp_MtpDevice_delete_object(JNIEnv *env, jobject thiz, jint object_id)
531 MtpDevice* device = get_device_from_object(env, thiz);
540 android_mtp_MtpDevice_get_parent(JNIEnv *env, jobject thiz, jint object_id)
542 MtpDevice* device = get_device_from_object(env, thiz);
550 android_mtp_MtpDevice_get_storage_id(JNIEnv *env, jobject thiz, jint object_id)
552 MtpDevice* device = get_device_from_object(env, thiz);
560 android_mtp_MtpDevice_import_file(JNIEnv *env, jobject thiz, jint object_id, jstring dest_path)
562 MtpDevice* device = get_device_from_object(env, thiz);
564 const char *destPathStr = env->GetStringUTFChars(dest_path, NULL);
570 env->ReleaseStringUTFChars(dest_path, destPathStr);
578 android_mtp_MtpDevice_import_file_to_fd(JNIEnv *env, jobject thiz, jint object_id, jint fd)
580 MtpDevice* device = get_device_from_object(env, thiz);
589 JNIEnv *env, jobject thiz, jint object_id, jlong sizeLong, jint fd)
592 if (!check_uint32_arg(env, "size", sizeLong, &size))
595 MtpDevice* device = get_device_from_object(env, thiz);
603 android_mtp_MtpDevice_send_object_info(JNIEnv *env, jobject thiz, jobject info)
605 MtpDevice* device = get_device_from_object(env, thiz);
611 if (env->GetIntField(info, field_objectInfo_handle) != -1) {
616 object_info->mStorageID = env->GetIntField(info, field_objectInfo_storageId);
617 object_info->mFormat = env->GetIntField(info, field_objectInfo_format);
618 object_info->mProtectionStatus = env->GetIntField(info, field_objectInfo_protectionStatus);
619 object_info->mCompressedSize = env->GetIntField(info, field_objectInfo_compressedSize);
620 object_info->mThumbFormat = env->GetIntField(info, field_objectInfo_thumbFormat);
622 env->GetIntField(info, field_objectInfo_thumbCompressedSize);
623 object_info->mThumbPixWidth = env->GetIntField(info, field_objectInfo_thumbPixWidth);
624 object_info->mThumbPixHeight = env->GetIntField(info, field_objectInfo_thumbPixHeight);
625 object_info->mImagePixWidth = env->GetIntField(info, field_objectInfo_imagePixWidth);
626 object_info->mImagePixHeight = env->GetIntField(info, field_objectInfo_imagePixHeight);
627 object_info->mImagePixDepth = env->GetIntField(info, field_objectInfo_imagePixDepth);
628 object_info->mParent = env->GetIntField(info, field_objectInfo_parent);
629 object_info->mAssociationType = env->GetIntField(info, field_objectInfo_associationType);
630 object_info->mAssociationDesc = env->GetIntField(info, field_objectInfo_associationDesc);
631 object_info->mSequenceNumber = env->GetIntField(info, field_objectInfo_sequenceNumber);
633 jstring name_jstring = (jstring) env->GetObjectField(info, field_objectInfo_name);
635 const char* name_string = env->GetStringUTFChars(name_jstring, NULL);
637 env->ReleaseStringUTFChars(name_jstring, name_string);
640 object_info->mDateCreated = env->GetLongField(info, field_objectInfo_dateCreated) / 1000LL;
641 object_info->mDateModified = env->GetLongField(info, field_objectInfo_dateModified) / 1000LL;
643 jstring keywords_jstring = (jstring) env->GetObjectField(info, field_objectInfo_keywords);
645 const char* keywords_string = env->GetStringUTFChars(keywords_jstring, NULL);
647 env->ReleaseStringUTFChars(keywords_jstring, keywords_string);
657 jobject result = env->NewObject(clazz_objectInfo, constructor_objectInfo);
664 fill_jobject_from_object_info(env, result, object_info);
669 static jint android_mtp_MtpDevice_submit_event_request(JNIEnv *env, jobject thiz)
671 MtpDevice* const device = get_device_from_object(env, thiz);
673 env->ThrowNew(clazz_io_exception, "");
679 static jobject android_mtp_MtpDevice_reap_event_request(JNIEnv *env, jobject thiz, jint seq)
681 MtpDevice* const device = get_device_from_object(env, thiz);
683 env->ThrowNew(clazz_io_exception, "");
689 env->ThrowNew(clazz_operation_canceled_exception, "");
692 jobject result = env->NewObject(clazz_event, constructor_event);
693 env->SetIntField(result, field_event_eventCode, eventCode);
694 env->SetIntField(result, field_event_parameter1, static_cast<jint>(parameters[0]));
695 env->SetIntField(result, field_event_parameter2, static_cast<jint>(parameters[1]));
696 env->SetIntField(result, field_event_parameter3, static_cast<jint>(parameters[2]));
700 static void android_mtp_MtpDevice_discard_event_request(JNIEnv *env, jobject thiz, jint seq)
702 MtpDevice* const device = get_device_from_object(env, thiz);
712 JNIEnv *env, jobject thiz, jint handle, jint format) {
713 MtpDevice* const device = get_device_from_object(env, thiz);
715 env->ThrowNew(clazz_io_exception, "Failed to obtain MtpDevice.");
722 env->ThrowNew(clazz_io_exception, "Failed to obtain property desc.");
727 env->ThrowNew(clazz_io_exception, "Unexpected property data type.");
732 env->ThrowNew(clazz_io_exception, "Failed to obtain property value.");
738 env->ThrowNew(clazz_io_exception, "Object size is too large to express as jlong.");
782 int register_android_mtp_MtpDevice(JNIEnv *env)
788 clazz = env->FindClass("android/mtp/MtpDeviceInfo");
793 constructor_deviceInfo = env->GetMethodID(clazz, "<init>", "()V");
798 field_deviceInfo_manufacturer = env->GetFieldID(clazz, "mManufacturer", "Ljava/lang/String;");
803 field_deviceInfo_model = env->GetFieldID(clazz, "mModel", "Ljava/lang/String;");
808 field_deviceInfo_version = env->GetFieldID(clazz, "mVersion", "Ljava/lang/String;");
813 field_deviceInfo_serialNumber = env->GetFieldID(clazz, "mSerialNumber", "Ljava/lang/String;");
818 field_deviceInfo_operationsSupported = env->GetFieldID(clazz, "mOperationsSupported", "[I");
823 field_deviceInfo_eventsSupported = env->GetFieldID(clazz, "mEventsSupported", "[I");
828 clazz_deviceInfo = (jclass)env->NewGlobalRef(clazz);
830 clazz = env->FindClass("android/mtp/MtpStorageInfo");
835 constructor_storageInfo = env->GetMethodID(clazz, "<init>", "()V");
840 field_storageInfo_storageId = env->GetFieldID(clazz, "mStorageId", "I");
845 field_storageInfo_maxCapacity = env->GetFieldID(clazz, "mMaxCapacity", "J");
850 field_storageInfo_freeSpace = env->GetFieldID(clazz, "mFreeSpace", "J");
855 field_storageInfo_description = env->GetFieldID(clazz, "mDescription", "Ljava/lang/String;");
860 field_storageInfo_volumeIdentifier = env->GetFieldID(clazz, "mVolumeIdentifier", "Ljava/lang/String;");
865 clazz_storageInfo = (jclass)env->NewGlobalRef(clazz);
867 clazz = env->FindClass("android/mtp/MtpObjectInfo");
872 constructor_objectInfo = env->GetMethodID(clazz, "<init>", "()V");
877 field_objectInfo_handle = env->GetFieldID(clazz, "mHandle", "I");
882 field_objectInfo_storageId = env->GetFieldID(clazz, "mStorageId", "I");
887 field_objectInfo_format = env->GetFieldID(clazz, "mFormat", "I");
892 field_objectInfo_protectionStatus = env->GetFieldID(clazz, "mProtectionStatus", "I");
897 field_objectInfo_compressedSize = env->GetFieldID(clazz, "mCompressedSize", "I");
902 field_objectInfo_thumbFormat = env->GetFieldID(clazz, "mThumbFormat", "I");
907 field_objectInfo_thumbCompressedSize = env->GetFieldID(clazz, "mThumbCompressedSize", "I");
912 field_objectInfo_thumbPixWidth = env->GetFieldID(clazz, "mThumbPixWidth", "I");
917 field_objectInfo_thumbPixHeight = env->GetFieldID(clazz, "mThumbPixHeight", "I");
922 field_objectInfo_imagePixWidth = env->GetFieldID(clazz, "mImagePixWidth", "I");
927 field_objectInfo_imagePixHeight = env->GetFieldID(clazz, "mImagePixHeight", "I");
932 field_objectInfo_imagePixDepth = env->GetFieldID(clazz, "mImagePixDepth", "I");
937 field_objectInfo_parent = env->GetFieldID(clazz, "mParent", "I");
942 field_objectInfo_associationType = env->GetFieldID(clazz, "mAssociationType", "I");
947 field_objectInfo_associationDesc = env->GetFieldID(clazz, "mAssociationDesc", "I");
952 field_objectInfo_sequenceNumber = env->GetFieldID(clazz, "mSequenceNumber", "I");
957 field_objectInfo_name = env->GetFieldID(clazz, "mName", "Ljava/lang/String;");
962 field_objectInfo_dateCreated = env->GetFieldID(clazz, "mDateCreated", "J");
967 field_objectInfo_dateModified = env->GetFieldID(clazz, "mDateModified", "J");
972 field_objectInfo_keywords = env->GetFieldID(clazz, "mKeywords", "Ljava/lang/String;");
977 clazz_objectInfo = (jclass)env->NewGlobalRef(clazz);
979 clazz = env->FindClass("android/mtp/MtpEvent");
984 constructor_event = env->GetMethodID(clazz, "<init>", "()V");
989 field_event_eventCode = env->GetFieldID(clazz, "mEventCode", "I");
994 field_event_parameter1 = env->GetFieldID(clazz, "mParameter1", "I");
999 field_event_parameter2 = env->GetFieldID(clazz, "mParameter2", "I");
1004 field_event_parameter3 = env->GetFieldID(clazz, "mParameter3", "I");
1009 clazz_event = (jclass)env->NewGlobalRef(clazz);
1011 clazz = env->FindClass("android/mtp/MtpDevice");
1016 field_context = env->GetFieldID(clazz, "mNativeContext", "J");
1021 clazz = env->FindClass("java/io/IOException");
1026 clazz_io_exception = (jclass)env->NewGlobalRef(clazz);
1027 clazz = env->FindClass("android/os/OperationCanceledException");
1032 clazz_operation_canceled_exception = (jclass)env->NewGlobalRef(clazz);
1034 return AndroidRuntime::registerNativeMethods(env,