diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/preference/RingtonePreference.java | 30 | ||||
-rw-r--r-- | core/java/android/provider/Settings.java | 57 |
2 files changed, 86 insertions, 1 deletions
diff --git a/core/java/android/preference/RingtonePreference.java b/core/java/android/preference/RingtonePreference.java index 81c0595..dd260e0 100644 --- a/core/java/android/preference/RingtonePreference.java +++ b/core/java/android/preference/RingtonePreference.java @@ -51,6 +51,7 @@ public class RingtonePreference extends Preference implements private int mDialogStyle; private int mRequestCode; + private int mSubscriptionID = 0; /* Sub-1 by default */ public RingtonePreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); @@ -101,6 +102,28 @@ public class RingtonePreference extends Preference implements } /** + * Returns the subscription ID. + * + * @return The current subscription ID. + * @see #setSubId(int) + * @hide + */ + public int getSubId() { + return mSubscriptionID; + } + + /** + * Sets the subscription ID. + * + * @param subId subscription ID. + * @see #getSubId(int) + * @hide + */ + public void setSubId(int subId) { + mSubscriptionID = subId; + } + + /** * Returns whether to a show an item for the default sound/ringtone. * * @return Whether to show an item for the default sound/ringtone. @@ -187,8 +210,13 @@ public class RingtonePreference extends Preference implements ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, mShowDefault); if (mShowDefault) { - ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, + if (getRingtoneType() == RingtoneManager.TYPE_RINGTONE) { + ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, + RingtoneManager.getDefaultRingtoneUriBySubId(getSubId())); + } else { + ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(getRingtoneType())); + } } if (mDialogStyle != 0) { ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DIALOG_THEME, diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 28e04e8..a738b83 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -2780,6 +2780,30 @@ public final class Settings { private static final Validator RINGTONE_VALIDATOR = sUriValidator; /** + * Persistent store for the SIM-2 ringtone URI. + * <p> + * If you need to play SIM-2 ringtone at any given time, it is recommended + * you give {@link #DEFAULT_RINGTONE_URI_2} to the media player. It will resolve + * to the set default ringtone at the time of playing. + * + * @see #DEFAULT_RINGTONE_URI_2 + * @hide + */ + public static final String RINGTONE_2 = "ringtone_2"; + + /** + * Persistent store for the SIM-3 ringtone URI. + * <p> + * If you need to play SIM-3 ringtone at any given time, it is recommended + * you give {@link #DEFAULT_RINGTONE_URI_3} to the media player. It will resolve + * to the set default ringtone at the time of playing. + * + * @see #DEFAULT_RINGTONE_URI_3 + * @hide + */ + public static final String RINGTONE_3 = "ringtone_3"; + + /** * A {@link Uri} that will point to the current default ringtone at any * given time. * <p> @@ -2790,6 +2814,39 @@ public final class Settings { public static final Uri DEFAULT_RINGTONE_URI = getUriFor(RINGTONE); /** + * A {@link Uri} that will point to the current SIM-2 ringtone at any + * given time. + * <p> + * If the current default ringtone is in the DRM provider and the caller + * does not have permission, the exception will be a + * FileNotFoundException. + * + * @hide + */ + public static final Uri DEFAULT_RINGTONE_URI_2 = getUriFor(RINGTONE_2); + + /** + * A {@link Uri} that will point to the current SIM-3 ringtone at any + * given time. + * <p> + * If the current default ringtone is in the DRM provider and the caller + * does not have permission, the exception will be a + * FileNotFoundException. + * + * @hide + */ + public static final Uri DEFAULT_RINGTONE_URI_3 = getUriFor(RINGTONE_3); + + /** + * Maximum number of ringtones supported. + * <p> + * Maximum number of ringtones supported by settings. Increment this + * if a new URI needs to be added for ringtone. + * @hide + */ + public static final int MAX_NUM_RINGTONES = 3; + + /** * Persistent store for the system-wide default notification sound. * * @see #RINGTONE |