Merge "Use the try catch to deal with the StaleDataException." am: 1fa847ad64 am: 15698dd32d am: 4b16237ab7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1433917 Change-Id: I3013edfee1921ce0dce503355d0c866e345e7538
This commit is contained in:
@@ -34,6 +34,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
import android.database.Cursor;
|
||||
import android.database.StaleDataException;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.os.FileUtils;
|
||||
@@ -492,7 +493,12 @@ public class RingtoneManager {
|
||||
public Uri getRingtoneUri(int position) {
|
||||
// use cursor directly instead of requerying it, which could easily
|
||||
// cause position to shuffle.
|
||||
if (mCursor == null || !mCursor.moveToPosition(position)) {
|
||||
try {
|
||||
if (mCursor == null || !mCursor.moveToPosition(position)) {
|
||||
return null;
|
||||
}
|
||||
} catch (StaleDataException | IllegalStateException e) {
|
||||
Log.e(TAG, "Unexpected Exception has been catched.", e);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user