Support reading since_epoch and secondary brightness files

TWFunc::Fixup_Time_On_Boot: Will now try to read
/sys/class/rtc/rtc0/since_epoch to correct time, if that fails
it will try to use the ats files to correct time.

TWFunc::Set_Brightness: One single function to set brightness
from both the automated functions and the gui actions. It is
able to set a second brightness path if present, it will set
them both the same value. Many Sony devices have 2 brightness
files in the sysfs that must be set to properly set the
brightness.

Change-Id: I7ca582109085dfbcb46b8de73ad031e4b7903fca
diff --git a/gui/blanktimer.cpp b/gui/blanktimer.cpp
index 383b157..1b18429 100644
--- a/gui/blanktimer.cpp
+++ b/gui/blanktimer.cpp
@@ -97,11 +97,11 @@
 		if (sleepTimer > 2 && diff.tv_sec > (sleepTimer - 2) && conblank == 0) {
 			orig_brightness = getBrightness();
 			setConBlank(1);
-			setBrightness(5);
+			TWFunc::Set_Brightness("5");
 		}
 		if (sleepTimer && diff.tv_sec > sleepTimer && conblank < 2) {
 			setConBlank(2);
-			setBrightness(0);
+			TWFunc::Set_Brightness("0");
 			screenoff = true;
 			TWFunc::check_and_run_script("/sbin/postscreenblank.sh", "blank");
 			PageManager::ChangeOverlay("lock");
@@ -115,39 +115,20 @@
 	return -1; //shouldn't get here
 }
 
-int blanktimer::getBrightness(void) {
-	string results;
+string blanktimer::getBrightness(void) {
+	string result;
 	string brightness_path;
 	DataManager::GetValue("tw_brightness_file", brightness_path);
-	if ((TWFunc::read_file(brightness_path, results)) != 0)
-		return -1;
-	int result = atoi(results.c_str());
-	if (result == 0) {
-		int tw_brightness;
-		DataManager::GetValue("tw_brightness", tw_brightness);
-		if (tw_brightness) {
-			result = tw_brightness;
-		} else {
-			result = 255;
-		}
+	if (brightness_path == "/nobrightness")
+		return brightness_path;
+	DataManager::GetValue("tw_brightness", result);
+	if (result == "") {
+		result = "255";
 	}
 	return result;
 
 }
 
-int blanktimer::setBrightness(int brightness) {
-	string brightness_path;
-	string bstring;
-	char buff[100];
-	DataManager::GetValue("tw_brightness_file", brightness_path);
-	sprintf(buff, "%d", brightness);
-	bstring = buff;
-	if ((TWFunc::write_file(brightness_path, bstring)) != 0)
-		return -1;
-	gui_forceRender();
-	return 0;
-}
-
 void blanktimer::resetTimerAndUnblank(void) {
 	setTimer();
 	switch (conblank) {
@@ -165,7 +146,8 @@
 			screenoff = false;
 			// No break here, we want to keep going
 		case 1:
-			setBrightness(orig_brightness);
+			if (orig_brightness != "/nobrightness")
+				TWFunc::Set_Brightness(orig_brightness);
 			setConBlank(0);
 			break;
 	}