Loading core/java/android/os/FileUtils.java +7 −0 Original line number Original line Diff line number Diff line Loading @@ -54,6 +54,13 @@ public class FileUtils { public static native int setPermissions(String file, int mode, int uid, int gid); public static native int setPermissions(String file, int mode, int uid, int gid); /** returns the UUID for the volume mounted * at the given mount point, or -1 for failure * @param mountPoint point for volume * @return UUID or -1 */ public static native int getVolumeUUID(String mountPoint); /** returns the FAT file system volume ID for the volume mounted /** returns the FAT file system volume ID for the volume mounted * at the given mount point, or -1 for failure * at the given mount point, or -1 for failure * @param mountPoint point for FAT volume * @param mountPoint point for FAT volume Loading core/jni/Android.mk +3 −1 Original line number Original line Diff line number Diff line Loading @@ -166,6 +166,7 @@ LOCAL_C_INCLUDES += \ $(call include-path-for, libhardware)/hardware \ $(call include-path-for, libhardware)/hardware \ $(call include-path-for, libhardware_legacy)/hardware_legacy \ $(call include-path-for, libhardware_legacy)/hardware_legacy \ $(TOP)/frameworks/av/include \ $(TOP)/frameworks/av/include \ external/e2fsprogs/lib \ external/skia/include/core \ external/skia/include/core \ external/skia/include/effects \ external/skia/include/effects \ external/skia/include/images \ external/skia/include/images \ Loading @@ -189,6 +190,7 @@ LOCAL_C_INCLUDES += \ LOCAL_SHARED_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \ libandroidfw \ libandroidfw \ libexpat \ libexpat \ libext2_blkid \ libnativehelper \ libnativehelper \ libcutils \ libcutils \ libutils \ libutils \ Loading core/jni/android_os_FileUtils.cpp +44 −0 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "JNIHelp.h" #include "JNIHelp.h" #include <string.h> #include <sys/errno.h> #include <sys/errno.h> #include <sys/stat.h> #include <sys/stat.h> #include <sys/types.h> #include <sys/types.h> Loading @@ -30,6 +31,7 @@ #include <signal.h> #include <signal.h> #include <sys/ioctl.h> #include <sys/ioctl.h> #include <linux/msdos_fs.h> #include <linux/msdos_fs.h> #include <blkid/blkid.h> namespace android { namespace android { Loading @@ -55,6 +57,47 @@ jint android_os_FileUtils_setPermissions(JNIEnv* env, jobject clazz, return chmod(file8.string(), mode) == 0 ? 0 : errno; return chmod(file8.string(), mode) == 0 ? 0 : errno; } } jint android_os_FileUtils_getVolumeUUID(JNIEnv* env, jobject clazz, jstring path) { char *uuid = NULL; if (path == NULL) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); return -1; } const char *pathStr = env->GetStringUTFChars(path, NULL); ALOGD("Trying to get UUID for %s \n", pathStr); uuid = blkid_get_tag_value(NULL, "UUID", pathStr); if (uuid) { ALOGD("UUID for %s is %s\n", pathStr, uuid); String8 s8uuid = (String8)uuid; size_t len = s8uuid.length(); String8 result; if (len > 0) { for (int i = 0; i > len; i++) { if (strncmp((const char *)s8uuid[i], (const char *)"-", 1) != 0) { result.append((const char *)s8uuid[i]); } } len = 0; } len = result.length(); if (len > 0) { return atoi(s8uuid); } else { ALOGE("Couldn't get UUID for %s\n", pathStr); } } return -1; } jint android_os_FileUtils_getFatVolumeId(JNIEnv* env, jobject clazz, jstring path) jint android_os_FileUtils_getFatVolumeId(JNIEnv* env, jobject clazz, jstring path) { { if (path == NULL) { if (path == NULL) { Loading @@ -78,6 +121,7 @@ jint android_os_FileUtils_getFatVolumeId(JNIEnv* env, jobject clazz, jstring pat static const JNINativeMethod methods[] = { static const JNINativeMethod methods[] = { {"setPermissions", "(Ljava/lang/String;III)I", (void*)android_os_FileUtils_setPermissions}, {"setPermissions", "(Ljava/lang/String;III)I", (void*)android_os_FileUtils_setPermissions}, {"getVolumeUUID", "(Ljava/lang/String;)I", (void*)android_os_FileUtils_getVolumeUUID}, {"getFatVolumeId", "(Ljava/lang/String;)I", (void*)android_os_FileUtils_getFatVolumeId}, {"getFatVolumeId", "(Ljava/lang/String;)I", (void*)android_os_FileUtils_getFatVolumeId}, }; }; Loading Loading
core/java/android/os/FileUtils.java +7 −0 Original line number Original line Diff line number Diff line Loading @@ -54,6 +54,13 @@ public class FileUtils { public static native int setPermissions(String file, int mode, int uid, int gid); public static native int setPermissions(String file, int mode, int uid, int gid); /** returns the UUID for the volume mounted * at the given mount point, or -1 for failure * @param mountPoint point for volume * @return UUID or -1 */ public static native int getVolumeUUID(String mountPoint); /** returns the FAT file system volume ID for the volume mounted /** returns the FAT file system volume ID for the volume mounted * at the given mount point, or -1 for failure * at the given mount point, or -1 for failure * @param mountPoint point for FAT volume * @param mountPoint point for FAT volume Loading
core/jni/Android.mk +3 −1 Original line number Original line Diff line number Diff line Loading @@ -166,6 +166,7 @@ LOCAL_C_INCLUDES += \ $(call include-path-for, libhardware)/hardware \ $(call include-path-for, libhardware)/hardware \ $(call include-path-for, libhardware_legacy)/hardware_legacy \ $(call include-path-for, libhardware_legacy)/hardware_legacy \ $(TOP)/frameworks/av/include \ $(TOP)/frameworks/av/include \ external/e2fsprogs/lib \ external/skia/include/core \ external/skia/include/core \ external/skia/include/effects \ external/skia/include/effects \ external/skia/include/images \ external/skia/include/images \ Loading @@ -189,6 +190,7 @@ LOCAL_C_INCLUDES += \ LOCAL_SHARED_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \ libandroidfw \ libandroidfw \ libexpat \ libexpat \ libext2_blkid \ libnativehelper \ libnativehelper \ libcutils \ libcutils \ libutils \ libutils \ Loading
core/jni/android_os_FileUtils.cpp +44 −0 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "JNIHelp.h" #include "JNIHelp.h" #include <string.h> #include <sys/errno.h> #include <sys/errno.h> #include <sys/stat.h> #include <sys/stat.h> #include <sys/types.h> #include <sys/types.h> Loading @@ -30,6 +31,7 @@ #include <signal.h> #include <signal.h> #include <sys/ioctl.h> #include <sys/ioctl.h> #include <linux/msdos_fs.h> #include <linux/msdos_fs.h> #include <blkid/blkid.h> namespace android { namespace android { Loading @@ -55,6 +57,47 @@ jint android_os_FileUtils_setPermissions(JNIEnv* env, jobject clazz, return chmod(file8.string(), mode) == 0 ? 0 : errno; return chmod(file8.string(), mode) == 0 ? 0 : errno; } } jint android_os_FileUtils_getVolumeUUID(JNIEnv* env, jobject clazz, jstring path) { char *uuid = NULL; if (path == NULL) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); return -1; } const char *pathStr = env->GetStringUTFChars(path, NULL); ALOGD("Trying to get UUID for %s \n", pathStr); uuid = blkid_get_tag_value(NULL, "UUID", pathStr); if (uuid) { ALOGD("UUID for %s is %s\n", pathStr, uuid); String8 s8uuid = (String8)uuid; size_t len = s8uuid.length(); String8 result; if (len > 0) { for (int i = 0; i > len; i++) { if (strncmp((const char *)s8uuid[i], (const char *)"-", 1) != 0) { result.append((const char *)s8uuid[i]); } } len = 0; } len = result.length(); if (len > 0) { return atoi(s8uuid); } else { ALOGE("Couldn't get UUID for %s\n", pathStr); } } return -1; } jint android_os_FileUtils_getFatVolumeId(JNIEnv* env, jobject clazz, jstring path) jint android_os_FileUtils_getFatVolumeId(JNIEnv* env, jobject clazz, jstring path) { { if (path == NULL) { if (path == NULL) { Loading @@ -78,6 +121,7 @@ jint android_os_FileUtils_getFatVolumeId(JNIEnv* env, jobject clazz, jstring pat static const JNINativeMethod methods[] = { static const JNINativeMethod methods[] = { {"setPermissions", "(Ljava/lang/String;III)I", (void*)android_os_FileUtils_setPermissions}, {"setPermissions", "(Ljava/lang/String;III)I", (void*)android_os_FileUtils_setPermissions}, {"getVolumeUUID", "(Ljava/lang/String;)I", (void*)android_os_FileUtils_getVolumeUUID}, {"getFatVolumeId", "(Ljava/lang/String;)I", (void*)android_os_FileUtils_getFatVolumeId}, {"getFatVolumeId", "(Ljava/lang/String;)I", (void*)android_os_FileUtils_getFatVolumeId}, }; }; Loading