diff options
author | Samuel Holland <samuel@sholland.org> | 2018-09-05 18:33:42 -0500 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2018-11-11 21:50:23 -0600 |
commit | a264f7ab36bf1335999d53cb4a0d753c54b231d0 (patch) | |
tree | 8adb020e43111ff0420569c16c8c529f69b6a0e5 /app/src/main/java/com/wireguard/android/util | |
parent | 4e134772d7d2fea02722a87e413947965764fef8 (diff) |
Auto-format the source directories
Blame Jason for writing Java in vim.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com/wireguard/android/util')
-rw-r--r-- | app/src/main/java/com/wireguard/android/util/SharedLibraryLoader.java | 3 | ||||
-rw-r--r-- | app/src/main/java/com/wireguard/android/util/ToolsInstaller.java | 65 |
2 files changed, 34 insertions, 34 deletions
diff --git a/app/src/main/java/com/wireguard/android/util/SharedLibraryLoader.java b/app/src/main/java/com/wireguard/android/util/SharedLibraryLoader.java index 6270d0fe..d6032a18 100644 --- a/app/src/main/java/com/wireguard/android/util/SharedLibraryLoader.java +++ b/app/src/main/java/com/wireguard/android/util/SharedLibraryLoader.java @@ -19,7 +19,8 @@ import java.util.zip.ZipFile; public final class SharedLibraryLoader { private static final String TAG = "WireGuard/" + SharedLibraryLoader.class.getSimpleName(); - private SharedLibraryLoader() { } + private SharedLibraryLoader() { + } public static void loadSharedLibrary(final Context context, final String libName) { Throwable noAbiException; diff --git a/app/src/main/java/com/wireguard/android/util/ToolsInstaller.java b/app/src/main/java/com/wireguard/android/util/ToolsInstaller.java index 5a667baa..143a8724 100644 --- a/app/src/main/java/com/wireguard/android/util/ToolsInstaller.java +++ b/app/src/main/java/com/wireguard/android/util/ToolsInstaller.java @@ -26,11 +26,10 @@ import java.util.List; public final class ToolsInstaller { public static final int ERROR = 0x0; - public static final int YES = 0x1; - public static final int NO = 0x2; public static final int MAGISK = 0x4; + public static final int NO = 0x2; public static final int SYSTEM = 0x8; - + public static final int YES = 0x1; private static final String[][] EXECUTABLES = { {"libwg.so", "wg"}, {"libwg-quick.so", "wg-quick"}, @@ -107,34 +106,8 @@ public final class ToolsInstaller { } } - private boolean willInstallAsMagiskModule() { - synchronized (lock) { - if (installAsMagiskModule == null) { - try { - installAsMagiskModule = Application.getRootShell().run(null, "[ -d /sbin/.core/mirror -a -d /sbin/.core/img -a ! -f /cache/.disable_magisk ]") == OsConstants.EXIT_SUCCESS; - } catch (final Exception ignored) { - installAsMagiskModule = false; - } - } - return installAsMagiskModule; - } - } - - private int installSystem() throws NoRootException { - if (INSTALL_DIR == null) - return OsConstants.ENOENT; - final StringBuilder script = new StringBuilder("set -ex; "); - script.append("trap 'mount -o ro,remount /system' EXIT; mount -o rw,remount /system; "); - for (final String[] names : EXECUTABLES) { - final File destination = new File(INSTALL_DIR, names[1]); - script.append(String.format("cp '%s' '%s'; chmod 755 '%s'; restorecon '%s' || true; ", - new File(nativeLibraryDir, names[0]), destination, destination, destination)); - } - try { - return Application.getRootShell().run(null, script.toString()) == 0 ? YES | SYSTEM : ERROR; - } catch (final IOException ignored) { - return ERROR; - } + public int install() throws NoRootException { + return willInstallAsMagiskModule() ? installMagisk() : installSystem(); } private int installMagisk() throws NoRootException { @@ -158,8 +131,21 @@ public final class ToolsInstaller { } } - public int install() throws NoRootException { - return willInstallAsMagiskModule() ? installMagisk() : installSystem(); + private int installSystem() throws NoRootException { + if (INSTALL_DIR == null) + return OsConstants.ENOENT; + final StringBuilder script = new StringBuilder("set -ex; "); + script.append("trap 'mount -o ro,remount /system' EXIT; mount -o rw,remount /system; "); + for (final String[] names : EXECUTABLES) { + final File destination = new File(INSTALL_DIR, names[1]); + script.append(String.format("cp '%s' '%s'; chmod 755 '%s'; restorecon '%s' || true; ", + new File(nativeLibraryDir, names[0]), destination, destination, destination)); + } + try { + return Application.getRootShell().run(null, script.toString()) == 0 ? YES | SYSTEM : ERROR; + } catch (final IOException ignored) { + return ERROR; + } } public int symlink() throws NoRootException { @@ -184,4 +170,17 @@ public final class ToolsInstaller { return OsConstants.EXIT_FAILURE; } } + + private boolean willInstallAsMagiskModule() { + synchronized (lock) { + if (installAsMagiskModule == null) { + try { + installAsMagiskModule = Application.getRootShell().run(null, "[ -d /sbin/.core/mirror -a -d /sbin/.core/img -a ! -f /cache/.disable_magisk ]") == OsConstants.EXIT_SUCCESS; + } catch (final Exception ignored) { + installAsMagiskModule = false; + } + } + return installAsMagiskModule; + } + } } |