summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2011-01-19 10:20:38 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-01-19 10:20:38 -0800
commitdc80b7ec053dd9e6f195bb807924d1e3891c00aa (patch)
treecff37b49b4e9211c5d4e8736024d2e45b606add5 /media
parent4061c9aa6d77bd7ad3b43d898b3e55fd62f57f18 (diff)
parent897f894e88a3a1c9010309f04c6bf466125ff818 (diff)
downloadframeworks_base-dc80b7ec053dd9e6f195bb807924d1e3891c00aa.zip
frameworks_base-dc80b7ec053dd9e6f195bb807924d1e3891c00aa.tar.gz
frameworks_base-dc80b7ec053dd9e6f195bb807924d1e3891c00aa.tar.bz2
Merge "MTP: Close and reopen driver file after an error." into honeycomb
Diffstat (limited to 'media')
-rw-r--r--media/jni/android_mtp_MtpServer.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/media/jni/android_mtp_MtpServer.cpp b/media/jni/android_mtp_MtpServer.cpp
index 4693ec5c..8908e67 100644
--- a/media/jni/android_mtp_MtpServer.cpp
+++ b/media/jni/android_mtp_MtpServer.cpp
@@ -96,18 +96,19 @@ public:
virtual bool threadLoop() {
sMutex.lock();
- mFd = open("/dev/mtp_usb", O_RDWR);
- printf("open returned %d\n", mFd);
- if (mFd < 0) {
- LOGE("could not open MTP driver\n");
- sMutex.unlock();
- return false;
- }
-
- mServer = new MtpServer(mFd, mDatabase, AID_MEDIA_RW, 0664, 0775);
- mServer->addStorage(mStoragePath, mReserveSpace);
while (!mDone) {
+ mFd = open("/dev/mtp_usb", O_RDWR);
+ printf("open returned %d\n", mFd);
+ if (mFd < 0) {
+ LOGE("could not open MTP driver\n");
+ sMutex.unlock();
+ return false;
+ }
+
+ mServer = new MtpServer(mFd, mDatabase, AID_MEDIA_RW, 0664, 0775);
+ mServer->addStorage(mStoragePath, mReserveSpace);
+
sMutex.unlock();
LOGD("MtpThread mServer->run");
@@ -115,12 +116,12 @@ public:
sleep(1);
sMutex.lock();
- }
- close(mFd);
- mFd = -1;
- delete mServer;
- mServer = NULL;
+ close(mFd);
+ mFd = -1;
+ delete mServer;
+ mServer = NULL;
+ }
JNIEnv* env = AndroidRuntime::getJNIEnv();
env->SetIntField(mJavaServer, field_context, 0);