diff options
Diffstat (limited to 'twrp-functions.cpp')
-rw-r--r-- | twrp-functions.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/twrp-functions.cpp b/twrp-functions.cpp index 885d352db..1798c49b7 100644 --- a/twrp-functions.cpp +++ b/twrp-functions.cpp @@ -1260,4 +1260,22 @@ int TWFunc::Set_Brightness(std::string brightness_value) return -1; } +bool TWFunc::Toggle_MTP(bool enable) { +#ifdef TW_HAS_MTP + static int was_enabled = false; + + if (enable && was_enabled) { + if (!PartitionManager.Enable_MTP()) + PartitionManager.Disable_MTP(); + } else { + was_enabled = DataManager::GetIntValue("tw_mtp_enabled"); + PartitionManager.Disable_MTP(); + usleep(500); + } + return was_enabled; +#else + return false; +#endif +} + #endif // ndef BUILD_TWRPTAR_MAIN |