1 /*
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  */
16 package android.net;
17 
18 import android.os.Parcel;
19 import 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  */
27 public 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
describeContents()35     public int describeContents() {
36         return 0;
37     }
38 
39     @Override
writeToParcel(Parcel out, int flags)40     public void writeToParcel(Parcel out, int flags) {
41         out.writeInt(status);
42         out.writeInt(resourceId);
43     }
44 
IpSecTransformResponse(int inStatus)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 
IpSecTransformResponse(int inStatus, int inResourceId)53     public IpSecTransformResponse(int inStatus, int inResourceId) {
54         status = inStatus;
55         resourceId = inResourceId;
56     }
57 
IpSecTransformResponse(Parcel in)58     private IpSecTransformResponse(Parcel in) {
59         status = in.readInt();
60         resourceId = in.readInt();
61     }
62 
63     @android.annotation.NonNull
64     public static final Parcelable.Creator<IpSecTransformResponse> CREATOR =
65             new Parcelable.Creator<IpSecTransformResponse>() {
66                 public IpSecTransformResponse createFromParcel(Parcel in) {
67                     return new IpSecTransformResponse(in);
68                 }
69 
70                 public IpSecTransformResponse[] newArray(int size) {
71                     return new IpSecTransformResponse[size];
72                 }
73             };
74 }
75