Update Shell

This commit is contained in:
topjohnwu
2017-08-03 23:33:08 +08:00
parent 8195a4d616
commit 2ecbca303b
10 changed files with 35 additions and 30 deletions
@@ -2,11 +2,8 @@ package com.topjohnwu.magisk.asyncs;
import android.content.Context;
import android.os.Build;
import android.text.TextUtils;
import com.topjohnwu.magisk.MagiskManager;
import com.topjohnwu.magisk.utils.Shell;
import com.topjohnwu.magisk.utils.Utils;
import com.topjohnwu.magisk.utils.WebService;
import java.io.File;
@@ -17,16 +14,14 @@ import java.io.InputStream;
public class DownloadBusybox extends ParallelTask<Void, Void, Void> {
private File busybox;
private Shell shell;
public DownloadBusybox(Context context, File bb) {
busybox = bb;
shell = Utils.getMagiskManager(context).shell;
}
@Override
protected Void doInBackground(Void... voids) {
shell.su("rm -rf " + busybox.getParentFile());
getShell().su("rm -rf " + busybox.getParentFile());
busybox.getParentFile().mkdirs();
try {
FileOutputStream out = new FileOutputStream(busybox);
@@ -44,7 +39,7 @@ public class DownloadBusybox extends ParallelTask<Void, Void, Void> {
}
out.close();
in.close();
shell.su_raw(
getShell().su_raw(
"chmod -R 755 " + busybox.getParent(),
busybox + " --install -s " + busybox.getParent()
);
@@ -1,7 +1,6 @@
package com.topjohnwu.magisk.asyncs;
import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import android.text.TextUtils;
@@ -83,7 +82,7 @@ public class FlashZip extends ParallelTask<Void, String, Integer> {
}
if (!unzipAndCheck()) return 0;
mList.add(magiskManager.getString(R.string.zip_install_progress_msg, mFilename));
magiskManager.shell.su(mList,
getShell().su(mList,
"BOOTMODE=true sh " + mScriptFile + " dummy 1 " + mCachedFile +
" && echo 'Success!' || echo 'Failed!'"
);
@@ -100,7 +99,7 @@ public class FlashZip extends ParallelTask<Void, String, Integer> {
protected void onPostExecute(Integer result) {
MagiskManager magiskManager = getMagiskManager();
if (magiskManager == null) return;
magiskManager.shell.su_raw(
getShell().su_raw(
"rm -rf " + mCachedFile.getParent(),
"rm -rf " + MagiskManager.TMP_FOLDER_PATH
);
@@ -23,10 +23,10 @@ public class LoadModules extends ParallelTask<Void, Void, Void> {
magiskManager.moduleMap = new ValueSortedMap<>();
for (String path : Utils.getModList(magiskManager.shell, MagiskManager.MAGISK_PATH)) {
for (String path : Utils.getModList(getShell(), MagiskManager.MAGISK_PATH)) {
Logger.dev("LoadModules: Adding modules from " + path);
try {
Module module = new Module(magiskManager.shell, path);
Module module = new Module(getShell(), path);
magiskManager.moduleMap.put(module.getId(), module);
} catch (BaseModule.CacheModException ignored) {}
}
@@ -38,7 +38,7 @@ public abstract class ParallelTask<Params, Progress, Result> extends AsyncTask<P
protected Shell getShell() {
MagiskManager magiskManager = getMagiskManager();
return magiskManager == null ? null : getMagiskManager().shell;
return magiskManager == null ? null : Shell.getShell(magiskManager);
}
@SuppressWarnings("unchecked")