Handle picker defaults for notification and alarm

when determining the URI for the default choice in ringtone picker, wait
until we parse whether we're picking for ringtone, notification, or alarm.
Use this knowledge instead of always filling in with value for ringtone.

Bug: 30551658
diff --git a/src/com/android/providers/media/RingtonePickerActivity.java b/src/com/android/providers/media/RingtonePickerActivity.java
index 0774256..86d55b3 100644
--- a/src/com/android/providers/media/RingtonePickerActivity.java
+++ b/src/com/android/providers/media/RingtonePickerActivity.java
@@ -142,6 +142,15 @@
 
         Intent intent = getIntent();
 
+        // Give the Activity so it can do managed queries
+        mRingtoneManager = new RingtoneManager(this);
+
+        // Get the types of ringtones to show
+        mType = intent.getIntExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, -1);
+        if (mType != -1) {
+            mRingtoneManager.setType(mType);
+        }
+
         /*
          * Get whether to show the 'Default' item, and the URI to play when the
          * default is clicked
@@ -149,7 +158,16 @@
         mHasDefaultItem = intent.getBooleanExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
         mUriForDefaultItem = intent.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI);
         if (mUriForDefaultItem == null) {
-            mUriForDefaultItem = Settings.System.DEFAULT_RINGTONE_URI;
+            if (mType == RingtoneManager.TYPE_NOTIFICATION) {
+                mUriForDefaultItem = Settings.System.DEFAULT_NOTIFICATION_URI;
+            } else if (mType == RingtoneManager.TYPE_ALARM) {
+                mUriForDefaultItem = Settings.System.DEFAULT_ALARM_ALERT_URI;
+            } else if (mType == RingtoneManager.TYPE_RINGTONE) {
+                mUriForDefaultItem = Settings.System.DEFAULT_RINGTONE_URI;
+            } else {
+                // or leave it null for silence.
+                mUriForDefaultItem = Settings.System.DEFAULT_RINGTONE_URI;
+            }
         }
 
         if (savedInstanceState != null) {
@@ -162,14 +180,6 @@
                 RingtoneManager.EXTRA_RINGTONE_AUDIO_ATTRIBUTES_FLAGS,
                 0 /*defaultValue == no flags*/);
 
-        // Give the Activity so it can do managed queries
-        mRingtoneManager = new RingtoneManager(this);
-
-        // Get the types of ringtones to show
-        mType = intent.getIntExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, -1);
-        if (mType != -1) {
-            mRingtoneManager.setType(mType);
-        }
 
         mCursor = new LocalizedCursor(mRingtoneManager.getCursor(), getResources(), COLUMN_LABEL);