Use Java synchronize instead serial tasks

This commit is contained in:
topjohnwu
2017-06-06 03:06:23 +08:00
parent ff6938280e
commit efeddda328
17 changed files with 143 additions and 146 deletions
@@ -1,5 +1,7 @@
package com.topjohnwu.magisk.utils;
import com.topjohnwu.magisk.asyncs.RootTask;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
@@ -14,6 +16,7 @@ public class Shell {
// -1 = problematic/unknown issue; 0 = not rooted; 1 = properly rooted
public static int rootStatus;
public static final Object lock = new Object();
private static boolean isInit = false;
private static Process rootShell;
@@ -212,4 +215,15 @@ public class Shell {
return new ArrayList<>(res);
}
public static void su_async(List<String> result, String... commands) {
new RootTask<Void, Void, Void>() {
@Override
protected Void doInRoot(Void... params) {
List<String> ret = Shell.su(commands);
if (result != null) result.addAll(ret);
return null;
}
}.exec();
}
}