blob: e01f7c3545a827fe7e0f3518443b16488a5a8fda [file] [log] [blame]
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001/*
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
17package com.android.settings;
18
19import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
Michael Chan0bd445b2009-12-03 00:31:59 -080020
Michael Chandf9504e2009-12-06 01:04:04 -080021import com.android.settings.bluetooth.DockEventReceiver;
Michael Chan0bd445b2009-12-03 00:31:59 -080022
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080023import android.content.BroadcastReceiver;
24import android.content.ContentResolver;
25import android.content.Context;
26import android.content.Intent;
27import android.content.IntentFilter;
28import android.media.AudioManager;
29import android.os.Bundle;
30import android.os.IMountService;
31import android.os.RemoteException;
32import android.os.ServiceManager;
Amith Yamasani8f2fb65b2009-12-01 19:06:14 -080033import android.preference.CheckBoxPreference;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080034import android.preference.ListPreference;
35import android.preference.Preference;
36import android.preference.PreferenceActivity;
Amith Yamasani8f2fb65b2009-12-01 19:06:14 -080037import android.preference.PreferenceGroup;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080038import android.preference.PreferenceScreen;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080039import android.provider.Settings;
Amith Yamasani8f2fb65b2009-12-01 19:06:14 -080040import android.provider.Settings.SettingNotFoundException;
41import android.telephony.TelephonyManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080042import android.util.Log;
43import android.view.IWindowManager;
44
45public class SoundAndDisplaySettings extends PreferenceActivity implements
46 Preference.OnPreferenceChangeListener {
47 private static final String TAG = "SoundAndDisplaysSettings";
48
49 /** If there is no setting in the provider, use this. */
50 private static final int FALLBACK_SCREEN_TIMEOUT_VALUE = 30000;
Chouting Zhang386278a2009-06-24 14:25:43 -050051 private static final int FALLBACK_EMERGENCY_TONE_VALUE = 0;
Michael Chandf9504e2009-12-06 01:04:04 -080052
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080053 private static final String KEY_SILENT = "silent";
54 private static final String KEY_VIBRATE = "vibrate";
55 private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
56 private static final String KEY_DTMF_TONE = "dtmf_tone";
57 private static final String KEY_SOUND_EFFECTS = "sound_effects";
Dan Murphy22e18682009-09-22 11:47:08 -050058 private static final String KEY_HAPTIC_FEEDBACK = "haptic_feedback";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080059 private static final String KEY_ANIMATIONS = "animations";
The Android Open Source Project648bf5f2009-03-09 11:52:14 -070060 private static final String KEY_ACCELEROMETER = "accelerometer";
Amith Yamasani8f2fb65b2009-12-01 19:06:14 -080061 private static final String KEY_PLAY_MEDIA_NOTIFICATION_SOUNDS =
62 "play_media_notification_sounds";
63 private static final String KEY_EMERGENCY_TONE = "emergency_tone";
64 private static final String KEY_SOUND_SETTINGS = "sound_settings";
65 private static final String KEY_NOTIFICATION_PULSE = "notification_pulse";
Amith Yamasanid2b3ab02009-12-02 13:56:05 -080066 private static final String KEY_DOCK_SETTINGS = "dock_settings";
Amith Yamasani8f2fb65b2009-12-01 19:06:14 -080067
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080068 private CheckBoxPreference mSilent;
69
70 private CheckBoxPreference mPlayMediaNotificationSounds;
71
Amith Yamasanid2b3ab02009-12-02 13:56:05 -080072 private Preference mDockSettings;
73 private boolean mHasDockSettings;
74
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080075 private IMountService mMountService = null;
76
77 /*
78 * If we are currently in one of the silent modes (the ringer mode is set to either
79 * "silent mode" or "vibrate mode"), then toggling the "Phone vibrate"
80 * preference will switch between "silent mode" and "vibrate mode".
81 * Otherwise, it will adjust the normal ringer mode's ring or ring+vibrate
82 * setting.
83 */
84 private CheckBoxPreference mVibrate;
85 private CheckBoxPreference mDtmfTone;
86 private CheckBoxPreference mSoundEffects;
Dan Murphy22e18682009-09-22 11:47:08 -050087 private CheckBoxPreference mHapticFeedback;
Dianne Hackborn76315392009-09-03 13:33:55 -070088 private ListPreference mAnimations;
The Android Open Source Project648bf5f2009-03-09 11:52:14 -070089 private CheckBoxPreference mAccelerometer;
Amith Yamasani8f2fb65b2009-12-01 19:06:14 -080090 private CheckBoxPreference mNotificationPulse;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080091 private float[] mAnimationScales;
Michael Chandf9504e2009-12-06 01:04:04 -080092
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080093 private AudioManager mAudioManager;
Michael Chandf9504e2009-12-06 01:04:04 -080094
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080095 private IWindowManager mWindowManager;
96
97 private BroadcastReceiver mReceiver = new BroadcastReceiver() {
98 @Override
99 public void onReceive(Context context, Intent intent) {
Amith Yamasanid2b3ab02009-12-02 13:56:05 -0800100 if (intent.getAction().equals(AudioManager.RINGER_MODE_CHANGED_ACTION)) {
101 updateState(false);
102 } else if (intent.getAction().equals(Intent.ACTION_DOCK_EVENT)) {
103 handleDockChange(intent);
104 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800105 }
106 };
107
Amith Yamasanid2b3ab02009-12-02 13:56:05 -0800108 private PreferenceGroup mSoundSettings;
109
Michael Chan0bd445b2009-12-03 00:31:59 -0800110 private Intent mDockIntent;
111
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800112 @Override
113 protected void onCreate(Bundle savedInstanceState) {
114 super.onCreate(savedInstanceState);
115 ContentResolver resolver = getContentResolver();
Chouting Zhang386278a2009-06-24 14:25:43 -0500116 int activePhoneType = TelephonyManager.getDefault().getPhoneType();
Michael Chandf9504e2009-12-06 01:04:04 -0800117
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800118 mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
119 mWindowManager = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
120
121 mMountService = IMountService.Stub.asInterface(ServiceManager.getService("mount"));
Michael Chandf9504e2009-12-06 01:04:04 -0800122
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800123 addPreferencesFromResource(R.xml.sound_and_display_settings);
Amith Yamasani8f2fb65b2009-12-01 19:06:14 -0800124
Chouting Zhang386278a2009-06-24 14:25:43 -0500125 if (TelephonyManager.PHONE_TYPE_CDMA != activePhoneType) {
126 // device is not CDMA, do not display CDMA emergency_tone
127 getPreferenceScreen().removePreference(findPreference(KEY_EMERGENCY_TONE));
Amith Yamasani8f2fb65b2009-12-01 19:06:14 -0800128 }
Chouting Zhang386278a2009-06-24 14:25:43 -0500129
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800130 mSilent = (CheckBoxPreference) findPreference(KEY_SILENT);
131 mPlayMediaNotificationSounds = (CheckBoxPreference) findPreference(KEY_PLAY_MEDIA_NOTIFICATION_SOUNDS);
132
133 mVibrate = (CheckBoxPreference) findPreference(KEY_VIBRATE);
134 mDtmfTone = (CheckBoxPreference) findPreference(KEY_DTMF_TONE);
135 mDtmfTone.setPersistent(false);
136 mDtmfTone.setChecked(Settings.System.getInt(resolver,
137 Settings.System.DTMF_TONE_WHEN_DIALING, 1) != 0);
138 mSoundEffects = (CheckBoxPreference) findPreference(KEY_SOUND_EFFECTS);
139 mSoundEffects.setPersistent(false);
140 mSoundEffects.setChecked(Settings.System.getInt(resolver,
141 Settings.System.SOUND_EFFECTS_ENABLED, 0) != 0);
Dan Murphy22e18682009-09-22 11:47:08 -0500142 mHapticFeedback = (CheckBoxPreference) findPreference(KEY_HAPTIC_FEEDBACK);
143 mHapticFeedback.setPersistent(false);
144 mHapticFeedback.setChecked(Settings.System.getInt(resolver,
145 Settings.System.HAPTIC_FEEDBACK_ENABLED, 0) != 0);
Dianne Hackborn76315392009-09-03 13:33:55 -0700146 mAnimations = (ListPreference) findPreference(KEY_ANIMATIONS);
147 mAnimations.setOnPreferenceChangeListener(this);
The Android Open Source Project648bf5f2009-03-09 11:52:14 -0700148 mAccelerometer = (CheckBoxPreference) findPreference(KEY_ACCELEROMETER);
149 mAccelerometer.setPersistent(false);
Michael Chandf9504e2009-12-06 01:04:04 -0800150
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800151 ListPreference screenTimeoutPreference =
152 (ListPreference) findPreference(KEY_SCREEN_TIMEOUT);
153 screenTimeoutPreference.setValue(String.valueOf(Settings.System.getInt(
154 resolver, SCREEN_OFF_TIMEOUT, FALLBACK_SCREEN_TIMEOUT_VALUE)));
155 screenTimeoutPreference.setOnPreferenceChangeListener(this);
Chouting Zhang386278a2009-06-24 14:25:43 -0500156
157 if (TelephonyManager.PHONE_TYPE_CDMA == activePhoneType) {
158 ListPreference emergencyTonePreference =
159 (ListPreference) findPreference(KEY_EMERGENCY_TONE);
160 emergencyTonePreference.setValue(String.valueOf(Settings.System.getInt(
161 resolver, Settings.System.EMERGENCY_TONE, FALLBACK_EMERGENCY_TONE_VALUE)));
162 emergencyTonePreference.setOnPreferenceChangeListener(this);
163 }
Amith Yamasani8f2fb65b2009-12-01 19:06:14 -0800164
Amith Yamasanid2b3ab02009-12-02 13:56:05 -0800165 mSoundSettings = (PreferenceGroup) findPreference(KEY_SOUND_SETTINGS);
Amith Yamasani8f2fb65b2009-12-01 19:06:14 -0800166 mNotificationPulse = (CheckBoxPreference)
Amith Yamasanid2b3ab02009-12-02 13:56:05 -0800167 mSoundSettings.findPreference(KEY_NOTIFICATION_PULSE);
168 if (mNotificationPulse != null &&
Amith Yamasani8f2fb65b2009-12-01 19:06:14 -0800169 getResources().getBoolean(R.bool.has_intrusive_led) == false) {
Amith Yamasanid2b3ab02009-12-02 13:56:05 -0800170 mSoundSettings.removePreference(mNotificationPulse);
Amith Yamasani8f2fb65b2009-12-01 19:06:14 -0800171 } else {
172 try {
173 mNotificationPulse.setChecked(Settings.System.getInt(resolver,
174 Settings.System.NOTIFICATION_LIGHT_PULSE) == 1);
175 mNotificationPulse.setOnPreferenceChangeListener(this);
176 } catch (SettingNotFoundException snfe) {
177 Log.e(TAG, Settings.System.NOTIFICATION_LIGHT_PULSE + " not found");
178 }
179 }
Amith Yamasanid2b3ab02009-12-02 13:56:05 -0800180
181 initDockSettings();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800182 }
Amith Yamasani8f2fb65b2009-12-01 19:06:14 -0800183
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800184 @Override
185 protected void onResume() {
186 super.onResume();
Michael Chandf9504e2009-12-06 01:04:04 -0800187
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800188 updateState(true);
Michael Chandf9504e2009-12-06 01:04:04 -0800189
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800190 IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION);
Amith Yamasanid2b3ab02009-12-02 13:56:05 -0800191 if (mHasDockSettings) {
192 if (mDockSettings != null) {
193 mSoundSettings.removePreference(mDockSettings);
194 }
195 filter.addAction(Intent.ACTION_DOCK_EVENT);
196 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800197 registerReceiver(mReceiver, filter);
198 }
199
200 @Override
201 protected void onPause() {
202 super.onPause();
203
204 unregisterReceiver(mReceiver);
205 }
206
Amith Yamasanid2b3ab02009-12-02 13:56:05 -0800207 private void initDockSettings() {
208 mDockSettings = mSoundSettings.findPreference(KEY_DOCK_SETTINGS);
209 mHasDockSettings = getResources().getBoolean(R.bool.has_dock_settings);
210 if (mDockSettings != null) {
211 mSoundSettings.removePreference(mDockSettings);
212 // Don't care even if we dock
213 if (getResources().getBoolean(R.bool.has_dock_settings) == false) {
214 mDockSettings = null;
215 }
216 }
217 }
218
219 private void handleDockChange(Intent intent) {
220 if (mHasDockSettings && mDockSettings != null) {
221 int dockState = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, 0);
222 if (dockState != Intent.EXTRA_DOCK_STATE_UNDOCKED) {
223 // Show dock settings item
224 mSoundSettings.addPreference(mDockSettings);
Michael Chan0bd445b2009-12-03 00:31:59 -0800225
226 // Save the intent to send to the activity
227 mDockIntent = intent;
Amith Yamasanid2b3ab02009-12-02 13:56:05 -0800228 } else {
229 // Remove dock settings item
230 mSoundSettings.removePreference(mDockSettings);
231 }
232 }
233 }
234
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800235 private void updateState(boolean force) {
236 final int ringerMode = mAudioManager.getRingerMode();
237 final boolean silentOrVibrateMode =
238 ringerMode != AudioManager.RINGER_MODE_NORMAL;
Michael Chandf9504e2009-12-06 01:04:04 -0800239
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800240 if (silentOrVibrateMode != mSilent.isChecked() || force) {
241 mSilent.setChecked(silentOrVibrateMode);
242 }
243
244 try {
245 mPlayMediaNotificationSounds.setChecked(mMountService.getPlayNotificationSounds());
246 } catch (RemoteException e) {
247 }
Michael Chandf9504e2009-12-06 01:04:04 -0800248
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800249 boolean vibrateSetting;
250 if (silentOrVibrateMode) {
251 vibrateSetting = ringerMode == AudioManager.RINGER_MODE_VIBRATE;
252 } else {
253 vibrateSetting = mAudioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER)
Michael Chandf9504e2009-12-06 01:04:04 -0800254 == AudioManager.VIBRATE_SETTING_ON;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800255 }
256 if (vibrateSetting != mVibrate.isChecked() || force) {
257 mVibrate.setChecked(vibrateSetting);
258 }
Michael Chandf9504e2009-12-06 01:04:04 -0800259
Jason Parekh2c9b3262009-03-24 17:48:28 -0700260 int silentModeStreams = Settings.System.getInt(getContentResolver(),
261 Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0);
Michael Chandf9504e2009-12-06 01:04:04 -0800262 boolean isAlarmInclSilentMode = (silentModeStreams & (1 << AudioManager.STREAM_ALARM)) != 0;
Jason Parekh2c9b3262009-03-24 17:48:28 -0700263 mSilent.setSummary(isAlarmInclSilentMode ?
264 R.string.silent_mode_incl_alarm_summary :
265 R.string.silent_mode_summary);
Michael Chandf9504e2009-12-06 01:04:04 -0800266
Dianne Hackborn76315392009-09-03 13:33:55 -0700267 int animations = 0;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800268 try {
269 mAnimationScales = mWindowManager.getAnimationScales();
270 } catch (RemoteException e) {
271 }
272 if (mAnimationScales != null) {
Dianne Hackborn76315392009-09-03 13:33:55 -0700273 if (mAnimationScales.length >= 1) {
274 animations = ((int)(mAnimationScales[0]+.5f)) % 10;
275 }
276 if (mAnimationScales.length >= 2) {
277 animations += (((int)(mAnimationScales[1]+.5f)) & 0x7) * 10;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800278 }
279 }
Dianne Hackborn76315392009-09-03 13:33:55 -0700280 int idx = 0;
281 int best = 0;
282 CharSequence[] aents = mAnimations.getEntryValues();
283 for (int i=0; i<aents.length; i++) {
284 int val = Integer.parseInt(aents[i].toString());
285 if (val <= animations && val > best) {
286 best = val;
287 idx = i;
288 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800289 }
Dianne Hackborn76315392009-09-03 13:33:55 -0700290 mAnimations.setValueIndex(idx);
291 updateAnimationsSummary(mAnimations.getValue());
The Android Open Source Project648bf5f2009-03-09 11:52:14 -0700292 mAccelerometer.setChecked(Settings.System.getInt(
Michael Chandf9504e2009-12-06 01:04:04 -0800293 getContentResolver(),
The Android Open Source Project648bf5f2009-03-09 11:52:14 -0700294 Settings.System.ACCELEROMETER_ROTATION, 0) != 0);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800295 }
296
Dianne Hackborn76315392009-09-03 13:33:55 -0700297 private void updateAnimationsSummary(Object value) {
298 CharSequence[] summaries = getResources().getTextArray(R.array.animations_summaries);
299 CharSequence[] values = mAnimations.getEntryValues();
300 for (int i=0; i<values.length; i++) {
Marco Nelissen620e5f92009-09-09 09:06:40 -0700301 //Log.i("foo", "Comparing entry "+ values[i] + " to current "
302 // + mAnimations.getValue());
Dianne Hackborn76315392009-09-03 13:33:55 -0700303 if (values[i].equals(value)) {
304 mAnimations.setSummary(summaries[i]);
305 break;
306 }
307 }
308 }
Michael Chandf9504e2009-12-06 01:04:04 -0800309
Amith Yamasanieb72bcd2009-07-07 11:37:08 -0700310 private void setRingerMode(boolean silent, boolean vibrate) {
311 if (silent) {
312 mAudioManager.setRingerMode(vibrate ? AudioManager.RINGER_MODE_VIBRATE :
313 AudioManager.RINGER_MODE_SILENT);
314 } else {
315 mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
316 mAudioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER,
317 vibrate ? AudioManager.VIBRATE_SETTING_ON
318 : AudioManager.VIBRATE_SETTING_OFF);
319 }
320 }
321
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800322 @Override
323 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
Amith Yamasanieb72bcd2009-07-07 11:37:08 -0700324 if (preference == mSilent || preference == mVibrate) {
325 setRingerMode(mSilent.isChecked(), mVibrate.isChecked());
326 if (preference == mSilent) updateState(false);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800327 } else if (preference == mPlayMediaNotificationSounds) {
328 try {
329 mMountService.setPlayNotificationSounds(mPlayMediaNotificationSounds.isChecked());
330 } catch (RemoteException e) {
331 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800332 } else if (preference == mDtmfTone) {
333 Settings.System.putInt(getContentResolver(), Settings.System.DTMF_TONE_WHEN_DIALING,
334 mDtmfTone.isChecked() ? 1 : 0);
Michael Chandf9504e2009-12-06 01:04:04 -0800335
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800336 } else if (preference == mSoundEffects) {
337 if (mSoundEffects.isChecked()) {
338 mAudioManager.loadSoundEffects();
339 } else {
340 mAudioManager.unloadSoundEffects();
341 }
342 Settings.System.putInt(getContentResolver(), Settings.System.SOUND_EFFECTS_ENABLED,
343 mSoundEffects.isChecked() ? 1 : 0);
Dan Murphy22e18682009-09-22 11:47:08 -0500344
345 } else if (preference == mHapticFeedback) {
346 Settings.System.putInt(getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED,
347 mHapticFeedback.isChecked() ? 1 : 0);
Michael Chandf9504e2009-12-06 01:04:04 -0800348
The Android Open Source Project648bf5f2009-03-09 11:52:14 -0700349 } else if (preference == mAccelerometer) {
350 Settings.System.putInt(getContentResolver(),
351 Settings.System.ACCELEROMETER_ROTATION,
352 mAccelerometer.isChecked() ? 1 : 0);
Amith Yamasani8f2fb65b2009-12-01 19:06:14 -0800353 } else if (preference == mNotificationPulse) {
354 boolean value = mNotificationPulse.isChecked();
355 Settings.System.putInt(getContentResolver(),
356 Settings.System.NOTIFICATION_LIGHT_PULSE, value ? 1 : 0);
Michael Chan0bd445b2009-12-03 00:31:59 -0800357 } else if (preference == mDockSettings) {
358 Intent i = new Intent(mDockIntent);
Michael Chandf9504e2009-12-06 01:04:04 -0800359 i.setAction(DockEventReceiver.ACTION_DOCK_SHOW_UI);
360 i.setClass(this, DockEventReceiver.class);
361 sendBroadcast(i);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800362 }
Amith Yamasani8f2fb65b2009-12-01 19:06:14 -0800363
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800364 return true;
365 }
366
367 public boolean onPreferenceChange(Preference preference, Object objValue) {
Amith Yamasani8f2fb65b2009-12-01 19:06:14 -0800368 final String key = preference.getKey();
369 if (KEY_ANIMATIONS.equals(key)) {
Dianne Hackborn76315392009-09-03 13:33:55 -0700370 try {
371 int value = Integer.parseInt((String) objValue);
372 if (mAnimationScales.length >= 1) {
373 mAnimationScales[0] = value%10;
374 }
375 if (mAnimationScales.length >= 2) {
376 mAnimationScales[1] = (value/10)%10;
377 }
378 try {
379 mWindowManager.setAnimationScales(mAnimationScales);
380 } catch (RemoteException e) {
381 }
382 updateAnimationsSummary(objValue);
383 } catch (NumberFormatException e) {
384 Log.e(TAG, "could not persist animation setting", e);
385 }
Michael Chandf9504e2009-12-06 01:04:04 -0800386
Dianne Hackborn76315392009-09-03 13:33:55 -0700387 }
Amith Yamasani8f2fb65b2009-12-01 19:06:14 -0800388 if (KEY_SCREEN_TIMEOUT.equals(key)) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800389 int value = Integer.parseInt((String) objValue);
390 try {
Michael Chandf9504e2009-12-06 01:04:04 -0800391 Settings.System.putInt(getContentResolver(),
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800392 SCREEN_OFF_TIMEOUT, value);
393 } catch (NumberFormatException e) {
394 Log.e(TAG, "could not persist screen timeout setting", e);
395 }
Amith Yamasani8f2fb65b2009-12-01 19:06:14 -0800396 } else if (KEY_EMERGENCY_TONE.equals(key)) {
Chouting Zhang386278a2009-06-24 14:25:43 -0500397 int value = Integer.parseInt((String) objValue);
398 try {
399 Settings.System.putInt(getContentResolver(),
400 Settings.System.EMERGENCY_TONE, value);
401 } catch (NumberFormatException e) {
402 Log.e(TAG, "could not persist emergency tone setting", e);
403 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800404 }
Amith Yamasani8f2fb65b2009-12-01 19:06:14 -0800405
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800406 return true;
407 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800408}