Loading packages/MtpDocumentsProvider/jni/com_android_mtp_AppFuse.cpp +18 −20 Original line number Original line Diff line number Diff line Loading @@ -120,44 +120,45 @@ public: AppFuse(JNIEnv* env, jobject self) : AppFuse(JNIEnv* env, jobject self) : env_(env), self_(self), handle_counter_(0) {} env_(env), self_(self), handle_counter_(0) {} bool handle_fuse_request(int fd, FuseRequest* req) { void handle_fuse_request(int fd, FuseRequest* req) { ALOGV("Request op=%d", req->header().opcode); ALOGV("Request op=%d", req->header().opcode); switch (req->header().opcode) { switch (req->header().opcode) { // TODO: Handle more operations that are enough to provide seekable // TODO: Handle more operations that are enough to provide seekable // FD. // FD. case FUSE_LOOKUP: case FUSE_LOOKUP: invoke_handler(fd, req, &AppFuse::handle_fuse_lookup); invoke_handler(fd, req, &AppFuse::handle_fuse_lookup); return true; return; case FUSE_FORGET: // Return without replying. return; case FUSE_INIT: case FUSE_INIT: invoke_handler(fd, req, &AppFuse::handle_fuse_init); invoke_handler(fd, req, &AppFuse::handle_fuse_init); return true; return; case FUSE_GETATTR: case FUSE_GETATTR: invoke_handler(fd, req, &AppFuse::handle_fuse_getattr); invoke_handler(fd, req, &AppFuse::handle_fuse_getattr); return true; return; case FUSE_FORGET: return false; case FUSE_OPEN: case FUSE_OPEN: invoke_handler(fd, req, &AppFuse::handle_fuse_open); invoke_handler(fd, req, &AppFuse::handle_fuse_open); return true; return; case FUSE_READ: case FUSE_READ: invoke_handler(fd, req, &AppFuse::handle_fuse_read); invoke_handler(fd, req, &AppFuse::handle_fuse_read); return true; return; case FUSE_WRITE: case FUSE_WRITE: invoke_handler(fd, req, &AppFuse::handle_fuse_write); invoke_handler(fd, req, &AppFuse::handle_fuse_write); return true; return; case FUSE_RELEASE: case FUSE_RELEASE: invoke_handler(fd, req, &AppFuse::handle_fuse_release); invoke_handler(fd, req, &AppFuse::handle_fuse_release); return true; return; case FUSE_FLUSH: case FUSE_FLUSH: invoke_handler(fd, req, &AppFuse::handle_fuse_flush); invoke_handler(fd, req, &AppFuse::handle_fuse_flush); return true; return; default: { default: { ALOGV("NOTIMPL op=%d uniq=%" PRIx64 " nid=%" PRIx64 "\n", ALOGV("NOTIMPL op=%d uniq=%" PRIx64 " nid=%" PRIx64 "\n", req->header().opcode, req->header().opcode, req->header().unique, req->header().unique, req->header().nodeid); req->header().nodeid); fuse_reply(fd, req->header().unique, -ENOSYS, NULL, 0); fuse_reply(fd, req->header().unique, -ENOSYS, NULL, 0); return true; return; } } } } } } Loading Loading @@ -445,8 +446,7 @@ private: } } }; }; jboolean com_android_mtp_AppFuse_start_app_fuse_loop( void com_android_mtp_AppFuse_start_app_fuse_loop(JNIEnv* env, jobject self, jint jfd) { JNIEnv* env, jobject self, jint jfd) { ScopedFd fd(static_cast<int>(jfd)); ScopedFd fd(static_cast<int>(jfd)); AppFuse appfuse(env, self); AppFuse appfuse(env, self); Loading @@ -458,8 +458,8 @@ jboolean com_android_mtp_AppFuse_start_app_fuse_loop( read(fd, request.buffer, sizeof(request.buffer))); read(fd, request.buffer, sizeof(request.buffer))); if (result < 0) { if (result < 0) { if (errno == ENODEV) { if (errno == ENODEV) { ALOGE("Someone stole our marbles!\n"); ALOGV("AppFuse was unmounted.\n"); return JNI_FALSE; return; } } ALOGE("Failed to read bytes from FD: errno=%d\n", errno); ALOGE("Failed to read bytes from FD: errno=%d\n", errno); continue; continue; Loading @@ -477,16 +477,14 @@ jboolean com_android_mtp_AppFuse_start_app_fuse_loop( continue; continue; } } if (!appfuse.handle_fuse_request(fd, &request)) { appfuse.handle_fuse_request(fd, &request); return JNI_TRUE; } } } } } static const JNINativeMethod gMethods[] = { static const JNINativeMethod gMethods[] = { { { "native_start_app_fuse_loop", "native_start_app_fuse_loop", "(I)Z", "(I)V", (void *) com_android_mtp_AppFuse_start_app_fuse_loop (void *) com_android_mtp_AppFuse_start_app_fuse_loop } } }; }; Loading packages/MtpDocumentsProvider/src/com/android/mtp/AppFuse.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -75,7 +75,7 @@ public class AppFuse { void close() { void close() { try { try { // Remote side of ParcelFileDescriptor is tracking the close of mDeviceFd, and unmount // Remote side of ParcelFileDescriptor is tracking the close of mDeviceFd, and unmount // the corresponding fuse file system. The mMessageThread will receive FUSE_FORGET, and // the corresponding fuse file system. The mMessageThread will receive ENODEV, and // then terminate itself. // then terminate itself. mDeviceFd.close(); mDeviceFd.close(); mMessageThread.join(); mMessageThread.join(); Loading Loading @@ -236,7 +236,7 @@ public class AppFuse { } } } } private native boolean native_start_app_fuse_loop(int fd); private native void native_start_app_fuse_loop(int fd); private class AppFuseMessageThread extends Thread { private class AppFuseMessageThread extends Thread { /** /** Loading Loading
packages/MtpDocumentsProvider/jni/com_android_mtp_AppFuse.cpp +18 −20 Original line number Original line Diff line number Diff line Loading @@ -120,44 +120,45 @@ public: AppFuse(JNIEnv* env, jobject self) : AppFuse(JNIEnv* env, jobject self) : env_(env), self_(self), handle_counter_(0) {} env_(env), self_(self), handle_counter_(0) {} bool handle_fuse_request(int fd, FuseRequest* req) { void handle_fuse_request(int fd, FuseRequest* req) { ALOGV("Request op=%d", req->header().opcode); ALOGV("Request op=%d", req->header().opcode); switch (req->header().opcode) { switch (req->header().opcode) { // TODO: Handle more operations that are enough to provide seekable // TODO: Handle more operations that are enough to provide seekable // FD. // FD. case FUSE_LOOKUP: case FUSE_LOOKUP: invoke_handler(fd, req, &AppFuse::handle_fuse_lookup); invoke_handler(fd, req, &AppFuse::handle_fuse_lookup); return true; return; case FUSE_FORGET: // Return without replying. return; case FUSE_INIT: case FUSE_INIT: invoke_handler(fd, req, &AppFuse::handle_fuse_init); invoke_handler(fd, req, &AppFuse::handle_fuse_init); return true; return; case FUSE_GETATTR: case FUSE_GETATTR: invoke_handler(fd, req, &AppFuse::handle_fuse_getattr); invoke_handler(fd, req, &AppFuse::handle_fuse_getattr); return true; return; case FUSE_FORGET: return false; case FUSE_OPEN: case FUSE_OPEN: invoke_handler(fd, req, &AppFuse::handle_fuse_open); invoke_handler(fd, req, &AppFuse::handle_fuse_open); return true; return; case FUSE_READ: case FUSE_READ: invoke_handler(fd, req, &AppFuse::handle_fuse_read); invoke_handler(fd, req, &AppFuse::handle_fuse_read); return true; return; case FUSE_WRITE: case FUSE_WRITE: invoke_handler(fd, req, &AppFuse::handle_fuse_write); invoke_handler(fd, req, &AppFuse::handle_fuse_write); return true; return; case FUSE_RELEASE: case FUSE_RELEASE: invoke_handler(fd, req, &AppFuse::handle_fuse_release); invoke_handler(fd, req, &AppFuse::handle_fuse_release); return true; return; case FUSE_FLUSH: case FUSE_FLUSH: invoke_handler(fd, req, &AppFuse::handle_fuse_flush); invoke_handler(fd, req, &AppFuse::handle_fuse_flush); return true; return; default: { default: { ALOGV("NOTIMPL op=%d uniq=%" PRIx64 " nid=%" PRIx64 "\n", ALOGV("NOTIMPL op=%d uniq=%" PRIx64 " nid=%" PRIx64 "\n", req->header().opcode, req->header().opcode, req->header().unique, req->header().unique, req->header().nodeid); req->header().nodeid); fuse_reply(fd, req->header().unique, -ENOSYS, NULL, 0); fuse_reply(fd, req->header().unique, -ENOSYS, NULL, 0); return true; return; } } } } } } Loading Loading @@ -445,8 +446,7 @@ private: } } }; }; jboolean com_android_mtp_AppFuse_start_app_fuse_loop( void com_android_mtp_AppFuse_start_app_fuse_loop(JNIEnv* env, jobject self, jint jfd) { JNIEnv* env, jobject self, jint jfd) { ScopedFd fd(static_cast<int>(jfd)); ScopedFd fd(static_cast<int>(jfd)); AppFuse appfuse(env, self); AppFuse appfuse(env, self); Loading @@ -458,8 +458,8 @@ jboolean com_android_mtp_AppFuse_start_app_fuse_loop( read(fd, request.buffer, sizeof(request.buffer))); read(fd, request.buffer, sizeof(request.buffer))); if (result < 0) { if (result < 0) { if (errno == ENODEV) { if (errno == ENODEV) { ALOGE("Someone stole our marbles!\n"); ALOGV("AppFuse was unmounted.\n"); return JNI_FALSE; return; } } ALOGE("Failed to read bytes from FD: errno=%d\n", errno); ALOGE("Failed to read bytes from FD: errno=%d\n", errno); continue; continue; Loading @@ -477,16 +477,14 @@ jboolean com_android_mtp_AppFuse_start_app_fuse_loop( continue; continue; } } if (!appfuse.handle_fuse_request(fd, &request)) { appfuse.handle_fuse_request(fd, &request); return JNI_TRUE; } } } } } static const JNINativeMethod gMethods[] = { static const JNINativeMethod gMethods[] = { { { "native_start_app_fuse_loop", "native_start_app_fuse_loop", "(I)Z", "(I)V", (void *) com_android_mtp_AppFuse_start_app_fuse_loop (void *) com_android_mtp_AppFuse_start_app_fuse_loop } } }; }; Loading
packages/MtpDocumentsProvider/src/com/android/mtp/AppFuse.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -75,7 +75,7 @@ public class AppFuse { void close() { void close() { try { try { // Remote side of ParcelFileDescriptor is tracking the close of mDeviceFd, and unmount // Remote side of ParcelFileDescriptor is tracking the close of mDeviceFd, and unmount // the corresponding fuse file system. The mMessageThread will receive FUSE_FORGET, and // the corresponding fuse file system. The mMessageThread will receive ENODEV, and // then terminate itself. // then terminate itself. mDeviceFd.close(); mDeviceFd.close(); mMessageThread.join(); mMessageThread.join(); Loading Loading @@ -236,7 +236,7 @@ public class AppFuse { } } } } private native boolean native_start_app_fuse_loop(int fd); private native void native_start_app_fuse_loop(int fd); private class AppFuseMessageThread extends Thread { private class AppFuseMessageThread extends Thread { /** /** Loading