diff options
Diffstat (limited to 'CrespoParts/src/com/cyanogenmod/CrespoParts/TouchKeyBlinkTimeout.java')
-rw-r--r-- | CrespoParts/src/com/cyanogenmod/CrespoParts/TouchKeyBlinkTimeout.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/CrespoParts/src/com/cyanogenmod/CrespoParts/TouchKeyBlinkTimeout.java b/CrespoParts/src/com/cyanogenmod/CrespoParts/TouchKeyBlinkTimeout.java new file mode 100644 index 0000000..3fdcf4d --- /dev/null +++ b/CrespoParts/src/com/cyanogenmod/CrespoParts/TouchKeyBlinkTimeout.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 TouchKeyBlinkTimeout implements OnPreferenceChangeListener { + + private static final String FILE = "/sys/class/misc/notification/blinktimeout"; + + 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_BLINK_TIMEOUT, "5")); + } + + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + Utils.writeValue(FILE, (String) newValue); + return true; + } + +}
\ No newline at end of file |