Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,6 @@
package android.media;
import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
......@@ -573,12 +572,13 @@ public class RingtoneManager {
FileUtils.closeQuietly(cursor);
throw new FileNotFoundException("No item found for " + baseUri);
} else if (cursor.getCount() > 1) {
int resultCount = cursor.getCount();
// Find more than 1 result.
// We are not sure which one is the right ringtone file so just abandon this case.
FileUtils.closeQuietly(cursor);
throw new FileNotFoundException(
"Find multiple ringtone candidates by title+ringtone_type query: count: "
+ cursor.getCount());
+ resultCount);
}
if (cursor.moveToFirst()) {
ringtoneUri = ContentUris.withAppendedId(baseUri, cursor.getLong(0));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment