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 29 public final NetworkInfo networkInfo; 30 public final LinkProperties linkProperties; 31 public final LinkCapabilities linkCapabilities; 32 /** Currently only used by testing. */ 33 public final String subscriberId; 34 35 public NetworkState(NetworkInfo networkInfo, LinkProperties linkProperties, 36 LinkCapabilities linkCapabilities) { 37 this(networkInfo, linkProperties, linkCapabilities, null); 38 } 39 40 public NetworkState(NetworkInfo networkInfo, LinkProperties linkProperties, 41 LinkCapabilities linkCapabilities, String subscriberId) { 42 this.networkInfo = networkInfo; 43 this.linkProperties = linkProperties; 44 this.linkCapabilities = linkCapabilities; 45 this.subscriberId = subscriberId; 46 } 47 48 public NetworkState(Parcel in) { 49 networkInfo = in.readParcelable(null); 50 linkProperties = in.readParcelable(null); 51 linkCapabilities = in.readParcelable(null); 52 subscriberId = in.readString(); 53 } 54 55 /** {@inheritDoc} */ 56 public int describeContents() { 57 return 0; 58 } 59 60 /** {@inheritDoc} */ 61 public void writeToParcel(Parcel out, int flags) { 62 out.writeParcelable(networkInfo, flags); 63 out.writeParcelable(linkProperties, flags); 64 out.writeParcelable(linkCapabilities, flags); 65 out.writeString(subscriberId); 66 } 67 68 public static final Creator<NetworkState> CREATOR = new Creator<NetworkState>() { 69 public NetworkState createFromParcel(Parcel in) { 70 return new NetworkState(in); 71 } 72 73 public NetworkState[] newArray(int size) { 74 return new NetworkState[size]; 75 } 76 }; 77 78 } 79