public static final int SPLIT_TUNNELING_BLOCK_IPV6 = 2;
private String mName, mGateway, mUsername, mPassword, mCertificate, mUserCertificate;
- private String mRemoteId, mLocalId, mExcludedSubnets, mIncludedSubnets;
+ private String mRemoteId, mLocalId, mExcludedSubnets, mIncludedSubnets, mSelectedApps;
private Integer mMTU, mPort, mSplitTunneling;
+ private SelectedAppsHandling mSelectedAppsHandling = SelectedAppsHandling.SELECTED_APPS_DISABLE;
private VpnType mVpnType;
private UUID mUUID;
private long mId = -1;
+ public enum SelectedAppsHandling
+ {
+ SELECTED_APPS_DISABLE(0),
+ SELECTED_APPS_EXCLUDE(1),
+ SELECTED_APPS_ONLY(2);
+
+ private Integer mValue;
+
+ SelectedAppsHandling(int value)
+ {
+ mValue = value;
+ }
+
+ public Integer getValue()
+ {
+ return mValue;
+ }
+ }
+
public VpnProfile()
{
this.mUUID = UUID.randomUUID();
{
this.mIncludedSubnets = includedSubnets;
}
-
public String getIncludedSubnets()
{
return mIncludedSubnets;
}
+ public void setSelectedApps(String selectedApps)
+ {
+ this.mSelectedApps = selectedApps;
+ }
+
+ public String getSelectedApps()
+ {
+ return mSelectedApps;
+ }
+
+ public void setSelectedAppsHandling(SelectedAppsHandling selectedAppsHandling)
+ {
+ this.mSelectedAppsHandling = selectedAppsHandling;
+ }
+
+ public void setSelectedAppsHandling(Integer value)
+ {
+ mSelectedAppsHandling = SelectedAppsHandling.SELECTED_APPS_DISABLE;
+ for (SelectedAppsHandling handling : SelectedAppsHandling.values())
+ {
+ if (handling.mValue.equals(value))
+ {
+ mSelectedAppsHandling = handling;
+ break;
+ }
+ }
+ }
+
+ public SelectedAppsHandling getSelectedAppsHandling()
+ {
+ return mSelectedAppsHandling;
+ }
+
public Integer getSplitTunneling()
{
return mSplitTunneling;
public static final String KEY_REMOTE_ID = "remote_id";
public static final String KEY_EXCLUDED_SUBNETS = "excluded_subnets";
public static final String KEY_INCLUDED_SUBNETS = "included_subnets";
+ public static final String KEY_SELECTED_APPS = "selected_apps";
+ public static final String KEY_SELECTED_APPS_LIST = "selected_apps_list";
private DatabaseHelper mDbHelper;
private SQLiteDatabase mDatabase;
private static final String DATABASE_NAME = "strongswan.db";
private static final String TABLE_VPNPROFILE = "vpnprofile";
- private static final int DATABASE_VERSION = 11;
+ private static final int DATABASE_VERSION = 12;
public static final String DATABASE_CREATE =
"CREATE TABLE " + TABLE_VPNPROFILE + " (" +
KEY_LOCAL_ID + " TEXT," +
KEY_REMOTE_ID + " TEXT," +
KEY_EXCLUDED_SUBNETS + " TEXT," +
- KEY_INCLUDED_SUBNETS + " TEXT" +
+ KEY_INCLUDED_SUBNETS + " TEXT," +
+ KEY_SELECTED_APPS + " INTEGER," +
+ KEY_SELECTED_APPS_LIST + " TEXT" +
");";
private static final String[] ALL_COLUMNS = new String[] {
KEY_ID,
KEY_REMOTE_ID,
KEY_EXCLUDED_SUBNETS,
KEY_INCLUDED_SUBNETS,
+ KEY_SELECTED_APPS,
+ KEY_SELECTED_APPS_LIST,
};
private static class DatabaseHelper extends SQLiteOpenHelper
db.execSQL("ALTER TABLE " + TABLE_VPNPROFILE + " ADD " + KEY_INCLUDED_SUBNETS +
" TEXT;");
}
+ if (oldVersion < 12)
+ {
+ db.execSQL("ALTER TABLE " + TABLE_VPNPROFILE + " ADD " + KEY_SELECTED_APPS +
+ " INTEGER;");
+ db.execSQL("ALTER TABLE " + TABLE_VPNPROFILE + " ADD " + KEY_SELECTED_APPS_LIST +
+ " TEXT;");
+ }
}
private void updateColumns(SQLiteDatabase db)
profile.setRemoteId(cursor.getString(cursor.getColumnIndex(KEY_REMOTE_ID)));
profile.setExcludedSubnets(cursor.getString(cursor.getColumnIndex(KEY_EXCLUDED_SUBNETS)));
profile.setIncludedSubnets(cursor.getString(cursor.getColumnIndex(KEY_INCLUDED_SUBNETS)));
+ profile.setSelectedAppsHandling(getInt(cursor, cursor.getColumnIndex(KEY_SELECTED_APPS)));
+ profile.setSelectedApps(cursor.getString(cursor.getColumnIndex(KEY_SELECTED_APPS_LIST)));
return profile;
}
values.put(KEY_REMOTE_ID, profile.getRemoteId());
values.put(KEY_EXCLUDED_SUBNETS, profile.getExcludedSubnets());
values.put(KEY_INCLUDED_SUBNETS, profile.getIncludedSubnets());
+ values.put(KEY_SELECTED_APPS, profile.getSelectedAppsHandling().getValue());
+ values.put(KEY_SELECTED_APPS_LIST, profile.getSelectedApps());
return values;
}