From 68383dca5e18dc887a75c443204096fe8490b887 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Wed, 11 Aug 2021 22:42:09 +0200 Subject: [PATCH] Allow change of minSdkVersion via settings --- .../bytecodeviewer/SettingsSerializer.java | 6 ++++-- .../bytecodeviewer/gui/MainViewerGUI.java | 20 +++++++++++++++++-- .../translation/TranslatedComponents.java | 3 ++- .../club/bytecodeviewer/util/Dex2Jar.java | 7 ++++--- src/main/resources/translations/english.json | 5 +++-- src/main/resources/translations/german.json | 3 ++- 6 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/SettingsSerializer.java b/src/main/java/the/bytecode/club/bytecodeviewer/SettingsSerializer.java index 13bacc0e..77fdb77a 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/SettingsSerializer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/SettingsSerializer.java @@ -163,7 +163,7 @@ public class SettingsSerializer save("deprecated"); save("deprecated"); save("deprecated"); - save(BytecodeViewer.viewer.fontSpinner.getValue()); + save(BytecodeViewer.viewer.getFontSize()); save(Configuration.deleteForeignLibraries); if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel())) @@ -200,6 +200,7 @@ public class SettingsSerializer save(Configuration.lastPluginDirectory); save(Configuration.python2Extra); save(Configuration.python3Extra); + save(BytecodeViewer.viewer.getMinSdkVersion()); } catch (Exception e) { BytecodeViewer.handleException(e); } @@ -396,6 +397,7 @@ public class SettingsSerializer Configuration.lastPluginDirectory = asString(138); Configuration.python2Extra = asBoolean(139); Configuration.python3Extra = asBoolean(140); + BytecodeViewer.viewer.minSdkVersionSpinner.setValue(asInt(141)); } catch (IndexOutOfBoundsException e) { @@ -426,4 +428,4 @@ public class SettingsSerializer { return Integer.parseInt(DiskReader.loadString(settingsName, lineNumber, false)); } -} \ No newline at end of file +} diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java index 15a0cb21..3ec36554 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java @@ -266,7 +266,11 @@ public class MainViewerGUI extends JFrame public final JCheckBoxMenuItem recoveryTypehInts = new TranslatedJCheckBoxMenuItem("Recover Type Hints", TranslatedComponents.RECOVER_TYPE__HINTS); public final JCheckBoxMenuItem forceTurningIFs = new TranslatedJCheckBoxMenuItem("Force Returning IFs", TranslatedComponents.FORCE_RETURNING_IFS); public final JCheckBoxMenuItem forLoopAGGCapture = new TranslatedJCheckBoxMenuItem("For Loop AGG Capture", TranslatedComponents.FOR_LOOP_AGG_CAPTURE); - + + //Smali/D2Jar + public final JMenu minSdkVersionMenu = new TranslatedJMenu("Minimum SDK version", TranslatedComponents.MIN_SDK_VERSION); + public final JSpinner minSdkVersionSpinner = new JSpinner(); + //obfuscation public final JMenu obfuscate = new JMenu("Obfuscate"); public final JMenuItem renameFields = new JMenuItem("Rename Fields"); @@ -611,6 +615,13 @@ public class MainViewerGUI extends JFrame bytecodeDecompilerSettingsSecondaryMenu.add(appendBracketsToLabels); bytecodeDecompilerSettingsDialog = new SettingsDialog(bytecodeDecompilerSettingsSecondaryMenu, new JPanel()); bytecodeDecompilerSettings.addActionListener((e)-> bytecodeDecompilerSettingsDialog.showDialog()); + + //Smali minSdkVersion + minSdkVersionSpinner.setPreferredSize(new Dimension(60, 24)); + minSdkVersionSpinner.setMinimumSize(new Dimension(60, 24)); + minSdkVersionSpinner.setModel(new SpinnerNumberModel(26, 1, null, 1)); + minSdkVersionMenu.add(minSdkVersionSpinner); + settingsMainMenu.add(minSdkVersionMenu); deleteForeignOutdatedLibs.addActionListener(arg0 -> showForeignLibraryWarning()); forcePureAsciiAsText.addActionListener(arg0 -> SettingsSerializer.saveSettingsAsync()); @@ -798,6 +809,11 @@ public class MainViewerGUI extends JFrame { return (int) fontSpinner.getValue(); } + + public int getMinSdkVersion() + { + return (int) minSdkVersionSpinner.getValue(); + } public synchronized void clearBusyStatus() { @@ -968,4 +984,4 @@ public class MainViewerGUI extends JFrame } public static final long serialVersionUID = 1851409230530948543L; -} \ No newline at end of file +} diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedComponents.java b/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedComponents.java index 173b7f37..6912e611 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedComponents.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedComponents.java @@ -250,6 +250,7 @@ public enum TranslatedComponents DESC, RESULTS, REFRESH, + MIN_SDK_VERSION, ; @@ -265,4 +266,4 @@ public enum TranslatedComponents { return componentReference; } -} \ No newline at end of file +} diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/Dex2Jar.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/Dex2Jar.java index 9e4ffd53..74d742d9 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/Dex2Jar.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/Dex2Jar.java @@ -1,9 +1,8 @@ package the.bytecode.club.bytecodeviewer.util; import com.googlecode.d2j.dex.Dex2jar; -import the.bytecode.club.bytecodeviewer.BytecodeViewer; - import java.io.File; +import the.bytecode.club.bytecodeviewer.BytecodeViewer; /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * @@ -60,7 +59,9 @@ public class Dex2Jar { public static synchronized void saveAsDex(File input, File output, boolean delete) { try { - com.googlecode.dex2jar.tools.Jar2Dex.main(input.getAbsolutePath(), "-o", output.getAbsolutePath()); + com.googlecode.dex2jar.tools.Jar2Dex.main(input.getAbsolutePath(), + "-o", output.getAbsolutePath(), + "-s", BytecodeViewer.viewer.getMinSdkVersion() + ""); if (delete) input.delete(); } catch (Exception e) { diff --git a/src/main/resources/translations/english.json b/src/main/resources/translations/english.json index 2f4037d7..52733c72 100644 --- a/src/main/resources/translations/english.json +++ b/src/main/resources/translations/english.json @@ -279,5 +279,6 @@ "SAVE": "Save...", "SAVE_AS": "Save As...", "RESULTS": "Results", - "REFRESH": "Refresh" -} \ No newline at end of file + "REFRESH": "Refresh", + "MIN_SDK_VERSION": "Minimum SDK version" +} diff --git a/src/main/resources/translations/german.json b/src/main/resources/translations/german.json index 6a1e0b19..9f40eb6b 100644 --- a/src/main/resources/translations/german.json +++ b/src/main/resources/translations/german.json @@ -254,5 +254,6 @@ "CLOSE_ALL_BUT_THIS": "Alle außer diesen schließen", "CLOSE_TAB": "Tab schließen", "PLEASE_SEND_THIS_ERROR_LOG_TO": "Bitte senden Sie dieses Fehlerprotokoll an", - "PLEASE_SEND_RESOURCES": "Wenn Sie entsprechende gesetzliche Rechte an der jeweiligen Klasse besitzen" + "PLEASE_SEND_RESOURCES": "Wenn Sie entsprechende gesetzliche Rechte an der jeweiligen Klasse besitzen", + "MIN_SDK_VERSION": "Minimale SDK-Version" }