Add find file class to search for files
Scan a folder for a file based on file name. First scan the files in the current path, then search real directories and finally search symlinks in that order. Goal is to locate important sysfs files for things like brightness, battery capacity, lun files, etc This implementation just scans for the brightness file for the LCD Change-Id: I8ed3e74a2e2851d58b443718b6e92b50a5491f08
This commit is contained in:
committed by
Gerrit Code Review
parent
1eba56f577
commit
00028b4adb
@@ -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)));
|
||||
|
||||
Reference in New Issue
Block a user