blob: 224ca628cf277a70d26225dcb3ec41ffd005e97d [file] [log] [blame]
Kenny Root05ca4c92011-09-15 10:36:25 -07001/*
2 * Copyright (C) 2011 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.content.pm;
18
Mathew Inwood5c0d3542018-08-14 13:54:31 +010019import android.annotation.UnsupportedAppUsage;
Kenny Root05ca4c92011-09-15 10:36:25 -070020import android.os.Parcel;
21import android.os.Parcelable;
22
23import java.security.PublicKey;
24
25/**
26 * Contains information about a package verifier as used by
27 * {@code PackageManagerService} during package verification.
28 *
29 * @hide
30 */
31public class VerifierInfo implements Parcelable {
32 /** Package name of the verifier. */
33 public final String packageName;
34
35 /** Signatures used to sign the package verifier's package. */
36 public final PublicKey publicKey;
37
38 /**
39 * Creates an object that represents a verifier info object.
40 *
41 * @param packageName the package name in Java-style. Must not be {@code
42 * null} or empty.
43 * @param publicKey the public key for the signer encoded in Base64. Must
44 * not be {@code null} or empty.
45 * @throws IllegalArgumentException if either argument is null or empty.
46 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +010047 @UnsupportedAppUsage
Kenny Root05ca4c92011-09-15 10:36:25 -070048 public VerifierInfo(String packageName, PublicKey publicKey) {
49 if (packageName == null || packageName.length() == 0) {
50 throw new IllegalArgumentException("packageName must not be null or empty");
51 } else if (publicKey == null) {
52 throw new IllegalArgumentException("publicKey must not be null");
53 }
54
55 this.packageName = packageName;
56 this.publicKey = publicKey;
57 }
58
59 private VerifierInfo(Parcel source) {
60 packageName = source.readString();
61 publicKey = (PublicKey) source.readSerializable();
62 }
63
64 @Override
65 public int describeContents() {
66 return 0;
67 }
68
69 @Override
70 public void writeToParcel(Parcel dest, int flags) {
71 dest.writeString(packageName);
72 dest.writeSerializable(publicKey);
73 }
74
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -070075 public static final @android.annotation.NonNull Parcelable.Creator<VerifierInfo> CREATOR
Kenny Root05ca4c92011-09-15 10:36:25 -070076 = new Parcelable.Creator<VerifierInfo>() {
77 public VerifierInfo createFromParcel(Parcel source) {
78 return new VerifierInfo(source);
79 }
80
81 public VerifierInfo[] newArray(int size) {
82 return new VerifierInfo[size];
83 }
84 };
85}