Merge "Fix IllegalStateException in onOptionsItemSelected" into ub-contactsdialer-a-dev
diff --git a/src/com/android/contacts/editor/ContactEditorBaseFragment.java b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
index 1c0ecab..2be2d3b 100644
--- a/src/com/android/contacts/editor/ContactEditorBaseFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
@@ -713,8 +713,10 @@
     }
 
     private void onRingtonePicked(Uri pickedUri) {
-        if (pickedUri == null || RingtoneManager.isDefault(pickedUri)) {
-            mCustomRingtone = null;
+        if (pickedUri == null) {
+            mCustomRingtone = ""; // silent ringtone
+        } else if (RingtoneManager.isDefault(pickedUri)){
+            mCustomRingtone = null; // default ringtone
         } else {
             mCustomRingtone = pickedUri.toString();
         }
@@ -914,7 +916,11 @@
 
         final Uri ringtoneUri;
         if (mCustomRingtone != null) {
-            ringtoneUri = Uri.parse(mCustomRingtone);
+            if ("".equals(mCustomRingtone)) { // select silent ringtone in RingtonePickerActivity
+                ringtoneUri = null;
+            } else {
+                ringtoneUri = Uri.parse(mCustomRingtone);
+            }
         } else {
             // Otherwise pick default ringtone Uri so that something is selected.
             ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);