diff options
author | Sam Mortimer <sam@mortimer.me.uk> | 2012-06-28 21:58:22 -0700 |
---|---|---|
committer | Andrew Dodd <atd7@cornell.edu> | 2012-07-07 11:34:13 -0400 |
commit | 3f7b71553971be861faf7d486735c4a8cc4f7854 (patch) | |
tree | 8c9764ea24413cfbdc0cdf260f6169a98f86029a | |
parent | 44f182eecda0fc1e2f9bd387efe86f116664e860 (diff) | |
download | device_samsung_n7000-3f7b71553971be861faf7d486735c4a8cc4f7854.zip device_samsung_n7000-3f7b71553971be861faf7d486735c4a8cc4f7854.tar.gz device_samsung_n7000-3f7b71553971be861faf7d486735c4a8cc4f7854.tar.bz2 |
n7000: configurable touchkey backlight timeout (2/2)
requires smdk4210 kernel change:
http://review.cyanogenmod.com/#/c/18357/
Patch applied with conflict resolution to N7000
tree.
Change-Id: Icd4bd6749886ef1eaf7f4527bf7052a18b549868
9 files changed, 124 insertions, 6 deletions
diff --git a/DeviceSettings/res/values-de/arrays.xml b/DeviceSettings/res/values-de/arrays.xml index 3b7cd82..04797c6 100644 --- a/DeviceSettings/res/values-de/arrays.xml +++ b/DeviceSettings/res/values-de/arrays.xml @@ -56,4 +56,14 @@ <item>HSDPA + HSUPA</item> </string-array> + <string-array name="touchkey_timeout_entries"> + <item>Niemals</item> + <item>1 Sekunde</item> + <item>2 Sekunden</item> + <item>3 Sekunden (Standard)</item> + <item>4 Sekunden</item> + <item>5 Sekunden</item> + <item>6 Sekunden</item> + </string-array> + </resources> diff --git a/DeviceSettings/res/values/arrays.xml b/DeviceSettings/res/values/arrays.xml index a86899a..4ee28de 100644 --- a/DeviceSettings/res/values/arrays.xml +++ b/DeviceSettings/res/values/arrays.xml @@ -112,4 +112,24 @@ <item>23</item> </string-array> + <string-array name="touchkey_timeout_entries"> + <item>Never</item> + <item>1 second</item> + <item>2 seconds</item> + <item>3 seconds (default)</item> + <item>4 seconds</item> + <item>5 seconds</item> + <item>6 seconds</item> + </string-array> + + <string-array name="touchkey_timeout_entries_values" translatable="false"> + <item>0</item> + <item>1</item> + <item>2</item> + <item>3</item> + <item>4</item> + <item>5</item> + <item>6</item> + </string-array> + </resources> diff --git a/DeviceSettings/res/values/strings.xml b/DeviceSettings/res/values/strings.xml index 08ee90c..d3f0891 100644 --- a/DeviceSettings/res/values/strings.xml +++ b/DeviceSettings/res/values/strings.xml @@ -28,6 +28,8 @@ <string name="touchkey_subcat_title">Touch key</string> <string name="touchkey_light_title_head">Enable keys backlight</string> <string name="touchkey_light_summary_head">Light up touch keys when screen is on</string> + <string name="touchkey_timeout_title_head">Backlight timeout</string> + <string name="touchkey_timeout_summary_head">Delay after a keypress before backlight turns off</string> <string name="category_haptic_title">Haptic</string> <string name="vibrator_subcat_title">Vibrator</string> diff --git a/DeviceSettings/res/xml/sensors_preferences.xml b/DeviceSettings/res/xml/sensors_preferences.xml index 9029a62..497587d 100644 --- a/DeviceSettings/res/xml/sensors_preferences.xml +++ b/DeviceSettings/res/xml/sensors_preferences.xml @@ -24,6 +24,15 @@ android:key="touchkey_light" android:title="@string/touchkey_light_title_head" android:summary="@string/touchkey_light_summary_head" + android:defaultValue="true" + /> + <com.cyanogenmod.settings.device.TouchkeyTimeout + android:key="touchkey_timeout" + android:title="@string/touchkey_timeout_title_head" + android:summary="@string/touchkey_timeout_summary_head" + android:entries="@array/touchkey_timeout_entries" + android:entryValues="@array/touchkey_timeout_entries_values" + android:defaultValue="3" /> </PreferenceCategory> </PreferenceScreen> diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java index 58003a2..a60d9e8 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java @@ -45,6 +45,7 @@ public class DeviceSettings extends FragmentActivity { public static final String KEY_CALIBRATE_GYRO = "calibrate_gyro"; public static final String KEY_TOUCHSCREEN_SENSITIVITY = "touchscreen_sensitivity"; public static final String KEY_TOUCHKEY_LIGHT = "touchkey_light"; + public static final String KEY_TOUCHKEY_TIMEOUT = "touchkey_timeout"; public static final String KEY_VIBRATOR_INTENSITY = "vibrator_intensity"; ViewPager mViewPager; diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/SensorsFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/SensorsFragmentActivity.java index bc42a95..bbe5f08 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/SensorsFragmentActivity.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/SensorsFragmentActivity.java @@ -36,8 +36,8 @@ public class SensorsFragmentActivity extends PreferenceFragment { private static final String TAG = "GalaxyNoteParts_General"; private static final String FILE_USE_GYRO_CALIB = "/sys/class/sec/gsensorcal/calibration"; - private static final String FILE_TOUCHKEY_LIGHT = "/data/.disable_touchlight"; - private static final String FILE_TOUCHKEY_TOGGLE = "/sys/class/sec/sec_touchkey/brightness"; + private static final String FILE_TOUCHKEY_DISABLE = "/sys/class/sec/sec_touchkey/force_disable"; + private static final String FILE_TOUCHKEY_BRIGHTNESS = "/sys/class/sec/sec_touchkey/brightness"; @Override public void onCreate(Bundle savedInstanceState) { @@ -47,6 +47,12 @@ public class SensorsFragmentActivity extends PreferenceFragment { PreferenceScreen prefSet = getPreferenceScreen(); + if (((CheckBoxPreference)prefSet.findPreference(DeviceSettings.KEY_TOUCHKEY_LIGHT)).isChecked()) { + prefSet.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(true); + } else { + prefSet.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(false); + } + } @Override @@ -67,8 +73,15 @@ public class SensorsFragmentActivity extends PreferenceFragment { Utils.writeValue(FILE_USE_GYRO_CALIB, "1"); Utils.showDialog((Context)getActivity(), "Calibration done", "The gyroscope has been successfully calibrated!"); } else if (key.compareTo(DeviceSettings.KEY_TOUCHKEY_LIGHT) == 0) { - Utils.writeValue(FILE_TOUCHKEY_LIGHT, ((CheckBoxPreference)preference).isChecked() ? "1" : "0"); - Utils.writeValue(FILE_TOUCHKEY_TOGGLE, ((CheckBoxPreference)preference).isChecked() ? "1" : "2"); + if (((CheckBoxPreference)preference).isChecked()) { + Utils.writeValue(FILE_TOUCHKEY_DISABLE, "0"); + Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, "1"); + preferenceScreen.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(true); + } else { + Utils.writeValue(FILE_TOUCHKEY_DISABLE, "1"); + Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, "2"); + preferenceScreen.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(false); + } } return true; @@ -89,6 +102,8 @@ public class SensorsFragmentActivity extends PreferenceFragment { Utils.writeValue(FILE_USE_GYRO_CALIB, "0"); boolean light = sharedPrefs.getBoolean(DeviceSettings.KEY_TOUCHKEY_LIGHT, true); - Utils.writeValue(FILE_TOUCHKEY_LIGHT, light); + + Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, light ? "1" : "0"); + Utils.writeValue(FILE_TOUCHKEY_DISABLE, light ? "0" : "1"); } } diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java index a3b5135..cb3624a 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java @@ -32,6 +32,7 @@ public class Startup extends BroadcastReceiver { HapticFragmentActivity.restore(context); VibratorIntensity.restore(context); SensorsFragmentActivity.restore(context); + TouchkeyTimeout.restore(context); } } diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java b/DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java new file mode 100644 index 0000000..ce741f8 --- /dev/null +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2012 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.cyanogenmod.settings.device; + +import java.io.IOException; +import android.content.Context; +import android.util.AttributeSet; +import android.content.SharedPreferences; +import android.preference.Preference; +import android.preference.ListPreference; +import android.preference.Preference.OnPreferenceChangeListener; +import android.preference.PreferenceManager; + +public class TouchkeyTimeout extends ListPreference implements OnPreferenceChangeListener { + + public TouchkeyTimeout(Context context, AttributeSet attrs) { + super(context, attrs); + this.setOnPreferenceChangeListener(this); + } + + private static final String FILE_TOUCHKEY_TIMEOUT = "/sys/class/sec/sec_touchkey/led_timeout"; + + public static boolean isSupported() { + return Utils.fileExists(FILE_TOUCHKEY_TIMEOUT); + } + + /** + * Restore touchscreen sensitivity 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_TOUCHKEY_TIMEOUT, sharedPrefs.getString(DeviceSettings.KEY_TOUCHKEY_TIMEOUT, "3")); + } + + public boolean onPreferenceChange(Preference preference, Object newValue) { + Utils.writeValue(FILE_TOUCHKEY_TIMEOUT, (String) newValue); + return true; + } + +} diff --git a/init.smdk4210.rc b/init.smdk4210.rc index 0acd613..dc48af8 100644 --- a/init.smdk4210.rc +++ b/init.smdk4210.rc @@ -176,7 +176,7 @@ on post-fs-data # Permissions for input devices chown system radio /sys/devices/virtual/sec/sec_key/sec_key_pressed - chown system radio /sys/devices/virtual/sec/sec_touchkey/enable_disable + chown system radio /sys/devices/virtual/sec/sec_touchkey/force_disable chown system radio /sys/devices/virtual/sec/sec_touchkey/recommended_version chown system radio /sys/devices/virtual/sec/sec_touchkey/touch_sensitivity chown system radio /sys/devices/virtual/sec/sec_touchkey/brightness @@ -188,6 +188,7 @@ on post-fs-data chown system radio /sys/devices/virtual/sec/sec_touchkey/touchkey_firm_update_status chown system radio /sys/devices/virtual/sec/sec_touchkey/touchkey_firm_update chown system radio /sys/devices/virtual/sec/sec_touchkey/updated_version + chown system radio /sys/devices/virtual/sec/sec_touchkey/led_timeout chown system radio /sys/devices/virtual/sec/tsp_noise_test/set_firm_version chown system radio /sys/devices/virtual/sec/tsp_noise_test/set_threshould |