Fixed ApnEditor crash issue
This root caused is that we closed the managed cursor which lifecycle is managed by Activity. Actually, we don't need the managed cursor in this case, just use the normal cursor and close it after we got the apn data from the database. Bug: 77894798 Test: make ROBOTEST_FILTER=ApnEditorTest -j40 RunSettingsRoboTests Change-Id: I6eb80bbd53354e00e871e974f520668dcbceac63
This commit is contained in:
@@ -1195,12 +1195,19 @@ public class ApnEditor extends SettingsPreferenceFragment
|
||||
}
|
||||
}
|
||||
|
||||
private ApnData getApnDataFromUri(Uri uri) {
|
||||
ApnData apnData;
|
||||
try (Cursor cursor = getActivity().managedQuery(
|
||||
uri, sProjection, null /* selection */, null /* sortOrder */)) {
|
||||
cursor.moveToFirst();
|
||||
apnData = new ApnData(uri, cursor);
|
||||
@VisibleForTesting
|
||||
ApnData getApnDataFromUri(Uri uri) {
|
||||
ApnData apnData = null;
|
||||
try (Cursor cursor = getContentResolver().query(
|
||||
uri,
|
||||
sProjection,
|
||||
null /* selection */,
|
||||
null /* selectionArgs */,
|
||||
null /* sortOrder */)) {
|
||||
if (cursor != null) {
|
||||
cursor.moveToFirst();
|
||||
apnData = new ApnData(uri, cursor);
|
||||
}
|
||||
}
|
||||
|
||||
if (apnData == null) {
|
||||
|
Reference in New Issue
Block a user