summaryrefslogtreecommitdiffstats
path: root/data.cpp
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2014-04-09 21:29:02 +0200
committerGerrit Code Review <gerrit2@gerrit>2014-04-15 15:26:44 +0200
commit00028b4adbe1475fe799a7cec148b37182ac5e9f (patch)
tree9b132f947eab70fa9ab685e751f017860f522636 /data.cpp
parentFix touch on Sprint HTC One m8 (diff)
downloadandroid_bootable_recovery-00028b4adbe1475fe799a7cec148b37182ac5e9f.tar
android_bootable_recovery-00028b4adbe1475fe799a7cec148b37182ac5e9f.tar.gz
android_bootable_recovery-00028b4adbe1475fe799a7cec148b37182ac5e9f.tar.bz2
android_bootable_recovery-00028b4adbe1475fe799a7cec148b37182ac5e9f.tar.lz
android_bootable_recovery-00028b4adbe1475fe799a7cec148b37182ac5e9f.tar.xz
android_bootable_recovery-00028b4adbe1475fe799a7cec148b37182ac5e9f.tar.zst
android_bootable_recovery-00028b4adbe1475fe799a7cec148b37182ac5e9f.zip
Diffstat (limited to '')
-rw-r--r--data.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/data.cpp b/data.cpp
index c9628a411..1fbe0ffad 100644
--- a/data.cpp
+++ b/data.cpp
@@ -45,6 +45,7 @@
#ifndef TW_NO_SCREEN_TIMEOUT
#include "gui/blanktimer.hpp"
#endif
+#include "find_file.hpp"
#ifdef TW_USE_MODEL_HARDWARE_ID_FOR_DEVICE_ID
#include "cutils/properties.h"
@@ -940,17 +941,31 @@ void DataManager::SetDefaultValues()
#ifndef TW_MAX_BRIGHTNESS
#define TW_MAX_BRIGHTNESS 255
#endif
+ string findbright;
if (strcmp(EXPAND(TW_BRIGHTNESS_PATH), "/nobrightness") != 0) {
- LOGINFO("TW_BRIGHTNESS_PATH := %s\n", EXPAND(TW_BRIGHTNESS_PATH));
+ findbright = EXPAND(TW_BRIGHTNESS_PATH);
+ LOGINFO("TW_BRIGHTNESS_PATH := %s\n", findbright.c_str());
+ if (!TWFunc::Path_Exists(findbright)) {
+ LOGINFO("Specified brightness file '%s' not found.\n", findbright.c_str());
+ findbright = "";
+ }
+ }
+ if (findbright.empty()) {
+ // Attempt to locate the brightness file
+ findbright = Find_File::Find("brightness", "/sys/class/backlight");
+ }
+ if (findbright.empty()) {
+ LOGINFO("Unable to locate brightness file\n");
+ mConstValues.insert(make_pair("tw_has_brightnesss_file", "0"));
+ } else {
+ LOGINFO("Found brightness file at '%s'\n", findbright.c_str());
mConstValues.insert(make_pair("tw_has_brightnesss_file", "1"));
- mConstValues.insert(make_pair("tw_brightness_file", EXPAND(TW_BRIGHTNESS_PATH)));
+ mConstValues.insert(make_pair("tw_brightness_file", findbright));
ostringstream maxVal;
maxVal << TW_MAX_BRIGHTNESS;
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)));
- } else {
- mConstValues.insert(make_pair("tw_has_brightnesss_file", "0"));
}
#endif
mValues.insert(make_pair(TW_MILITARY_TIME, make_pair("0", 1)));