ToolsInstallerPreference: do not check for magisk on main thread

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld
2018-06-06 00:29:44 +02:00
parent 0496b94aa8
commit 51fb57433b
3 changed files with 11 additions and 7 deletions
@@ -80,6 +80,7 @@ public final class ToolsInstaller {
}
public int areInstalled() throws NoRootException {
willInstallAsMagiskModule(true);
if (INSTALL_DIR == null)
return OsConstants.ENOENT;
final StringBuilder script = new StringBuilder();
@@ -116,9 +117,11 @@ public final class ToolsInstaller {
}
}
public boolean willInstallAsMagiskModule() {
public boolean willInstallAsMagiskModule(boolean checkForIt) {
synchronized (lock) {
if (installAsMagiskModule == null) {
if (!checkForIt)
throw new RuntimeException("Expected to already know whether this is a Magisk system");
try {
installAsMagiskModule = rootShell.run(null, "[ -d /sbin/.core/mirror -a -d /sbin/.core/img -a ! -f /cache/.disable_magisk ]") == OsConstants.EXIT_SUCCESS;
} catch (final Exception ignored) {
@@ -168,7 +171,7 @@ public final class ToolsInstaller {
}
public int install() throws NoRootException {
return willInstallAsMagiskModule() ? installMagisk() : installSystem();
return willInstallAsMagiskModule(true) ? installMagisk() : installSystem();
}
public int symlink() throws NoRootException {