am 216a7b97: am dc80b7ec: Merge "MTP: Close and reopen driver file after an error." into honeycomb

* commit '216a7b97ebedc6886d98a117fcfe0b83891e5e45':
  MTP: Close and reopen driver file after an error.
This commit is contained in:
Mike Lockwood
2011-01-19 10:26:30 -08:00
committed by Android Git Automerger

View File

@@ -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);