MTP: Remove race condition in initial device enumeration for host mode.
Change-Id: Iee01aaae3f8cca4234daa289bef6631da4d6c2b6
Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/media/mtp/MtpClient.h b/media/mtp/MtpClient.h
index 907a80b..fa5c527 100644
--- a/media/mtp/MtpClient.h
+++ b/media/mtp/MtpClient.h
@@ -19,6 +19,8 @@
#include "MtpTypes.h"
+#include <utils/threads.h>
+
struct usb_host_context;
namespace android {
@@ -29,6 +31,8 @@
private:
MtpDeviceList mDeviceList;
MtpClientThread* mThread;
+ Condition mThreadStartCondition;
+ Mutex mMutex;
struct usb_host_context* mUsbHostContext;
bool mDone;
@@ -50,11 +54,13 @@
// these return true if we should stop monitoring USB and clean up
bool usbDeviceAdded(const char *devname);
bool usbDeviceRemoved(const char *devname);
+ bool usbDiscoveryDone();
friend class MtpClientThread;
bool threadLoop();
static int usb_device_added(const char *devname, void* client_data);
static int usb_device_removed(const char *devname, void* client_data);
+ static int usb_discovery_done(void* client_data);
};
}; // namespace android