summaryrefslogtreecommitdiffstats
path: root/partitionmanager.cpp
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2014-09-05 04:48:41 +0200
committerEthan Yonker <dees_troy@teamw.in>2014-09-05 04:59:20 +0200
commit8dfa77780fe1e3944a5b63b453e7a25b11ca25c4 (patch)
tree3d535c23f2a448761d390ed3148ec3c1f95b370a /partitionmanager.cpp
parentFix reporting of folder size on exfat-fuse (diff)
downloadandroid_bootable_recovery-8dfa77780fe1e3944a5b63b453e7a25b11ca25c4.tar
android_bootable_recovery-8dfa77780fe1e3944a5b63b453e7a25b11ca25c4.tar.gz
android_bootable_recovery-8dfa77780fe1e3944a5b63b453e7a25b11ca25c4.tar.bz2
android_bootable_recovery-8dfa77780fe1e3944a5b63b453e7a25b11ca25c4.tar.lz
android_bootable_recovery-8dfa77780fe1e3944a5b63b453e7a25b11ca25c4.tar.xz
android_bootable_recovery-8dfa77780fe1e3944a5b63b453e7a25b11ca25c4.tar.zst
android_bootable_recovery-8dfa77780fe1e3944a5b63b453e7a25b11ca25c4.zip
Diffstat (limited to '')
-rw-r--r--partitionmanager.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index a8b61c3fc..bc27ccbcb 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -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);