OSDN Git Service

DO NOT MERGE : Always set sys.usb.ffs.mtp.ready during configure
authorJerry Zhang <zhangjerry@google.com>
Mon, 23 Oct 2017 19:03:40 +0000 (12:03 -0700)
committerandroid-build-team Robot <android-build-team-robot@google.com>
Thu, 14 Dec 2017 21:11:29 +0000 (21:11 +0000)
Sometimes, due to a race, the configure
will fail even though descriptors are actually
written because MtpServer did not die properly.
MtpServer lifetime is fixed properly in master
with multiplexed io, but to work around the
issue here, we set the property at all times.

Also reduce the timeout to leave room for
UsbDeviceManager.

Bug: 67844294
Test: Plug/replug device on sled with usb debugging off x50
Test: Verify that the race is hit, but projection still starts
Test: Verify that all other usb configurations still work
Change-Id: I39dd4d3db95e087f065d58ba80ca980559920c99
(cherry picked from commit 9dc10038b05cc59457ba0a10d90a3b3faddd34c3)

media/mtp/MtpFfsHandle.cpp
media/mtp/MtpServer.cpp

index 8d894c1..9139925 100644 (file)
@@ -614,7 +614,7 @@ int MtpFfsHandle::start() {
 
 int MtpFfsHandle::configure(bool usePtp) {
     // Wait till previous server invocation has closed
-    if (!mLock.try_lock_for(std::chrono::milliseconds(1000))) {
+    if (!mLock.try_lock_for(std::chrono::milliseconds(300))) {
         LOG(ERROR) << "MtpServer was unable to get configure lock";
         return -1;
     }
index 2180462..67fd221 100644 (file)
@@ -132,7 +132,7 @@ int MtpServer::configure(bool usePtp) {
 
     int ret = sHandle->configure(usePtp);
     if (ret) ALOGE("Failed to configure MTP driver!");
-    else android::base::SetProperty("sys.usb.ffs.mtp.ready", "1");
+    android::base::SetProperty("sys.usb.ffs.mtp.ready", "1");
 
     return ret;
 }