mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-07 10:35:52 +01:00
Added interface of Java decoding and building.
This commit is contained in:
parent
3cee5a0b02
commit
3955e7082c
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package brut.androlib;
|
package brut.androlib;
|
||||||
|
|
||||||
|
import brut.androlib.java.AndrolibJava;
|
||||||
import brut.androlib.res.AndrolibResources;
|
import brut.androlib.res.AndrolibResources;
|
||||||
import brut.androlib.res.data.ResTable;
|
import brut.androlib.res.data.ResTable;
|
||||||
import brut.androlib.res.util.ExtFile;
|
import brut.androlib.res.util.ExtFile;
|
||||||
@ -65,6 +66,12 @@ public class Androlib {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void decodeSourcesJava(ExtFile apkFile, File outDir)
|
||||||
|
throws AndrolibException {
|
||||||
|
LOGGER.info("Decoding Java sources...");
|
||||||
|
new AndrolibJava().decode(apkFile, outDir);
|
||||||
|
}
|
||||||
|
|
||||||
public void decodeResourcesRaw(ExtFile apkFile, File outDir)
|
public void decodeResourcesRaw(ExtFile apkFile, File outDir)
|
||||||
throws AndrolibException {
|
throws AndrolibException {
|
||||||
try {
|
try {
|
||||||
@ -120,7 +127,9 @@ public class Androlib {
|
|||||||
public void buildSources(File appDir, boolean forceBuildAll)
|
public void buildSources(File appDir, boolean forceBuildAll)
|
||||||
throws AndrolibException {
|
throws AndrolibException {
|
||||||
if (! buildSourcesRaw(appDir, forceBuildAll)
|
if (! buildSourcesRaw(appDir, forceBuildAll)
|
||||||
&& ! buildSourcesSmali(appDir, forceBuildAll)) {
|
&& ! buildSourcesSmali(appDir, forceBuildAll)
|
||||||
|
&& ! buildSourcesJava(appDir, forceBuildAll)
|
||||||
|
) {
|
||||||
LOGGER.warning("Could not find sources");
|
LOGGER.warning("Could not find sources");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,6 +171,24 @@ public class Androlib {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean buildSourcesJava(File appDir, boolean forceBuildAll)
|
||||||
|
throws AndrolibException {
|
||||||
|
File javaDir = new File(appDir, "src");
|
||||||
|
if (! javaDir.exists()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
File dex = new File(appDir, APK_DIRNAME + "/classes.dex");
|
||||||
|
if (! forceBuildAll) {
|
||||||
|
LOGGER.info("Checking whether sources has changed...");
|
||||||
|
}
|
||||||
|
if (forceBuildAll || isModified(javaDir, dex)) {
|
||||||
|
LOGGER.info("Building java sources...");
|
||||||
|
dex.delete();
|
||||||
|
new AndrolibJava().build(javaDir, dex);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void buildResources(ExtFile appDir, boolean forceBuildAll,
|
public void buildResources(ExtFile appDir, boolean forceBuildAll,
|
||||||
boolean framework) throws AndrolibException {
|
boolean framework) throws AndrolibException {
|
||||||
if (! buildResourcesRaw(appDir, forceBuildAll)
|
if (! buildResourcesRaw(appDir, forceBuildAll)
|
||||||
|
@ -68,6 +68,9 @@ public class ApkDecoder {
|
|||||||
case DECODE_SOURCES_SMALI:
|
case DECODE_SOURCES_SMALI:
|
||||||
mAndrolib.decodeSourcesSmali(mApkFile, outDir);
|
mAndrolib.decodeSourcesSmali(mApkFile, outDir);
|
||||||
break;
|
break;
|
||||||
|
case DECODE_SOURCES_JAVA:
|
||||||
|
mAndrolib.decodeSourcesJava(mApkFile, outDir);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
switch (mDecodeResources) {
|
switch (mDecodeResources) {
|
||||||
case DECODE_RESOURCES_NONE:
|
case DECODE_RESOURCES_NONE:
|
||||||
@ -81,7 +84,8 @@ public class ApkDecoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setDecodeSources(short mode) throws AndrolibException {
|
public void setDecodeSources(short mode) throws AndrolibException {
|
||||||
if (mode != DECODE_SOURCES_NONE && mode != DECODE_SOURCES_SMALI) {
|
if (mode != DECODE_SOURCES_NONE && mode != DECODE_SOURCES_SMALI
|
||||||
|
&& mode != DECODE_SOURCES_JAVA) {
|
||||||
throw new AndrolibException("Invalid decode sources mode: " + mode);
|
throw new AndrolibException("Invalid decode sources mode: " + mode);
|
||||||
}
|
}
|
||||||
mDecodeSources = mode;
|
mDecodeSources = mode;
|
||||||
@ -104,6 +108,7 @@ public class ApkDecoder {
|
|||||||
|
|
||||||
public final static short DECODE_SOURCES_NONE = 0x0000;
|
public final static short DECODE_SOURCES_NONE = 0x0000;
|
||||||
public final static short DECODE_SOURCES_SMALI = 0x0001;
|
public final static short DECODE_SOURCES_SMALI = 0x0001;
|
||||||
|
public final static short DECODE_SOURCES_JAVA = 0x0002;
|
||||||
|
|
||||||
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;
|
||||||
|
34
src/brut/androlib/java/AndrolibJava.java
Normal file
34
src/brut/androlib/java/AndrolibJava.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010 Ryszard Wiśniewski <brut.alll@gmail.com>.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package brut.androlib.java;
|
||||||
|
|
||||||
|
import brut.androlib.res.util.ExtFile;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||||
|
*/
|
||||||
|
public class AndrolibJava {
|
||||||
|
|
||||||
|
public void decode(ExtFile apkFile, File outDir) {
|
||||||
|
throw new UnsupportedOperationException("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void build(File javaDir, File dex) {
|
||||||
|
throw new UnsupportedOperationException("Not yet implemented");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user