Merge "Fix NPE in MissedCallNotifierImpl"
diff --git a/src/com/android/server/telecom/Ringer.java b/src/com/android/server/telecom/Ringer.java
index a5bcca0..635d500 100644
--- a/src/com/android/server/telecom/Ringer.java
+++ b/src/com/android/server/telecom/Ringer.java
@@ -120,6 +120,11 @@
return false;
}
+ // Don't ring/acquire focus if there is no ringtone
+ if (mRingtoneFactory.getRingtone(foregroundCall) == null) {
+ isRingerAudible = false;
+ }
+
if (isRingerAudible) {
mRingingCall = foregroundCall;
Log.addEvent(foregroundCall, LogUtils.Events.START_RINGER);
diff --git a/src/com/android/server/telecom/RingtoneFactory.java b/src/com/android/server/telecom/RingtoneFactory.java
index 4bf731c..b14e1ab 100644
--- a/src/com/android/server/telecom/RingtoneFactory.java
+++ b/src/com/android/server/telecom/RingtoneFactory.java
@@ -67,9 +67,18 @@
if(ringtone == null) {
// Contact didn't specify ringtone or custom Ringtone creation failed. Get default
// ringtone for user or profile.
- ringtone = RingtoneManager.getRingtone(
- hasDefaultRingtoneForUser(userContext) ? userContext : mContext,
- Settings.System.DEFAULT_RINGTONE_URI);
+ Context contextToUse = hasDefaultRingtoneForUser(userContext) ? userContext : mContext;
+ Uri defaultRingtoneUri;
+ if (UserManager.get(contextToUse).isUserUnlocked(contextToUse.getUserId())) {
+ defaultRingtoneUri = RingtoneManager.getActualDefaultRingtoneUri(contextToUse,
+ RingtoneManager.TYPE_RINGTONE);
+ } else {
+ defaultRingtoneUri = Settings.System.DEFAULT_RINGTONE_URI;
+ }
+ if (defaultRingtoneUri == null) {
+ return null;
+ }
+ ringtone = RingtoneManager.getRingtone(contextToUse, defaultRingtoneUri);
}
if (ringtone != null) {
ringtone.setStreamType(AudioManager.STREAM_RING);