From 3f7b71553971be861faf7d486735c4a8cc4f7854 Mon Sep 17 00:00:00 2001 From: Sam Mortimer Date: Thu, 28 Jun 2012 21:58:22 -0700 Subject: 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 --- DeviceSettings/res/values-de/arrays.xml | 10 ++++ DeviceSettings/res/values/arrays.xml | 20 ++++++++ DeviceSettings/res/values/strings.xml | 2 + DeviceSettings/res/xml/sensors_preferences.xml | 9 ++++ .../settings/device/DeviceSettings.java | 1 + .../settings/device/SensorsFragmentActivity.java | 25 +++++++-- .../com/cyanogenmod/settings/device/Startup.java | 1 + .../settings/device/TouchkeyTimeout.java | 59 ++++++++++++++++++++++ init.smdk4210.rc | 3 +- 9 files changed, 124 insertions(+), 6 deletions(-) create mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java 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 @@ HSDPA + HSUPA + + Niemals + 1 Sekunde + 2 Sekunden + 3 Sekunden (Standard) + 4 Sekunden + 5 Sekunden + 6 Sekunden + + 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 @@ 23 + + Never + 1 second + 2 seconds + 3 seconds (default) + 4 seconds + 5 seconds + 6 seconds + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + + 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 @@ Touch key Enable keys backlight Light up touch keys when screen is on + Backlight timeout + Delay after a keypress before backlight turns off Haptic Vibrator 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" + /> + 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 -- cgit v1.1