mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-12 13:57:46 +01:00
Add ability to force decoding of manifest
This commit is contained in:
parent
2b9728e9f3
commit
dd81dbfc9c
@ -124,6 +124,9 @@ public class Main {
|
|||||||
if (cli.hasOption("r") || cli.hasOption("no-res")) {
|
if (cli.hasOption("r") || cli.hasOption("no-res")) {
|
||||||
decoder.setDecodeResources(ApkDecoder.DECODE_RESOURCES_NONE);
|
decoder.setDecodeResources(ApkDecoder.DECODE_RESOURCES_NONE);
|
||||||
}
|
}
|
||||||
|
if (cli.hasOption("force-manifest")) {
|
||||||
|
decoder.setForceDecodeManifest(ApkDecoder.FORCE_DECODE_MANIFEST_FULL);
|
||||||
|
}
|
||||||
if (cli.hasOption("no-assets")) {
|
if (cli.hasOption("no-assets")) {
|
||||||
decoder.setDecodeAssets(ApkDecoder.DECODE_ASSETS_NONE);
|
decoder.setDecodeAssets(ApkDecoder.DECODE_ASSETS_NONE);
|
||||||
}
|
}
|
||||||
@ -286,6 +289,11 @@ public class Main {
|
|||||||
.desc("Do not decode resources.")
|
.desc("Do not decode resources.")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
Option forceManOption = Option.builder()
|
||||||
|
.longOpt("force-manifest")
|
||||||
|
.desc("Decode the APK's compiled manifest, even if decoding of resources is set to \"false\".")
|
||||||
|
.build();
|
||||||
|
|
||||||
Option noAssetOption = Option.builder()
|
Option noAssetOption = Option.builder()
|
||||||
.longOpt("no-assets")
|
.longOpt("no-assets")
|
||||||
.desc("Do not decode assets.")
|
.desc("Do not decode assets.")
|
||||||
@ -405,6 +413,7 @@ public class Main {
|
|||||||
DecodeOptions.addOption(analysisOption);
|
DecodeOptions.addOption(analysisOption);
|
||||||
DecodeOptions.addOption(apiLevelOption);
|
DecodeOptions.addOption(apiLevelOption);
|
||||||
DecodeOptions.addOption(noAssetOption);
|
DecodeOptions.addOption(noAssetOption);
|
||||||
|
DecodeOptions.addOption(forceManOption);
|
||||||
|
|
||||||
BuildOptions.addOption(debugBuiOption);
|
BuildOptions.addOption(debugBuiOption);
|
||||||
BuildOptions.addOption(aaptOption);
|
BuildOptions.addOption(aaptOption);
|
||||||
@ -453,6 +462,7 @@ public class Main {
|
|||||||
allOptions.addOption(analysisOption);
|
allOptions.addOption(analysisOption);
|
||||||
allOptions.addOption(debugDecOption);
|
allOptions.addOption(debugDecOption);
|
||||||
allOptions.addOption(noDbgOption);
|
allOptions.addOption(noDbgOption);
|
||||||
|
allOptions.addOption(forceManOption);
|
||||||
allOptions.addOption(noAssetOption);
|
allOptions.addOption(noAssetOption);
|
||||||
allOptions.addOption(keepResOption);
|
allOptions.addOption(keepResOption);
|
||||||
allOptions.addOption(debugBuiOption);
|
allOptions.addOption(debugBuiOption);
|
||||||
|
@ -104,6 +104,15 @@ public class ApkDecoder {
|
|||||||
switch (mDecodeResources) {
|
switch (mDecodeResources) {
|
||||||
case DECODE_RESOURCES_NONE:
|
case DECODE_RESOURCES_NONE:
|
||||||
mAndrolib.decodeResourcesRaw(mApkFile, outDir);
|
mAndrolib.decodeResourcesRaw(mApkFile, outDir);
|
||||||
|
if (mForceDecodeManifest == FORCE_DECODE_MANIFEST_FULL) {
|
||||||
|
setTargetSdkVersion();
|
||||||
|
setAnalysisMode(mAnalysisMode, true);
|
||||||
|
|
||||||
|
// done after raw decoding of resources because copyToDir overwrites dest files
|
||||||
|
if (hasManifest()) {
|
||||||
|
mAndrolib.decodeManifestWithResources(mApkFile, outDir, getResTable());
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DECODE_RESOURCES_FULL:
|
case DECODE_RESOURCES_FULL:
|
||||||
setTargetSdkVersion();
|
setTargetSdkVersion();
|
||||||
@ -119,14 +128,12 @@ public class ApkDecoder {
|
|||||||
// if there's no resources.asrc, decode the manifest without looking
|
// if there's no resources.asrc, decode the manifest without looking
|
||||||
// up attribute references
|
// up attribute references
|
||||||
if (hasManifest()) {
|
if (hasManifest()) {
|
||||||
switch (mDecodeResources) {
|
if (mDecodeResources == DECODE_RESOURCES_FULL
|
||||||
case DECODE_RESOURCES_NONE:
|
|| mForceDecodeManifest == FORCE_DECODE_MANIFEST_FULL) {
|
||||||
|
mAndrolib.decodeManifestFull(mApkFile, outDir, getResTable());
|
||||||
|
}
|
||||||
|
else {
|
||||||
mAndrolib.decodeManifestRaw(mApkFile, outDir);
|
mAndrolib.decodeManifestRaw(mApkFile, outDir);
|
||||||
break;
|
|
||||||
case DECODE_RESOURCES_FULL:
|
|
||||||
mAndrolib.decodeManifestFull(mApkFile, outDir,
|
|
||||||
getResTable());
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -190,6 +197,13 @@ public class ApkDecoder {
|
|||||||
mDecodeResources = mode;
|
mDecodeResources = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setForceDecodeManifest(short mode) throws AndrolibException {
|
||||||
|
if (mode != FORCE_DECODE_MANIFEST_NONE && mode != FORCE_DECODE_MANIFEST_FULL) {
|
||||||
|
throw new AndrolibException("Invalid force decode manifest mode");
|
||||||
|
}
|
||||||
|
mForceDecodeManifest = mode;
|
||||||
|
}
|
||||||
|
|
||||||
public void setDecodeAssets(short mode) throws AndrolibException {
|
public void setDecodeAssets(short mode) throws AndrolibException {
|
||||||
if (mode != DECODE_ASSETS_NONE && mode != DECODE_ASSETS_FULL) {
|
if (mode != DECODE_ASSETS_NONE && mode != DECODE_ASSETS_FULL) {
|
||||||
throw new AndrolibException("Invalid decode asset mode");
|
throw new AndrolibException("Invalid decode asset mode");
|
||||||
@ -306,6 +320,9 @@ public class ApkDecoder {
|
|||||||
public final static short DECODE_RESOURCES_NONE = 0x0100;
|
public final static short DECODE_RESOURCES_NONE = 0x0100;
|
||||||
public final static short DECODE_RESOURCES_FULL = 0x0101;
|
public final static short DECODE_RESOURCES_FULL = 0x0101;
|
||||||
|
|
||||||
|
public final static short FORCE_DECODE_MANIFEST_NONE = 0x0000;
|
||||||
|
public final static short FORCE_DECODE_MANIFEST_FULL = 0x0001;
|
||||||
|
|
||||||
public final static short DECODE_ASSETS_NONE = 0x0000;
|
public final static short DECODE_ASSETS_NONE = 0x0000;
|
||||||
public final static short DECODE_ASSETS_FULL = 0x0001;
|
public final static short DECODE_ASSETS_FULL = 0x0001;
|
||||||
|
|
||||||
@ -417,6 +434,7 @@ public class ApkDecoder {
|
|||||||
private ResTable mResTable;
|
private ResTable mResTable;
|
||||||
private short mDecodeSources = DECODE_SOURCES_SMALI;
|
private short mDecodeSources = DECODE_SOURCES_SMALI;
|
||||||
private short mDecodeResources = DECODE_RESOURCES_FULL;
|
private short mDecodeResources = DECODE_RESOURCES_FULL;
|
||||||
|
private short mForceDecodeManifest = FORCE_DECODE_MANIFEST_NONE;
|
||||||
private short mDecodeAssets = DECODE_ASSETS_FULL;
|
private short mDecodeAssets = DECODE_ASSETS_FULL;
|
||||||
private boolean mForceDelete = false;
|
private boolean mForceDelete = false;
|
||||||
private boolean mKeepBrokenResources = false;
|
private boolean mKeepBrokenResources = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user