diff options
author | Andrew Dodd <atd7@cornell.edu> | 2012-06-17 12:16:05 -0400 |
---|---|---|
committer | Andrew Dodd <atd7@cornell.edu> | 2012-06-17 12:16:05 -0400 |
commit | f5a640bbed057a3b4af7f2720a8a99cc4d8f158d (patch) | |
tree | 551418934fce87a5d1e73336bdf8fd8c8102256b | |
parent | 02d3dd24907604e7f61f1baa15d3662c42b437fa (diff) | |
download | device_samsung_n7000-f5a640bbed057a3b4af7f2720a8a99cc4d8f158d.zip device_samsung_n7000-f5a640bbed057a3b4af7f2720a8a99cc4d8f158d.tar.gz device_samsung_n7000-f5a640bbed057a3b4af7f2720a8a99cc4d8f158d.tar.bz2 |
DeviceSettings: Control vibrator strength
Change-Id: I504f483cf8ef30274ceb2742d87be380aadacf6b
10 files changed, 179 insertions, 0 deletions
diff --git a/DeviceSettings/res/values-de/arrays.xml b/DeviceSettings/res/values-de/arrays.xml index 982125b..6f5dda7 100644 --- a/DeviceSettings/res/values-de/arrays.xml +++ b/DeviceSettings/res/values-de/arrays.xml @@ -42,6 +42,14 @@ <item>100</item> </string-array> + <string-array name="vibrator_intensity_entries"> + <item>0%</item> + <item>25%</item> + <item>50% (Standard)</item> + <item>75%</item> + <item>100%</item> + </string-array> + <string-array name="hspa_entries"> <item>Nur UMTS</item> <item>Nur HSDPA</item> diff --git a/DeviceSettings/res/values-de/strings.xml b/DeviceSettings/res/values-de/strings.xml index cf1e922..4d0589e 100644 --- a/DeviceSettings/res/values-de/strings.xml +++ b/DeviceSettings/res/values-de/strings.xml @@ -29,6 +29,11 @@ <string name="touchkey_light_title_head">Aktiviere Tastenbeleuchtung</string> <string name="touchkey_light_summary_head">Tasten leuchten auf während der Birdschirm aktiv ist</string> + <string name="category_haptic_title">Haptik</string> + <string name="vibrator_subcat_title">Vibrator</string> + <string name="vibrator_intensity_title_head">Vibrator Intensität</string> + <string name="vibrator_intensity_summary_head">Setze Vibrator Intensität</string> + <string name="category_radio_title">Mobilfunk</string> <string name="hspa_title_head">HSPA</string> <string name="hspa_summary_head">Aktiviert HSDPA/HSUPA</string> diff --git a/DeviceSettings/res/values/arrays.xml b/DeviceSettings/res/values/arrays.xml index 894157d..e75ee6e 100644 --- a/DeviceSettings/res/values/arrays.xml +++ b/DeviceSettings/res/values/arrays.xml @@ -84,6 +84,22 @@ <item>100</item> </string-array> + <string-array name="vibrator_intensity_entries"> + <item>0%</item> + <item>25%</item> + <item>50% (Default)</item> + <item>75%</item> + <item>100%</item> + </string-array> + + <string-array name="vibrator_intensity_entries_values" translatable="false"> + <item>0</item> + <item>25</item> + <item>50</item> + <item>75</item> + <item>100</item> + </string-array> + <string-array name="hspa_entries"> <item>UMTS Only</item> <item>HSDPA Only</item> diff --git a/DeviceSettings/res/values/strings.xml b/DeviceSettings/res/values/strings.xml index 6259102..5c38440 100644 --- a/DeviceSettings/res/values/strings.xml +++ b/DeviceSettings/res/values/strings.xml @@ -29,6 +29,11 @@ <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="category_haptic_title">Haptic</string> + <string name="vibrator_subcat_title">Vibrator</string> + <string name="vibrator_intensity_title_head">Vibrator Intensity</string> + <string name="vibrator_intensity_summary_head">Set vibrator intensity</string> + <string name="category_radio_title">Radio</string> <string name="hspa_title_head">HSPA</string> <string name="hspa_summary_head">Enable HSDPA/HSUPA</string> diff --git a/DeviceSettings/res/xml/haptic_preferences.xml b/DeviceSettings/res/xml/haptic_preferences.xml new file mode 100644 index 0000000..31c0e21 --- /dev/null +++ b/DeviceSettings/res/xml/haptic_preferences.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> + <PreferenceCategory + android:title="@string/vibrator_subcat_title"> + <com.cyanogenmod.settings.device.VibratorIntensity + android:key="vibrator_intensity" + android:title="@string/vibrator_intensity_title_head" + android:summary="@string/vibrator_intensity_summary_head" + android:entries="@array/vibrator_intensity_entries" + android:entryValues="@array/vibrator_intensity_entries_values" + android:defaultValue="50" /> + </PreferenceCategory> +</PreferenceScreen> diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java index 4bd1810..58003a2 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_VIBRATOR_INTENSITY = "vibrator_intensity"; ViewPager mViewPager; TabsAdapter mTabsAdapter; @@ -69,6 +70,8 @@ public class DeviceSettings extends FragmentActivity { mDNIeFragmentActivity.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.category_sensors_title), SensorsFragmentActivity.class, null); + mTabsAdapter.addTab(bar.newTab().setText(R.string.category_haptic_title), + HapticFragmentActivity.class, null); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0)); diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java new file mode 100644 index 0000000..d67c234 --- /dev/null +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java @@ -0,0 +1,66 @@ +/* + * 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 android.content.Context; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.preference.CheckBoxPreference; +import android.preference.ListPreference; +import android.preference.Preference; +import android.preference.PreferenceActivity; +import android.preference.PreferenceFragment; +import android.preference.PreferenceManager; +import android.preference.PreferenceScreen; +import android.util.Log; + +import com.cyanogenmod.settings.device.R; + +public class HapticFragmentActivity extends PreferenceFragment { + + private static final String PREF_ENABLED = "1"; + private static final String TAG = "GalaxyNoteParts_General"; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + addPreferencesFromResource(R.xml.haptic_preferences); + + PreferenceScreen prefSet = getPreferenceScreen(); + + } + + @Override + public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { + + String boxValue; + String key = preference.getKey(); + + Log.w(TAG, "key: " + key); + + return true; + } + + public static boolean isSupported(String FILE) { + return Utils.fileExists(FILE); + } + + public static void restore(Context context) { + SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); + } +} diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java index 6951f26..7566273 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java @@ -29,6 +29,8 @@ public class Startup extends BroadcastReceiver { mDNIeNegative.restore(context); mDNIeOutdoor.restore(context); RadioFragmentActivity.restore(context); + HapticFragmentActivity.restore(context); + VibratorIntensity.restore(context); } } diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.java new file mode 100644 index 0000000..7a809a5 --- /dev/null +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.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 VibratorIntensity extends ListPreference implements OnPreferenceChangeListener { + + public VibratorIntensity(Context context, AttributeSet attrs) { + super(context, attrs); + this.setOnPreferenceChangeListener(this); + } + + private static final String FILE = "/sys/vibrator/pwm_val"; + + public static boolean isSupported() { + return Utils.fileExists(FILE); + } + + /** + * Restore vibrator intensity 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(DeviceSettings.KEY_VIBRATOR_INTENSITY, "50")); + } + + public boolean onPreferenceChange(Preference preference, Object newValue) { + Utils.writeValue(FILE, (String) newValue); + return true; + } + +} diff --git a/init.smdk4210.rc b/init.smdk4210.rc index 53da0e1..0acd613 100644 --- a/init.smdk4210.rc +++ b/init.smdk4210.rc @@ -228,6 +228,8 @@ on post-fs-data # Vibetonz chmod 0660 /dev/tspdrv chown root shell /dev/tspdrv + chmod 0660 /sys/vibrator/pwm_val + chown system system /sys/vibrator/pwm_val # Permissions for LCD chown system radio /sys/class/lcd/panel/lcd_power |