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 17 package android.security.keystore; 18 19 import android.os.Parcel; 20 import android.os.Parcelable; 21 import android.os.ParcelFormatException; 22 23 /** 24 * The Java side of the KeystoreResponse. 25 * <p> 26 * Serialization code for this and subclasses must be kept in sync with system/security/keystore. 27 * @hide 28 */ 29 public class KeystoreResponse implements Parcelable { 30 public final int error_code_; 31 public final String error_msg_; 32 33 public static final @android.annotation.NonNull Parcelable.Creator<KeystoreResponse> CREATOR = new 34 Parcelable.Creator<KeystoreResponse>() { 35 @Override 36 public KeystoreResponse createFromParcel(Parcel in) { 37 final int error_code = in.readInt(); 38 final String error_msg = in.readString(); 39 return new KeystoreResponse(error_code, error_msg); 40 } 41 42 @Override 43 public KeystoreResponse[] newArray(int size) { 44 return new KeystoreResponse[size]; 45 } 46 }; 47 KeystoreResponse(int error_code, String error_msg)48 protected KeystoreResponse(int error_code, String error_msg) { 49 this.error_code_ = error_code; 50 this.error_msg_ = error_msg; 51 } 52 53 /** 54 * @return the error_code_ 55 */ getErrorCode()56 public final int getErrorCode() { 57 return error_code_; 58 } 59 60 /** 61 * @return the error_msg_ 62 */ getErrorMessage()63 public final String getErrorMessage() { 64 return error_msg_; 65 } 66 67 68 @Override describeContents()69 public int describeContents() { 70 return 0; 71 } 72 73 @Override writeToParcel(Parcel out, int flags)74 public void writeToParcel(Parcel out, int flags) { 75 out.writeInt(error_code_); 76 out.writeString(error_msg_); 77 } 78 } 79