MTP: Return error if user tries to copy a file >= 4GB to a FAT32 file system

Bug: 4561836

Change-Id: I2bffb93b032038f6c220c24c752ccd7ca66c23a0
Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/media/jni/android_mtp_MtpServer.cpp b/media/jni/android_mtp_MtpServer.cpp
index aaf85c3..446b630 100644
--- a/media/jni/android_mtp_MtpServer.cpp
+++ b/media/jni/android_mtp_MtpServer.cpp
@@ -48,6 +48,7 @@
 static jfieldID field_MtpStorage_description;
 static jfieldID field_MtpStorage_reserveSpace;
 static jfieldID field_MtpStorage_removable;
+static jfieldID field_MtpStorage_maxFileSize;
 
 static Mutex sMutex;
 
@@ -228,12 +229,14 @@
         jstring description = (jstring)env->GetObjectField(jstorage, field_MtpStorage_description);
         jlong reserveSpace = env->GetLongField(jstorage, field_MtpStorage_reserveSpace);
         jboolean removable = env->GetBooleanField(jstorage, field_MtpStorage_removable);
+        jlong maxFileSize = env->GetLongField(jstorage, field_MtpStorage_maxFileSize);
 
         const char *pathStr = env->GetStringUTFChars(path, NULL);
         if (pathStr != NULL) {
             const char *descriptionStr = env->GetStringUTFChars(description, NULL);
             if (descriptionStr != NULL) {
-                MtpStorage* storage = new MtpStorage(storageID, pathStr, descriptionStr, reserveSpace, removable);
+                MtpStorage* storage = new MtpStorage(storageID, pathStr, descriptionStr,
+                        reserveSpace, removable, maxFileSize);
                 thread->addStorage(storage);
                 env->ReleaseStringUTFChars(path, pathStr);
                 env->ReleaseStringUTFChars(description, descriptionStr);
@@ -312,6 +315,11 @@
         LOGE("Can't find MtpStorage.mRemovable");
         return -1;
     }
+    field_MtpStorage_maxFileSize = env->GetFieldID(clazz, "mMaxFileSize", "J");
+    if (field_MtpStorage_maxFileSize == NULL) {
+        LOGE("Can't find MtpStorage.mMaxFileSize");
+        return -1;
+    }
     clazz_MtpStorage = (jclass)env->NewGlobalRef(clazz);
 
     clazz = env->FindClass("android/mtp/MtpServer");