[Settings] Crash when resetting downloaded eSIM
Context need to be maintained when performing async operation in background thread. Bug: 202787946 Test: local Change-Id: Ia5b81ae66e9482b10df5133b2f1444fc007a78e8
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.settings.network;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -75,23 +76,24 @@ public class EraseEuiccDataDialogFragment extends InstrumentedDialogFragment imp
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||||
if (ConfirmationSimDeletionPredicate.getSingleton().test(getContext())) {
|
Context context = getContext();
|
||||||
|
if (ConfirmationSimDeletionPredicate.getSingleton().test(context)) {
|
||||||
// Create a "verify it's you" verification over keyguard
|
// Create a "verify it's you" verification over keyguard
|
||||||
// when "erase" button been pressed.
|
// when "erase" button been pressed.
|
||||||
// This might protect from erasing by some automation process.
|
// This might protect from erasing by some automation process.
|
||||||
WifiDppUtils.showLockScreen(getContext(), () -> runAsyncWipe());
|
WifiDppUtils.showLockScreen(context, () -> runAsyncWipe(context));
|
||||||
} else {
|
} else {
|
||||||
runAsyncWipe();
|
runAsyncWipe(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runAsyncWipe() {
|
private void runAsyncWipe(Context context) {
|
||||||
AsyncTask.execute(new Runnable() {
|
AsyncTask.execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
RecoverySystem.wipeEuiccData(
|
RecoverySystem.wipeEuiccData(
|
||||||
getContext(), PACKAGE_NAME_EUICC_DATA_MANAGEMENT_CALLBACK);
|
context, PACKAGE_NAME_EUICC_DATA_MANAGEMENT_CALLBACK);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user