summaryrefslogtreecommitdiffstats
path: root/CrespoParts/src/com/cyanogenmod/CrespoParts/TouchKeyBacklightTimeout.java
diff options
context:
space:
mode:
authorKoushik Dutta <koushd@gmail.com>2011-11-20 21:58:36 -0800
committerKoushik Dutta <koushd@gmail.com>2011-11-20 21:58:36 -0800
commit4aefda8d63e0cc887366adf3cc1347af84dfb729 (patch)
treeb2c88ec0192b222f12e2d9b78ddf625142d116f5 /CrespoParts/src/com/cyanogenmod/CrespoParts/TouchKeyBacklightTimeout.java
parent16754dd56552e914576971ddc53ef852ca84244c (diff)
downloaddevice_samsung_crespo-4aefda8d63e0cc887366adf3cc1347af84dfb729.zip
device_samsung_crespo-4aefda8d63e0cc887366adf3cc1347af84dfb729.tar.gz
device_samsung_crespo-4aefda8d63e0cc887366adf3cc1347af84dfb729.tar.bz2
squash changes
Diffstat (limited to 'CrespoParts/src/com/cyanogenmod/CrespoParts/TouchKeyBacklightTimeout.java')
-rw-r--r--CrespoParts/src/com/cyanogenmod/CrespoParts/TouchKeyBacklightTimeout.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/CrespoParts/src/com/cyanogenmod/CrespoParts/TouchKeyBacklightTimeout.java b/CrespoParts/src/com/cyanogenmod/CrespoParts/TouchKeyBacklightTimeout.java
new file mode 100644
index 0000000..c07f042
--- /dev/null
+++ b/CrespoParts/src/com/cyanogenmod/CrespoParts/TouchKeyBacklightTimeout.java
@@ -0,0 +1,36 @@
+package com.cyanogenmod.CrespoParts;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceManager;
+
+public class TouchKeyBacklightTimeout implements OnPreferenceChangeListener {
+
+ private static final String FILE = "/sys/class/misc/notification/bl_timeout";
+
+ public static boolean isSupported() {
+ return Utils.fileExists(FILE);
+ }
+
+ /**
+ * Restore backlight timeout setting from SharedPreferences. (Write to kernel.)
+ * @param context The context to read the SharedPreferences from
+ */
+ public static void restore(Context context) {
+ if (!isSupported()) {
+ return;
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ Utils.writeValue(FILE, sharedPrefs.getString(CrespoParts.KEY_BACKLIGHT_TIMEOUT, "5"));
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ Utils.writeValue(FILE, (String) newValue);
+ return true;
+ }
+
+} \ No newline at end of file