1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.internal.net; 18 19 import android.app.PendingIntent; 20 import android.content.Context; 21 import android.content.Intent; 22 import android.os.Parcel; 23 import android.os.Parcelable; 24 25 import java.util.List; 26 27 /** 28 * A simple container used to carry information in VpnBuilder, VpnDialogs, 29 * and com.android.server.connectivity.Vpn. Internal use only. 30 * 31 * @hide 32 */ 33 public class VpnConfig implements Parcelable { 34 35 public static final String SERVICE_INTERFACE = "android.net.VpnService"; 36 37 public static final String LEGACY_VPN = "[Legacy VPN]"; 38 39 public static Intent getIntentForConfirmation() { 40 Intent intent = new Intent(); 41 intent.setClassName("com.android.vpndialogs", "com.android.vpndialogs.ConfirmDialog"); 42 return intent; 43 } 44 45 public static PendingIntent getIntentForStatusPanel(Context context, VpnConfig config) { 46 Intent intent = new Intent(); 47 intent.setClassName("com.android.vpndialogs", "com.android.vpndialogs.ManageDialog"); 48 intent.putExtra("config", config); 49 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY | 50 Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); 51 return PendingIntent.getActivity(context, 0, intent, (config == null) ? 52 PendingIntent.FLAG_NO_CREATE : PendingIntent.FLAG_CANCEL_CURRENT); 53 } 54 55 public String user; 56 public String interfaze; 57 public String session; 58 public int mtu = -1; 59 public String addresses; 60 public String routes; 61 public List<String> dnsServers; 62 public List<String> searchDomains; 63 public PendingIntent configureIntent; 64 public long startTime = -1; 65 66 @Override 67 public int describeContents() { 68 return 0; 69 } 70 71 @Override 72 public void writeToParcel(Parcel out, int flags) { 73 out.writeString(user); 74 out.writeString(interfaze); 75 out.writeString(session); 76 out.writeInt(mtu); 77 out.writeString(addresses); 78 out.writeString(routes); 79 out.writeStringList(dnsServers); 80 out.writeStringList(searchDomains); 81 out.writeParcelable(configureIntent, flags); 82 out.writeLong(startTime); 83 } 84 85 public static final Parcelable.Creator<VpnConfig> CREATOR = 86 new Parcelable.Creator<VpnConfig>() { 87 @Override 88 public VpnConfig createFromParcel(Parcel in) { 89 VpnConfig config = new VpnConfig(); 90 config.user = in.readString(); 91 config.interfaze = in.readString(); 92 config.session = in.readString(); 93 config.mtu = in.readInt(); 94 config.addresses = in.readString(); 95 config.routes = in.readString(); 96 config.dnsServers = in.createStringArrayList(); 97 config.searchDomains = in.createStringArrayList(); 98 config.configureIntent = in.readParcelable(null); 99 config.startTime = in.readLong(); 100 return config; 101 } 102 103 @Override 104 public VpnConfig[] newArray(int size) { 105 return new VpnConfig[size]; 106 } 107 }; 108 } 109