]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Accept a profile's UUID when initiating
authorTobias Brunner <tobias@strongswan.org>
Wed, 6 Jun 2018 14:29:02 +0000 (16:29 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 3 Jul 2018 09:31:32 +0000 (11:31 +0200)
src/frontends/android/app/src/main/java/org/strongswan/android/ui/MainActivity.java

index cd5504ac9b31db13f1c37ae39ece232531bb21e2..d91898b36850f6ca4e332aad8551d89f83e36d2b 100644 (file)
@@ -58,6 +58,7 @@ import org.strongswan.android.ui.VpnProfileListFragment.OnVpnProfileSelectedList
 import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.UUID;
 
 public class MainActivity extends AppCompatActivity implements OnVpnProfileSelectedListener
 {
@@ -341,14 +342,30 @@ public class MainActivity extends AppCompatActivity implements OnVpnProfileSelec
         */
        private void startVpnProfile(Intent intent, boolean foreground)
        {
-               long profileId = intent.getLongExtra(EXTRA_VPN_PROFILE_ID, 0);
-               if (profileId <= 0)
-               {       /* invalid invocation */
-                       return;
-               }
+               VpnProfile profile = null;
+
                VpnProfileDataSource dataSource = new VpnProfileDataSource(this);
                dataSource.open();
-               VpnProfile profile = dataSource.getVpnProfile(profileId);
+               String profileUUID = intent.getStringExtra(EXTRA_VPN_PROFILE_ID);
+               if (profileUUID != null)
+               {
+                       try
+                       {
+                               profile = dataSource.getVpnProfile(UUID.fromString(profileUUID));
+                       }
+                       catch (Exception e)
+                       {       /* invalid UUID */
+                               e.printStackTrace();
+                       }
+               }
+               else
+               {
+                       long profileId = intent.getLongExtra(EXTRA_VPN_PROFILE_ID, 0);
+                       if (profileId > 0)
+                       {
+                               profile = dataSource.getVpnProfile(profileId);
+                       }
+               }
                dataSource.close();
 
                if (profile != null)