mirror of
https://github.com/emanuele-f/PCAPdroid.git
synced 2026-07-03 21:21:12 +08:00
Fix possible IllegalStateException in mitm wizard
This commit is contained in:
parent
aa2efb8079
commit
4a1e24b710
@ -163,6 +163,14 @@ public class InstallCertificate extends StepFragment implements MitmListener {
|
||||
@Override
|
||||
public void onMitmGetCaCertificateResult(@Nullable String ca_pem) {
|
||||
mAddon.disconnect();
|
||||
|
||||
// NOTE: this may be called when context is null
|
||||
Context context = getContext();
|
||||
if(context == null) {
|
||||
Log.d(TAG, "null context");
|
||||
return;
|
||||
}
|
||||
|
||||
mCaPem = ca_pem;
|
||||
|
||||
// NOTE: onMitmGetCaCertificateResult can be called by fallbackToCertExport
|
||||
@ -178,7 +186,7 @@ public class InstallCertificate extends StepFragment implements MitmListener {
|
||||
certOk();
|
||||
else {
|
||||
// Cert not installed
|
||||
MitmAddon.setDecryptionSetupDone(requireContext(), false);
|
||||
MitmAddon.setDecryptionSetupDone(context, false);
|
||||
mStepIcon.setColorFilter(mWarnColor);
|
||||
mStepButton.setEnabled(true);
|
||||
|
||||
@ -195,7 +203,7 @@ public class InstallCertificate extends StepFragment implements MitmListener {
|
||||
});
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(requireContext(), "addon did not return certificate", Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(context, "addon did not return certificate", Toast.LENGTH_LONG).show();
|
||||
certFail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,9 @@ package com.emanuelef.remote_capture.interfaces;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface MitmListener {
|
||||
// NOTE: for fragments, this may be called when their context is null
|
||||
void onMitmGetCaCertificateResult(@Nullable String ca_pem);
|
||||
|
||||
void onMitmServiceConnect();
|
||||
void onMitmServiceDisconnect();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user