Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 09c4eaf7 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by Android Git Automerger
Browse files

am 7f9e9012: Merge "RingtoneManager: query results depend on caller permission" into mnc-dev

* commit '7f9e9012':
  RingtoneManager: query results depend on caller permission
parents 8ac962a7 7f9e9012
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -23,9 +23,11 @@ import android.annotation.SdkConstant.SdkConstantType;
import android.app.Activity;
import android.content.ContentUris;
import android.content.Context;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.Environment;
import android.os.Process;
import android.provider.MediaStore;
import android.provider.Settings;
import android.provider.Settings.System;
@@ -359,6 +361,9 @@ public class RingtoneManager {
     * If {@link RingtoneManager#RingtoneManager(Activity)} was not used, the
     * caller should manage the returned cursor through its activity's life
     * cycle to prevent leaking the cursor.
     * <p>
     * Note that the list of ringtones available will differ depending on whether the caller
     * has the {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission.
     *
     * @return A {@link Cursor} of all the ringtones available.
     * @see #ID_COLUMN_INDEX
@@ -455,7 +460,9 @@ public class RingtoneManager {

    /**
     * Returns a valid ringtone URI. No guarantees on which it returns. If it
     * cannot find one, returns null.
     * cannot find one, returns null. If it can only find one on external storage and the caller
     * doesn't have the {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission,
     * returns null.
     *
     * @param context The context to use for querying.
     * @return A ringtone URI, or null if one cannot be found.
@@ -495,6 +502,12 @@ public class RingtoneManager {
    }

    private Cursor getMediaRingtones() {
        if (PackageManager.PERMISSION_GRANTED != mContext.checkPermission(
                android.Manifest.permission.READ_EXTERNAL_STORAGE,
                Process.myPid(), Process.myUid())) {
            Log.w(TAG, "No READ_EXTERNAL_STORAGE permission, ignoring ringtones on ext storage");
            return null;
        }
         // Get the external media cursor. First check to see if it is mounted.
        final String status = Environment.getExternalStorageState();