1 /* 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 17 package android.net; 18 19 import android.os.Parcel; 20 import android.os.Parcelable; 21 22 /** 23 * Snapshot of network state. 24 * 25 * @hide 26 */ 27 public class NetworkState implements Parcelable { 28 public static final NetworkState EMPTY = new NetworkState(null, null, null, null, null, null); 29 30 public final NetworkInfo networkInfo; 31 public final LinkProperties linkProperties; 32 public final NetworkCapabilities networkCapabilities; 33 public final Network network; 34 public final String subscriberId; 35 public final String networkId; 36 37 public NetworkState(NetworkInfo networkInfo, LinkProperties linkProperties, 38 NetworkCapabilities networkCapabilities, Network network, String subscriberId, 39 String networkId) { 40 this.networkInfo = networkInfo; 41 this.linkProperties = linkProperties; 42 this.networkCapabilities = networkCapabilities; 43 this.network = network; 44 this.subscriberId = subscriberId; 45 this.networkId = networkId; 46 } 47 48 public NetworkState(Parcel in) { 49 networkInfo = in.readParcelable(null); 50 linkProperties = in.readParcelable(null); 51 networkCapabilities = in.readParcelable(null); 52 network = in.readParcelable(null); 53 subscriberId = in.readString(); 54 networkId = in.readString(); 55 } 56 57 @Override 58 public int describeContents() { 59 return 0; 60 } 61 62 @Override 63 public void writeToParcel(Parcel out, int flags) { 64 out.writeParcelable(networkInfo, flags); 65 out.writeParcelable(linkProperties, flags); 66 out.writeParcelable(networkCapabilities, flags); 67 out.writeParcelable(network, flags); 68 out.writeString(subscriberId); 69 out.writeString(networkId); 70 } 71 72 public static final Creator<NetworkState> CREATOR = new Creator<NetworkState>() { 73 @Override 74 public NetworkState createFromParcel(Parcel in) { 75 return new NetworkState(in); 76 } 77 78 @Override 79 public NetworkState[] newArray(int size) { 80 return new NetworkState[size]; 81 } 82 }; 83 } 84