AI 145870: Add a build property for the default alarm alert. Update the various
framework classes to deal with the new property. Also update various documentation that mentions the default ringtones. Use the build property as the default alert when the user has not chosen an alert for an alarm. This is also used if the alarm alert is null when the alarm fires. BUG=1723684 Automated import of CL 145870
This commit is contained in:
committed by
The Android Open Source Project
parent
9ae010a349
commit
3156bb00dd
@@ -95141,6 +95141,17 @@
|
||||
visibility="public"
|
||||
>
|
||||
</field>
|
||||
<field name="ALARM_ALERT"
|
||||
type="java.lang.String"
|
||||
transient="false"
|
||||
volatile="false"
|
||||
value=""alarm_alert""
|
||||
static="true"
|
||||
final="true"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
</field>
|
||||
<field name="ALWAYS_FINISH_ACTIVITIES"
|
||||
type="java.lang.String"
|
||||
transient="false"
|
||||
@@ -95261,6 +95272,16 @@
|
||||
visibility="public"
|
||||
>
|
||||
</field>
|
||||
<field name="DEFAULT_ALARM_ALERT_URI"
|
||||
type="android.net.Uri"
|
||||
transient="false"
|
||||
volatile="false"
|
||||
static="true"
|
||||
final="true"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
</field>
|
||||
<field name="DEFAULT_NOTIFICATION_URI"
|
||||
type="android.net.Uri"
|
||||
transient="false"
|
||||
|
||||
@@ -31,8 +31,9 @@ import android.util.Log;
|
||||
* The chosen ringtone's URI will be persisted as a string.
|
||||
* <p>
|
||||
* If the user chooses the "Default" item, the saved string will be one of
|
||||
* {@link System#DEFAULT_RINGTONE_URI} or
|
||||
* {@link System#DEFAULT_NOTIFICATION_URI}. If the user chooses the "Silent"
|
||||
* {@link System#DEFAULT_RINGTONE_URI},
|
||||
* {@link System#DEFAULT_NOTIFICATION_URI}, or
|
||||
* {@link System#DEFAULT_ALARM_ALERT_URI}. If the user chooses the "Silent"
|
||||
* item, the saved string will be an empty string.
|
||||
*
|
||||
* @attr ref android.R.styleable#RingtonePreference_ringtoneType
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.database.ContentObserver;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.media.AudioManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.Settings;
|
||||
@@ -147,10 +148,16 @@ public class VolumePreference extends SeekBarPreference implements
|
||||
System.getUriFor(System.VOLUME_SETTINGS[mStreamType]),
|
||||
false, mVolumeObserver);
|
||||
|
||||
mRingtone = RingtoneManager.getRingtone(mContext,
|
||||
mStreamType == AudioManager.STREAM_NOTIFICATION
|
||||
? Settings.System.DEFAULT_NOTIFICATION_URI
|
||||
: Settings.System.DEFAULT_RINGTONE_URI);
|
||||
Uri defaultUri = null;
|
||||
if (mStreamType == AudioManager.STREAM_RING) {
|
||||
defaultUri = Settings.System.DEFAULT_RINGTONE_URI;
|
||||
} else if (mStreamType == AudioManager.STREAM_NOTIFICATION) {
|
||||
defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
|
||||
} else {
|
||||
defaultUri = Settings.System.DEFAULT_ALARM_ALERT_URI;
|
||||
}
|
||||
|
||||
mRingtone = RingtoneManager.getRingtone(mContext, defaultUri);
|
||||
mRingtone.setStreamType(mStreamType);
|
||||
}
|
||||
|
||||
|
||||
@@ -1181,6 +1181,22 @@ public final class Settings {
|
||||
*/
|
||||
public static final Uri DEFAULT_NOTIFICATION_URI = getUriFor(NOTIFICATION_SOUND);
|
||||
|
||||
/**
|
||||
* Persistent store for the system-wide default alarm alert.
|
||||
*
|
||||
* @see #RINGTONE
|
||||
* @see #DEFAULT_ALARM_ALERT_URI
|
||||
*/
|
||||
public static final String ALARM_ALERT = "alarm_alert";
|
||||
|
||||
/**
|
||||
* A {@link Uri} that will point to the current default alarm alert at
|
||||
* any given time.
|
||||
*
|
||||
* @see #DEFAULT_ALARM_ALERT_URI
|
||||
*/
|
||||
public static final Uri DEFAULT_ALARM_ALERT_URI = getUriFor(ALARM_ALERT);
|
||||
|
||||
/**
|
||||
* Setting to enable Auto Replace (AutoText) in text editors. 1 = On, 0 = Off
|
||||
*/
|
||||
|
||||
@@ -269,10 +269,14 @@ public class MediaScanner
|
||||
private boolean mDefaultRingtoneSet;
|
||||
/** Whether the scanner has set a default sound for the notification ringtone. */
|
||||
private boolean mDefaultNotificationSet;
|
||||
/** Whether the scanner has set a default sound for the alarm ringtone. */
|
||||
private boolean mDefaultAlarmSet;
|
||||
/** The filename for the default sound for the ringer ringtone. */
|
||||
private String mDefaultRingtoneFilename;
|
||||
/** The filename for the default sound for the notification ringtone. */
|
||||
private String mDefaultNotificationFilename;
|
||||
/** The filename for the default sound for the alarm ringtone. */
|
||||
private String mDefaultAlarmAlertFilename;
|
||||
/**
|
||||
* The prefix for system properties that define the default sound for
|
||||
* ringtones. Concatenate the name of the setting from Settings
|
||||
@@ -331,6 +335,8 @@ public class MediaScanner
|
||||
+ Settings.System.RINGTONE);
|
||||
mDefaultNotificationFilename = SystemProperties.get(DEFAULT_RINGTONE_PROPERTY_PREFIX
|
||||
+ Settings.System.NOTIFICATION_SOUND);
|
||||
mDefaultAlarmAlertFilename = SystemProperties.get(DEFAULT_RINGTONE_PROPERTY_PREFIX
|
||||
+ Settings.System.ALARM_ALERT);
|
||||
}
|
||||
|
||||
private MyMediaScannerClient mClient = new MyMediaScannerClient();
|
||||
@@ -709,6 +715,12 @@ public class MediaScanner
|
||||
setSettingIfNotSet(Settings.System.RINGTONE, tableUri, rowId);
|
||||
mDefaultRingtoneSet = true;
|
||||
}
|
||||
} else if (alarms && !mDefaultAlarmSet) {
|
||||
if (TextUtils.isEmpty(mDefaultAlarmAlertFilename) ||
|
||||
doesPathHaveFilename(entry.mPath, mDefaultAlarmAlertFilename)) {
|
||||
setSettingIfNotSet(Settings.System.ALARM_ALERT, tableUri, rowId);
|
||||
mDefaultAlarmSet = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -122,8 +122,9 @@ public class RingtoneManager {
|
||||
* current ringtone, which will be used to show a checkmark next to the item
|
||||
* for this {@link Uri}. If showing an item for "Default" (@see
|
||||
* {@link #EXTRA_RINGTONE_SHOW_DEFAULT}), this can also be one of
|
||||
* {@link System#DEFAULT_RINGTONE_URI} or
|
||||
* {@link System#DEFAULT_NOTIFICATION_URI} to have the "Default" item
|
||||
* {@link System#DEFAULT_RINGTONE_URI},
|
||||
* {@link System#DEFAULT_NOTIFICATION_URI}, or
|
||||
* {@link System#DEFAULT_ALARM_ALERT_URI} to have the "Default" item
|
||||
* checked.
|
||||
*
|
||||
* @see #ACTION_RINGTONE_PICKER
|
||||
@@ -134,8 +135,9 @@ public class RingtoneManager {
|
||||
/**
|
||||
* Given to the ringtone picker as a {@link Uri}. The {@link Uri} of the
|
||||
* ringtone to play when the user attempts to preview the "Default"
|
||||
* ringtone. This can be one of {@link System#DEFAULT_RINGTONE_URI} or
|
||||
* {@link System#DEFAULT_NOTIFICATION_URI} to have the "Default" point to
|
||||
* ringtone. This can be one of {@link System#DEFAULT_RINGTONE_URI},
|
||||
* {@link System#DEFAULT_NOTIFICATION_URI}, or
|
||||
* {@link System#DEFAULT_ALARM_ALERT_URI} to have the "Default" point to
|
||||
* the current sound for the given default sound type. If you are showing a
|
||||
* ringtone picker for some other type of sound, you are free to provide any
|
||||
* {@link Uri} here.
|
||||
@@ -163,8 +165,9 @@ public class RingtoneManager {
|
||||
* <p>
|
||||
* It will be one of:
|
||||
* <li> the picked ringtone,
|
||||
* <li> a {@link Uri} that equals {@link System#DEFAULT_RINGTONE_URI} or
|
||||
* {@link System#DEFAULT_NOTIFICATION_URI} if the default was chosen,
|
||||
* <li> a {@link Uri} that equals {@link System#DEFAULT_RINGTONE_URI},
|
||||
* {@link System#DEFAULT_NOTIFICATION_URI}, or
|
||||
* {@link System#DEFAULT_ALARM_ALERT_URI} if the default was chosen,
|
||||
* <li> null if the "Silent" item was picked.
|
||||
*
|
||||
* @see #ACTION_RINGTONE_PICKER
|
||||
@@ -625,7 +628,8 @@ public class RingtoneManager {
|
||||
*
|
||||
* @param context A context used for querying.
|
||||
* @param type The type whose default sound should be returned. One of
|
||||
* {@link #TYPE_RINGTONE} or {@link #TYPE_NOTIFICATION}.
|
||||
* {@link #TYPE_RINGTONE}, {@link #TYPE_NOTIFICATION}, or
|
||||
* {@link #TYPE_ALARM}.
|
||||
* @return A {@link Uri} pointing to the default sound for the sound type.
|
||||
* @see #setActualDefaultRingtoneUri(Context, int, Uri)
|
||||
*/
|
||||
@@ -641,7 +645,8 @@ public class RingtoneManager {
|
||||
*
|
||||
* @param context A context used for querying.
|
||||
* @param type The type whose default sound should be set. One of
|
||||
* {@link #TYPE_RINGTONE} or {@link #TYPE_NOTIFICATION}.
|
||||
* {@link #TYPE_RINGTONE}, {@link #TYPE_NOTIFICATION}, or
|
||||
* {@link #TYPE_ALARM}.
|
||||
* @param ringtoneUri A {@link Uri} pointing to the default sound to set.
|
||||
* @see #getActualDefaultRingtoneUri(Context, int)
|
||||
*/
|
||||
@@ -656,6 +661,8 @@ public class RingtoneManager {
|
||||
return Settings.System.RINGTONE;
|
||||
} else if ((type & TYPE_NOTIFICATION) != 0) {
|
||||
return Settings.System.NOTIFICATION_SOUND;
|
||||
} else if ((type & TYPE_ALARM) != 0) {
|
||||
return Settings.System.ALARM_ALERT;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -675,8 +682,9 @@ public class RingtoneManager {
|
||||
* Returns the type of a default {@link Uri}.
|
||||
*
|
||||
* @param defaultRingtoneUri The default {@link Uri}. For example,
|
||||
* {@link System#DEFAULT_RINGTONE_URI} or
|
||||
* {@link System#DEFAULT_NOTIFICATION_URI}.
|
||||
* {@link System#DEFAULT_RINGTONE_URI},
|
||||
* {@link System#DEFAULT_NOTIFICATION_URI}, or
|
||||
* {@link System#DEFAULT_ALARM_ALERT_URI}.
|
||||
* @return The type of the defaultRingtoneUri, or -1.
|
||||
*/
|
||||
public static int getDefaultType(Uri defaultRingtoneUri) {
|
||||
@@ -686,6 +694,8 @@ public class RingtoneManager {
|
||||
return TYPE_RINGTONE;
|
||||
} else if (defaultRingtoneUri.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
|
||||
return TYPE_NOTIFICATION;
|
||||
} else if (defaultRingtoneUri.equals(Settings.System.DEFAULT_ALARM_ALERT_URI)) {
|
||||
return TYPE_ALARM;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
@@ -705,6 +715,8 @@ public class RingtoneManager {
|
||||
return Settings.System.DEFAULT_RINGTONE_URI;
|
||||
} else if ((type & TYPE_NOTIFICATION) != 0) {
|
||||
return Settings.System.DEFAULT_NOTIFICATION_URI;
|
||||
} else if ((type & TYPE_ALARM) != 0) {
|
||||
return Settings.System.DEFAULT_ALARM_ALERT_URI;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user