blob: 95e3802eeefa1e18739dfd7c6a363f35c14a2ab0 [file] [log] [blame]
Jeff Sharkeyd2a45872011-05-28 20:56:34 -07001/*
2 * Copyright (C) 2011 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 * Snapshot of network state.
24 *
25 * @hide
26 */
27public class NetworkState implements Parcelable {
Jeff Sharkeyf07c7b92016-04-22 09:50:16 -060028 public static final NetworkState EMPTY = new NetworkState(null, null, null, null, null, null);
Jeff Sharkeyd2a45872011-05-28 20:56:34 -070029
30 public final NetworkInfo networkInfo;
31 public final LinkProperties linkProperties;
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -070032 public final NetworkCapabilities networkCapabilities;
Sreeram Ramachandran21b5ee32014-11-12 22:31:52 -080033 public final Network network;
Jeff Sharkeyb09540f2011-06-19 01:08:12 -070034 public final String subscriberId;
Jeff Sharkeye8914c32012-05-01 16:26:09 -070035 public final String networkId;
Jeff Sharkeyd2a45872011-05-28 20:56:34 -070036
37 public NetworkState(NetworkInfo networkInfo, LinkProperties linkProperties,
Sreeram Ramachandran21b5ee32014-11-12 22:31:52 -080038 NetworkCapabilities networkCapabilities, Network network, String subscriberId,
39 String networkId) {
Jeff Sharkeyd2a45872011-05-28 20:56:34 -070040 this.networkInfo = networkInfo;
41 this.linkProperties = linkProperties;
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -070042 this.networkCapabilities = networkCapabilities;
Sreeram Ramachandran21b5ee32014-11-12 22:31:52 -080043 this.network = network;
Jeff Sharkeyb09540f2011-06-19 01:08:12 -070044 this.subscriberId = subscriberId;
Jeff Sharkeye8914c32012-05-01 16:26:09 -070045 this.networkId = networkId;
Jeff Sharkeyd2a45872011-05-28 20:56:34 -070046 }
47
48 public NetworkState(Parcel in) {
49 networkInfo = in.readParcelable(null);
50 linkProperties = in.readParcelable(null);
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -070051 networkCapabilities = in.readParcelable(null);
Sreeram Ramachandran21b5ee32014-11-12 22:31:52 -080052 network = in.readParcelable(null);
Jeff Sharkeyb09540f2011-06-19 01:08:12 -070053 subscriberId = in.readString();
Jeff Sharkeye8914c32012-05-01 16:26:09 -070054 networkId = in.readString();
Jeff Sharkeyd2a45872011-05-28 20:56:34 -070055 }
56
Jeff Sharkeybfdd6802012-04-09 10:49:19 -070057 @Override
Jeff Sharkeyd2a45872011-05-28 20:56:34 -070058 public int describeContents() {
59 return 0;
60 }
61
Jeff Sharkeybfdd6802012-04-09 10:49:19 -070062 @Override
Jeff Sharkeyd2a45872011-05-28 20:56:34 -070063 public void writeToParcel(Parcel out, int flags) {
64 out.writeParcelable(networkInfo, flags);
65 out.writeParcelable(linkProperties, flags);
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -070066 out.writeParcelable(networkCapabilities, flags);
Sreeram Ramachandran21b5ee32014-11-12 22:31:52 -080067 out.writeParcelable(network, flags);
Jeff Sharkeyb09540f2011-06-19 01:08:12 -070068 out.writeString(subscriberId);
Jeff Sharkeye8914c32012-05-01 16:26:09 -070069 out.writeString(networkId);
Jeff Sharkeyd2a45872011-05-28 20:56:34 -070070 }
71
72 public static final Creator<NetworkState> CREATOR = new Creator<NetworkState>() {
Jeff Sharkeybfdd6802012-04-09 10:49:19 -070073 @Override
Jeff Sharkeyd2a45872011-05-28 20:56:34 -070074 public NetworkState createFromParcel(Parcel in) {
75 return new NetworkState(in);
76 }
77
Jeff Sharkeybfdd6802012-04-09 10:49:19 -070078 @Override
Jeff Sharkeyd2a45872011-05-28 20:56:34 -070079 public NetworkState[] newArray(int size) {
80 return new NetworkState[size];
81 }
82 };
Jeff Sharkeyd2a45872011-05-28 20:56:34 -070083}