summaryrefslogtreecommitdiff
path: root/media/jni/android_mtp_MtpServer.cpp
diff options
context:
space:
mode:
authorJerry Zhang <zhangjerry@google.com>2016-10-24 14:35:08 -0700
committerJerry Zhang <zhangjerry@google.com>2016-12-12 11:05:32 -0800
commitbb598ee16f4b61978c88358e8f96153395cdb7ad (patch)
tree7d6ddd52811d30560e0e713cecedd28bedcf6a99 /media/jni/android_mtp_MtpServer.cpp
parent021e8ff2afeedf1e096a0709867c615a955a978c (diff)
Modify UsbDeviceManager stack to allow MtpServer to use FunctionFS drivers.
Functionfs requires MtpServer to write descriptors before the device can be configured. This adds a new configure call that will occur only when functions are changed (new argument added to updateUsbStateBroadcast for this) and be called after sys.usb.config is changed but before the waitForState call to ensure compatibility with configfs devices. Bug: 30976142 Change-Id: I7e94a5847d3b19c0fd75139e1b15a3f2a1cea01d Test: Manual
Diffstat (limited to 'media/jni/android_mtp_MtpServer.cpp')
-rw-r--r--media/jni/android_mtp_MtpServer.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/media/jni/android_mtp_MtpServer.cpp b/media/jni/android_mtp_MtpServer.cpp
index d13187c39846..afd3082ec51b 100644
--- a/media/jni/android_mtp_MtpServer.cpp
+++ b/media/jni/android_mtp_MtpServer.cpp
@@ -56,17 +56,16 @@ static inline MtpServer* getMtpServer(JNIEnv *env, jobject thiz) {
return (MtpServer*)env->GetLongField(thiz, field_MtpServer_nativeContext);
}
+static void android_mtp_configure(JNIEnv *, jobject, jboolean usePtp) {
+ MtpServer::configure(usePtp);
+}
+
static void
android_mtp_MtpServer_setup(JNIEnv *env, jobject thiz, jobject javaDatabase, jboolean usePtp)
{
- int fd = open("/dev/mtp_usb", O_RDWR);
- if (fd >= 0) {
- MtpServer* server = new MtpServer(fd, getMtpDatabase(env, javaDatabase),
- usePtp, AID_MEDIA_RW, 0664, 0775);
- env->SetLongField(thiz, field_MtpServer_nativeContext, (jlong)server);
- } else {
- ALOGE("could not open MTP driver, errno: %d", errno);
- }
+ MtpServer* server = new MtpServer(getMtpDatabase(env, javaDatabase),
+ usePtp, AID_MEDIA_RW, 0664, 0775);
+ env->SetLongField(thiz, field_MtpServer_nativeContext, (jlong)server);
}
static void
@@ -180,6 +179,7 @@ android_mtp_MtpServer_remove_storage(JNIEnv *env, jobject thiz, jint storageId)
// ----------------------------------------------------------------------------
static const JNINativeMethod gMethods[] = {
+ {"native_configure", "(Z)V", (void *)android_mtp_configure},
{"native_setup", "(Landroid/mtp/MtpDatabase;Z)V",
(void *)android_mtp_MtpServer_setup},
{"native_run", "()V", (void *)android_mtp_MtpServer_run},