Merge "Don\'t backup ringtone on non-telephony devices." into lmp-mr1-dev automerge: a30fdf7
automerge: 8298afb
* commit '8298afbc78f2b2c609f2e52ca3fc7c6a2cd9797e':
Don't backup ringtone on non-telephony devices.
This commit is contained in:
@@ -30,6 +30,7 @@ import android.os.RemoteException;
|
|||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -38,11 +39,14 @@ public class SettingsHelper {
|
|||||||
private static final String SILENT_RINGTONE = "_silent";
|
private static final String SILENT_RINGTONE = "_silent";
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private AudioManager mAudioManager;
|
private AudioManager mAudioManager;
|
||||||
|
private TelephonyManager mTelephonyManager;
|
||||||
|
|
||||||
public SettingsHelper(Context context) {
|
public SettingsHelper(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mAudioManager = (AudioManager) context
|
mAudioManager = (AudioManager) context
|
||||||
.getSystemService(Context.AUDIO_SERVICE);
|
.getSystemService(Context.AUDIO_SERVICE);
|
||||||
|
mTelephonyManager = (TelephonyManager) context
|
||||||
|
.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,12 +79,23 @@ public class SettingsHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String onBackupValue(String name, String value) {
|
public String onBackupValue(String name, String value) {
|
||||||
// Special processing for backing up ringtones
|
// Special processing for backing up ringtones & notification sounds
|
||||||
if (Settings.System.RINGTONE.equals(name)
|
if (Settings.System.RINGTONE.equals(name)
|
||||||
|| Settings.System.NOTIFICATION_SOUND.equals(name)) {
|
|| Settings.System.NOTIFICATION_SOUND.equals(name)) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
// Silent ringtone
|
if (Settings.System.RINGTONE.equals(name)) {
|
||||||
return SILENT_RINGTONE;
|
// 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
|
||||||
|
return SILENT_RINGTONE;
|
||||||
|
} else {
|
||||||
|
// Skip backup of ringtone on non-telephony devices.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Backup a null notification sound as silent
|
||||||
|
return SILENT_RINGTONE;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return getCanonicalRingtoneValue(value);
|
return getCanonicalRingtoneValue(value);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user