diff options
| author | Robin Lee <rgl@google.com> | 2016-04-11 11:23:10 +0100 | 
|---|---|---|
| committer | Arne Schwabe <arne@rfc2549.org> | 2016-04-12 15:31:12 +0200 | 
| commit | 973e2f29c3a7948104320dde7c184ca56db4c021 (patch) | |
| tree | d2faa07faf19bb8ae74cca9d2fef3215ebe709c1 | |
| parent | f4bba2b57f4d0e616010a2c25d92d5656bede036 (diff) | |
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.
| -rw-r--r-- | main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java | 11 | 
1 files changed, 5 insertions, 6 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java index 536abdc2..ef397fa8 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java +++ b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java @@ -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 */  | 
