blob: e634234493e31523f4258a780f341fea8b5085bd [file] [log] [blame]
Chad Brubaker7a2c9732015-01-13 17:41:22 -08001/**
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
Mathew Inwoode420f8b2018-08-16 18:40:47 +010019import android.annotation.UnsupportedAppUsage;
Chad Brubaker7a2c9732015-01-13 17:41:22 -080020import android.os.Parcel;
21import 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 */
28public class KeystoreArguments implements Parcelable {
29 public byte[][] args;
30
Mathew Inwoode420f8b2018-08-16 18:40:47 +010031 @UnsupportedAppUsage
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -070032 public static final @android.annotation.NonNull Parcelable.Creator<KeystoreArguments> CREATOR = new
Chad Brubaker7a2c9732015-01-13 17:41:22 -080033 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 Inwoode420f8b2018-08-16 18:40:47 +010046 @UnsupportedAppUsage
Chad Brubaker7a2c9732015-01-13 17:41:22 -080047 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}