From a18f108e8439c2b1d564f30634eeb8b51a0dbfa2 Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Mon, 7 Jul 2014 15:07:58 -0500 Subject: Fix setting of brightness during startup Change-Id: I1bd01df971857a2dd5e75ed87c488d075d765527 --- data.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/data.cpp b/data.cpp index 39f24c13e..79d3f78f9 100644 --- a/data.cpp +++ b/data.cpp @@ -51,6 +51,10 @@ #include "cutils/properties.h" #endif +#ifndef TW_MAX_BRIGHTNESS +#define TW_MAX_BRIGHTNESS 255 +#endif + extern "C" { #include "twcommon.h" @@ -946,9 +950,6 @@ void DataManager::SetDefaultValues() mValues.insert(make_pair("tw_gui_done", make_pair("0", 0))); mValues.insert(make_pair("tw_encrypt_backup", make_pair("0", 0))); #ifdef TW_BRIGHTNESS_PATH -#ifndef TW_MAX_BRIGHTNESS -#define TW_MAX_BRIGHTNESS 255 -#endif string findbright; if (strcmp(EXPAND(TW_BRIGHTNESS_PATH), "/nobrightness") != 0) { findbright = EXPAND(TW_BRIGHTNESS_PATH); @@ -975,6 +976,8 @@ void DataManager::SetDefaultValues() mConstValues.insert(make_pair("tw_brightness_max", maxVal.str())); mValues.insert(make_pair("tw_brightness", make_pair(maxVal.str(), 1))); mValues.insert(make_pair("tw_brightness_pct", make_pair("100", 1))); + string max_bright = maxVal.str(); + TWFunc::write_file(findbright, max_bright); } #endif mValues.insert(make_pair(TW_MILITARY_TIME, make_pair("0", 1))); @@ -1136,13 +1139,12 @@ void DataManager::ReadSettingsFile(void) #endif // ifdef TW_OEM_BUILD PartitionManager.Mount_All_Storage(); update_tz_environment_variables(); -#ifdef TW_MAX_BRIGHTNESS - if (strcmp(EXPAND(TW_BRIGHTNESS_PATH), "/nobrightness") != 0) { - string brightness_path = EXPAND(TW_BRIGHTNESS_PATH); + + string brightness_path = GetStrValue("tw_brightness_file"); + if (!brightness_path.empty() && brightness_path != "/nobrightness" && TWFunc::Path_Exists(brightness_path)) { string brightness_value = GetStrValue("tw_brightness"); TWFunc::write_file(brightness_path, brightness_value); } -#endif } string DataManager::GetCurrentStoragePath(void) -- cgit v1.2.3