Browse Source

base: Phone ringtone setting for Multi SIM device [1/3]

Add below changes to handle default phone ringtone for slot2.
1. Add Settings.System.RINGTONE2 as the key in SettingsProvider to
save ringtone for slot2.
2. Support "ro.config.ringtone" for Multi SIM device.
3. Adapt ringtone for slot2 in current ringtone related APIs.

Bug: 118735436
Test: Manual
Change-Id: I9c6ccff938122332d222853d469ad9a623c7d193
Signed-off-by: NurKeinNeid <mralexman3000@gmail.com>
ten
Ting Yu 2 years ago
parent
commit
c1e28e4c01

+ 2
- 0
api/current.txt View File

@@ -38906,6 +38906,7 @@ package android.provider {
field public static final android.net.Uri DEFAULT_ALARM_ALERT_URI;
field public static final android.net.Uri DEFAULT_NOTIFICATION_URI;
field public static final android.net.Uri DEFAULT_RINGTONE_URI;
field public static final android.net.Uri DEFAULT_RINGTONE2_URI;
field @Deprecated public static final String DEVICE_PROVISIONED = "device_provisioned";
field @Deprecated public static final String DIM_SCREEN = "dim_screen";
field public static final String DTMF_TONE_TYPE_WHEN_DIALING = "dtmf_tone_type";
@@ -38934,6 +38935,7 @@ package android.provider {
field @Deprecated public static final String RADIO_NFC = "nfc";
field @Deprecated public static final String RADIO_WIFI = "wifi";
field public static final String RINGTONE = "ringtone";
field public static final String RINGTONE2 = "ringtone2";
field public static final String SCREEN_BRIGHTNESS = "screen_brightness";
field public static final String SCREEN_BRIGHTNESS_MODE = "screen_brightness_mode";
field public static final int SCREEN_BRIGHTNESS_MODE_AUTOMATIC = 1; // 0x1

+ 1
- 0
core/java/android/preference/RingtonePreference.java View File

@@ -33,6 +33,7 @@ import android.util.AttributeSet;
* <p>
* If the user chooses the "Default" item, the saved string will be one of
* {@link System#DEFAULT_RINGTONE_URI},
* {@link System#DEFAULT_RINGTONE2_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.

+ 25
- 0
core/java/android/provider/Settings.java View File

@@ -3858,6 +3858,14 @@ public final class Settings {
*/
public static final String RINGTONE = "ringtone";

/**
* Persistent store for the system-wide default ringtone for Slot2 URI.
*
* @see #RINGTONE
* @see #DEFAULT_RINGTONE2_URI
*/
public static final String RINGTONE2 = "ringtone2";

private static final Validator RINGTONE_VALIDATOR = URI_VALIDATOR;

/**
@@ -3870,11 +3878,24 @@ public final class Settings {
*/
public static final Uri DEFAULT_RINGTONE_URI = getUriFor(RINGTONE);

/**
* A {@link Uri} that will point to the current default ringtone for Slot2
* at any given time.
*
* @see #DEFAULT_RINGTONE_URI
*/
public static final Uri DEFAULT_RINGTONE2_URI = getUriFor(RINGTONE2);

/** {@hide} */
public static final String RINGTONE_CACHE = "ringtone_cache";
/** {@hide} */
public static final Uri RINGTONE_CACHE_URI = getUriFor(RINGTONE_CACHE);

/** {@hide} */
public static final String RINGTONE2_CACHE = "ringtone2_cache";
/** {@hide} */
public static final Uri RINGTONE2_CACHE_URI = getUriFor(RINGTONE2_CACHE);

/**
* Persistent store for the system-wide default notification sound.
*
@@ -5095,6 +5116,7 @@ public final class Settings {
POINTER_SPEED,
VIBRATE_WHEN_RINGING,
RINGTONE,
RINGTONE2,
LOCK_TO_APP_ENABLED,
NOTIFICATION_SOUND,
ACCELEROMETER_ROTATION,
@@ -5202,6 +5224,7 @@ public final class Settings {
PUBLIC_SETTINGS.add(VOLUME_NOTIFICATION);
PUBLIC_SETTINGS.add(VOLUME_BLUETOOTH_SCO);
PUBLIC_SETTINGS.add(RINGTONE);
PUBLIC_SETTINGS.add(RINGTONE2);
PUBLIC_SETTINGS.add(NOTIFICATION_SOUND);
PUBLIC_SETTINGS.add(ALARM_ALERT);
PUBLIC_SETTINGS.add(TEXT_AUTO_REPLACE);
@@ -5356,6 +5379,7 @@ public final class Settings {
VALIDATORS.put(RING_VIBRATION_INTENSITY, VIBRATION_INTENSITY_VALIDATOR);
VALIDATORS.put(HAPTIC_FEEDBACK_INTENSITY, VIBRATION_INTENSITY_VALIDATOR);
VALIDATORS.put(RINGTONE, RINGTONE_VALIDATOR);
VALIDATORS.put(RINGTONE2, RINGTONE_VALIDATOR);
VALIDATORS.put(NOTIFICATION_SOUND, NOTIFICATION_SOUND_VALIDATOR);
VALIDATORS.put(ALARM_ALERT, ALARM_ALERT_VALIDATOR);
VALIDATORS.put(TEXT_AUTO_REPLACE, TEXT_AUTO_REPLACE_VALIDATOR);
@@ -5501,6 +5525,7 @@ public final class Settings {
public static final Map<String, String> CLONE_FROM_PARENT_ON_VALUE = new ArrayMap<>();
static {
CLONE_FROM_PARENT_ON_VALUE.put(RINGTONE, Secure.SYNC_PARENT_SOUNDS);
CLONE_FROM_PARENT_ON_VALUE.put(RINGTONE2, Secure.SYNC_PARENT_SOUNDS);
CLONE_FROM_PARENT_ON_VALUE.put(NOTIFICATION_SOUND, Secure.SYNC_PARENT_SOUNDS);
CLONE_FROM_PARENT_ON_VALUE.put(ALARM_ALERT, Secure.SYNC_PARENT_SOUNDS);
}

+ 1
- 0
core/tests/coretests/src/android/provider/SettingsBackupTest.java View File

@@ -71,6 +71,7 @@ public class SettingsBackupTest {
Settings.System.POINTER_LOCATION, // backup candidate?
Settings.System.DEBUG_ENABLE_ENHANCED_CALL_BLOCKING, // used for testing only
Settings.System.RINGTONE_CACHE, // internal cache
Settings.System.RINGTONE2_CACHE, // internal cache
Settings.System.SCREEN_BRIGHTNESS, // removed in P
Settings.System.SETUP_WIZARD_HAS_RUN, // Only used by SuW
Settings.System.SHOW_GTALK_SERVICE_STATUS, // candidate for backup?

+ 41
- 8
media/java/android/media/MediaScanner.java View File

@@ -358,6 +358,8 @@ public class MediaScanner implements AutoCloseable {
private int mOriginalCount;
/** Whether the scanner has set a default sound for the ringer ringtone. */
private boolean mDefaultRingtoneSet;
/** Whether the scanner has set a default sound for the ringer ringtone2. */
private boolean mDefaultRingtone2Set;
/** 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. */
@@ -365,6 +367,8 @@ public class MediaScanner implements AutoCloseable {
/** The filename for the default sound for the ringer ringtone. */
@UnsupportedAppUsage
private String mDefaultRingtoneFilename;
/** The filename for the default sound for the ringer ringtone2. */
private String mDefaultRingtone2Filename;
/** The filename for the default sound for the notification ringtone. */
@UnsupportedAppUsage
private String mDefaultNotificationFilename;
@@ -377,6 +381,8 @@ public class MediaScanner implements AutoCloseable {
* to get the full system property.
*/
private static final String DEFAULT_RINGTONE_PROPERTY_PREFIX = "ro.config.";
/** The seperator to split ringtone for each slot in ro.config.ringtone. */
private static final String RINGTONE_SEPARATOR = ",";

private final BitmapFactory.Options mBitmapOptions = new BitmapFactory.Options();

@@ -486,8 +492,17 @@ public class MediaScanner implements AutoCloseable {
}

private void setDefaultRingtoneFileNames() {
mDefaultRingtoneFilename = SystemProperties.get(DEFAULT_RINGTONE_PROPERTY_PREFIX
String defaultRingtoneProp = SystemProperties.get(DEFAULT_RINGTONE_PROPERTY_PREFIX
+ Settings.System.RINGTONE);
if (!TextUtils.isEmpty(defaultRingtoneProp)) {
String defaultRingtoneArray[] = defaultRingtoneProp.split(RINGTONE_SEPARATOR);
mDefaultRingtoneFilename = defaultRingtoneArray[0];
if (defaultRingtoneArray.length > 1) {
// If length of defaultRingtoneArray more than 1, it means ro.default.ringtone
// also includes slot2's ringtone
mDefaultRingtone2Filename = defaultRingtoneArray[1];
}
}
mDefaultNotificationFilename = SystemProperties.get(DEFAULT_RINGTONE_PROPERTY_PREFIX
+ Settings.System.NOTIFICATION_SOUND);
mDefaultAlarmAlertFilename = SystemProperties.get(DEFAULT_RINGTONE_PROPERTY_PREFIX
@@ -647,7 +662,11 @@ public class MediaScanner implements AutoCloseable {
if (((!mDefaultNotificationSet &&
doesPathHaveFilename(entry.mPath, mDefaultNotificationFilename))
|| (!mDefaultRingtoneSet &&
!TextUtils.isEmpty(mDefaultRingtoneFilename) &&
doesPathHaveFilename(entry.mPath, mDefaultRingtoneFilename))
|| (!mDefaultRingtone2Set &&
!TextUtils.isEmpty(mDefaultRingtone2Filename) &&
doesPathHaveFilename(entry.mPath, mDefaultRingtone2Filename))
|| (!mDefaultAlarmSet &&
doesPathHaveFilename(entry.mPath, mDefaultAlarmAlertFilename)))) {
Log.w(TAG, "forcing rescan of " + entry.mPath +
@@ -1089,9 +1108,13 @@ public class MediaScanner implements AutoCloseable {
doesPathHaveFilename(entry.mPath, mDefaultNotificationFilename)) {
needToSetSettings = true;
}
} else if (ringtones && !mDefaultRingtoneSet) {
if (TextUtils.isEmpty(mDefaultRingtoneFilename) ||
doesPathHaveFilename(entry.mPath, mDefaultRingtoneFilename)) {
} else if (ringtones) {
if (!mDefaultRingtoneSet && (TextUtils.isEmpty(mDefaultRingtoneFilename) ||
doesPathHaveFilename(entry.mPath, mDefaultRingtoneFilename))) {
needToSetSettings = true;
}
if (!mDefaultRingtone2Set && (TextUtils.isEmpty(mDefaultRingtone2Filename) ||
doesPathHaveFilename(entry.mPath, mDefaultRingtone2Filename))) {
needToSetSettings = true;
}
} else if (alarms && !mDefaultAlarmSet) {
@@ -1157,8 +1180,16 @@ public class MediaScanner implements AutoCloseable {
setRingtoneIfNotSet(Settings.System.NOTIFICATION_SOUND, tableUri, rowId);
mDefaultNotificationSet = true;
} else if (ringtones) {
setRingtoneIfNotSet(Settings.System.RINGTONE, tableUri, rowId);
mDefaultRingtoneSet = true;
if (!TextUtils.isEmpty(mDefaultRingtoneFilename)
&& doesPathHaveFilename(entry.mPath, mDefaultRingtoneFilename)) {
setRingtoneIfNotSet(Settings.System.RINGTONE, tableUri, rowId);
mDefaultRingtoneSet = true;
}
if (!TextUtils.isEmpty(mDefaultRingtone2Filename)
&& doesPathHaveFilename(entry.mPath, mDefaultRingtone2Filename)) {
setRingtoneIfNotSet(Settings.System.RINGTONE2, tableUri, rowId);
mDefaultRingtone2Set = true;
}
} else if (alarms) {
setRingtoneIfNotSet(Settings.System.ALARM_ALERT, tableUri, rowId);
mDefaultAlarmSet = true;
@@ -1185,8 +1216,9 @@ public class MediaScanner implements AutoCloseable {
if (TextUtils.isEmpty(existingSettingValue)) {
final Uri settingUri = Settings.System.getUriFor(settingName);
final Uri ringtoneUri = ContentUris.withAppendedId(uri, rowId);
RingtoneManager.setActualDefaultRingtoneUri(mContext,
RingtoneManager.getDefaultType(settingUri), ringtoneUri);
final int slotId = Settings.System.RINGTONE2.equals(settingName) ? 1 : 0;
RingtoneManager.setActualDefaultRingtoneUriBySlot(mContext,
RingtoneManager.getDefaultType(settingUri), ringtoneUri, slotId);
}
Settings.System.putInt(cr, settingSetIndicatorName(settingName), 1);
}
@@ -1265,6 +1297,7 @@ public class MediaScanner implements AutoCloseable {
}

mDefaultRingtoneSet = wasRingtoneAlreadySet(Settings.System.RINGTONE);
mDefaultRingtone2Set = wasRingtoneAlreadySet(Settings.System.RINGTONE2);
mDefaultNotificationSet = wasRingtoneAlreadySet(Settings.System.NOTIFICATION_SOUND);
mDefaultAlarmSet = wasRingtoneAlreadySet(Settings.System.ALARM_ALERT);


+ 85
- 15
media/java/android/media/RingtoneManager.java View File

@@ -45,6 +45,7 @@ import android.os.UserManager;
import android.provider.MediaStore;
import android.provider.Settings;
import android.provider.Settings.System;
import android.telephony.SubscriptionManager;
import android.util.Log;

import com.android.internal.database.SortCursor;
@@ -146,6 +147,7 @@ public class RingtoneManager {
* 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},
* {@link System#DEFAULT_RINGTONE2_URI},
* {@link System#DEFAULT_NOTIFICATION_URI}, or
* {@link System#DEFAULT_ALARM_ALERT_URI} to have the "Default" item
* checked.
@@ -159,7 +161,7 @@ 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},
* {@link System#DEFAULT_NOTIFICATION_URI}, or
* {@link System#DEFAULT_RINGTONE2_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
@@ -198,7 +200,7 @@ public class RingtoneManager {
* It will be one of:
* <li> the picked ringtone,
* <li> a {@link Uri} that equals {@link System#DEFAULT_RINGTONE_URI},
* {@link System#DEFAULT_NOTIFICATION_URI}, or
* {@link System#DEFAULT_RINGTONE2_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.
*
@@ -763,8 +765,8 @@ public class RingtoneManager {
/**
* Gets the current default sound's {@link Uri}. This will give the actual
* sound {@link Uri}, instead of using this, most clients can use
* {@link System#DEFAULT_RINGTONE_URI}.
*
* {@link System#DEFAULT_RINGTONE_URI} or {@link System#DEFAULT_RINGTONE2_URI}.
*
* @param context A context used for querying.
* @param type The type whose default sound should be returned. One of
* {@link #TYPE_RINGTONE}, {@link #TYPE_NOTIFICATION}, or
@@ -773,7 +775,27 @@ public class RingtoneManager {
* @see #setActualDefaultRingtoneUri(Context, int, Uri)
*/
public static Uri getActualDefaultRingtoneUri(Context context, int type) {
String setting = getSettingForType(type);
return getActualDefaultRingtoneUriBySlot(context, type,
SubscriptionManager.getDefaultVoicePhoneId());
}

/**
* Gets the current default sound's {@link Uri} by slotId. This will give the actual
* sound {@link Uri}, instead of using this, most clients can use
* {@link System#DEFAULT_RINGTONE_URI} or {@link System#DEFAULT_RINGTONE2_URI}.
*
* @param context A context used for querying.
* @param type The type whose default sound should be returned. One of
* {@link #TYPE_RINGTONE}, {@link #TYPE_NOTIFICATION}, or
* {@link #TYPE_ALARM}.
* @param slotId The slotId whose default sound should be returned.
* @return A {@link Uri} pointing to the default sound for the sound type.
* @see #setActualDefaultRingtoneUriBySlot(Context, int, Uri, int)
*
* @hide
*/
public static Uri getActualDefaultRingtoneUriBySlot(Context context, int type, int slotId) {
String setting = getSettingForTypeBySlot(type, slotId);
if (setting == null) return null;
final String uriString = Settings.System.getStringForUser(context.getContentResolver(),
setting, context.getUserId());
@@ -791,7 +813,7 @@ public class RingtoneManager {
/**
* Sets the {@link Uri} of the default sound for a given sound type.
*
*
* @param context A context used for querying.
* @param type The type whose default sound should be set. One of
* {@link #TYPE_RINGTONE}, {@link #TYPE_NOTIFICATION}, or
@@ -800,7 +822,26 @@ public class RingtoneManager {
* @see #getActualDefaultRingtoneUri(Context, int)
*/
public static void setActualDefaultRingtoneUri(Context context, int type, Uri ringtoneUri) {
String setting = getSettingForType(type);
setActualDefaultRingtoneUriBySlot(context, type, ringtoneUri,
SubscriptionManager.getDefaultVoicePhoneId());
}

/**
* Sets the {@link Uri} of the default sound by slotId for a given sound type.
*
* @param context A context used for querying.
* @param type The type whose default sound should be set. One of
* {@link #TYPE_RINGTONE}, {@link #TYPE_NOTIFICATION}, or
* {@link #TYPE_ALARM}.
* @param ringtoneUri A {@link Uri} pointing to the default sound to set.
* @param slotId The slotId whose default sound should be set.
* @see #getActualDefaultRingtoneUriBySlot(Context, int, int)
*
* @hide
*/
public static void setActualDefaultRingtoneUriBySlot(Context context, int type,
Uri ringtoneUri, int slotId) {
String setting = getSettingForTypeBySlot(type, slotId);
if (setting == null) return;

final ContentResolver resolver = context.getContentResolver();
@@ -818,7 +859,7 @@ public class RingtoneManager {
// Stream selected ringtone into cache so it's available for playback
// when CE storage is still locked
if (ringtoneUri != null) {
final Uri cacheUri = getCacheForType(type, context.getUserId());
final Uri cacheUri = getCacheForTypeBySlot(type, context.getUserId(), slotId);
try (InputStream in = openRingtone(context, ringtoneUri);
OutputStream out = resolver.openOutputStream(cacheUri)) {
FileUtils.copy(in, out);
@@ -943,9 +984,9 @@ public class RingtoneManager {
}
}

private static String getSettingForType(int type) {
private static String getSettingForTypeBySlot(int type, int slotId) {
if ((type & TYPE_RINGTONE) != 0) {
return Settings.System.RINGTONE;
return slotId == 1 ? Settings.System.RINGTONE2 : Settings.System.RINGTONE;
} else if ((type & TYPE_NOTIFICATION) != 0) {
return Settings.System.NOTIFICATION_SOUND;
} else if ((type & TYPE_ALARM) != 0) {
@@ -957,13 +998,22 @@ public class RingtoneManager {

/** {@hide} */
public static Uri getCacheForType(int type) {
return getCacheForType(type, UserHandle.getCallingUserId());
return getCacheForTypeBySlot(type, UserHandle.getCallingUserId(),
SubscriptionManager.getDefaultVoicePhoneId());
}

/** {@hide} */
public static Uri getCacheForType(int type, int userId) {
return getCacheForTypeBySlot(type, userId, SubscriptionManager.getDefaultVoicePhoneId());
}

/** {@hide} */
public static Uri getCacheForTypeBySlot(int type, int userId, int slotId) {
if ((type & TYPE_RINGTONE) != 0) {
return ContentProvider.maybeAddUserId(Settings.System.RINGTONE_CACHE_URI, userId);
Uri ringtoneUri = slotId == 1
? Settings.System.RINGTONE2_CACHE_URI
: Settings.System.RINGTONE_CACHE_URI;
return ContentProvider.maybeAddUserId(ringtoneUri, userId);
} else if ((type & TYPE_NOTIFICATION) != 0) {
return ContentProvider.maybeAddUserId(Settings.System.NOTIFICATION_SOUND_CACHE_URI,
userId);
@@ -988,6 +1038,7 @@ public class RingtoneManager {
*
* @param defaultRingtoneUri The default {@link Uri}. For example,
* {@link System#DEFAULT_RINGTONE_URI},
* {@link System#DEFAULT_RINGTONE2_URI},
* {@link System#DEFAULT_NOTIFICATION_URI}, or
* {@link System#DEFAULT_ALARM_ALERT_URI}.
* @return The type of the defaultRingtoneUri, or -1.
@@ -996,7 +1047,8 @@ public class RingtoneManager {
defaultRingtoneUri = ContentProvider.getUriWithoutUserId(defaultRingtoneUri);
if (defaultRingtoneUri == null) {
return -1;
} else if (defaultRingtoneUri.equals(Settings.System.DEFAULT_RINGTONE_URI)) {
} else if (defaultRingtoneUri.equals(Settings.System.DEFAULT_RINGTONE_URI)
|| defaultRingtoneUri.equals(Settings.System.DEFAULT_RINGTONE2_URI)) {
return TYPE_RINGTONE;
} else if (defaultRingtoneUri.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
return TYPE_NOTIFICATION;
@@ -1012,13 +1064,31 @@ public class RingtoneManager {
* Rather than returning the actual ringtone's sound {@link Uri}, this will
* return the symbolic {@link Uri} which will resolved to the actual sound
* when played.
*
*
* @param type The ringtone type whose default should be returned.
* @return The {@link Uri} of the default ringtone for the given type.
*/
public static Uri getDefaultUri(int type) {
return getDefaultUriBySlot(type, SubscriptionManager.getDefaultVoicePhoneId());
}

/**
* Returns the {@link Uri} for the default ringtone by slotId of a particular type.
* Rather than returning the actual ringtone's sound {@link Uri}, this will
* return the symbolic {@link Uri} which will resolved to the actual sound
* when played.
*
* @param type The ringtone type whose default should be returned.
* @param slotId The slotId whose default should be returned.
* @return The {@link Uri} of the default ringtone for the given type.
*
* @hide
*/
public static Uri getDefaultUriBySlot(int type, int slotId) {
if ((type & TYPE_RINGTONE) != 0) {
return Settings.System.DEFAULT_RINGTONE_URI;
return slotId == 1
? Settings.System.DEFAULT_RINGTONE2_URI
: Settings.System.DEFAULT_RINGTONE_URI;
} else if ((type & TYPE_NOTIFICATION) != 0) {
return Settings.System.DEFAULT_NOTIFICATION_URI;
} else if ((type & TYPE_ALARM) != 0) {

+ 7
- 3
packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java View File

@@ -146,6 +146,7 @@ public class SettingsHelper {
} else if (isAlreadyConfiguredCriticalAccessibilitySetting(name)) {
return;
} else if (Settings.System.RINGTONE.equals(name)
|| Settings.System.RINGTONE2.equals(name)
|| Settings.System.NOTIFICATION_SOUND.equals(name)
|| Settings.System.ALARM_ALERT.equals(name)) {
setRingtone(name, value);
@@ -178,11 +179,12 @@ public class SettingsHelper {

public String onBackupValue(String name, String value) {
// Special processing for backing up ringtones & notification sounds
if (Settings.System.RINGTONE.equals(name)
if (Settings.System.RINGTONE.equals(name) || Settings.System.RINGTONE2.equals(name)
|| Settings.System.NOTIFICATION_SOUND.equals(name)
|| Settings.System.ALARM_ALERT.equals(name)) {
if (value == null) {
if (Settings.System.RINGTONE.equals(name)) {
if (Settings.System.RINGTONE.equals(name)
|| Settings.System.RINGTONE2.equals(name)) {
// For ringtones, we need to distinguish between non-telephony vs telephony
if (mTelephonyManager != null && mTelephonyManager.isVoiceCapable()) {
// Backup a null ringtone as silent on voice-capable devices
@@ -206,7 +208,7 @@ public class SettingsHelper {
/**
* Sets the ringtone of type specified by the name.
*
* @param name should be Settings.System.RINGTONE, Settings.System.NOTIFICATION_SOUND
* @param name should be Settings.System.RINGTONE, Settings.System.RINGTONE2, Settings.System.NOTIFICATION_SOUND
* or Settings.System.ALARM_ALERT.
* @param value can be a canonicalized uri or "_silent" to indicate a silent (null) ringtone.
*/
@@ -233,6 +235,8 @@ public class SettingsHelper {
switch (name) {
case Settings.System.RINGTONE:
return RingtoneManager.TYPE_RINGTONE;
case Settings.System.RINGTONE2:
return RingtoneManager.TYPE_RINGTONE;
case Settings.System.NOTIFICATION_SOUND:
return RingtoneManager.TYPE_NOTIFICATION;
case Settings.System.ALARM_ALERT:

+ 6
- 0
packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java View File

@@ -2616,8 +2616,14 @@ class SettingsProtoDumpUtil {
Settings.System.RINGTONE,
SystemSettingsProto.Ringtone.DEFAULT_URI);
dumpSetting(s, p,
Settings.System.RINGTONE2,
SystemSettingsProto.Ringtone.DEFAULT_URI);
dumpSetting(s, p,
Settings.System.RINGTONE_CACHE,
SystemSettingsProto.Ringtone.CACHE);
dumpSetting(s, p,
Settings.System.RINGTONE2_CACHE,
SystemSettingsProto.Ringtone.CACHE);
p.end(ringtoneToken);

final long rotationToken = p.start(SystemSettingsProto.ROTATION);

+ 5
- 0
packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java View File

@@ -767,6 +767,9 @@ public class SettingsProvider extends ContentProvider {
if (Settings.System.RINGTONE_CACHE_URI.equals(uri)) {
cacheRingtoneSetting = Settings.System.RINGTONE;
cacheName = Settings.System.RINGTONE_CACHE;
} else if (Settings.System.RINGTONE2_CACHE_URI.equals(uri)) {
cacheRingtoneSetting = Settings.System.RINGTONE2;
cacheName = Settings.System.RINGTONE2_CACHE;
} else if (Settings.System.NOTIFICATION_SOUND_CACHE_URI.equals(uri)) {
cacheRingtoneSetting = Settings.System.NOTIFICATION_SOUND;
cacheName = Settings.System.NOTIFICATION_SOUND_CACHE;
@@ -1724,6 +1727,8 @@ public class SettingsProvider extends ContentProvider {
String cacheName = null;
if (Settings.System.RINGTONE.equals(name)) {
cacheName = Settings.System.RINGTONE_CACHE;
} else if (Settings.System.RINGTONE2.equals(name)) {
cacheName = Settings.System.RINGTONE2_CACHE;
} else if (Settings.System.NOTIFICATION_SOUND.equals(name)) {
cacheName = Settings.System.NOTIFICATION_SOUND_CACHE;
} else if (Settings.System.ALARM_ALERT.equals(name)) {

Loading…
Cancel
Save