MTP: Use fork instead of pthread

Change-Id: I95cf6f4def0c86f40c775738f0712323f0a0f146
This commit is contained in:
Ethan Yonker
2014-09-04 21:48:41 -05:00
parent 82ce28122d
commit 8dfa77780f
4 changed files with 31 additions and 10 deletions
+12 -7
View File
@@ -2153,7 +2153,7 @@ TWPartition *TWPartitionManager::Get_Default_Storage_Partition()
bool TWPartitionManager::Enable_MTP(void) {
#ifdef TW_HAS_MTP
if (mtpthread) {
if (mtppid) {
LOGERR("MTP already enabled\n");
return true;
}
@@ -2183,9 +2183,14 @@ bool TWPartitionManager::Enable_MTP(void) {
}
}
if (count) {
mtpthread = mtp->runserver();
DataManager::SetValue("tw_mtp_enabled", 1);
return true;
mtppid = mtp->forkserver();
if (mtppid) {
DataManager::SetValue("tw_mtp_enabled", 1);
return true;
} else {
LOGERR("Failed to enable MTP\n");
return false;
}
}
LOGERR("No valid storage partitions found for MTP.\n");
#else
@@ -2206,9 +2211,9 @@ bool TWPartitionManager::Disable_MTP(void) {
string productstr = product;
TWFunc::write_file("/sys/class/android_usb/android0/idVendor", vendorstr);
TWFunc::write_file("/sys/class/android_usb/android0/idProduct", productstr);
if (mtpthread) {
pthread_kill(mtpthread, 0);
mtpthread = NULL;
if (mtppid) {
kill(mtppid, SIGTERM);
mtppid = 0;
}
property_set("sys.usb.config", "adb");
DataManager::SetValue("tw_mtp_enabled", 0);