1 /* 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 */ 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 IpSecTunnelInterface resource Id and and corresponding status 23 * from the IpSecService to an IpSecTunnelInterface object. 24 * 25 * @hide 26 */ 27 public 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 describeContents()36 public int describeContents() { 37 return 0; 38 } 39 40 @Override writeToParcel(Parcel out, int flags)41 public void writeToParcel(Parcel out, int flags) { 42 out.writeInt(status); 43 out.writeInt(resourceId); 44 out.writeString(interfaceName); 45 } 46 IpSecTunnelInterfaceResponse(int inStatus)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 IpSecTunnelInterfaceResponse(int inStatus, int inResourceId, String inInterfaceName)56 public IpSecTunnelInterfaceResponse(int inStatus, int inResourceId, String inInterfaceName) { 57 status = inStatus; 58 resourceId = inResourceId; 59 interfaceName = inInterfaceName; 60 } 61 IpSecTunnelInterfaceResponse(Parcel in)62 private IpSecTunnelInterfaceResponse(Parcel in) { 63 status = in.readInt(); 64 resourceId = in.readInt(); 65 interfaceName = in.readString(); 66 } 67 68 public static final @android.annotation.NonNull 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 } 79