Janis Danisevskis | 8ff1e19 | 2016-06-03 11:31:55 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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.keymaster; |
| 18 | |
| 19 | import android.content.pm.Signature; |
| 20 | import android.os.Parcel; |
| 21 | import android.os.Parcelable; |
| 22 | |
| 23 | /** |
| 24 | * @hide |
| 25 | * This class constitutes and excerpt from the PackageManager's PackageInfo for the purpose of |
| 26 | * key attestation. It is part of the KeyAttestationApplicationId, which is used by |
| 27 | * keystore to identify the caller of the keystore API towards a remote party. |
| 28 | */ |
| 29 | public class KeyAttestationPackageInfo implements Parcelable { |
| 30 | private final String mPackageName; |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 31 | private final long mPackageVersionCode; |
Janis Danisevskis | 8ff1e19 | 2016-06-03 11:31:55 -0700 | [diff] [blame] | 32 | private final Signature[] mPackageSignatures; |
| 33 | |
| 34 | /** |
| 35 | * @param mPackageName |
| 36 | * @param mPackageVersionCode |
| 37 | * @param mPackageSignatures |
| 38 | */ |
| 39 | public KeyAttestationPackageInfo( |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 40 | String mPackageName, long mPackageVersionCode, Signature[] mPackageSignatures) { |
Janis Danisevskis | 8ff1e19 | 2016-06-03 11:31:55 -0700 | [diff] [blame] | 41 | super(); |
| 42 | this.mPackageName = mPackageName; |
| 43 | this.mPackageVersionCode = mPackageVersionCode; |
| 44 | this.mPackageSignatures = mPackageSignatures; |
| 45 | } |
| 46 | /** |
| 47 | * @return the mPackageName |
| 48 | */ |
| 49 | public String getPackageName() { |
| 50 | return mPackageName; |
| 51 | } |
| 52 | /** |
| 53 | * @return the mPackageVersionCode |
| 54 | */ |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 55 | public long getPackageVersionCode() { |
Janis Danisevskis | 8ff1e19 | 2016-06-03 11:31:55 -0700 | [diff] [blame] | 56 | return mPackageVersionCode; |
| 57 | } |
| 58 | /** |
| 59 | * @return the mPackageSignatures |
| 60 | */ |
| 61 | public Signature[] getPackageSignatures() { |
| 62 | return mPackageSignatures; |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public int describeContents() { |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public void writeToParcel(Parcel dest, int flags) { |
| 72 | dest.writeString(mPackageName); |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 73 | dest.writeLong(mPackageVersionCode); |
Janis Danisevskis | 8ff1e19 | 2016-06-03 11:31:55 -0700 | [diff] [blame] | 74 | dest.writeTypedArray(mPackageSignatures, flags); |
| 75 | } |
| 76 | |
| 77 | public static final Parcelable.Creator<KeyAttestationPackageInfo> CREATOR |
| 78 | = new Parcelable.Creator<KeyAttestationPackageInfo>() { |
| 79 | @Override |
| 80 | public KeyAttestationPackageInfo createFromParcel(Parcel source) { |
| 81 | return new KeyAttestationPackageInfo(source); |
| 82 | } |
| 83 | |
| 84 | @Override |
| 85 | public KeyAttestationPackageInfo[] newArray(int size) { |
| 86 | return new KeyAttestationPackageInfo[size]; |
| 87 | } |
| 88 | }; |
| 89 | |
| 90 | private KeyAttestationPackageInfo(Parcel source) { |
| 91 | mPackageName = source.readString(); |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 92 | mPackageVersionCode = source.readLong(); |
Janis Danisevskis | 8ff1e19 | 2016-06-03 11:31:55 -0700 | [diff] [blame] | 93 | mPackageSignatures = source.createTypedArray(Signature.CREATOR); |
| 94 | } |
| 95 | } |