diff options
author | kaiyiz <kaiyiz@codeaurora.org> | 2014-09-03 15:37:45 +0800 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2016-08-24 08:06:57 -0600 |
commit | 1cc3728ba7a99c66dab2662469d2f85b2d71ead2 (patch) | |
tree | 36e1caa473fbeee0e694ef26dde1846029061bdd | |
parent | 7a3a23a20cc105e3343c2aed883cacd967dcfb58 (diff) | |
download | android_packages_apps_DeskClock-1cc3728ba7a99c66dab2662469d2f85b2d71ead2.tar.gz android_packages_apps_DeskClock-1cc3728ba7a99c66dab2662469d2f85b2d71ead2.tar.bz2 android_packages_apps_DeskClock-1cc3728ba7a99c66dab2662469d2f85b2d71ead2.zip |
Clock: Customize Alarm for carrier
- Customize the default auto silience value and alarm behavier in a
call.
- Ring alarm in all user profiles even in silent and meeting mode.
Conflicts:
res/values/config.xml
src/com/android/deskclock/alarms/AlarmService.java
src/com/android/deskclock/provider/AlarmInstance.java
CRs-Fixed: 1014635
Change-Id: I1b617f8f97ab6e271dcaaf854800aaae083e8b1e
-rw-r--r-- | res/values/config.xml | 7 | ||||
-rw-r--r-- | res/values/strings.xml | 7 | ||||
-rw-r--r-- | res/xml/settings.xml | 7 | ||||
-rw-r--r-- | src/com/android/deskclock/AsyncRingtonePlayer.java | 12 | ||||
-rw-r--r-- | src/com/android/deskclock/alarms/AlarmService.java | 9 | ||||
-rw-r--r-- | src/com/android/deskclock/provider/AlarmInstance.java | 12 |
6 files changed, 45 insertions, 9 deletions
diff --git a/res/values/config.xml b/res/values/config.xml index 855923d9a..89a417744 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -1,5 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2011 The Android Open Source Project +<!-- Copyright (c) 2014, The Linux Foundation. All rights reserved. + Not a Contribution. + + Copyright (C) 2011 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -25,4 +28,6 @@ <item type="integer" name="world_clocks_per_row">1</item> <!-- Number of world clocks in a row, for the digital appwidget. --> <item type="integer" name="appwidget_world_clocks_per_row">2</item> + <bool name="config_ring_alarm_force">false</bool> + <bool name="config_silent_during_call">false</bool> </resources> diff --git a/res/values/strings.xml b/res/values/strings.xml index 5f18d1de9..24264ee7d 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,5 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2007 The Android Open Source Project +<!-- Copyright (c) 2014, The Linux Foundation. All rights reserved. + Not a Contribution. + + Copyright (C) 2007 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -288,6 +291,8 @@ <!-- Auto silence summary when turned off --> <string name="auto_silence_never">Never</string> + <string name="default_auto_silence_value">10</string> + <!-- Entries listed in the ListPreference when invoking the auto silence preference. --> <string-array name="auto_silence_entries"> diff --git a/res/xml/settings.xml b/res/xml/settings.xml index 37b416a13..4baddc8de 100644 --- a/res/xml/settings.xml +++ b/res/xml/settings.xml @@ -1,5 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2009 The Android Open Source Project +<!-- Copyright (c) 2014, The Linux Foundation. All rights reserved. + Not a Contribution. + + Copyright (C) 2009 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -50,7 +53,7 @@ android:title="@string/auto_silence_title" android:entries="@array/auto_silence_entries" android:entryValues="@array/auto_silence_values" - android:defaultValue="10" + android:defaultValue="@string/default_auto_silence_value" android:dialogTitle="@string/auto_silence_title" /> <com.android.deskclock.settings.SnoozeLengthDialog diff --git a/src/com/android/deskclock/AsyncRingtonePlayer.java b/src/com/android/deskclock/AsyncRingtonePlayer.java index 8a794a695..3fb8230e4 100644 --- a/src/com/android/deskclock/AsyncRingtonePlayer.java +++ b/src/com/android/deskclock/AsyncRingtonePlayer.java @@ -63,7 +63,7 @@ public final class AsyncRingtonePlayer { private PlaybackDelegate mPlaybackDelegate; /** The context. */ - private final Context mContext; + private static Context mContext; /** The key of the preference that controls the crescendo behavior when playing a ringtone. */ private final String mCrescendoPrefKey; @@ -367,7 +367,15 @@ public final class AsyncRingtonePlayer { .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) .build()); } - + player.setAudioStreamType(AudioManager.STREAM_ALARM); + player.setLooping(true); + player.prepare(); + mAudioManager.requestAudioFocus(null, AudioManager.STREAM_ALARM, + AudioManager.AUDIOFOCUS_GAIN_TRANSIENT); + player.start(); + } else if (mContext.getResources().getBoolean(R.bool.config_ring_alarm_force)) { + mAudioManager.setStreamVolume(AudioManager.STREAM_ALARM, + mAudioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM), 0); player.setAudioStreamType(AudioManager.STREAM_ALARM); player.setLooping(true); player.prepare(); diff --git a/src/com/android/deskclock/alarms/AlarmService.java b/src/com/android/deskclock/alarms/AlarmService.java index cd1bec4b1..e9eb2265f 100644 --- a/src/com/android/deskclock/alarms/AlarmService.java +++ b/src/com/android/deskclock/alarms/AlarmService.java @@ -1,4 +1,7 @@ /* + * Copyright (c) 2014, The Linux Foundation. All rights reserved. + * Not a Contribution. + * * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -109,7 +112,11 @@ public class AlarmService extends Service { // we register onCallStateChanged, we get the initial in-call state // which kills the alarm. Check against the initial call state so // we don't kill the alarm during a call. - if (state != TelephonyManager.CALL_STATE_IDLE && state != mInitialCallState) { + if (AlarmService.this.getResources().getBoolean(R.bool.config_silent_during_call) + && state != TelephonyManager.CALL_STATE_IDLE) { + sendBroadcast(AlarmStateManager.createStateChangeIntent(AlarmService.this, + "AlarmService", mCurrentAlarm, AlarmInstance.MISSED_STATE)); + } else if (state != TelephonyManager.CALL_STATE_IDLE && state != mInitialCallState) { startService(AlarmStateManager.createStateChangeIntent(AlarmService.this, "AlarmService", mCurrentAlarm, AlarmInstance.MISSED_STATE)); } diff --git a/src/com/android/deskclock/provider/AlarmInstance.java b/src/com/android/deskclock/provider/AlarmInstance.java index 5be3c03f9..5a4ccb389 100644 --- a/src/com/android/deskclock/provider/AlarmInstance.java +++ b/src/com/android/deskclock/provider/AlarmInstance.java @@ -1,4 +1,7 @@ /* + * Copyright (c) 2014, The Linux Foundation. All rights reserved. + * Not a Contribution. + * * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -425,8 +428,13 @@ public final class AlarmInstance implements ClockContract.InstancesColumns { * @return the time when alarm should be silence, or null if never */ public Calendar getTimeout(Context context) { - String timeoutSetting = Utils.getDefaultSharedPreferences(context) - .getString(SettingsActivity.KEY_AUTO_SILENCE, DEFAULT_ALARM_TIMEOUT_SETTING); + String timeoutSetting = PreferenceManager.getDefaultSharedPreferences(context) + .getString(SettingsActivity.KEY_AUTO_SILENCE, null); + if (timeoutSetting == null) { + timeoutSetting = context.getResources() + .getString(R.string.default_auto_silence_value); + } + int timeoutMinutes = Integer.parseInt(timeoutSetting); // Alarm silence has been set to "None" |