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