mirror of
https://github.com/emanuele-f/PCAPdroid.git
synced 2026-06-11 21:01:45 +08:00
Fix possible IllegalStateException on VPN start
"IllegalStateException: Unavailable in lockdown mode" is happening on some devices. On most devices it just returnss a null intent
This commit is contained in:
parent
6b8ab97713
commit
5abc3a7e20
@ -148,14 +148,22 @@ public class CaptureHelper {
|
||||
return;
|
||||
}
|
||||
|
||||
Intent vpnPrepareIntent = VpnService.prepare(mContext);
|
||||
Intent vpnPrepareIntent = null;
|
||||
try {
|
||||
vpnPrepareIntent = VpnService.prepare(mContext);
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(vpnPrepareIntent != null) {
|
||||
final Intent prepareIntent = vpnPrepareIntent;
|
||||
|
||||
if (mLauncher != null)
|
||||
new AlertDialog.Builder(mContext)
|
||||
.setMessage(R.string.vpn_setup_msg)
|
||||
.setPositiveButton(R.string.ok, (dialog, whichButton) -> {
|
||||
try {
|
||||
mLauncher.launch(vpnPrepareIntent);
|
||||
mLauncher.launch(prepareIntent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Utils.showToastLong(mContext, R.string.no_intent_handler_found);
|
||||
mListener.onCaptureStartResult(false);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user