N.B. If this method is changed, the above method #getApkDepBlockLength must also be updated to reflect the expected size of the dep block @param apkFile apk file @param context application context @return dependency file in bytes @throws IOException IOException
(File apkFile, final Context context)
| 379 | * @throws IOException IOException |
| 380 | */ |
| 381 | public static byte[] makeApkDepBlock(File apkFile, final Context context) throws IOException { |
| 382 | apkFile = apkFile.getCanonicalFile(); |
| 383 | Parcel parcel = Parcel.obtain(); |
| 384 | try { |
| 385 | parcel.writeByte(APK_SIGNATURE_VERSION); |
| 386 | parcel.writeString(apkFile.getPath()); |
| 387 | parcel.writeLong(apkFile.lastModified()); |
| 388 | parcel.writeInt(getAppVersionCode(context)); |
| 389 | return parcel.marshall(); |
| 390 | } finally { |
| 391 | parcel.recycle(); |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | public static int getAppVersionCode(final Context context) { |
| 396 | final PackageManager pm = context.getPackageManager(); |
no test coverage detected