| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.net.vcn; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.SystemApi; |
| 21 |
import android.net.NetworkCapabilities; |
| 22 |
import android.os.Parcel; |
| 23 |
import android.os.Parcelable; |
| 24 |
|
| 25 |
import java.util.Objects; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
@SystemApi |
| 38 |
public final class VcnNetworkPolicyResult implements Parcelable { |
| 39 |
private final boolean mIsTearDownRequested; |
| 40 |
private final NetworkCapabilities mNetworkCapabilities; |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
public VcnNetworkPolicyResult( |
| 48 |
boolean isTearDownRequested, @NonNull NetworkCapabilities networkCapabilities) { |
| 49 |
Objects.requireNonNull(networkCapabilities, "networkCapabilities must be non-null"); |
| 50 |
|
| 51 |
mIsTearDownRequested = isTearDownRequested; |
| 52 |
mNetworkCapabilities = networkCapabilities; |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
public boolean isTeardownRequested() { |
| 63 |
return mIsTearDownRequested; |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
@NonNull |
| 71 |
public NetworkCapabilities getNetworkCapabilities() { |
| 72 |
return mNetworkCapabilities; |
| 73 |
} |
| 74 |
|
| 75 |
@Override |
| 76 |
public int hashCode() { |
| 77 |
return Objects.hash(mIsTearDownRequested, mNetworkCapabilities); |
| 78 |
} |
| 79 |
|
| 80 |
@Override |
| 81 |
public boolean equals(Object o) { |
| 82 |
if (this == o) return true; |
| 83 |
if (!(o instanceof VcnNetworkPolicyResult)) return false; |
| 84 |
final VcnNetworkPolicyResult that = (VcnNetworkPolicyResult) o; |
| 85 |
|
| 86 |
return mIsTearDownRequested == that.mIsTearDownRequested |
| 87 |
&& mNetworkCapabilities.equals(that.mNetworkCapabilities); |
| 88 |
} |
| 89 |
|
| 90 |
@Override |
| 91 |
public String toString() { |
| 92 |
return "VcnNetworkPolicyResult { " |
| 93 |
+ "mIsTeardownRequested = " |
| 94 |
+ mIsTearDownRequested |
| 95 |
+ ", mNetworkCapabilities" |
| 96 |
+ mNetworkCapabilities |
| 97 |
+ " }"; |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
@Override |
| 102 |
public int describeContents() { |
| 103 |
return 0; |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
@Override |
| 108 |
public void writeToParcel(@NonNull Parcel dest, int flags) { |
| 109 |
dest.writeBoolean(mIsTearDownRequested); |
| 110 |
dest.writeParcelable(mNetworkCapabilities, flags); |
| 111 |
} |
| 112 |
|
| 113 |
|
| 114 |
public static final @NonNull Creator<VcnNetworkPolicyResult> CREATOR = |
| 115 |
new Creator<VcnNetworkPolicyResult>() { |
| 116 |
public VcnNetworkPolicyResult createFromParcel(Parcel in) { |
| 117 |
return new VcnNetworkPolicyResult(in.readBoolean(), in.readParcelable(null, android.net.NetworkCapabilities.class)); |
| 118 |
} |
| 119 |
|
| 120 |
public VcnNetworkPolicyResult[] newArray(int size) { |
| 121 |
return new VcnNetworkPolicyResult[size]; |
| 122 |
} |
| 123 |
}; |
| 124 |
} |