Sreeram Ramachandran | 8cd33ed | 2014-07-23 15:23:15 -0700 | [diff] [blame] | 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 | /** |
Jeff Sharkey | 3256601 | 2014-12-02 18:30:14 -0800 | [diff] [blame] | 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. |
Sreeram Ramachandran | 8cd33ed | 2014-07-23 15:23:15 -0700 | [diff] [blame] | 26 | * |
| 27 | * @hide |
| 28 | */ |
| 29 | public class NetworkMisc implements Parcelable { |
Robert Greenwalt | e73cc46 | 2014-09-07 16:50:01 -0700 | [diff] [blame] | 30 | |
Sreeram Ramachandran | 8cd33ed | 2014-07-23 15:23:15 -0700 | [diff] [blame] | 31 | /** |
Jeff Sharkey | 3256601 | 2014-12-02 18:30:14 -0800 | [diff] [blame] | 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. |
Sreeram Ramachandran | 8cd33ed | 2014-07-23 15:23:15 -0700 | [diff] [blame] | 35 | */ |
| 36 | public boolean allowBypass; |
| 37 | |
Robert Greenwalt | e73cc46 | 2014-09-07 16:50:01 -0700 | [diff] [blame] | 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 | |
Jeff Sharkey | 3256601 | 2014-12-02 18:30:14 -0800 | [diff] [blame] | 47 | /** |
Lorenzo Colitti | e03c3c7 | 2015-04-03 16:38:52 +0900 | [diff] [blame] | 48 | * Set if the user desires to use this network even if it is unvalidated. This field has meaning |
Andrew Solovay | a44f2c07 | 2018-10-02 14:14:42 -0700 | [diff] [blame] | 49 | * only if {@link explicitlySelected} is true. If it is, this field must also be set to the |
Lorenzo Colitti | e03c3c7 | 2015-04-03 16:38:52 +0900 | [diff] [blame] | 50 | * appropriate value based on previous user choice. |
| 51 | */ |
| 52 | public boolean acceptUnvalidated; |
| 53 | |
| 54 | /** |
fionaxu | 1bf6ec2 | 2016-05-23 16:33:16 -0700 | [diff] [blame] | 55 | * Set to avoid surfacing the "Sign in to network" notification. |
| 56 | * if carrier receivers/apps are registered to handle the carrier-specific provisioning |
| 57 | * procedure, a carrier specific provisioning notification will be placed. |
| 58 | * only one notification should be displayed. This field is set based on |
| 59 | * which notification should be used for provisioning. |
| 60 | */ |
| 61 | public boolean provisioningNotificationDisabled; |
| 62 | |
| 63 | /** |
Jeff Sharkey | 3256601 | 2014-12-02 18:30:14 -0800 | [diff] [blame] | 64 | * For mobile networks, this is the subscriber ID (such as IMSI). |
| 65 | */ |
| 66 | public String subscriberId; |
| 67 | |
Yuuki Habu | 8f54b61 | 2018-09-06 09:37:55 +0900 | [diff] [blame] | 68 | /** |
| 69 | * Set to skip 464xlat. This means the device will treat the network as IPv6-only and |
| 70 | * will not attempt to detect a NAT64 via RFC 7050 DNS lookups. |
| 71 | */ |
| 72 | public boolean skip464xlat; |
| 73 | |
Robert Greenwalt | e73cc46 | 2014-09-07 16:50:01 -0700 | [diff] [blame] | 74 | public NetworkMisc() { |
| 75 | } |
| 76 | |
| 77 | public NetworkMisc(NetworkMisc nm) { |
| 78 | if (nm != null) { |
| 79 | allowBypass = nm.allowBypass; |
| 80 | explicitlySelected = nm.explicitlySelected; |
Lorenzo Colitti | e03c3c7 | 2015-04-03 16:38:52 +0900 | [diff] [blame] | 81 | acceptUnvalidated = nm.acceptUnvalidated; |
Jeff Sharkey | 3256601 | 2014-12-02 18:30:14 -0800 | [diff] [blame] | 82 | subscriberId = nm.subscriberId; |
fionaxu | 1bf6ec2 | 2016-05-23 16:33:16 -0700 | [diff] [blame] | 83 | provisioningNotificationDisabled = nm.provisioningNotificationDisabled; |
Yuuki Habu | 8f54b61 | 2018-09-06 09:37:55 +0900 | [diff] [blame] | 84 | skip464xlat = nm.skip464xlat; |
Robert Greenwalt | e73cc46 | 2014-09-07 16:50:01 -0700 | [diff] [blame] | 85 | } |
| 86 | } |
| 87 | |
Sreeram Ramachandran | 8cd33ed | 2014-07-23 15:23:15 -0700 | [diff] [blame] | 88 | @Override |
| 89 | public int describeContents() { |
| 90 | return 0; |
| 91 | } |
| 92 | |
| 93 | @Override |
| 94 | public void writeToParcel(Parcel out, int flags) { |
| 95 | out.writeInt(allowBypass ? 1 : 0); |
Robert Greenwalt | e73cc46 | 2014-09-07 16:50:01 -0700 | [diff] [blame] | 96 | out.writeInt(explicitlySelected ? 1 : 0); |
Lorenzo Colitti | e03c3c7 | 2015-04-03 16:38:52 +0900 | [diff] [blame] | 97 | out.writeInt(acceptUnvalidated ? 1 : 0); |
Jeff Sharkey | 3256601 | 2014-12-02 18:30:14 -0800 | [diff] [blame] | 98 | out.writeString(subscriberId); |
fionaxu | 1bf6ec2 | 2016-05-23 16:33:16 -0700 | [diff] [blame] | 99 | out.writeInt(provisioningNotificationDisabled ? 1 : 0); |
Yuuki Habu | 8f54b61 | 2018-09-06 09:37:55 +0900 | [diff] [blame] | 100 | out.writeInt(skip464xlat ? 1 : 0); |
Sreeram Ramachandran | 8cd33ed | 2014-07-23 15:23:15 -0700 | [diff] [blame] | 101 | } |
| 102 | |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame^] | 103 | public static final @android.annotation.NonNull Creator<NetworkMisc> CREATOR = new Creator<NetworkMisc>() { |
Sreeram Ramachandran | 8cd33ed | 2014-07-23 15:23:15 -0700 | [diff] [blame] | 104 | @Override |
| 105 | public NetworkMisc createFromParcel(Parcel in) { |
| 106 | NetworkMisc networkMisc = new NetworkMisc(); |
| 107 | networkMisc.allowBypass = in.readInt() != 0; |
Robert Greenwalt | e73cc46 | 2014-09-07 16:50:01 -0700 | [diff] [blame] | 108 | networkMisc.explicitlySelected = in.readInt() != 0; |
Lorenzo Colitti | e03c3c7 | 2015-04-03 16:38:52 +0900 | [diff] [blame] | 109 | networkMisc.acceptUnvalidated = in.readInt() != 0; |
Jeff Sharkey | 3256601 | 2014-12-02 18:30:14 -0800 | [diff] [blame] | 110 | networkMisc.subscriberId = in.readString(); |
fionaxu | 1bf6ec2 | 2016-05-23 16:33:16 -0700 | [diff] [blame] | 111 | networkMisc.provisioningNotificationDisabled = in.readInt() != 0; |
Yuuki Habu | 8f54b61 | 2018-09-06 09:37:55 +0900 | [diff] [blame] | 112 | networkMisc.skip464xlat = in.readInt() != 0; |
Sreeram Ramachandran | 8cd33ed | 2014-07-23 15:23:15 -0700 | [diff] [blame] | 113 | return networkMisc; |
| 114 | } |
| 115 | |
| 116 | @Override |
| 117 | public NetworkMisc[] newArray(int size) { |
| 118 | return new NetworkMisc[size]; |
| 119 | } |
| 120 | }; |
| 121 | } |