Load scripts in memory
This commit is contained in:
parent
c562cbc2bb
commit
8f926c7ca9
@ -31,11 +31,8 @@ import com.topjohnwu.magisk.utils.Shell;
|
|||||||
import com.topjohnwu.magisk.utils.Topic;
|
import com.topjohnwu.magisk.utils.Topic;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -229,23 +226,14 @@ public class MagiskManager extends Application {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File utils = new File(getFilesDir(), Utils.UTIL_FUNCTIONS);
|
try (InputStream in = getAssets().open(Utils.UTIL_FUNCTIONS)) {
|
||||||
|
shell.loadInputStream(in);
|
||||||
try (InputStream in = getAssets().open(Utils.UTIL_FUNCTIONS);
|
|
||||||
OutputStream out = new FileOutputStream(utils)
|
|
||||||
) {
|
|
||||||
int read;
|
|
||||||
byte[] bytes = new byte[4096];
|
|
||||||
while ((read = in.read(bytes)) != -1) {
|
|
||||||
out.write(bytes, 0, read);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
shell.su_raw(
|
shell.su_raw(
|
||||||
"export PATH=" + BUSYBOXPATH + ":$PATH",
|
"export PATH=" + BUSYBOXPATH + ":$PATH",
|
||||||
". " + utils,
|
|
||||||
"mount_partitions",
|
"mount_partitions",
|
||||||
"BOOTIMAGE=",
|
"BOOTIMAGE=",
|
||||||
"find_boot_image",
|
"find_boot_image",
|
||||||
|
@ -9,6 +9,7 @@ import java.io.BufferedReader;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -132,6 +133,19 @@ public class Shell {
|
|||||||
return rootStatus > 0;
|
return rootStatus > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadInputStream(InputStream in) {
|
||||||
|
try {
|
||||||
|
int read;
|
||||||
|
byte[] bytes = new byte[4096];
|
||||||
|
while ((read = in.read(bytes)) != -1) {
|
||||||
|
STDIN.write(bytes, 0, read);
|
||||||
|
}
|
||||||
|
STDIN.flush();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> sh(String... commands) {
|
public List<String> sh(String... commands) {
|
||||||
List<String> res = new ArrayList<>();
|
List<String> res = new ArrayList<>();
|
||||||
if (!isValid) return res;
|
if (!isValid) return res;
|
||||||
|
Loading…
Reference in New Issue
Block a user