diff options
author | Sreeram Ramachandran <sreeram@google.com> | 2014-07-23 15:23:15 -0700 |
---|---|---|
committer | Sreeram Ramachandran <sreeram@google.com> | 2014-07-25 15:17:23 -0700 |
commit | 8cd33ed84e94036a5e1201485af7603dc6fb0d9b (patch) | |
tree | 5b822366b9faecffa2dfc8d6f4e0b70afc05c84b /core/java/android/net | |
parent | 2b92253021f6b117786ed445a42e19df9916d619 (diff) | |
download | frameworks_base-8cd33ed84e94036a5e1201485af7603dc6fb0d9b.zip frameworks_base-8cd33ed84e94036a5e1201485af7603dc6fb0d9b.tar.gz frameworks_base-8cd33ed84e94036a5e1201485af7603dc6fb0d9b.tar.bz2 |
Implement support for bypassable VPNs.
Bypassable VPNs grab all traffic by default (just like secure VPNs), but:
+ They allow all apps to choose other networks using the multinetwork APIs.
If these other networks are insecure ("untrusted"), they will enforce that the
app holds the necessary permissions, such as CHANGE_NETWORK_STATE.
+ They support consistent routing. If an app has an existing connection over
some other network when the bypassable VPN comes up, it's not interrupted.
Bug: 15347374
Change-Id: Iaee9c6f6fa8103215738570d2b65d3fcf10343f3
Diffstat (limited to 'core/java/android/net')
-rw-r--r-- | core/java/android/net/ConnectivityManager.java | 4 | ||||
-rw-r--r-- | core/java/android/net/IConnectivityManager.aidl | 3 | ||||
-rw-r--r-- | core/java/android/net/NetworkAgent.java | 7 | ||||
-rw-r--r-- | core/java/android/net/NetworkMisc.aidl | 19 | ||||
-rw-r--r-- | core/java/android/net/NetworkMisc.java | 57 | ||||
-rw-r--r-- | core/java/android/net/VpnService.java | 2 |
6 files changed, 87 insertions, 5 deletions
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index 0df4d45..30be4da 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -2068,9 +2068,9 @@ public class ConnectivityManager { /** {@hide} */ public void registerNetworkAgent(Messenger messenger, NetworkInfo ni, LinkProperties lp, - NetworkCapabilities nc, int score) { + NetworkCapabilities nc, int score, NetworkMisc misc) { try { - mService.registerNetworkAgent(messenger, ni, lp, nc, score); + mService.registerNetworkAgent(messenger, ni, lp, nc, score, misc); } catch (RemoteException e) { } } diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl index 8b12fb8..35f1305 100644 --- a/core/java/android/net/IConnectivityManager.aidl +++ b/core/java/android/net/IConnectivityManager.aidl @@ -22,6 +22,7 @@ import android.net.LinkProperties; import android.net.Network; import android.net.NetworkCapabilities; import android.net.NetworkInfo; +import android.net.NetworkMisc; import android.net.NetworkQuotaInfo; import android.net.NetworkRequest; import android.net.NetworkState; @@ -150,7 +151,7 @@ interface IConnectivityManager void unregisterNetworkFactory(in Messenger messenger); void registerNetworkAgent(in Messenger messenger, in NetworkInfo ni, in LinkProperties lp, - in NetworkCapabilities nc, int score); + in NetworkCapabilities nc, int score, in NetworkMisc misc); NetworkRequest requestNetwork(in NetworkCapabilities networkCapabilities, in Messenger messenger, int timeoutSec, in IBinder binder, int legacy); diff --git a/core/java/android/net/NetworkAgent.java b/core/java/android/net/NetworkAgent.java index 41eab02..a365af0 100644 --- a/core/java/android/net/NetworkAgent.java +++ b/core/java/android/net/NetworkAgent.java @@ -108,6 +108,11 @@ public abstract class NetworkAgent extends Handler { public NetworkAgent(Looper looper, Context context, String logTag, NetworkInfo ni, NetworkCapabilities nc, LinkProperties lp, int score) { + this(looper, context, logTag, ni, nc, lp, score, null); + } + + public NetworkAgent(Looper looper, Context context, String logTag, NetworkInfo ni, + NetworkCapabilities nc, LinkProperties lp, int score, NetworkMisc misc) { super(looper); LOG_TAG = logTag; mContext = context; @@ -119,7 +124,7 @@ public abstract class NetworkAgent extends Handler { ConnectivityManager cm = (ConnectivityManager)mContext.getSystemService( Context.CONNECTIVITY_SERVICE); cm.registerNetworkAgent(new Messenger(this), new NetworkInfo(ni), - new LinkProperties(lp), new NetworkCapabilities(nc), score); + new LinkProperties(lp), new NetworkCapabilities(nc), score, misc); } @Override diff --git a/core/java/android/net/NetworkMisc.aidl b/core/java/android/net/NetworkMisc.aidl new file mode 100644 index 0000000..c65583f --- /dev/null +++ b/core/java/android/net/NetworkMisc.aidl @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.net; + +parcelable NetworkMisc; diff --git a/core/java/android/net/NetworkMisc.java b/core/java/android/net/NetworkMisc.java new file mode 100644 index 0000000..34f6cf4 --- /dev/null +++ b/core/java/android/net/NetworkMisc.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.net; + +import android.os.Parcel; +import android.os.Parcelable; + +/** + * A grab-bag of information (metadata, policies, properties, etc) about a {@link Network}. + * + * @hide + */ +public class NetworkMisc implements Parcelable { + /** + * If the {@link Network} is a VPN, whether apps are allowed to bypass the VPN. This is set by + * a {@link VpnService} and used by {@link ConnectivityService} when creating a VPN. + */ + public boolean allowBypass; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeInt(allowBypass ? 1 : 0); + } + + public static final Creator<NetworkMisc> CREATOR = new Creator<NetworkMisc>() { + @Override + public NetworkMisc createFromParcel(Parcel in) { + NetworkMisc networkMisc = new NetworkMisc(); + networkMisc.allowBypass = in.readInt() != 0; + return networkMisc; + } + + @Override + public NetworkMisc[] newArray(int size) { + return new NetworkMisc[size]; + } + }; +} diff --git a/core/java/android/net/VpnService.java b/core/java/android/net/VpnService.java index 3fd415f..4b07e3f 100644 --- a/core/java/android/net/VpnService.java +++ b/core/java/android/net/VpnService.java @@ -563,7 +563,7 @@ public class VpnService extends Service { * @return this {@link Builder} object to facilitate chaining of method calls. */ public Builder allowBypass() { - // TODO + mConfig.allowBypass = true; return this; } |