0
0
mirror of https://github.com/schwabe/ics-openvpn.git synced 2024-09-20 12:02:28 +02:00

Handle case where profileUUID is missing

Android NYC+ might start the VPN service on its own without any
useful intent extras saying which profile to load.

Handle it the same as the restart case -- use the most recent profile
instead of crashing.
This commit is contained in:
Robin Lee 2016-04-11 11:23:10 +01:00 committed by Arne Schwabe
parent f4bba2b57f
commit 973e2f29c3

View File

@ -358,8 +358,11 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
return START_REDELIVER_INTENT;
}
/* The intent is null when the service has been restarted */
if (intent == null) {
if (intent != null && intent.hasExtra(getPackageName() + ".profileUUID")) {
String profileUUID = intent.getStringExtra(getPackageName() + ".profileUUID");
mProfile = ProfileManager.get(this, profileUUID);
} else {
/* The intent is null when we are set as always-on or the service has been restarted. */
mProfile = ProfileManager.getLastConnectedProfile(this, false);
VpnStatus.logInfo(R.string.service_restarted);
@ -374,10 +377,6 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
/* Recreate the intent */
intent = mProfile.getStartServiceIntent(this);
} else {
String profileUUID = intent.getStringExtra(getPackageName() + ".profileUUID");
mProfile = ProfileManager.get(this, profileUUID);
}
/* start the OpenVPN process itself in a background thread */