Skip to content

Commit

Permalink
Merge pull request iBotPeaches#1173 from iBotPeaches/major/remove-sma…
Browse files Browse the repository at this point in the history
…lidebugging

Removes SmaliDebugging
  • Loading branch information
iBotPeaches committed Feb 28, 2016
2 parents 1ff3a37 + eabedeb commit a2b3d6b
Show file tree
Hide file tree
Showing 26 changed files with 39 additions and 1,261 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
env:
- TERM=dumb
language: java
git:
submodules: false
jdk:
- openjdk7
- oraclejdk7
Expand All @@ -21,9 +19,7 @@ before_install:
- git config --global user.name "Travis CI Bot"
- sudo apt-get update -qq
- sudo apt-get install -qq libstdc++6:i386 lib32z1 expect
- sed -i 's/[email protected]:/https:\/\/github.com\//' .gitmodules
- git submodule update --init --recursive
install: ./gradlew applyPatches
script: ./gradlew build fatJar proguard
branches:
only:
Expand Down
5 changes: 1 addition & 4 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,4 @@ released under the following license:
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.
*******************************************************************************

The sub project (brut.apktool.smali) is a clone of the smali project. Its
license can be found at brut.apktool.smali/NOTICE-SMALI
*******************************************************************************
19 changes: 5 additions & 14 deletions brut.apktool/apktool-cli/src/main/java/brut/apktool/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,8 @@ private static void cmdDecode(CommandLine cli) throws AndrolibException {
decoder.setDecodeSources(ApkDecoder.DECODE_SOURCES_NONE);
}
if (cli.hasOption("d") || cli.hasOption("debug")) {
decoder.setDebugMode(true);
}
if (cli.hasOption("debug-line-prefix")) {
decoder.setDebugLinePrefix(cli.getOptionValue("debug-line-prefix"));
System.err.println("SmaliDebugging has been removed in 2.1.0 onward. Please see: https://github.com/iBotPeaches/Apktool/issues/1061");
System.exit(1);
}
if (cli.hasOption("b") || cli.hasOption("no-debug-info")) {
decoder.setBaksmaliDebugMode(false);
Expand Down Expand Up @@ -201,7 +199,8 @@ private static void cmdBuild(CommandLine cli) throws BrutException {
apkOptions.forceBuildAll = true;
}
if (cli.hasOption("d") || cli.hasOption("debug")) {
apkOptions.debugMode = true;
System.err.println("SmaliDebugging has been removed in 2.1.0 onward. Please see: https://github.com/iBotPeaches/Apktool/issues/1061");
System.exit(1);
}
if (cli.hasOption("v") || cli.hasOption("verbose")) {
apkOptions.verbose = true;
Expand Down Expand Up @@ -273,19 +272,13 @@ private static void _Options() {
.create("r");

Option debugDecOption = OptionBuilder.withLongOpt("debug")
.withDescription("Decode in debug mode. Check project page for more info.")
.withDescription("REMOVED (DOES NOT WORK): Decode in debug mode.")
.create("d");

Option analysisOption = OptionBuilder.withLongOpt("match-original")
.withDescription("Keeps files to closest to original as possible. Prevents rebuild.")
.create("m");

Option debugLinePrefix = OptionBuilder.withLongOpt("debug-line-prefix")
.withDescription("Smali line prefix when decoding in debug mode. Default is \"a=0;// \".")
.hasArg(true)
.withArgName("prefix")
.create();

Option apiLevelOption = OptionBuilder.withLongOpt("api")
.withDescription("The numeric api-level of the file to generate, e.g. 14 for ICS.")
.hasArg(true)
Expand Down Expand Up @@ -369,7 +362,6 @@ private static void _Options() {

// check for advance mode
if (isAdvanceMode()) {
DecodeOptions.addOption(debugLinePrefix);
DecodeOptions.addOption(debugDecOption);
DecodeOptions.addOption(noDbgOption);
DecodeOptions.addOption(keepResOption);
Expand Down Expand Up @@ -416,7 +408,6 @@ private static void _Options() {
allOptions.addOption((Option)op);
}
allOptions.addOption(analysisOption);
allOptions.addOption(debugLinePrefix);
allOptions.addOption(debugDecOption);
allOptions.addOption(noDbgOption);
allOptions.addOption(keepResOption);
Expand Down
6 changes: 2 additions & 4 deletions brut.apktool/apktool-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ dependencies {
compile project(':brut.j.dir'),
project(':brut.j.util'),
project(':brut.j.common'),
project(':brut.apktool.smali:util'),
project(':brut.apktool.smali:dexlib2'),
project(':brut.apktool.smali:baksmali'),
project(':brut.apktool.smali:smali'),
depends.baksmali,
depends.smali,
depends.snakeyaml,
depends.xmlpull,
depends.guava,
Expand Down
45 changes: 6 additions & 39 deletions brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package brut.androlib;

import brut.androlib.java.AndrolibJava;
import brut.androlib.meta.MetaInfo;
import brut.androlib.meta.UsesFramework;
import brut.androlib.res.AndrolibResources;
Expand Down Expand Up @@ -80,8 +79,8 @@ public void decodeSourcesRaw(ExtFile apkFile, File outDir, String filename)
}
}

public void decodeSourcesSmali(File apkFile, File outDir, String filename, boolean debug, String debugLinePrefix,
boolean bakdeb, int api) throws AndrolibException {
public void decodeSourcesSmali(File apkFile, File outDir, String filename, boolean bakdeb, int api)
throws AndrolibException {
try {
File smaliDir;
if (filename.equalsIgnoreCase("classes.dex")) {
Expand All @@ -92,18 +91,12 @@ public void decodeSourcesSmali(File apkFile, File outDir, String filename, boole
OS.rmdir(smaliDir);
smaliDir.mkdirs();
LOGGER.info("Baksmaling " + filename + "...");
SmaliDecoder.decode(apkFile, smaliDir, filename, debug, debugLinePrefix, bakdeb, api);
SmaliDecoder.decode(apkFile, smaliDir, filename, bakdeb, api);
} catch (BrutException ex) {
throw new AndrolibException(ex);
}
}

public void decodeSourcesJava(ExtFile apkFile, File outDir, boolean debug)
throws AndrolibException {
LOGGER.info("Decoding Java sources...");
new AndrolibJava().decode(apkFile, outDir);
}

public void decodeManifestRaw(ExtFile apkFile, File outDir)
throws AndrolibException {
try {
Expand Down Expand Up @@ -299,9 +292,7 @@ public void build(ExtFile appDir, File outFile)

public void buildSources(File appDir)
throws AndrolibException {
if (!buildSourcesRaw(appDir, "classes.dex")
&& !buildSourcesSmali(appDir, "smali", "classes.dex")
&& !buildSourcesJava(appDir)) {
if (!buildSourcesRaw(appDir, "classes.dex") && !buildSourcesSmali(appDir, "smali", "classes.dex")) {
LOGGER.warning("Could not find sources");
}
}
Expand All @@ -316,9 +307,7 @@ public void buildNonDefaultSources(ExtFile appDir)
if (name.startsWith("smali_")) {
String filename = name.substring(name.indexOf("_") + 1) + ".dex";

if (!buildSourcesRaw(appDir, filename)
&& !buildSourcesSmali(appDir, name, filename)
&& !buildSourcesJava(appDir)) {
if (!buildSourcesRaw(appDir, filename) && !buildSourcesSmali(appDir, name, filename)) {
LOGGER.warning("Could not find sources");
}
}
Expand Down Expand Up @@ -372,25 +361,7 @@ public boolean buildSourcesSmali(File appDir, String folder, String filename)
if (apkOptions.forceBuildAll || isModified(smaliDir, dex)) {
LOGGER.info("Smaling " + folder + " folder into " + filename +"...");
dex.delete();
SmaliBuilder.build(smaliDir, dex, apkOptions.debugMode);
}
return true;
}

public boolean buildSourcesJava(File appDir)
throws AndrolibException {
File javaDir = new File(appDir, "src");
if (!javaDir.exists()) {
return false;
}
File dex = new File(appDir, APK_DIRNAME + "/classes.dex");
if (! apkOptions.forceBuildAll) {
LOGGER.info("Checking whether sources has changed...");
}
if (apkOptions.forceBuildAll || isModified(javaDir, dex)) {
LOGGER.info("Building java sources...");
dex.delete();
new AndrolibJava().build(javaDir, dex);
SmaliBuilder.build(smaliDir, dex);
}
return true;
}
Expand Down Expand Up @@ -487,10 +458,6 @@ public boolean buildManifest(ExtFile appDir, UsesFramework usesFramework)

File apkDir = new File(appDir, APK_DIRNAME);

if (apkOptions.debugMode) {
ResXmlPatcher.removeApplicationDebugTag(new File(apkDir,"AndroidManifest.xml"));
}

if (apkOptions.forceBuildAll || isModified(newFiles(APK_MANIFEST_FILENAMES, appDir),
newFiles(APK_MANIFEST_FILENAMES, apkDir))) {
LOGGER.info("Building AndroidManifest.xml...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,7 @@ public void decode() throws AndrolibException, IOException, DirectoryException {
mAndrolib.decodeSourcesRaw(mApkFile, outDir, "classes.dex");
break;
case DECODE_SOURCES_SMALI:
mAndrolib.decodeSourcesSmali(mApkFile, outDir, "classes.dex", mDebug, mDebugLinePrefix, mBakDeb, mApi);
break;
case DECODE_SOURCES_JAVA:
mAndrolib.decodeSourcesJava(mApkFile, outDir, mDebug);
mAndrolib.decodeSourcesSmali(mApkFile, outDir, "classes.dex", mBakDeb, mApi);
break;
}
}
Expand All @@ -147,10 +144,7 @@ public void decode() throws AndrolibException, IOException, DirectoryException {
mAndrolib.decodeSourcesRaw(mApkFile, outDir, file);
break;
case DECODE_SOURCES_SMALI:
mAndrolib.decodeSourcesSmali(mApkFile, outDir, file, mDebug, mDebugLinePrefix, mBakDeb, mApi);
break;
case DECODE_SOURCES_JAVA:
mAndrolib.decodeSourcesJava(mApkFile, outDir, mDebug);
mAndrolib.decodeSourcesSmali(mApkFile, outDir, file, mBakDeb, mApi);
break;
}
}
Expand All @@ -167,7 +161,7 @@ public void decode() throws AndrolibException, IOException, DirectoryException {
}

public void setDecodeSources(short mode) throws AndrolibException {
if (mode != DECODE_SOURCES_NONE && mode != DECODE_SOURCES_SMALI && mode != DECODE_SOURCES_JAVA) {
if (mode != DECODE_SOURCES_NONE && mode != DECODE_SOURCES_SMALI) {
throw new AndrolibException("Invalid decode sources mode: " + mode);
}
mDecodeSources = mode;
Expand All @@ -180,11 +174,6 @@ public void setDecodeResources(short mode) throws AndrolibException {
mDecodeResources = mode;
}

public void setDebugMode(boolean debug) {
LOGGER.warning("SmaliDebugging has been deprecated. It will be removed in Apktool 2.1 - https://github.com/iBotPeaches/Apktool/issues/1061");
mDebug = debug;
}

public void setAnalysisMode(boolean mode, boolean pass) throws AndrolibException{
mAnalysisMode = mode;

Expand All @@ -208,10 +197,6 @@ public void setTargetSdkVersion() throws AndrolibException, IOException {
}
}

public void setDebugLinePrefix(String debugLinePrefix) {
mDebugLinePrefix = debugLinePrefix;
}

public void setBaksmaliDebugMode(boolean bakdeb) {
mBakDeb = bakdeb;
}
Expand Down Expand Up @@ -288,7 +273,6 @@ public boolean hasResources() throws AndrolibException {

public final static short DECODE_SOURCES_NONE = 0x0000;
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_FULL = 0x0101;
Expand Down Expand Up @@ -396,8 +380,6 @@ private void putSharedLibraryInfo(MetaInfo meta) throws AndrolibException {
private ResTable mResTable;
private short mDecodeSources = DECODE_SOURCES_SMALI;
private short mDecodeResources = DECODE_RESOURCES_FULL;
private String mDebugLinePrefix = "a=0;// ";
private boolean mDebug = false;
private boolean mForceDelete = false;
private boolean mKeepBrokenResources = false;
private boolean mBakDeb = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

public class ApkOptions {
public boolean forceBuildAll = false;
public boolean debugMode = false;
public boolean verbose = false;
public boolean copyOriginalFiles = false;
public boolean updateFiles = false;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,6 @@ public void aaptPackage(File apkFile, File manifest, File resDir, File rawDir, F
if (apkOptions.updateFiles) {
cmd.add("-u");
}
if (apkOptions.debugMode) { // inject debuggable="true" into manifest
cmd.add("--debug-mode");
}

// force package id so that some frameworks build with correct id
// disable if user adds own aapt (can't know if they have this feature)
if (mPackageId != null && ! customAapt && ! mSharedLibrary) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,6 @@
* @author Connor Tumbleson <[email protected]>
*/
public final class ResXmlPatcher {

/**
* Removes "debug" tag from file
*
* @param file AndroidManifest file
* @throws AndrolibException
*/
public static void removeApplicationDebugTag(File file) throws AndrolibException {
if (file.exists()) {
try {
Document doc = loadDocument(file);
Node application = doc.getElementById("application");

// load attr
NamedNodeMap attr = application.getAttributes();
Node debugAttr = attr.getNamedItem("debug");

// remove application:debug
if (debugAttr != null) {
attr.removeNamedItem("debug");
}

saveDocument(file, doc);

} catch (SAXException | ParserConfigurationException | IOException | TransformerException ignored) {
}
}
}

/**
* Any @string reference in a <provider> value in AndroidManifest.xml will break on
* build, thus preventing the application from installing. This is from a bug/error
Expand Down
Loading

0 comments on commit a2b3d6b

Please sign in to comment.