public abstract class ApkUtils
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ApkUtils.ApkSigningBlock
Information about the location of the APK Signing Block inside an APK.
|
static class |
ApkUtils.ZipSections
Information about the ZIP sections of an APK.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ANDROID_MANIFEST_ZIP_ENTRY_NAME
Name of the Android manifest ZIP entry in APKs.
|
| Modifier and Type | Method and Description |
|---|---|
static ApkUtils.ApkSigningBlock |
findApkSigningBlock(DataSource apk,
ApkUtils.ZipSections zipSections)
Returns the APK Signing Block of the provided APK.
|
static ApkUtils.ZipSections |
findZipSections(DataSource apk)
Finds the main ZIP sections of the provided APK.
|
static java.nio.ByteBuffer |
getAndroidManifest(DataSource apk)
Returns the contents of the APK's
AndroidManifest.xml. |
static boolean |
getDebuggableFromBinaryAndroidManifest(java.nio.ByteBuffer androidManifestContents)
Returns
true if the APK is debuggable according to its AndroidManifest.xml. |
static int |
getMinSdkVersionFromBinaryAndroidManifest(java.nio.ByteBuffer androidManifestContents)
Returns the lowest Android platform version (API Level) supported by an APK with the
provided
AndroidManifest.xml. |
static java.lang.String |
getPackageNameFromBinaryAndroidManifest(java.nio.ByteBuffer androidManifestContents)
Returns the package name of the APK according to its
AndroidManifest.xml or
null if package name is not declared. |
static void |
setZipEocdCentralDirectoryOffset(java.nio.ByteBuffer zipEndOfCentralDirectory,
long offset)
Sets the offset of the start of the ZIP Central Directory in the APK's ZIP End of Central
Directory record.
|
public static final java.lang.String ANDROID_MANIFEST_ZIP_ENTRY_NAME
public static ApkUtils.ZipSections findZipSections(DataSource apk) throws java.io.IOException, ZipFormatException
java.io.IOException - if an I/O error occurred while reading the APKZipFormatException - if the APK is malformedpublic static void setZipEocdCentralDirectoryOffset(java.nio.ByteBuffer zipEndOfCentralDirectory,
long offset)
zipEndOfCentralDirectory - APK's ZIP End of Central Directory recordoffset - offset of the ZIP Central Directory relative to the start of the archive. Must
be between 0 and 2^32 - 1 inclusive.public static ApkUtils.ApkSigningBlock findApkSigningBlock(DataSource apk, ApkUtils.ZipSections zipSections) throws java.io.IOException, ApkSigningBlockNotFoundException
java.io.IOException - if an I/O error occursApkSigningBlockNotFoundException - if there is no APK Signing Block in the APKpublic static java.nio.ByteBuffer getAndroidManifest(DataSource apk) throws java.io.IOException, ApkFormatException
AndroidManifest.xml.java.io.IOException - if an I/O error occurs while reading the APKApkFormatException - if the APK is malformedpublic static int getMinSdkVersionFromBinaryAndroidManifest(java.nio.ByteBuffer androidManifestContents)
throws MinSdkVersionException
AndroidManifest.xml.androidManifestContents - contents of AndroidManifest.xml in binary Android
resource formatMinSdkVersionException - if an error occurred while determining the API Levelpublic static boolean getDebuggableFromBinaryAndroidManifest(java.nio.ByteBuffer androidManifestContents)
throws ApkFormatException
true if the APK is debuggable according to its AndroidManifest.xml.
See the android:debuggable attribute of the application element.androidManifestContents - contents of AndroidManifest.xml in binary Android
resource formatApkFormatException - if the manifest is malformedpublic static java.lang.String getPackageNameFromBinaryAndroidManifest(java.nio.ByteBuffer androidManifestContents)
throws ApkFormatException
AndroidManifest.xml or
null if package name is not declared. See the package attribute of the
manifest element.androidManifestContents - contents of AndroidManifest.xml in binary Android
resource formatApkFormatException - if the manifest is malformed