|
|
|
@ -1781,12 +1781,12 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
Process process = Runtime.getRuntime().exec("/system/xbin/su root");
|
|
|
|
|
DataOutputStream os = new DataOutputStream(process.getOutputStream());
|
|
|
|
|
|
|
|
|
|
os.writeBytes("/system/bin/ip route delete 192.168.68.0/24 table 20 2>/dev/null || true\n");
|
|
|
|
|
os.writeBytes("/system/bin/ip route add 192.168.68.0/24 dev eth0 proto static scope link table 20\n");
|
|
|
|
|
// os.writeBytes("/system/bin/ip route delete 192.168.68.0/24 table 20 2>/dev/null || true\n");
|
|
|
|
|
os.writeBytes("/system/bin/ip route replace 192.168.68.0/24 dev eth0 proto static scope link table 20\n");
|
|
|
|
|
os.writeBytes("/system/bin/ip route flush cache\n");
|
|
|
|
|
// os.writeBytes("echo 'nameserver 8.8.8.8' > /etc/resolv.conf\n");
|
|
|
|
|
os.writeBytes("/system/bin/ip rule del to 192.168.68.0/24 2>/dev/null || true\n");
|
|
|
|
|
os.writeBytes("/system/bin/ip rule add from all to 192.168.68.0/24 lookup 20 prio 1000");
|
|
|
|
|
os.writeBytes("/system/bin/ip rule add from all to 192.168.68.0/24 lookup 20 prio 1000\n");
|
|
|
|
|
os.writeBytes("/system/bin/ip route flush cache\n");
|
|
|
|
|
os.writeBytes("exit\n"); // 重要:退出su shell
|
|
|
|
|
os.flush();
|
|
|
|
@ -1795,24 +1795,35 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sleep(100);
|
|
|
|
|
String routeCommand = "/system/xbin/su root /system/bin/ip rule add from all to 192.168.68.0/24 lookup 20 prio 1000";
|
|
|
|
|
for (int idx = 0; idx < 10; idx++) {
|
|
|
|
|
Process routeProcess3 = Runtime.getRuntime().exec(routeCommand);
|
|
|
|
|
Process routeProcess3 = Runtime.getRuntime().exec("/system/xbin/su root");
|
|
|
|
|
DataOutputStream os3 = new DataOutputStream(routeProcess3.getOutputStream());
|
|
|
|
|
// os3.writeBytes("/system/bin/ip rule del to 192.168.68.0/24 2>/dev/null || true\n");
|
|
|
|
|
os3.writeBytes("/system/bin/ip rule add from all to 192.168.68.0/24 lookup 20 prio 1000\n");
|
|
|
|
|
os3.writeBytes("CMD_EXIT_CODE=$?\n"); // 保存返回值
|
|
|
|
|
os3.writeBytes("echo \"CMD_RESULT:$CMD_EXIT_CODE\"\n"); // 输出标记和返回值
|
|
|
|
|
os3.writeBytes("/system/bin/ip route flush cache\n");
|
|
|
|
|
os3.writeBytes("exit\n"); // 重要:退出su shell
|
|
|
|
|
os3.flush();
|
|
|
|
|
|
|
|
|
|
int commandExitCode = -1;
|
|
|
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(routeProcess3.getErrorStream()));
|
|
|
|
|
String line;
|
|
|
|
|
StringBuilder error = new StringBuilder();
|
|
|
|
|
while ((line = reader.readLine()) != null) {
|
|
|
|
|
if (line.startsWith("CMD_RESULT:")) {
|
|
|
|
|
commandExitCode = Integer.parseInt(line.substring(11));
|
|
|
|
|
Log.d("RouteConfig", "Command exit code: " + commandExitCode);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exitValue = routeProcess3.waitFor();
|
|
|
|
|
if (exitValue == 0 || exitValue == 2) {
|
|
|
|
|
infoLog("Add route successfully");
|
|
|
|
|
if (exitValue == 0 || commandExitCode == 2) {
|
|
|
|
|
infoLog("Add route successfully Code=" + exitValue);
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(routeProcess3.getErrorStream()));
|
|
|
|
|
String line;
|
|
|
|
|
StringBuilder error = new StringBuilder();
|
|
|
|
|
while ((line = reader.readLine()) != null) {
|
|
|
|
|
error.append(line).append("\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (error.length() > 0) {
|
|
|
|
|
Log.e("RouteConfig", "Error output: " + error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sleep(500);
|
|
|
|
|
}
|
|
|
|
|