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

Commit ab53ed39 authored by Wenhao Shi's avatar Wenhao Shi
Browse files

Fix error throwing by calling getCount before closing the cursor.

Test: no need
Bug: 320419200
Change-Id: I6c894080bf476fb21773e2a44ef1f67ca37e4347
parent c05d2fa7
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@


package android.media;
package android.media;


import android.Manifest;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.RequiresPermission;
@@ -573,12 +572,13 @@ public class RingtoneManager {
            FileUtils.closeQuietly(cursor);
            FileUtils.closeQuietly(cursor);
            throw new FileNotFoundException("No item found for " + baseUri);
            throw new FileNotFoundException("No item found for " + baseUri);
        } else if (cursor.getCount() > 1) {
        } else if (cursor.getCount() > 1) {
            int resultCount = cursor.getCount();
            // Find more than 1 result.
            // Find more than 1 result.
            // We are not sure which one is the right ringtone file so just abandon this case.
            // We are not sure which one is the right ringtone file so just abandon this case.
            FileUtils.closeQuietly(cursor);
            FileUtils.closeQuietly(cursor);
            throw new FileNotFoundException(
            throw new FileNotFoundException(
                    "Find multiple ringtone candidates by title+ringtone_type query: count: "
                    "Find multiple ringtone candidates by title+ringtone_type query: count: "
                            + cursor.getCount());
                            + resultCount);
        }
        }
        if (cursor.moveToFirst()) {
        if (cursor.moveToFirst()) {
            ringtoneUri = ContentUris.withAppendedId(baseUri, cursor.getLong(0));
            ringtoneUri = ContentUris.withAppendedId(baseUri, cursor.getLong(0));