diff options
author | Mike Lockwood <lockwood@android.com> | 2010-08-18 12:32:26 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2010-08-18 13:31:48 -0400 |
commit | 2b2bff5d98ea5038c04ba65ac2bbf77692517ea8 (patch) | |
tree | ed34aab3ac3b89a039e4ca190695e0a56b60bdb1 /media/jni | |
parent | 9e837861b28b8186da0791c9a4e72f8a128a980c (diff) | |
download | frameworks_base-2b2bff5d98ea5038c04ba65ac2bbf77692517ea8.zip frameworks_base-2b2bff5d98ea5038c04ba65ac2bbf77692517ea8.tar.gz frameworks_base-2b2bff5d98ea5038c04ba65ac2bbf77692517ea8.tar.bz2 |
MTP: Remove retry loop from MTP server code
This should eliminate the spammy logging that my coworkers have noticed.
Change-Id: Ic0e611f5277dd13651490cbe5f7ded5f6e17db4f
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'media/jni')
-rw-r--r-- | media/jni/android_media_MtpServer.cpp | 55 |
1 files changed, 17 insertions, 38 deletions
diff --git a/media/jni/android_media_MtpServer.cpp b/media/jni/android_media_MtpServer.cpp index 1ef2c58..3305136 100644 --- a/media/jni/android_media_MtpServer.cpp +++ b/media/jni/android_media_MtpServer.cpp @@ -55,7 +55,6 @@ private: MtpDatabase* mDatabase; MtpServer* mServer; String8 mStoragePath; - bool mDone; jobject mJavaServer; public: @@ -63,41 +62,31 @@ public: : mDatabase(database), mServer(NULL), mStoragePath(storagePath), - mDone(false), mJavaServer(javaServer) { } virtual bool threadLoop() { - while (1) { - int fd = open("/dev/mtp_usb", O_RDWR); - printf("open returned %d\n", fd); - if (fd < 0) { - LOGE("could not open MTP driver\n"); - break; - } - - sMutex.lock(); - mServer = new MtpServer(fd, mDatabase, AID_SDCARD_RW, 0664, 0775); - mServer->addStorage(mStoragePath); - sMutex.unlock(); - - LOGD("MtpThread mServer->run"); - mServer->run(); - close(fd); - - sMutex.lock(); - delete mServer; - mServer = NULL; - if (mDone) - goto done; - sMutex.unlock(); - // wait a bit before retrying - sleep(1); + int fd = open("/dev/mtp_usb", O_RDWR); + printf("open returned %d\n", fd); + if (fd < 0) { + LOGE("could not open MTP driver\n"); + return false; } sMutex.lock(); -done: + mServer = new MtpServer(fd, mDatabase, AID_SDCARD_RW, 0664, 0775); + mServer->addStorage(mStoragePath); + sMutex.unlock(); + + LOGD("MtpThread mServer->run"); + mServer->run(); + close(fd); + + sMutex.lock(); + delete mServer; + mServer = NULL; + JNIEnv* env = AndroidRuntime::getJNIEnv(); env->SetIntField(mJavaServer, field_context, 0); env->DeleteGlobalRef(mJavaServer); @@ -107,11 +96,6 @@ done: return false; } - void setDone() { - LOGD("setDone"); - mDone = true; - } - void sendObjectAdded(MtpObjectHandle handle) { sMutex.lock(); if (mServer) @@ -171,11 +155,6 @@ android_media_MtpServer_stop(JNIEnv *env, jobject thiz) { #ifdef HAVE_ANDROID_OS LOGD("stop\n"); - sMutex.lock(); - MtpThread *thread = (MtpThread *)env->GetIntField(thiz, field_context); - if (thread) - thread->setDone(); - sMutex.unlock(); #endif } |