1 /* 2 * Copyright (C) 2014 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 android.net; 18 19 import android.os.Parcel; 20 import android.os.Parcelable; 21 22 /** 23 * A grab-bag of information (metadata, policies, properties, etc) about a {@link Network}. 24 * 25 * @hide 26 */ 27 public class NetworkMisc implements Parcelable { 28 29 /** 30 * If the {@link Network} is a VPN, whether apps are allowed to bypass the VPN. This is set by 31 * a {@link VpnService} and used by {@link ConnectivityService} when creating a VPN. 32 */ 33 public boolean allowBypass; 34 35 /** 36 * Set if the network was manually/explicitly connected to by the user either from settings 37 * or a 3rd party app. For example, turning on cell data is not explicit but tapping on a wifi 38 * ap in the wifi settings to trigger a connection is explicit. A 3rd party app asking to 39 * connect to a particular access point is also explicit, though this may change in the future 40 * as we want apps to use the multinetwork apis. 41 */ 42 public boolean explicitlySelected; 43 44 public NetworkMisc() { 45 } 46 47 public NetworkMisc(NetworkMisc nm) { 48 if (nm != null) { 49 allowBypass = nm.allowBypass; 50 explicitlySelected = nm.explicitlySelected; 51 } 52 } 53 54 @Override 55 public int describeContents() { 56 return 0; 57 } 58 59 @Override 60 public void writeToParcel(Parcel out, int flags) { 61 out.writeInt(allowBypass ? 1 : 0); 62 out.writeInt(explicitlySelected ? 1 : 0); 63 } 64 65 public static final Creator<NetworkMisc> CREATOR = new Creator<NetworkMisc>() { 66 @Override 67 public NetworkMisc createFromParcel(Parcel in) { 68 NetworkMisc networkMisc = new NetworkMisc(); 69 networkMisc.allowBypass = in.readInt() != 0; 70 networkMisc.explicitlySelected = in.readInt() != 0; 71 return networkMisc; 72 } 73 74 @Override 75 public NetworkMisc[] newArray(int size) { 76 return new NetworkMisc[size]; 77 } 78 }; 79 } 80