The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.settings; |
| 18 | |
| 19 | import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT; |
Michael Chan | 0bd445b | 2009-12-03 00:31:59 -0800 | [diff] [blame] | 20 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 21 | import android.content.BroadcastReceiver; |
| 22 | import android.content.ContentResolver; |
| 23 | import android.content.Context; |
| 24 | import android.content.Intent; |
| 25 | import android.content.IntentFilter; |
| 26 | import android.media.AudioManager; |
| 27 | import android.os.Bundle; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 28 | import android.os.RemoteException; |
| 29 | import android.os.ServiceManager; |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame] | 30 | import android.preference.CheckBoxPreference; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 31 | import android.preference.ListPreference; |
| 32 | import android.preference.Preference; |
| 33 | import android.preference.PreferenceActivity; |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame] | 34 | import android.preference.PreferenceGroup; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 35 | import android.preference.PreferenceScreen; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 36 | import android.provider.Settings; |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame] | 37 | import android.provider.Settings.SettingNotFoundException; |
| 38 | import android.telephony.TelephonyManager; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 39 | import android.util.Log; |
| 40 | import android.view.IWindowManager; |
| 41 | |
Amith Yamasani | 992f102 | 2010-01-25 09:17:53 -0800 | [diff] [blame] | 42 | public class SoundSettings extends PreferenceActivity implements |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 43 | Preference.OnPreferenceChangeListener { |
| 44 | private static final String TAG = "SoundAndDisplaysSettings"; |
| 45 | |
| 46 | /** If there is no setting in the provider, use this. */ |
| 47 | private static final int FALLBACK_SCREEN_TIMEOUT_VALUE = 30000; |
Chouting Zhang | 386278a | 2009-06-24 14:25:43 -0500 | [diff] [blame] | 48 | private static final int FALLBACK_EMERGENCY_TONE_VALUE = 0; |
Michael Chan | df9504e | 2009-12-06 01:04:04 -0800 | [diff] [blame] | 49 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 50 | private static final String KEY_SILENT = "silent"; |
| 51 | private static final String KEY_VIBRATE = "vibrate"; |
Daniel Sandler | 58cf829 | 2010-02-26 15:25:04 -0500 | [diff] [blame^] | 52 | private static final String KEY_VIBRATE_IN_SILENT = "vibrate_in_silent"; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 53 | private static final String KEY_DTMF_TONE = "dtmf_tone"; |
| 54 | private static final String KEY_SOUND_EFFECTS = "sound_effects"; |
Dan Murphy | 22e1868 | 2009-09-22 11:47:08 -0500 | [diff] [blame] | 55 | private static final String KEY_HAPTIC_FEEDBACK = "haptic_feedback"; |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame] | 56 | private static final String KEY_EMERGENCY_TONE = "emergency_tone"; |
| 57 | private static final String KEY_SOUND_SETTINGS = "sound_settings"; |
| 58 | private static final String KEY_NOTIFICATION_PULSE = "notification_pulse"; |
Daniel Sandler | 231d880 | 2010-02-17 15:35:21 -0500 | [diff] [blame] | 59 | private static final String KEY_LOCK_SOUNDS = "lock_sounds"; |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame] | 60 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 61 | private CheckBoxPreference mSilent; |
| 62 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 63 | /* |
| 64 | * If we are currently in one of the silent modes (the ringer mode is set to either |
| 65 | * "silent mode" or "vibrate mode"), then toggling the "Phone vibrate" |
| 66 | * preference will switch between "silent mode" and "vibrate mode". |
| 67 | * Otherwise, it will adjust the normal ringer mode's ring or ring+vibrate |
| 68 | * setting. |
| 69 | */ |
Daniel Sandler | 58cf829 | 2010-02-26 15:25:04 -0500 | [diff] [blame^] | 70 | private ListPreference mPhoneVibrate; |
| 71 | private CheckBoxPreference mVibrateInSilent; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 72 | private CheckBoxPreference mDtmfTone; |
| 73 | private CheckBoxPreference mSoundEffects; |
Dan Murphy | 22e1868 | 2009-09-22 11:47:08 -0500 | [diff] [blame] | 74 | private CheckBoxPreference mHapticFeedback; |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame] | 75 | private CheckBoxPreference mNotificationPulse; |
Daniel Sandler | 231d880 | 2010-02-17 15:35:21 -0500 | [diff] [blame] | 76 | private CheckBoxPreference mLockSounds; |
Michael Chan | df9504e | 2009-12-06 01:04:04 -0800 | [diff] [blame] | 77 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 78 | private AudioManager mAudioManager; |
Michael Chan | df9504e | 2009-12-06 01:04:04 -0800 | [diff] [blame] | 79 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 80 | private BroadcastReceiver mReceiver = new BroadcastReceiver() { |
| 81 | @Override |
| 82 | public void onReceive(Context context, Intent intent) { |
Amith Yamasani | d2b3ab0 | 2009-12-02 13:56:05 -0800 | [diff] [blame] | 83 | if (intent.getAction().equals(AudioManager.RINGER_MODE_CHANGED_ACTION)) { |
| 84 | updateState(false); |
Amith Yamasani | d2b3ab0 | 2009-12-02 13:56:05 -0800 | [diff] [blame] | 85 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 86 | } |
| 87 | }; |
| 88 | |
Amith Yamasani | d2b3ab0 | 2009-12-02 13:56:05 -0800 | [diff] [blame] | 89 | private PreferenceGroup mSoundSettings; |
| 90 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 91 | @Override |
| 92 | protected void onCreate(Bundle savedInstanceState) { |
| 93 | super.onCreate(savedInstanceState); |
| 94 | ContentResolver resolver = getContentResolver(); |
Chouting Zhang | 386278a | 2009-06-24 14:25:43 -0500 | [diff] [blame] | 95 | int activePhoneType = TelephonyManager.getDefault().getPhoneType(); |
Michael Chan | df9504e | 2009-12-06 01:04:04 -0800 | [diff] [blame] | 96 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 97 | mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 98 | |
Amith Yamasani | 992f102 | 2010-01-25 09:17:53 -0800 | [diff] [blame] | 99 | addPreferencesFromResource(R.xml.sound_settings); |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame] | 100 | |
Chouting Zhang | 386278a | 2009-06-24 14:25:43 -0500 | [diff] [blame] | 101 | if (TelephonyManager.PHONE_TYPE_CDMA != activePhoneType) { |
| 102 | // device is not CDMA, do not display CDMA emergency_tone |
| 103 | getPreferenceScreen().removePreference(findPreference(KEY_EMERGENCY_TONE)); |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame] | 104 | } |
Chouting Zhang | 386278a | 2009-06-24 14:25:43 -0500 | [diff] [blame] | 105 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 106 | mSilent = (CheckBoxPreference) findPreference(KEY_SILENT); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 107 | |
Daniel Sandler | 58cf829 | 2010-02-26 15:25:04 -0500 | [diff] [blame^] | 108 | mPhoneVibrate = (ListPreference) findPreference(KEY_VIBRATE); |
| 109 | mVibrateInSilent = (CheckBoxPreference) findPreference(KEY_VIBRATE_IN_SILENT); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 110 | mDtmfTone = (CheckBoxPreference) findPreference(KEY_DTMF_TONE); |
| 111 | mDtmfTone.setPersistent(false); |
| 112 | mDtmfTone.setChecked(Settings.System.getInt(resolver, |
| 113 | Settings.System.DTMF_TONE_WHEN_DIALING, 1) != 0); |
| 114 | mSoundEffects = (CheckBoxPreference) findPreference(KEY_SOUND_EFFECTS); |
| 115 | mSoundEffects.setPersistent(false); |
| 116 | mSoundEffects.setChecked(Settings.System.getInt(resolver, |
| 117 | Settings.System.SOUND_EFFECTS_ENABLED, 0) != 0); |
Dan Murphy | 22e1868 | 2009-09-22 11:47:08 -0500 | [diff] [blame] | 118 | mHapticFeedback = (CheckBoxPreference) findPreference(KEY_HAPTIC_FEEDBACK); |
| 119 | mHapticFeedback.setPersistent(false); |
| 120 | mHapticFeedback.setChecked(Settings.System.getInt(resolver, |
| 121 | Settings.System.HAPTIC_FEEDBACK_ENABLED, 0) != 0); |
Daniel Sandler | 231d880 | 2010-02-17 15:35:21 -0500 | [diff] [blame] | 122 | mLockSounds = (CheckBoxPreference) findPreference(KEY_LOCK_SOUNDS); |
| 123 | mLockSounds.setPersistent(false); |
| 124 | mLockSounds.setChecked(Settings.System.getInt(resolver, |
| 125 | Settings.System.LOCKSCREEN_SOUNDS_ENABLED, 1) != 0); |
Chouting Zhang | 386278a | 2009-06-24 14:25:43 -0500 | [diff] [blame] | 126 | |
| 127 | if (TelephonyManager.PHONE_TYPE_CDMA == activePhoneType) { |
| 128 | ListPreference emergencyTonePreference = |
| 129 | (ListPreference) findPreference(KEY_EMERGENCY_TONE); |
| 130 | emergencyTonePreference.setValue(String.valueOf(Settings.System.getInt( |
| 131 | resolver, Settings.System.EMERGENCY_TONE, FALLBACK_EMERGENCY_TONE_VALUE))); |
| 132 | emergencyTonePreference.setOnPreferenceChangeListener(this); |
| 133 | } |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame] | 134 | |
Amith Yamasani | d2b3ab0 | 2009-12-02 13:56:05 -0800 | [diff] [blame] | 135 | mSoundSettings = (PreferenceGroup) findPreference(KEY_SOUND_SETTINGS); |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame] | 136 | mNotificationPulse = (CheckBoxPreference) |
Amith Yamasani | d2b3ab0 | 2009-12-02 13:56:05 -0800 | [diff] [blame] | 137 | mSoundSettings.findPreference(KEY_NOTIFICATION_PULSE); |
| 138 | if (mNotificationPulse != null && |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame] | 139 | getResources().getBoolean(R.bool.has_intrusive_led) == false) { |
Amith Yamasani | d2b3ab0 | 2009-12-02 13:56:05 -0800 | [diff] [blame] | 140 | mSoundSettings.removePreference(mNotificationPulse); |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame] | 141 | } else { |
| 142 | try { |
| 143 | mNotificationPulse.setChecked(Settings.System.getInt(resolver, |
| 144 | Settings.System.NOTIFICATION_LIGHT_PULSE) == 1); |
| 145 | mNotificationPulse.setOnPreferenceChangeListener(this); |
| 146 | } catch (SettingNotFoundException snfe) { |
| 147 | Log.e(TAG, Settings.System.NOTIFICATION_LIGHT_PULSE + " not found"); |
| 148 | } |
| 149 | } |
Amith Yamasani | d2b3ab0 | 2009-12-02 13:56:05 -0800 | [diff] [blame] | 150 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 151 | } |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame] | 152 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 153 | @Override |
| 154 | protected void onResume() { |
| 155 | super.onResume(); |
Michael Chan | df9504e | 2009-12-06 01:04:04 -0800 | [diff] [blame] | 156 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 157 | updateState(true); |
Michael Chan | df9504e | 2009-12-06 01:04:04 -0800 | [diff] [blame] | 158 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 159 | IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION); |
| 160 | registerReceiver(mReceiver, filter); |
| 161 | } |
| 162 | |
| 163 | @Override |
| 164 | protected void onPause() { |
| 165 | super.onPause(); |
| 166 | |
| 167 | unregisterReceiver(mReceiver); |
| 168 | } |
| 169 | |
Daniel Sandler | 58cf829 | 2010-02-26 15:25:04 -0500 | [diff] [blame^] | 170 | // updateState in fact updates the UI to reflect the system state |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 171 | private void updateState(boolean force) { |
| 172 | final int ringerMode = mAudioManager.getRingerMode(); |
Daniel Sandler | 58cf829 | 2010-02-26 15:25:04 -0500 | [diff] [blame^] | 173 | |
| 174 | // NB: in the UI we now simply call this "silent mode". A separate |
| 175 | // setting controls whether we're in RINGER_MODE_SILENT or |
| 176 | // RINGER_MODE_VIBRATE. |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 177 | final boolean silentOrVibrateMode = |
| 178 | ringerMode != AudioManager.RINGER_MODE_NORMAL; |
Michael Chan | df9504e | 2009-12-06 01:04:04 -0800 | [diff] [blame] | 179 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 180 | if (silentOrVibrateMode != mSilent.isChecked() || force) { |
| 181 | mSilent.setChecked(silentOrVibrateMode); |
| 182 | } |
| 183 | |
Daniel Sandler | 58cf829 | 2010-02-26 15:25:04 -0500 | [diff] [blame^] | 184 | mVibrateInSilent.setEnabled(silentOrVibrateMode); |
| 185 | mVibrateInSilent.setChecked(Settings.System.getInt( |
| 186 | getContentResolver(), |
| 187 | Settings.System.VIBRATE_IN_SILENT, |
| 188 | 1) == 1); |
| 189 | |
| 190 | // Control phone vibe independent of silent mode |
| 191 | String phoneVibrateSetting = String.valueOf( |
| 192 | mAudioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER)); |
| 193 | |
| 194 | if (! phoneVibrateSetting.equals(mPhoneVibrate.getValue()) || force) { |
| 195 | mPhoneVibrate.setValue(phoneVibrateSetting); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 196 | } |
Michael Chan | df9504e | 2009-12-06 01:04:04 -0800 | [diff] [blame] | 197 | |
Jason Parekh | 2c9b326 | 2009-03-24 17:48:28 -0700 | [diff] [blame] | 198 | int silentModeStreams = Settings.System.getInt(getContentResolver(), |
| 199 | Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0); |
Michael Chan | df9504e | 2009-12-06 01:04:04 -0800 | [diff] [blame] | 200 | boolean isAlarmInclSilentMode = (silentModeStreams & (1 << AudioManager.STREAM_ALARM)) != 0; |
Jason Parekh | 2c9b326 | 2009-03-24 17:48:28 -0700 | [diff] [blame] | 201 | mSilent.setSummary(isAlarmInclSilentMode ? |
| 202 | R.string.silent_mode_incl_alarm_summary : |
| 203 | R.string.silent_mode_summary); |
Michael Chan | df9504e | 2009-12-06 01:04:04 -0800 | [diff] [blame] | 204 | |
Dianne Hackborn | 7631539 | 2009-09-03 13:33:55 -0700 | [diff] [blame] | 205 | } |
Michael Chan | df9504e | 2009-12-06 01:04:04 -0800 | [diff] [blame] | 206 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 207 | @Override |
| 208 | public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { |
Daniel Sandler | 58cf829 | 2010-02-26 15:25:04 -0500 | [diff] [blame^] | 209 | if (preference == mSilent) { |
| 210 | if (mSilent.isChecked()) { |
| 211 | boolean vibeInSilent = mVibrateInSilent.isChecked(); |
| 212 | mAudioManager.setRingerMode( |
| 213 | vibeInSilent ? AudioManager.RINGER_MODE_VIBRATE |
| 214 | : AudioManager.RINGER_MODE_SILENT); |
| 215 | } else { |
| 216 | mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL); |
| 217 | } |
| 218 | updateState(false); |
| 219 | } else if (preference == mPhoneVibrate) { |
| 220 | int vibeSetting = new Integer(mPhoneVibrate.getValue()).intValue(); |
| 221 | switch (vibeSetting) { |
| 222 | case AudioManager.VIBRATE_SETTING_ON: |
| 223 | case AudioManager.VIBRATE_SETTING_OFF: |
| 224 | case AudioManager.VIBRATE_SETTING_ONLY_SILENT: |
| 225 | mAudioManager.setVibrateSetting( |
| 226 | AudioManager.VIBRATE_TYPE_RINGER, |
| 227 | vibeSetting); |
| 228 | updateState(false); |
| 229 | break; |
| 230 | } |
| 231 | } else if (preference == mVibrateInSilent) { |
| 232 | boolean vibeInSilent = mVibrateInSilent.isChecked(); |
| 233 | Settings.System.putInt(getContentResolver(), |
| 234 | Settings.System.VIBRATE_IN_SILENT, |
| 235 | vibeInSilent ? 1 : 0); |
| 236 | int ringerMode = mAudioManager.getRingerMode(); |
| 237 | if (ringerMode != AudioManager.RINGER_MODE_NORMAL) { |
| 238 | mAudioManager.setRingerMode(vibeInSilent |
| 239 | ? AudioManager.RINGER_MODE_VIBRATE |
| 240 | : AudioManager.RINGER_MODE_SILENT); |
| 241 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 242 | } else if (preference == mDtmfTone) { |
| 243 | Settings.System.putInt(getContentResolver(), Settings.System.DTMF_TONE_WHEN_DIALING, |
| 244 | mDtmfTone.isChecked() ? 1 : 0); |
Michael Chan | df9504e | 2009-12-06 01:04:04 -0800 | [diff] [blame] | 245 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 246 | } else if (preference == mSoundEffects) { |
| 247 | if (mSoundEffects.isChecked()) { |
| 248 | mAudioManager.loadSoundEffects(); |
| 249 | } else { |
| 250 | mAudioManager.unloadSoundEffects(); |
| 251 | } |
| 252 | Settings.System.putInt(getContentResolver(), Settings.System.SOUND_EFFECTS_ENABLED, |
| 253 | mSoundEffects.isChecked() ? 1 : 0); |
Dan Murphy | 22e1868 | 2009-09-22 11:47:08 -0500 | [diff] [blame] | 254 | |
| 255 | } else if (preference == mHapticFeedback) { |
| 256 | Settings.System.putInt(getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, |
| 257 | mHapticFeedback.isChecked() ? 1 : 0); |
Michael Chan | df9504e | 2009-12-06 01:04:04 -0800 | [diff] [blame] | 258 | |
Daniel Sandler | 231d880 | 2010-02-17 15:35:21 -0500 | [diff] [blame] | 259 | } else if (preference == mLockSounds) { |
| 260 | Settings.System.putInt(getContentResolver(), Settings.System.LOCKSCREEN_SOUNDS_ENABLED, |
| 261 | mLockSounds.isChecked() ? 1 : 0); |
| 262 | |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame] | 263 | } else if (preference == mNotificationPulse) { |
| 264 | boolean value = mNotificationPulse.isChecked(); |
| 265 | Settings.System.putInt(getContentResolver(), |
| 266 | Settings.System.NOTIFICATION_LIGHT_PULSE, value ? 1 : 0); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 267 | } |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame] | 268 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 269 | return true; |
| 270 | } |
| 271 | |
| 272 | public boolean onPreferenceChange(Preference preference, Object objValue) { |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame] | 273 | final String key = preference.getKey(); |
Amith Yamasani | 992f102 | 2010-01-25 09:17:53 -0800 | [diff] [blame] | 274 | if (KEY_EMERGENCY_TONE.equals(key)) { |
Chouting Zhang | 386278a | 2009-06-24 14:25:43 -0500 | [diff] [blame] | 275 | int value = Integer.parseInt((String) objValue); |
| 276 | try { |
| 277 | Settings.System.putInt(getContentResolver(), |
| 278 | Settings.System.EMERGENCY_TONE, value); |
| 279 | } catch (NumberFormatException e) { |
| 280 | Log.e(TAG, "could not persist emergency tone setting", e); |
| 281 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 282 | } |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame] | 283 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 284 | return true; |
| 285 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 286 | } |