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; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 20 | import android.content.BroadcastReceiver; |
| 21 | import android.content.ContentResolver; |
| 22 | import android.content.Context; |
| 23 | import android.content.Intent; |
| 24 | import android.content.IntentFilter; |
| 25 | import android.media.AudioManager; |
| 26 | import android.os.Bundle; |
| 27 | import android.os.IMountService; |
| 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 | |
| 42 | public class SoundAndDisplaySettings extends PreferenceActivity implements |
| 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; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 49 | |
| 50 | private static final String KEY_SILENT = "silent"; |
| 51 | private static final String KEY_VIBRATE = "vibrate"; |
| 52 | private static final String KEY_SCREEN_TIMEOUT = "screen_timeout"; |
| 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"; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 56 | private static final String KEY_ANIMATIONS = "animations"; |
The Android Open Source Project | 648bf5f | 2009-03-09 11:52:14 -0700 | [diff] [blame] | 57 | private static final String KEY_ACCELEROMETER = "accelerometer"; |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame^] | 58 | private static final String KEY_PLAY_MEDIA_NOTIFICATION_SOUNDS = |
| 59 | "play_media_notification_sounds"; |
| 60 | private static final String KEY_EMERGENCY_TONE = "emergency_tone"; |
| 61 | private static final String KEY_SOUND_SETTINGS = "sound_settings"; |
| 62 | private static final String KEY_NOTIFICATION_PULSE = "notification_pulse"; |
| 63 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 64 | private CheckBoxPreference mSilent; |
| 65 | |
| 66 | private CheckBoxPreference mPlayMediaNotificationSounds; |
| 67 | |
| 68 | private IMountService mMountService = null; |
| 69 | |
| 70 | /* |
| 71 | * If we are currently in one of the silent modes (the ringer mode is set to either |
| 72 | * "silent mode" or "vibrate mode"), then toggling the "Phone vibrate" |
| 73 | * preference will switch between "silent mode" and "vibrate mode". |
| 74 | * Otherwise, it will adjust the normal ringer mode's ring or ring+vibrate |
| 75 | * setting. |
| 76 | */ |
| 77 | private CheckBoxPreference mVibrate; |
| 78 | private CheckBoxPreference mDtmfTone; |
| 79 | private CheckBoxPreference mSoundEffects; |
Dan Murphy | 22e1868 | 2009-09-22 11:47:08 -0500 | [diff] [blame] | 80 | private CheckBoxPreference mHapticFeedback; |
Dianne Hackborn | 7631539 | 2009-09-03 13:33:55 -0700 | [diff] [blame] | 81 | private ListPreference mAnimations; |
The Android Open Source Project | 648bf5f | 2009-03-09 11:52:14 -0700 | [diff] [blame] | 82 | private CheckBoxPreference mAccelerometer; |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame^] | 83 | private CheckBoxPreference mNotificationPulse; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 84 | private float[] mAnimationScales; |
| 85 | |
| 86 | private AudioManager mAudioManager; |
| 87 | |
| 88 | private IWindowManager mWindowManager; |
| 89 | |
| 90 | private BroadcastReceiver mReceiver = new BroadcastReceiver() { |
| 91 | @Override |
| 92 | public void onReceive(Context context, Intent intent) { |
| 93 | updateState(false); |
| 94 | } |
| 95 | }; |
| 96 | |
| 97 | @Override |
| 98 | protected void onCreate(Bundle savedInstanceState) { |
| 99 | super.onCreate(savedInstanceState); |
| 100 | ContentResolver resolver = getContentResolver(); |
Chouting Zhang | 386278a | 2009-06-24 14:25:43 -0500 | [diff] [blame] | 101 | int activePhoneType = TelephonyManager.getDefault().getPhoneType(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 102 | |
| 103 | mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); |
| 104 | mWindowManager = IWindowManager.Stub.asInterface(ServiceManager.getService("window")); |
| 105 | |
| 106 | mMountService = IMountService.Stub.asInterface(ServiceManager.getService("mount")); |
| 107 | |
| 108 | addPreferencesFromResource(R.xml.sound_and_display_settings); |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame^] | 109 | |
Chouting Zhang | 386278a | 2009-06-24 14:25:43 -0500 | [diff] [blame] | 110 | if (TelephonyManager.PHONE_TYPE_CDMA != activePhoneType) { |
| 111 | // device is not CDMA, do not display CDMA emergency_tone |
| 112 | getPreferenceScreen().removePreference(findPreference(KEY_EMERGENCY_TONE)); |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame^] | 113 | } |
Chouting Zhang | 386278a | 2009-06-24 14:25:43 -0500 | [diff] [blame] | 114 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 115 | mSilent = (CheckBoxPreference) findPreference(KEY_SILENT); |
| 116 | mPlayMediaNotificationSounds = (CheckBoxPreference) findPreference(KEY_PLAY_MEDIA_NOTIFICATION_SOUNDS); |
| 117 | |
| 118 | mVibrate = (CheckBoxPreference) findPreference(KEY_VIBRATE); |
| 119 | mDtmfTone = (CheckBoxPreference) findPreference(KEY_DTMF_TONE); |
| 120 | mDtmfTone.setPersistent(false); |
| 121 | mDtmfTone.setChecked(Settings.System.getInt(resolver, |
| 122 | Settings.System.DTMF_TONE_WHEN_DIALING, 1) != 0); |
| 123 | mSoundEffects = (CheckBoxPreference) findPreference(KEY_SOUND_EFFECTS); |
| 124 | mSoundEffects.setPersistent(false); |
| 125 | mSoundEffects.setChecked(Settings.System.getInt(resolver, |
| 126 | Settings.System.SOUND_EFFECTS_ENABLED, 0) != 0); |
Dan Murphy | 22e1868 | 2009-09-22 11:47:08 -0500 | [diff] [blame] | 127 | mHapticFeedback = (CheckBoxPreference) findPreference(KEY_HAPTIC_FEEDBACK); |
| 128 | mHapticFeedback.setPersistent(false); |
| 129 | mHapticFeedback.setChecked(Settings.System.getInt(resolver, |
| 130 | Settings.System.HAPTIC_FEEDBACK_ENABLED, 0) != 0); |
Dianne Hackborn | 7631539 | 2009-09-03 13:33:55 -0700 | [diff] [blame] | 131 | mAnimations = (ListPreference) findPreference(KEY_ANIMATIONS); |
| 132 | mAnimations.setOnPreferenceChangeListener(this); |
The Android Open Source Project | 648bf5f | 2009-03-09 11:52:14 -0700 | [diff] [blame] | 133 | mAccelerometer = (CheckBoxPreference) findPreference(KEY_ACCELEROMETER); |
| 134 | mAccelerometer.setPersistent(false); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 135 | |
| 136 | ListPreference screenTimeoutPreference = |
| 137 | (ListPreference) findPreference(KEY_SCREEN_TIMEOUT); |
| 138 | screenTimeoutPreference.setValue(String.valueOf(Settings.System.getInt( |
| 139 | resolver, SCREEN_OFF_TIMEOUT, FALLBACK_SCREEN_TIMEOUT_VALUE))); |
| 140 | screenTimeoutPreference.setOnPreferenceChangeListener(this); |
Chouting Zhang | 386278a | 2009-06-24 14:25:43 -0500 | [diff] [blame] | 141 | |
| 142 | if (TelephonyManager.PHONE_TYPE_CDMA == activePhoneType) { |
| 143 | ListPreference emergencyTonePreference = |
| 144 | (ListPreference) findPreference(KEY_EMERGENCY_TONE); |
| 145 | emergencyTonePreference.setValue(String.valueOf(Settings.System.getInt( |
| 146 | resolver, Settings.System.EMERGENCY_TONE, FALLBACK_EMERGENCY_TONE_VALUE))); |
| 147 | emergencyTonePreference.setOnPreferenceChangeListener(this); |
| 148 | } |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame^] | 149 | |
| 150 | PreferenceGroup soundSettings = (PreferenceGroup) findPreference(KEY_SOUND_SETTINGS); |
| 151 | mNotificationPulse = (CheckBoxPreference) |
| 152 | soundSettings.findPreference(KEY_NOTIFICATION_PULSE); |
| 153 | if (mNotificationPulse != null && soundSettings != null && |
| 154 | getResources().getBoolean(R.bool.has_intrusive_led) == false) { |
| 155 | soundSettings.removePreference(mNotificationPulse); |
| 156 | } else { |
| 157 | try { |
| 158 | mNotificationPulse.setChecked(Settings.System.getInt(resolver, |
| 159 | Settings.System.NOTIFICATION_LIGHT_PULSE) == 1); |
| 160 | mNotificationPulse.setOnPreferenceChangeListener(this); |
| 161 | } catch (SettingNotFoundException snfe) { |
| 162 | Log.e(TAG, Settings.System.NOTIFICATION_LIGHT_PULSE + " not found"); |
| 163 | } |
| 164 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 165 | } |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame^] | 166 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 167 | @Override |
| 168 | protected void onResume() { |
| 169 | super.onResume(); |
| 170 | |
| 171 | updateState(true); |
| 172 | |
| 173 | IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION); |
| 174 | registerReceiver(mReceiver, filter); |
| 175 | } |
| 176 | |
| 177 | @Override |
| 178 | protected void onPause() { |
| 179 | super.onPause(); |
| 180 | |
| 181 | unregisterReceiver(mReceiver); |
| 182 | } |
| 183 | |
| 184 | private void updateState(boolean force) { |
| 185 | final int ringerMode = mAudioManager.getRingerMode(); |
| 186 | final boolean silentOrVibrateMode = |
| 187 | ringerMode != AudioManager.RINGER_MODE_NORMAL; |
| 188 | |
| 189 | if (silentOrVibrateMode != mSilent.isChecked() || force) { |
| 190 | mSilent.setChecked(silentOrVibrateMode); |
| 191 | } |
| 192 | |
| 193 | try { |
| 194 | mPlayMediaNotificationSounds.setChecked(mMountService.getPlayNotificationSounds()); |
| 195 | } catch (RemoteException e) { |
| 196 | } |
| 197 | |
| 198 | boolean vibrateSetting; |
| 199 | if (silentOrVibrateMode) { |
| 200 | vibrateSetting = ringerMode == AudioManager.RINGER_MODE_VIBRATE; |
| 201 | } else { |
| 202 | vibrateSetting = mAudioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER) |
| 203 | == AudioManager.VIBRATE_SETTING_ON; |
| 204 | } |
| 205 | if (vibrateSetting != mVibrate.isChecked() || force) { |
| 206 | mVibrate.setChecked(vibrateSetting); |
| 207 | } |
| 208 | |
Jason Parekh | 2c9b326 | 2009-03-24 17:48:28 -0700 | [diff] [blame] | 209 | int silentModeStreams = Settings.System.getInt(getContentResolver(), |
| 210 | Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0); |
| 211 | boolean isAlarmInclSilentMode = (silentModeStreams & (1 << AudioManager.STREAM_ALARM)) != 0; |
| 212 | mSilent.setSummary(isAlarmInclSilentMode ? |
| 213 | R.string.silent_mode_incl_alarm_summary : |
| 214 | R.string.silent_mode_summary); |
| 215 | |
Dianne Hackborn | 7631539 | 2009-09-03 13:33:55 -0700 | [diff] [blame] | 216 | int animations = 0; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 217 | try { |
| 218 | mAnimationScales = mWindowManager.getAnimationScales(); |
| 219 | } catch (RemoteException e) { |
| 220 | } |
| 221 | if (mAnimationScales != null) { |
Dianne Hackborn | 7631539 | 2009-09-03 13:33:55 -0700 | [diff] [blame] | 222 | if (mAnimationScales.length >= 1) { |
| 223 | animations = ((int)(mAnimationScales[0]+.5f)) % 10; |
| 224 | } |
| 225 | if (mAnimationScales.length >= 2) { |
| 226 | animations += (((int)(mAnimationScales[1]+.5f)) & 0x7) * 10; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 227 | } |
| 228 | } |
Dianne Hackborn | 7631539 | 2009-09-03 13:33:55 -0700 | [diff] [blame] | 229 | int idx = 0; |
| 230 | int best = 0; |
| 231 | CharSequence[] aents = mAnimations.getEntryValues(); |
| 232 | for (int i=0; i<aents.length; i++) { |
| 233 | int val = Integer.parseInt(aents[i].toString()); |
| 234 | if (val <= animations && val > best) { |
| 235 | best = val; |
| 236 | idx = i; |
| 237 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 238 | } |
Dianne Hackborn | 7631539 | 2009-09-03 13:33:55 -0700 | [diff] [blame] | 239 | mAnimations.setValueIndex(idx); |
| 240 | updateAnimationsSummary(mAnimations.getValue()); |
The Android Open Source Project | 648bf5f | 2009-03-09 11:52:14 -0700 | [diff] [blame] | 241 | mAccelerometer.setChecked(Settings.System.getInt( |
| 242 | getContentResolver(), |
| 243 | Settings.System.ACCELEROMETER_ROTATION, 0) != 0); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 244 | } |
| 245 | |
Dianne Hackborn | 7631539 | 2009-09-03 13:33:55 -0700 | [diff] [blame] | 246 | private void updateAnimationsSummary(Object value) { |
| 247 | CharSequence[] summaries = getResources().getTextArray(R.array.animations_summaries); |
| 248 | CharSequence[] values = mAnimations.getEntryValues(); |
| 249 | for (int i=0; i<values.length; i++) { |
Marco Nelissen | 620e5f9 | 2009-09-09 09:06:40 -0700 | [diff] [blame] | 250 | //Log.i("foo", "Comparing entry "+ values[i] + " to current " |
| 251 | // + mAnimations.getValue()); |
Dianne Hackborn | 7631539 | 2009-09-03 13:33:55 -0700 | [diff] [blame] | 252 | if (values[i].equals(value)) { |
| 253 | mAnimations.setSummary(summaries[i]); |
| 254 | break; |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | |
Amith Yamasani | eb72bcd | 2009-07-07 11:37:08 -0700 | [diff] [blame] | 259 | private void setRingerMode(boolean silent, boolean vibrate) { |
| 260 | if (silent) { |
| 261 | mAudioManager.setRingerMode(vibrate ? AudioManager.RINGER_MODE_VIBRATE : |
| 262 | AudioManager.RINGER_MODE_SILENT); |
| 263 | } else { |
| 264 | mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL); |
| 265 | mAudioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, |
| 266 | vibrate ? AudioManager.VIBRATE_SETTING_ON |
| 267 | : AudioManager.VIBRATE_SETTING_OFF); |
| 268 | } |
| 269 | } |
| 270 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 271 | @Override |
| 272 | public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { |
Amith Yamasani | eb72bcd | 2009-07-07 11:37:08 -0700 | [diff] [blame] | 273 | if (preference == mSilent || preference == mVibrate) { |
| 274 | setRingerMode(mSilent.isChecked(), mVibrate.isChecked()); |
| 275 | if (preference == mSilent) updateState(false); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 276 | } else if (preference == mPlayMediaNotificationSounds) { |
| 277 | try { |
| 278 | mMountService.setPlayNotificationSounds(mPlayMediaNotificationSounds.isChecked()); |
| 279 | } catch (RemoteException e) { |
| 280 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 281 | } else if (preference == mDtmfTone) { |
| 282 | Settings.System.putInt(getContentResolver(), Settings.System.DTMF_TONE_WHEN_DIALING, |
| 283 | mDtmfTone.isChecked() ? 1 : 0); |
| 284 | |
| 285 | } else if (preference == mSoundEffects) { |
| 286 | if (mSoundEffects.isChecked()) { |
| 287 | mAudioManager.loadSoundEffects(); |
| 288 | } else { |
| 289 | mAudioManager.unloadSoundEffects(); |
| 290 | } |
| 291 | Settings.System.putInt(getContentResolver(), Settings.System.SOUND_EFFECTS_ENABLED, |
| 292 | mSoundEffects.isChecked() ? 1 : 0); |
Dan Murphy | 22e1868 | 2009-09-22 11:47:08 -0500 | [diff] [blame] | 293 | |
| 294 | } else if (preference == mHapticFeedback) { |
| 295 | Settings.System.putInt(getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, |
| 296 | mHapticFeedback.isChecked() ? 1 : 0); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 297 | |
The Android Open Source Project | 648bf5f | 2009-03-09 11:52:14 -0700 | [diff] [blame] | 298 | } else if (preference == mAccelerometer) { |
| 299 | Settings.System.putInt(getContentResolver(), |
| 300 | Settings.System.ACCELEROMETER_ROTATION, |
| 301 | mAccelerometer.isChecked() ? 1 : 0); |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame^] | 302 | } else if (preference == mNotificationPulse) { |
| 303 | boolean value = mNotificationPulse.isChecked(); |
| 304 | Settings.System.putInt(getContentResolver(), |
| 305 | Settings.System.NOTIFICATION_LIGHT_PULSE, value ? 1 : 0); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 306 | } |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame^] | 307 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 308 | return true; |
| 309 | } |
| 310 | |
| 311 | public boolean onPreferenceChange(Preference preference, Object objValue) { |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame^] | 312 | final String key = preference.getKey(); |
| 313 | if (KEY_ANIMATIONS.equals(key)) { |
Dianne Hackborn | 7631539 | 2009-09-03 13:33:55 -0700 | [diff] [blame] | 314 | try { |
| 315 | int value = Integer.parseInt((String) objValue); |
| 316 | if (mAnimationScales.length >= 1) { |
| 317 | mAnimationScales[0] = value%10; |
| 318 | } |
| 319 | if (mAnimationScales.length >= 2) { |
| 320 | mAnimationScales[1] = (value/10)%10; |
| 321 | } |
| 322 | try { |
| 323 | mWindowManager.setAnimationScales(mAnimationScales); |
| 324 | } catch (RemoteException e) { |
| 325 | } |
| 326 | updateAnimationsSummary(objValue); |
| 327 | } catch (NumberFormatException e) { |
| 328 | Log.e(TAG, "could not persist animation setting", e); |
| 329 | } |
| 330 | |
| 331 | } |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame^] | 332 | if (KEY_SCREEN_TIMEOUT.equals(key)) { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 333 | int value = Integer.parseInt((String) objValue); |
| 334 | try { |
| 335 | Settings.System.putInt(getContentResolver(), |
| 336 | SCREEN_OFF_TIMEOUT, value); |
| 337 | } catch (NumberFormatException e) { |
| 338 | Log.e(TAG, "could not persist screen timeout setting", e); |
| 339 | } |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame^] | 340 | } else if (KEY_EMERGENCY_TONE.equals(key)) { |
Chouting Zhang | 386278a | 2009-06-24 14:25:43 -0500 | [diff] [blame] | 341 | int value = Integer.parseInt((String) objValue); |
| 342 | try { |
| 343 | Settings.System.putInt(getContentResolver(), |
| 344 | Settings.System.EMERGENCY_TONE, value); |
| 345 | } catch (NumberFormatException e) { |
| 346 | Log.e(TAG, "could not persist emergency tone setting", e); |
| 347 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 348 | } |
Amith Yamasani | 8f2fb65b | 2009-12-01 19:06:14 -0800 | [diff] [blame^] | 349 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 350 | return true; |
| 351 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 352 | } |