summaryrefslogtreecommitdiffstats
path: root/twrp.cpp
diff options
context:
space:
mode:
authorMatt Mower <mowerm@gmail.com>2017-02-16 17:38:52 +0100
committerMatt Mower <mowerm@gmail.com>2017-02-24 03:10:17 +0100
commit653a1709350a9d66415fcef27d8f157b66a891f5 (patch)
treebcf82a3a1f26b4cd00fc1ac78930c2dbc98cd523 /twrp.cpp
parentFix handling of USB config during MTP switching (diff)
downloadandroid_bootable_recovery-653a1709350a9d66415fcef27d8f157b66a891f5.tar
android_bootable_recovery-653a1709350a9d66415fcef27d8f157b66a891f5.tar.gz
android_bootable_recovery-653a1709350a9d66415fcef27d8f157b66a891f5.tar.bz2
android_bootable_recovery-653a1709350a9d66415fcef27d8f157b66a891f5.tar.lz
android_bootable_recovery-653a1709350a9d66415fcef27d8f157b66a891f5.tar.xz
android_bootable_recovery-653a1709350a9d66415fcef27d8f157b66a891f5.tar.zst
android_bootable_recovery-653a1709350a9d66415fcef27d8f157b66a891f5.zip
Diffstat (limited to '')
-rw-r--r--twrp.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/twrp.cpp b/twrp.cpp
index 9ea6ba62e..977fea245 100644
--- a/twrp.cpp
+++ b/twrp.cpp
@@ -303,25 +303,25 @@ int main(int argc, char **argv) {
}
#ifdef TW_HAS_MTP
- // Enable MTP?
char mtp_crash_check[PROPERTY_VALUE_MAX];
property_get("mtp.crash_check", mtp_crash_check, "0");
- if (strcmp(mtp_crash_check, "0") == 0) {
+ if (DataManager::GetIntValue("tw_mtp_enabled")
+ && !strcmp(mtp_crash_check, "0") && !crash_counter
+ && (!DataManager::GetIntValue(TW_IS_ENCRYPTED) || DataManager::GetIntValue(TW_IS_DECRYPTED))) {
property_set("mtp.crash_check", "1");
- if (DataManager::GetIntValue("tw_mtp_enabled") == 1 && ((DataManager::GetIntValue(TW_IS_ENCRYPTED) != 0 && DataManager::GetIntValue(TW_IS_DECRYPTED) != 0) || DataManager::GetIntValue(TW_IS_ENCRYPTED) == 0)) {
- LOGINFO("Enabling MTP during startup\n");
- if (!PartitionManager.Enable_MTP())
- PartitionManager.Disable_MTP();
- else
- gui_msg("mtp_enabled=MTP Enabled");
- } else {
+ LOGINFO("Starting MTP\n");
+ if (!PartitionManager.Enable_MTP())
PartitionManager.Disable_MTP();
- }
+ else
+ gui_msg("mtp_enabled=MTP Enabled");
property_set("mtp.crash_check", "0");
- } else {
+ } else if (strcmp(mtp_crash_check, "0")) {
gui_warn("mtp_crash=MTP Crashed, not starting MTP on boot.");
DataManager::SetValue("tw_mtp_enabled", 0);
PartitionManager.Disable_MTP();
+ } else if (crash_counter == 1) {
+ LOGINFO("TWRP crashed; disabling MTP as a precaution.\n");
+ PartitionManager.Disable_MTP();
}
#endif