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

Commit abb5c4ea authored by Ethan Yonker's avatar Ethan Yonker Committed by Dees Troy
Browse files

Move sleep during MTP startup to MTP thread

Some devices are very slow to respond to the sysfs requests. To
prevent delaying the main GUI from booting during TWRP startup, we
move the sleep delay to just before we open the MTP device and
into the MTP thread so that it does not hold up the main TWRP
thread.

Change-Id: Ic931ef317d0fb7ef4dfdef46a32f68a014ff62c0
parent c1f5c0f7
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -56,6 +56,11 @@ int twmtp_MtpServer::setup()
{
	usePtp =  false;
	MyMtpDatabase* mtpdb = new MyMtpDatabase();
	/* Sleep for a bit before we open the MTP USB device because some
	 * devices are not ready due to the kernel not responding to our
	 * sysfs requests right away.
	 */
	usleep(800000);
#ifdef USB_MTP_DEVICE
#define STRINGIFY(x) #x
#define EXPAND(x) STRINGIFY(x)
+0 −1
Original line number Diff line number Diff line
@@ -1922,7 +1922,6 @@ bool TWPartitionManager::Enable_MTP(void) {
	TWFunc::write_file("/sys/class/android_usb/android0/idVendor", vendorstr);
	TWFunc::write_file("/sys/class/android_usb/android0/idProduct", productstr);
	property_set("sys.usb.config", "mtp,adb");
	usleep(2000); // Short sleep to prevent an occasional kernel panic on some devices
	std::vector<TWPartition*>::iterator iter;
	/* To enable MTP debug, use the twrp command line feature to
	 * twrp set tw_mtp_debug 1