refactor: move system info class to common app lib
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package jadx.commons.app;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class JadxSystemInfo {
|
||||
public static final String JAVA_VM = System.getProperty("java.vm.name", "?");
|
||||
public static final String JAVA_VER = System.getProperty("java.version", "?");
|
||||
|
||||
public static final String OS_NAME = System.getProperty("os.name", "?");
|
||||
public static final String OS_ARCH = System.getProperty("os.arch", "?");
|
||||
public static final String OS_VERSION = System.getProperty("os.version", "?");
|
||||
|
||||
private static final String OS_NAME_LOWER = OS_NAME.toLowerCase(Locale.ENGLISH);
|
||||
public static final boolean IS_WINDOWS = OS_NAME_LOWER.startsWith("windows");
|
||||
public static final boolean IS_MAC = OS_NAME_LOWER.startsWith("mac");
|
||||
public static final boolean IS_LINUX = !IS_WINDOWS && !IS_MAC;
|
||||
public static final boolean IS_UNIX = !IS_WINDOWS;
|
||||
|
||||
private static final String OS_ARCH_LOWER = OS_NAME.toLowerCase(Locale.ENGLISH);
|
||||
public static final boolean IS_AMD64 = OS_ARCH_LOWER.equals("amd64");
|
||||
public static final boolean IS_ARM64 = OS_ARCH_LOWER.equals("aarch64");
|
||||
|
||||
private JadxSystemInfo() {
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.cli.JCommanderWrapper;
|
||||
import jadx.cli.LogHelper;
|
||||
import jadx.commons.app.JadxSystemInfo;
|
||||
import jadx.core.Jadx;
|
||||
import jadx.core.utils.files.FileUtils;
|
||||
import jadx.gui.logs.LogCollector;
|
||||
import jadx.gui.settings.JadxSettings;
|
||||
@@ -17,7 +19,6 @@ import jadx.gui.ui.MainWindow;
|
||||
import jadx.gui.ui.dialog.ExceptionDialog;
|
||||
import jadx.gui.utils.LafManager;
|
||||
import jadx.gui.utils.NLS;
|
||||
import jadx.gui.utils.SystemInfo;
|
||||
|
||||
public class JadxGUI {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JadxGUI.class);
|
||||
@@ -67,10 +68,10 @@ public class JadxGUI {
|
||||
|
||||
private static void printSystemInfo() {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Starting jadx-gui. Version: '{}'. JVM: {} {}. OS: {} {}",
|
||||
SystemInfo.JADX_VERSION,
|
||||
SystemInfo.JAVA_VM, SystemInfo.JAVA_VER,
|
||||
SystemInfo.OS_NAME, SystemInfo.OS_VERSION);
|
||||
LOG.debug("Starting jadx-gui. Version: '{}'. JVM: {} {}. OS: {}, version: {}, arch: {}",
|
||||
Jadx.getVersion(),
|
||||
JadxSystemInfo.JAVA_VM, JadxSystemInfo.JAVA_VER,
|
||||
JadxSystemInfo.OS_NAME, JadxSystemInfo.OS_VERSION, JadxSystemInfo.OS_ARCH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
|
||||
import jadx.commons.app.JadxSystemInfo;
|
||||
import jadx.core.utils.exceptions.JadxRuntimeException;
|
||||
import jadx.gui.jobs.BackgroundExecutor;
|
||||
import jadx.gui.logs.LogOptions;
|
||||
import jadx.gui.treemodel.JRoot;
|
||||
import jadx.gui.ui.MainWindow;
|
||||
import jadx.gui.utils.SystemInfo;
|
||||
import jadx.gui.utils.UiUtils;
|
||||
|
||||
public class QuarkManager {
|
||||
@@ -132,7 +132,7 @@ public class QuarkManager {
|
||||
}
|
||||
}
|
||||
List<String> cmd = new ArrayList<>();
|
||||
if (SystemInfo.IS_WINDOWS) {
|
||||
if (JadxSystemInfo.IS_WINDOWS) {
|
||||
cmd.add("python");
|
||||
cmd.add("-m");
|
||||
cmd.add("venv");
|
||||
@@ -197,7 +197,7 @@ public class QuarkManager {
|
||||
}
|
||||
|
||||
private Path getVenvPath(String cmd) {
|
||||
if (SystemInfo.IS_WINDOWS) {
|
||||
if (JadxSystemInfo.IS_WINDOWS) {
|
||||
return VENV_PATH.resolve("Scripts").resolve(cmd + ".exe");
|
||||
}
|
||||
return VENV_PATH.resolve("bin").resolve(cmd);
|
||||
|
||||
@@ -7,11 +7,12 @@ import java.awt.event.InputEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
|
||||
import jadx.gui.utils.UiUtils;
|
||||
import jadx.commons.app.JadxSystemInfo;
|
||||
|
||||
public class JadxEventQueue extends EventQueue {
|
||||
|
||||
private static final boolean IS_X_TOOLKIT = UiUtils.isXToolkit();
|
||||
private static final boolean IS_X_TOOLKIT = JadxSystemInfo.IS_LINUX
|
||||
&& "sun.awt.X11.XToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName());
|
||||
|
||||
public static void register() {
|
||||
if (IS_X_TOOLKIT) {
|
||||
|
||||
@@ -84,6 +84,7 @@ import jadx.api.plugins.events.JadxEvents;
|
||||
import jadx.api.plugins.events.types.ReloadProject;
|
||||
import jadx.api.plugins.events.types.ReloadSettingsWindow;
|
||||
import jadx.api.plugins.utils.CommonFileUtils;
|
||||
import jadx.commons.app.JadxSystemInfo;
|
||||
import jadx.core.Jadx;
|
||||
import jadx.core.dex.nodes.ClassNode;
|
||||
import jadx.core.dex.nodes.FieldNode;
|
||||
@@ -172,7 +173,6 @@ import jadx.gui.utils.Icons;
|
||||
import jadx.gui.utils.LafManager;
|
||||
import jadx.gui.utils.Link;
|
||||
import jadx.gui.utils.NLS;
|
||||
import jadx.gui.utils.SystemInfo;
|
||||
import jadx.gui.utils.UiUtils;
|
||||
import jadx.gui.utils.dbg.UIWatchDog;
|
||||
import jadx.gui.utils.fileswatcher.LiveReloadWorker;
|
||||
@@ -1282,7 +1282,7 @@ public class MainWindow extends JFrame {
|
||||
JMenu help = new JadxMenu(NLS.str("menu.help"), shortcutsController);
|
||||
help.setMnemonic(KeyEvent.VK_H);
|
||||
help.add(showLogAction);
|
||||
if (SystemInfo.IS_UNIX && !SystemInfo.IS_MAC) {
|
||||
if (JadxSystemInfo.IS_LINUX) {
|
||||
help.add(new JadxGuiAction(ActionModel.CREATE_DESKTOP_ENTRY, this::createDesktopEntry));
|
||||
}
|
||||
if (Jadx.isDevVersion()) {
|
||||
@@ -1299,7 +1299,7 @@ public class MainWindow extends JFrame {
|
||||
help.add(uiWatchDog);
|
||||
}
|
||||
|
||||
if (SystemInfo.IS_MAC) {
|
||||
if (JadxSystemInfo.IS_MAC) {
|
||||
System.setProperty("apple.laf.useScreenMenuBar", "true");
|
||||
Desktop.getDesktop().setAboutHandler(e -> aboutAction.actionPerformed(null));
|
||||
} else {
|
||||
|
||||
@@ -38,6 +38,7 @@ import javax.swing.tree.TreeSelectionModel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.commons.app.JadxSystemInfo;
|
||||
import jadx.core.utils.StringUtils;
|
||||
import jadx.core.utils.exceptions.JadxRuntimeException;
|
||||
import jadx.gui.device.debugger.DbgUtils;
|
||||
@@ -48,7 +49,6 @@ import jadx.gui.device.protocol.ADBDeviceInfo;
|
||||
import jadx.gui.ui.MainWindow;
|
||||
import jadx.gui.ui.panel.IDebugController;
|
||||
import jadx.gui.utils.NLS;
|
||||
import jadx.gui.utils.SystemInfo;
|
||||
import jadx.gui.utils.UiUtils;
|
||||
|
||||
public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.JDWPProcessListener {
|
||||
@@ -208,7 +208,7 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J
|
||||
}
|
||||
|
||||
private void detectADBPath() {
|
||||
boolean isWinOS = SystemInfo.IS_WINDOWS;
|
||||
boolean isWinOS = JadxSystemInfo.IS_WINDOWS;
|
||||
String slash = isWinOS ? "\\" : "/";
|
||||
String adbName = isWinOS ? "adb.exe" : "adb";
|
||||
String sdkPath = System.getenv("ANDROID_HOME");
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.api.JadxDecompiler;
|
||||
import jadx.commons.app.JadxSystemInfo;
|
||||
import jadx.core.utils.exceptions.JadxRuntimeException;
|
||||
import jadx.gui.settings.JadxSettings;
|
||||
import jadx.gui.settings.JadxSettingsAdapter;
|
||||
@@ -66,11 +67,11 @@ public class ExceptionDialog extends JDialog {
|
||||
|
||||
Map<String, String> details = new LinkedHashMap<>();
|
||||
details.put("Jadx version", JadxDecompiler.getVersion());
|
||||
details.put("Java version", System.getProperty("java.version", "?"));
|
||||
details.put("Java VM", String.format("%s %s", System.getProperty("java.vm.vendor", "?"),
|
||||
System.getProperty("java.vm.name", "?")));
|
||||
details.put("Platform", String.format("%s (%s %s)", System.getProperty("os.name", "?"),
|
||||
System.getProperty("os.version", "?"), System.getProperty("os.arch", "?")));
|
||||
details.put("Java version", JadxSystemInfo.JAVA_VER);
|
||||
details.put("Java VM", String.format("%s %s",
|
||||
System.getProperty("java.vm.vendor", "?"), System.getProperty("java.vm.name", "?")));
|
||||
details.put("Platform", String.format("%s (%s %s)",
|
||||
JadxSystemInfo.OS_NAME, JadxSystemInfo.OS_VERSION, JadxSystemInfo.OS_ARCH));
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
details.put("Max heap size", String.format("%d MB", runtime.maxMemory() / (1024 * 1024)));
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ import javax.swing.JTextArea;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.commons.app.JadxSystemInfo;
|
||||
|
||||
import static java.awt.Desktop.Action;
|
||||
|
||||
public class Link extends JLabel {
|
||||
@@ -61,13 +63,13 @@ public class Link extends JLabel {
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (SystemInfo.IS_WINDOWS) {
|
||||
if (JadxSystemInfo.IS_WINDOWS) {
|
||||
new ProcessBuilder()
|
||||
.command(new String[] { "rundll32", "url.dll,FileProtocolHandler", url })
|
||||
.start();
|
||||
return;
|
||||
}
|
||||
if (SystemInfo.IS_MAC) {
|
||||
if (JadxSystemInfo.IS_MAC) {
|
||||
new ProcessBuilder()
|
||||
.command(new String[] { "open", url })
|
||||
.start();
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package jadx.gui.utils;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import jadx.api.JadxDecompiler;
|
||||
|
||||
public class SystemInfo {
|
||||
public static final String JADX_VERSION = JadxDecompiler.getVersion();
|
||||
|
||||
public static final String JAVA_VM = System.getProperty("java.vm.name");
|
||||
public static final String JAVA_VER = System.getProperty("java.version");
|
||||
|
||||
public static final String OS_NAME = System.getProperty("os.name");
|
||||
public static final String OS_VERSION = System.getProperty("os.version");
|
||||
|
||||
private static final String LOWER_OS_NAME = OS_NAME.toLowerCase(Locale.ENGLISH);
|
||||
public static final boolean IS_WINDOWS = LOWER_OS_NAME.startsWith("windows");
|
||||
public static final boolean IS_MAC = LOWER_OS_NAME.startsWith("mac");
|
||||
public static final boolean IS_LINUX = LOWER_OS_NAME.startsWith("linux");
|
||||
public static final boolean IS_UNIX = !IS_WINDOWS;
|
||||
|
||||
private SystemInfo() {
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory;
|
||||
import com.formdev.flatlaf.extras.FlatSVGIcon;
|
||||
|
||||
import jadx.commons.app.JadxCommonEnv;
|
||||
import jadx.commons.app.JadxSystemInfo;
|
||||
import jadx.core.dex.info.AccessInfo;
|
||||
import jadx.core.dex.instructions.args.ArgType;
|
||||
import jadx.core.utils.StringUtils;
|
||||
@@ -278,7 +279,7 @@ public class UiUtils {
|
||||
@SuppressWarnings("deprecation")
|
||||
@MagicConstant(flagsFromClass = InputEvent.class)
|
||||
private static int getCtrlButton() {
|
||||
if (SystemInfo.IS_MAC) {
|
||||
if (JadxSystemInfo.IS_MAC) {
|
||||
return Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
|
||||
} else {
|
||||
return InputEvent.CTRL_DOWN_MASK;
|
||||
@@ -444,12 +445,6 @@ public class UiUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isXToolkit() {
|
||||
return SystemInfo.IS_UNIX
|
||||
&& !SystemInfo.IS_MAC
|
||||
&& "sun.awt.X11.XToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName());
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public static void debugTimer(int periodInSeconds, Runnable action) {
|
||||
if (!LOG.isDebugEnabled()) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.Set;
|
||||
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import jadx.gui.utils.SystemInfo;
|
||||
import jadx.commons.app.JadxSystemInfo;
|
||||
|
||||
public class Shortcut {
|
||||
private static final Set<Integer> FORBIDDEN_KEY_CODES = new HashSet<>(List.of(
|
||||
@@ -88,7 +88,7 @@ public class Shortcut {
|
||||
public KeyStroke toKeyStroke() {
|
||||
return isKeyboard()
|
||||
? KeyStroke.getKeyStroke(keyCode, modifiers,
|
||||
modifiers != 0 && SystemInfo.IS_MAC)
|
||||
modifiers != 0 && JadxSystemInfo.IS_MAC)
|
||||
: null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user