android: Accept a profile's UUID when initiating
This commit is contained in:
+23
-6
@@ -58,6 +58,7 @@ import org.strongswan.android.ui.VpnProfileListFragment.OnVpnProfileSelectedList
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements OnVpnProfileSelectedListener
|
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)
|
private void startVpnProfile(Intent intent, boolean foreground)
|
||||||
{
|
{
|
||||||
long profileId = intent.getLongExtra(EXTRA_VPN_PROFILE_ID, 0);
|
VpnProfile profile = null;
|
||||||
if (profileId <= 0)
|
|
||||||
{ /* invalid invocation */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
VpnProfileDataSource dataSource = new VpnProfileDataSource(this);
|
VpnProfileDataSource dataSource = new VpnProfileDataSource(this);
|
||||||
dataSource.open();
|
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();
|
dataSource.close();
|
||||||
|
|
||||||
if (profile != null)
|
if (profile != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user