diff --git a/.gitignore b/.gitignore index 88c12c148..49c6ed094 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ tags *.img *.zip .vscode +.venv \ No newline at end of file diff --git a/Android.mk b/Android.mk index 7a1a7f9dd..dfdb4fc81 100755 --- a/Android.mk +++ b/Android.mk @@ -83,10 +83,15 @@ endif ifeq ($(PB_DISABLE_DEFAULT_TREBLE_COMP),true) LOCAL_CFLAGS += -DPB_DISABLE_DEFAULT_TREBLE_COMP=$(PB_DISABLE_DEFAULT_TREBLE_COMP) endif + ifneq ($(PB_TORCH_MAX_BRIGHTNESS),) LOCAL_CFLAGS += -DPB_MAX_BRIGHT_VALUE=\"$(PB_TORCH_BRIGHTNESS_MAX)\" endif +ifneq ($(PB_TORCH_PATH),) + LOCAL_CFLAGS += -DPB_TORCH_PATH=\"$(PB_TORCH_PATH)\" +endif + LOCAL_SRC_FILES := \ twrp.cpp \ fixContexts.cpp \ diff --git a/data.cpp b/data.cpp index 1d239414b..0375ffa2c 100755 --- a/data.cpp +++ b/data.cpp @@ -835,6 +835,7 @@ void DataManager::SetDefaultValues() mData.SetValue("pb_torch_on", "0"); mData.SetValue("pb_include_logs_after_flash", "0"); mData.SetValue("pb_include_dmesg_logging", "0"); + mData.SetValue("pb_torch_theme_support", "0"); #ifdef PB_MAX_BRIGHT_VALUE mConst.SetValue("pb_torch_brightness_slider", "0"); #endif diff --git a/gui/Android.mk b/gui/Android.mk index 72483a220..6f66e1ca5 100755 --- a/gui/Android.mk +++ b/gui/Android.mk @@ -104,9 +104,6 @@ endif ifeq ($(TW_SCREEN_BLANK_ON_BOOT), true) LOCAL_CFLAGS += -DTW_SCREEN_BLANK_ON_BOOT endif -ifneq ($(PB_TORCH_PATH),) - LOCAL_CFLAGS += -DPB_TORCH_PATH=\"$(PB_TORCH_PATH)\" -endif ifneq ($(PB_TORCH_MAX_BRIGHTNESS),) LOCAL_CFLAGS += -DPB_MAX_BRIGHT_VALUE=$(PB_TORCH_MAX_BRIGHTNESS) endif diff --git a/gui/action.cpp b/gui/action.cpp index d537f0345..af5885cd2 100755 --- a/gui/action.cpp +++ b/gui/action.cpp @@ -69,6 +69,10 @@ pid_t sideload_child_pid; extern std::vector Users_List; extern GUITerminal* term; +// PB Flashlight Paths +extern std::string pb_torch_flashpath; +extern std::string pb_torch_switchpath; + static void *ActionThread_work_wrapper(void *data); class ActionThread @@ -2449,51 +2453,16 @@ int GUIAction::repack(std::string arg __unused) int GUIAction::flashlight(std::string arg __unused) { - int br_value = DataManager::GetIntValue("pb_bright_value"); - string str_val, file, flashp1 = "/sys/class/leds", flashp2 = "/flashlight", flashpath; - string bright = "/brightness"; - string switch_path = TWFunc::Path_Exists(flashp1 + "/led:switch" + bright) ? (flashp1 + "/led:switch") : (flashp1 + "/led:switch_0"); - DIR* d; - struct dirent* de __attribute__((unused)); + if (DataManager::GetIntValue("pb_torch_theme_support") == 1) { + string bright = "/brightness"; + int br_value = DataManager::GetIntValue("pb_bright_value"); + string switch_path = pb_torch_switchpath; + string flashpath = pb_torch_flashpath; #ifdef PB_MAX_BRIGHT_VALUE - br_value = PB_MAX_BRIGHT_VALUE; - DataManager::SetValue("pb_torch_brightness_slider", "0"); -#endif -#ifdef PB_TORCH_PATH - flashpath = PB_TORCH_PATH; - LOGINFO("flashlight: Custom Node located at '%s'\n", flashpath.c_str()); - if (TWFunc::Path_Exists(flashpath)) - { - d = opendir(flashpath.c_str()); - if (d != NULL) - flashpath += bright; - } -#else - flashpath = flashp1 + flashp2 + bright; - if (!TWFunc::Path_Exists(flashpath)) - { - d = opendir(flashp1.c_str()); - if (d == NULL) - { - LOGINFO("Unable to open '%s'\n", flashp1.c_str()); - return 0; - } - while ((de = readdir(d)) != NULL) - { - file = de->d_name; - if(file.find("torch") != string::npos || file.find("torch_")) - { - flashpath = flashp1 + "/" + file + bright; - break; - } - } - closedir (d); - LOGINFO("Detected Node located at '%s'\n", flashpath.c_str()); - } + br_value = PB_MAX_BRIGHT_VALUE; + DataManager::SetValue("pb_torch_brightness_slider", "0"); #endif - str_val=""; - if (TWFunc::Path_Exists(flashpath)) { - LOGINFO("Flashlight Node Located at '%s'\n", flashpath.c_str()); + if (DataManager::GetIntValue("pb_torch_on") == 1) { LOGINFO("Flashlight Turning Off\n"); @@ -2511,9 +2480,6 @@ int GUIAction::flashlight(std::string arg __unused) TWFunc::write_to_file(switch_path + bright, "1"); DataManager::SetValue("pb_torch_on", "1"); } - } else { - LOGINFO("Incorrect Flashlight Path\n"); - DataManager::SetValue("pb_torch_brightness_slider", "0"); } return 0; } diff --git a/gui/theme/common/portrait.xml b/gui/theme/common/portrait.xml index 6581aab80..61eaf2222 100644 --- a/gui/theme/common/portrait.xml +++ b/gui/theme/common/portrait.xml @@ -4049,7 +4049,10 @@ - + + + + {@sel_br_val=Flashlight Brightness Value: %pb_bright_value%%} @@ -4817,7 +4820,10 @@