1/** 2 * Copyright (c) 2015, 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 17package android.security; 18 19import android.os.Parcel; 20import android.os.Parcelable; 21 22/** 23 * Class for handling the additional arguments to some keystore binder calls. 24 * This must be kept in sync with the deserialization code in system/security/keystore. 25 * @hide 26 */ 27public class KeystoreArguments implements Parcelable { 28 public byte[][] args; 29 30 public static final Parcelable.Creator<KeystoreArguments> CREATOR = new 31 Parcelable.Creator<KeystoreArguments>() { 32 public KeystoreArguments createFromParcel(Parcel in) { 33 return new KeystoreArguments(in); 34 } 35 public KeystoreArguments[] newArray(int size) { 36 return new KeystoreArguments[size]; 37 } 38 }; 39 40 public KeystoreArguments() { 41 args = null; 42 } 43 44 public KeystoreArguments(byte[][] args) { 45 this.args = args; 46 } 47 48 private KeystoreArguments(Parcel in) { 49 readFromParcel(in); 50 } 51 52 @Override 53 public void writeToParcel(Parcel out, int flags) { 54 if (args == null) { 55 out.writeInt(0); 56 } else { 57 out.writeInt(args.length); 58 for (byte[] arg : args) { 59 out.writeByteArray(arg); 60 } 61 } 62 } 63 64 private void readFromParcel(Parcel in) { 65 int length = in.readInt(); 66 args = new byte[length][]; 67 for (int i = 0; i < length; i++) { 68 args[i] = in.createByteArray(); 69 } 70 } 71 72 @Override 73 public int describeContents() { 74 return 0; 75 } 76} 77