blob: cfc176227fbc219884e7d6e6e919aab4b09d0891 [file] [log] [blame]
Nathan Harold8dc1fd02017-04-04 19:37:48 -07001/*
2 * Copyright (C) 2017 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 IpSecTransform resource Id and and corresponding status from the
23 * IpSecService to an IpSecTransform object.
24 *
25 * @hide
26 */
27public final class IpSecTransformResponse implements Parcelable {
28 private static final String TAG = "IpSecTransformResponse";
29
30 public final int resourceId;
31 public final int status;
32 // Parcelable Methods
33
34 @Override
35 public int describeContents() {
36 return 0;
37 }
38
39 @Override
40 public void writeToParcel(Parcel out, int flags) {
41 out.writeInt(status);
42 out.writeInt(resourceId);
43 }
44
45 public IpSecTransformResponse(int inStatus) {
46 if (inStatus == IpSecManager.Status.OK) {
47 throw new IllegalArgumentException("Valid status implies other args must be provided");
48 }
49 status = inStatus;
50 resourceId = IpSecManager.INVALID_RESOURCE_ID;
51 }
52
53 public IpSecTransformResponse(int inStatus, int inResourceId) {
54 status = inStatus;
55 resourceId = inResourceId;
56 }
57
58 private IpSecTransformResponse(Parcel in) {
59 status = in.readInt();
60 resourceId = in.readInt();
61 }
62
63 public static final Parcelable.Creator<IpSecTransformResponse> CREATOR =
64 new Parcelable.Creator<IpSecTransformResponse>() {
65 public IpSecTransformResponse createFromParcel(Parcel in) {
66 return new IpSecTransformResponse(in);
67 }
68
69 public IpSecTransformResponse[] newArray(int size) {
70 return new IpSecTransformResponse[size];
71 }
72 };
73}