Nathan Harold | 8dc1fd0 | 2017-04-04 19:37:48 -0700 | [diff] [blame] | 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 |
| 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 | |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 63 | public static final @android.annotation.NonNull Parcelable.Creator<IpSecTransformResponse> CREATOR = |
Nathan Harold | 8dc1fd0 | 2017-04-04 19:37:48 -0700 | [diff] [blame] | 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 | } |