Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 897f894e authored by Mike Lockwood's avatar Mike Lockwood
Browse files

MTP: Close and reopen driver file after an error.



BUG: 3368665

Change-Id: Ib1580c0e98a4d192aa0c213406fd3bafae597ec0
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent 242d0cdc
Loading
Loading
Loading
Loading
+16 −15
Original line number Diff line number Diff line
@@ -96,6 +96,8 @@ public:

    virtual bool threadLoop() {
        sMutex.lock();

        while (!mDone) {
            mFd = open("/dev/mtp_usb", O_RDWR);
            printf("open returned %d\n", mFd);
            if (mFd < 0) {
@@ -107,7 +109,6 @@ public:
            mServer = new MtpServer(mFd, mDatabase, AID_MEDIA_RW, 0664, 0775);
            mServer->addStorage(mStoragePath, mReserveSpace);

        while (!mDone) {
            sMutex.unlock();

            LOGD("MtpThread mServer->run");
@@ -115,12 +116,12 @@ public:
            sleep(1);

            sMutex.lock();
        }

            close(mFd);
            mFd = -1;
            delete mServer;
            mServer = NULL;
        }

        JNIEnv* env = AndroidRuntime::getJNIEnv();
        env->SetIntField(mJavaServer, field_context, 0);