| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.content.pm; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.os.Parcel; |
| 22 |
import android.os.Parcelable; |
| 23 |
|
| 24 |
import com.android.internal.util.DataClass; |
| 25 |
|
| 26 |
import java.io.ByteArrayInputStream; |
| 27 |
import java.io.InputStream; |
| 28 |
import java.security.cert.Certificate; |
| 29 |
import java.security.cert.CertificateEncodingException; |
| 30 |
import java.security.cert.CertificateException; |
| 31 |
import java.security.cert.CertificateFactory; |
| 32 |
import java.security.cert.X509Certificate; |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
@DataClass(genHiddenConstructor = true) |
| 40 |
@DataClass.Suppress({"getChecksum"}) |
| 41 |
public final class ApkChecksum implements Parcelable { |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
private final @Nullable String mSplitName; |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
private final @NonNull Checksum mChecksum; |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
private final @Nullable String mInstallerPackageName; |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
private final @Nullable byte[] mInstallerCertificate; |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
public ApkChecksum(@Nullable String splitName, @Checksum.Type int type, |
| 65 |
@NonNull byte[] value) { |
| 66 |
this(splitName, new Checksum(type, value), (String) null, (byte[]) null); |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
public ApkChecksum(@Nullable String splitName, @Checksum.Type int type, @NonNull byte[] value, |
| 75 |
@Nullable String sourcePackageName, @Nullable Certificate sourceCertificate) |
| 76 |
throws CertificateEncodingException { |
| 77 |
this(splitName, new Checksum(type, value), sourcePackageName, |
| 78 |
(sourceCertificate != null) ? sourceCertificate.getEncoded() : null); |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
public @Checksum.Type int getType() { |
| 86 |
return mChecksum.getType(); |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
public @NonNull byte[] getValue() { |
| 93 |
return mChecksum.getValue(); |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
public @Nullable byte[] getInstallerCertificateBytes() { |
| 101 |
return mInstallerCertificate; |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
public @Nullable Certificate getInstallerCertificate() throws CertificateException { |
| 110 |
if (mInstallerCertificate == null) { |
| 111 |
return null; |
| 112 |
} |
| 113 |
final CertificateFactory cf = CertificateFactory.getInstance("X.509"); |
| 114 |
final InputStream is = new ByteArrayInputStream(mInstallerCertificate); |
| 115 |
final X509Certificate cert = (X509Certificate) cf.generateCertificate(is); |
| 116 |
return cert; |
| 117 |
} |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
@DataClass.Generated.Member |
| 148 |
public ApkChecksum( |
| 149 |
@Nullable String splitName, |
| 150 |
@NonNull Checksum checksum, |
| 151 |
@Nullable String installerPackageName, |
| 152 |
@Nullable byte[] installerCertificate) { |
| 153 |
this.mSplitName = splitName; |
| 154 |
this.mChecksum = checksum; |
| 155 |
com.android.internal.util.AnnotationValidations.validate( |
| 156 |
NonNull.class, null, mChecksum); |
| 157 |
this.mInstallerPackageName = installerPackageName; |
| 158 |
this.mInstallerCertificate = installerCertificate; |
| 159 |
|
| 160 |
|
| 161 |
} |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
@DataClass.Generated.Member |
| 167 |
public @Nullable String getSplitName() { |
| 168 |
return mSplitName; |
| 169 |
} |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
@DataClass.Generated.Member |
| 175 |
public @Nullable String getInstallerPackageName() { |
| 176 |
return mInstallerPackageName; |
| 177 |
} |
| 178 |
|
| 179 |
@Override |
| 180 |
@DataClass.Generated.Member |
| 181 |
public void writeToParcel(@NonNull Parcel dest, int flags) { |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
byte flg = 0; |
| 186 |
if (mSplitName != null) flg |= 0x1; |
| 187 |
if (mInstallerPackageName != null) flg |= 0x4; |
| 188 |
if (mInstallerCertificate != null) flg |= 0x8; |
| 189 |
dest.writeByte(flg); |
| 190 |
if (mSplitName != null) dest.writeString(mSplitName); |
| 191 |
dest.writeTypedObject(mChecksum, flags); |
| 192 |
if (mInstallerPackageName != null) dest.writeString(mInstallerPackageName); |
| 193 |
if (mInstallerCertificate != null) dest.writeByteArray(mInstallerCertificate); |
| 194 |
} |
| 195 |
|
| 196 |
@Override |
| 197 |
@DataClass.Generated.Member |
| 198 |
public int describeContents() { return 0; } |
| 199 |
|
| 200 |
|
| 201 |
@SuppressWarnings({"unchecked", "RedundantCast"}) |
| 202 |
@DataClass.Generated.Member |
| 203 |
ApkChecksum(@NonNull Parcel in) { |
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
byte flg = in.readByte(); |
| 208 |
String splitName = (flg & 0x1) == 0 ? null : in.readString(); |
| 209 |
Checksum checksum = (Checksum) in.readTypedObject(Checksum.CREATOR); |
| 210 |
String installerPackageName = (flg & 0x4) == 0 ? null : in.readString(); |
| 211 |
byte[] installerCertificate = (flg & 0x8) == 0 ? null : in.createByteArray(); |
| 212 |
|
| 213 |
this.mSplitName = splitName; |
| 214 |
this.mChecksum = checksum; |
| 215 |
com.android.internal.util.AnnotationValidations.validate( |
| 216 |
NonNull.class, null, mChecksum); |
| 217 |
this.mInstallerPackageName = installerPackageName; |
| 218 |
this.mInstallerCertificate = installerCertificate; |
| 219 |
|
| 220 |
|
| 221 |
} |
| 222 |
|
| 223 |
@DataClass.Generated.Member |
| 224 |
public static final @NonNull Parcelable.Creator<ApkChecksum> CREATOR |
| 225 |
= new Parcelable.Creator<ApkChecksum>() { |
| 226 |
@Override |
| 227 |
public ApkChecksum[] newArray(int size) { |
| 228 |
return new ApkChecksum[size]; |
| 229 |
} |
| 230 |
|
| 231 |
@Override |
| 232 |
public ApkChecksum createFromParcel(@NonNull Parcel in) { |
| 233 |
return new ApkChecksum(in); |
| 234 |
} |
| 235 |
}; |
| 236 |
|
| 237 |
@DataClass.Generated( |
| 238 |
time = 1619810171079L, |
| 239 |
codegenVersion = "1.0.23", |
| 240 |
sourceFile = "frameworks/base/core/java/android/content/pm/ApkChecksum.java", |
| 241 |
inputSignatures = "private final @android.annotation.Nullable java.lang.String mSplitName\nprivate final @android.annotation.NonNull android.content.pm.Checksum mChecksum\nprivate final @android.annotation.Nullable java.lang.String mInstallerPackageName\nprivate final @android.annotation.Nullable byte[] mInstallerCertificate\npublic @android.content.pm.Checksum.Type int getType()\npublic @android.annotation.NonNull byte[] getValue()\npublic @android.annotation.Nullable byte[] getInstallerCertificateBytes()\npublic @android.annotation.Nullable java.security.cert.Certificate getInstallerCertificate()\nclass ApkChecksum extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genHiddenConstructor=true)") |
| 242 |
@Deprecated |
| 243 |
private void __metadata() {} |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
} |