blob: c23d831a4435d73459d0bb232cf1b19c5db09255 [file] [log] [blame]
Benedict Wong8149f6e2018-01-18 18:31:45 -08001/*
2 * Copyright (C) 2018 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 */
16package android.net;
17
18import android.os.Parcel;
19import android.os.Parcelable;
20
21/**
22 * This class is used to return an IpSecTunnelInterface resource Id and and corresponding status
23 * from the IpSecService to an IpSecTunnelInterface object.
24 *
25 * @hide
26 */
27public final class IpSecTunnelInterfaceResponse implements Parcelable {
28 private static final String TAG = "IpSecTunnelInterfaceResponse";
29
30 public final int resourceId;
31 public final String interfaceName;
32 public final int status;
33 // Parcelable Methods
34
35 @Override
36 public int describeContents() {
37 return 0;
38 }
39
40 @Override
41 public void writeToParcel(Parcel out, int flags) {
42 out.writeInt(status);
43 out.writeInt(resourceId);
44 out.writeString(interfaceName);
45 }
46
47 public IpSecTunnelInterfaceResponse(int inStatus) {
48 if (inStatus == IpSecManager.Status.OK) {
49 throw new IllegalArgumentException("Valid status implies other args must be provided");
50 }
51 status = inStatus;
52 resourceId = IpSecManager.INVALID_RESOURCE_ID;
53 interfaceName = "";
54 }
55
56 public IpSecTunnelInterfaceResponse(int inStatus, int inResourceId, String inInterfaceName) {
57 status = inStatus;
58 resourceId = inResourceId;
59 interfaceName = inInterfaceName;
60 }
61
62 private IpSecTunnelInterfaceResponse(Parcel in) {
63 status = in.readInt();
64 resourceId = in.readInt();
65 interfaceName = in.readString();
66 }
67
68 public static final Parcelable.Creator<IpSecTunnelInterfaceResponse> CREATOR =
69 new Parcelable.Creator<IpSecTunnelInterfaceResponse>() {
70 public IpSecTunnelInterfaceResponse createFromParcel(Parcel in) {
71 return new IpSecTunnelInterfaceResponse(in);
72 }
73
74 public IpSecTunnelInterfaceResponse[] newArray(int size) {
75 return new IpSecTunnelInterfaceResponse[size];
76 }
77 };
78}