OperationResult.java revision 08c7116ab9cd04ad6dd3c04aa1017237e7f409ac
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.keymaster;
18
19import android.os.IBinder;
20import android.os.Parcel;
21import android.os.Parcelable;
22
23/**
24 * Class for handling the parceling of return values from keymaster crypto operations
25 * (begin/update/finish).
26 * @hide
27 */
28public class OperationResult implements Parcelable {
29    public final int resultCode;
30    public final IBinder token;
31    public final int inputConsumed;
32    public final byte[] output;
33
34    public static final Parcelable.Creator<OperationResult> CREATOR = new
35            Parcelable.Creator<OperationResult>() {
36                public OperationResult createFromParcel(Parcel in) {
37                    return new OperationResult(in);
38                }
39
40                public OperationResult[] newArray(int length) {
41                    return new OperationResult[length];
42                }
43            };
44
45    protected OperationResult(Parcel in) {
46        resultCode = in.readInt();
47        token = in.readStrongBinder();
48        inputConsumed = in.readInt();
49        output = in.createByteArray();
50    }
51
52    @Override
53    public int describeContents() {
54        return 0;
55    }
56
57    @Override
58    public void writeToParcel(Parcel out, int flags) {
59        out.writeInt(resultCode);
60        out.writeStrongBinder(token);
61        out.writeInt(inputConsumed);
62        out.writeByteArray(output);
63    }
64}
65