Catch UnsupportedOperationException of startLegacyVpn

startLegacyVpn may throw UnsupportedOperationException. Instead
of crashing Settings, catch the exception and show a Toast.

Bug: 161776767
Test: Manual test, connect legacy vpn profile and observe Toast.
Change-Id: I5947f2043aa68478f659b34531202f225eab4568
This commit is contained in:
Hansen Kurli
2023-11-08 15:20:51 +08:00
parent e8df63f148
commit eea7c3c8d5

View File

@@ -207,6 +207,10 @@ public class ConfigDialogFragment extends InstrumentedDialogFragment implements
mService.startLegacyVpn(profile); mService.startLegacyVpn(profile);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
Toast.makeText(mContext, R.string.vpn_no_network, Toast.LENGTH_LONG).show(); Toast.makeText(mContext, R.string.vpn_no_network, Toast.LENGTH_LONG).show();
} catch (UnsupportedOperationException e) {
Log.e(TAG, "Attempted to start an unsupported VPN type.");
Toast.makeText(mContext, R.string.vpn_insecure_dialog_subtitle, Toast.LENGTH_LONG)
.show();
} }
} }
} }