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