Skip to content

Commit

Permalink
Blackview root working commit. Remount now is running with su command.
Browse files Browse the repository at this point in the history
  • Loading branch information
irinil committed Jul 30, 2020
1 parent 3a0685f commit 7578aba
Showing 1 changed file with 15 additions and 4 deletions.
Expand Up @@ -216,7 +216,6 @@ private static boolean installBinary(Context ctx, int resId, String filename) {
private static void copyRawFile(Context ctx, int resid, File file, String mode) throws IOException, InterruptedException {
final String abspath = file.getAbsolutePath();
Log.e(TAG, "FilesPath: " + abspath);
RootTools.remount(abspath, "RW");

// Write the iptables binary
final FileOutputStream out = new FileOutputStream(file);
Expand All @@ -242,21 +241,33 @@ private static void copyRawFile(Context ctx, int resid, File file, String mode)
*/
private static void copySystemBin(File file){
String systemPath= "/system/bin/";
RootTools.remount(systemPath, "RW");
//RootTools.remount("/", "RW"); //problem with remount in some devices
remountSystem();
Process process = null;
try {
process = Runtime.getRuntime().exec("su -c cp "+file.getAbsolutePath() +" "+systemPath+ file.getName());
process.waitFor();

// Log.e(TAG, "File copied in: " + file.getAbsolutePath()+" "+systemPath+ file.getName());

} catch (IOException | InterruptedException e) {
Log.e(TAG, "ErrorInCopy System Bin: " + e.getMessage());

}

}

private static void remountSystem(){
Process process = null;
try {
process = Runtime.getRuntime().exec("su -c mount -o rw,remount /");
process.waitFor();

} catch (IOException | InterruptedException e) {
Log.e(TAG, "ErrorInCopy Mount: " + e.getMessage());

}

}

public static boolean isNetfilterSupported() {
return new File("/proc/net/netfilter").exists()
&& new File("/proc/net/ip_tables_targets").exists();
Expand Down

0 comments on commit 7578aba

Please sign in to comment.