blob: a2da6eaa4922ce133d5c3a5172b61f8d9921308f [file] [log] [blame]
Sreeram Ramachandran8cd33ed2014-07-23 15:23:15 -07001/*
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/**
Jeff Sharkey32566012014-12-02 18:30:14 -080023 * 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 Ramachandran8cd33ed2014-07-23 15:23:15 -070026 *
27 * @hide
28 */
29public class NetworkMisc implements Parcelable {
Robert Greenwalte73cc462014-09-07 16:50:01 -070030
Sreeram Ramachandran8cd33ed2014-07-23 15:23:15 -070031 /**
Jeff Sharkey32566012014-12-02 18:30:14 -080032 * 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 Ramachandran8cd33ed2014-07-23 15:23:15 -070035 */
36 public boolean allowBypass;
37
Robert Greenwalte73cc462014-09-07 16:50:01 -070038 /**
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 Sharkey32566012014-12-02 18:30:14 -080047 /**
Lorenzo Colittie03c3c72015-04-03 16:38:52 +090048 * Set if the user desires to use this network even if it is unvalidated. This field has meaning
Andrew Solovaya44f2c072018-10-02 14:14:42 -070049 * only if {@link explicitlySelected} is true. If it is, this field must also be set to the
Lorenzo Colittie03c3c72015-04-03 16:38:52 +090050 * appropriate value based on previous user choice.
51 */
52 public boolean acceptUnvalidated;
53
54 /**
fionaxu1bf6ec22016-05-23 16:33:16 -070055 * 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 Sharkey32566012014-12-02 18:30:14 -080064 * For mobile networks, this is the subscriber ID (such as IMSI).
65 */
66 public String subscriberId;
67
Robert Greenwalte73cc462014-09-07 16:50:01 -070068 public NetworkMisc() {
69 }
70
71 public NetworkMisc(NetworkMisc nm) {
72 if (nm != null) {
73 allowBypass = nm.allowBypass;
74 explicitlySelected = nm.explicitlySelected;
Lorenzo Colittie03c3c72015-04-03 16:38:52 +090075 acceptUnvalidated = nm.acceptUnvalidated;
Jeff Sharkey32566012014-12-02 18:30:14 -080076 subscriberId = nm.subscriberId;
fionaxu1bf6ec22016-05-23 16:33:16 -070077 provisioningNotificationDisabled = nm.provisioningNotificationDisabled;
Robert Greenwalte73cc462014-09-07 16:50:01 -070078 }
79 }
80
Sreeram Ramachandran8cd33ed2014-07-23 15:23:15 -070081 @Override
82 public int describeContents() {
83 return 0;
84 }
85
86 @Override
87 public void writeToParcel(Parcel out, int flags) {
88 out.writeInt(allowBypass ? 1 : 0);
Robert Greenwalte73cc462014-09-07 16:50:01 -070089 out.writeInt(explicitlySelected ? 1 : 0);
Lorenzo Colittie03c3c72015-04-03 16:38:52 +090090 out.writeInt(acceptUnvalidated ? 1 : 0);
Jeff Sharkey32566012014-12-02 18:30:14 -080091 out.writeString(subscriberId);
fionaxu1bf6ec22016-05-23 16:33:16 -070092 out.writeInt(provisioningNotificationDisabled ? 1 : 0);
Sreeram Ramachandran8cd33ed2014-07-23 15:23:15 -070093 }
94
95 public static final Creator<NetworkMisc> CREATOR = new Creator<NetworkMisc>() {
96 @Override
97 public NetworkMisc createFromParcel(Parcel in) {
98 NetworkMisc networkMisc = new NetworkMisc();
99 networkMisc.allowBypass = in.readInt() != 0;
Robert Greenwalte73cc462014-09-07 16:50:01 -0700100 networkMisc.explicitlySelected = in.readInt() != 0;
Lorenzo Colittie03c3c72015-04-03 16:38:52 +0900101 networkMisc.acceptUnvalidated = in.readInt() != 0;
Jeff Sharkey32566012014-12-02 18:30:14 -0800102 networkMisc.subscriberId = in.readString();
fionaxu1bf6ec22016-05-23 16:33:16 -0700103 networkMisc.provisioningNotificationDisabled = in.readInt() != 0;
Sreeram Ramachandran8cd33ed2014-07-23 15:23:15 -0700104 return networkMisc;
105 }
106
107 @Override
108 public NetworkMisc[] newArray(int size) {
109 return new NetworkMisc[size];
110 }
111 };
112}