title: READ_EXTERNAL_STORAGE permission needed to open content://media/external/[...] in MediaPlayer?
body: <p>I'm playing an alarm sound in my App. On most devices this works flawlessly. Some users have described that no sound is playing. This seems to mainly affect Samsung and Huawei devices. This is a minimal example of where things fail:</p>
  
  <pre><code>alarmUri = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_ALARM);
  try {
              if(!mediaPlayer.isPlaying()) {
                  mediaPlayer.setDataSource(this, alarmUri);   
                  AudioManager audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
                  mediaPlayer.setAudioStreamType(audioManager.STREAM_ALARM);
                  mediaPlayer.setLooping(true);
                  mediaPlayer.prepare();
                  mediaPlayer.start();
              }
          } catch(Exception e) {                
                  Log.d(logtag,"Exception: " + e);
          }
  </code></pre>
  
  <p>For affected users, the following exception is thrown:</p>
  
  <blockquote>
    <p>Exception java.io.IOException: setDataSource failed.:
    status=0x80000000</p>
  </blockquote>
  
  <p>This only seems to happen when alarmURI looks like this: <code>content://media/external/audio/media/11</code>, i.e. it resides on an external store. I have never seen it occur when alarmURI looks this this <code>content://media/internal/audio/media/40</code>.</p>
  
  <p>Do I need the <code>READ_EXTERNAL_STORAGE</code> permission in order to play the sound, if the Uri I use contains the <code>/external/</code> part? Or am I missing something else? Normally, I would  expect a SecurityException to be thrown, if the permission was the issue. </p>
  
  <p>/e: I could reproduce the bug on my device. Here is a more detailed error report:</p>
  
  <blockquote>
    <p>Exception java.lang.SecurityException: Permission Denial: reading
    com.android.providers.media.MediaProvider uri
    content://media/external/audio/media from pid=27158, uid=10177
    requires android.permission.READ_EXTERNAL_STORAGE, or
    grantUriPermission()</p>
  </blockquote>