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