|
|
@ -1668,31 +1668,51 @@ public class MicroPhotoService extends Service {
|
|
|
|
sendBroadcast(getApplicationContext(), intent);
|
|
|
|
sendBroadcast(getApplicationContext(), intent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int exitValue = -1;
|
|
|
|
boolean success = false;
|
|
|
|
boolean success = false;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
Process process = Runtime.getRuntime().exec("/system/xbin/su root");
|
|
|
|
// Process process = Runtime.getRuntime().exec("/system/xbin/su root");
|
|
|
|
DataOutputStream os = new DataOutputStream(process.getOutputStream());
|
|
|
|
// DataOutputStream os = new DataOutputStream(process.getOutputStream());
|
|
|
|
|
|
|
|
|
|
|
|
os.writeBytes("ifconfig " + iface + " down\n");
|
|
|
|
// os.writeBytes("/system/bin/ifconfig " + iface + " down\n");
|
|
|
|
os.writeBytes("ifconfig " + iface + " " + ip + " netmask " + netmask + " up\n");
|
|
|
|
// os.writeBytes("/system/bin/ifconfig " + iface + " " + ip + " netmask " + netmask + " up\n");
|
|
|
|
os.writeBytes("route add default gw " + gateway + "\n");
|
|
|
|
// os.writeBytes("route add default gw " + gateway + "\n");
|
|
|
|
os.writeBytes("/system/bin/ip route delete 192.168.68.0/24 table 20\n");
|
|
|
|
// os.writeBytes("/system/bin/ip route delete 192.168.68.0/24 table 20\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 add 192.168.68.0/24 dev eth0 proto static scope link table 20\n");
|
|
|
|
// os.writeBytes("echo 'nameserver 8.8.8.8' > /etc/resolv.conf\n");
|
|
|
|
// os.writeBytes("echo 'nameserver 8.8.8.8' > /etc/resolv.conf\n");
|
|
|
|
os.writeBytes("exit\n"); // 重要:退出su shell
|
|
|
|
// os.writeBytes("exit\n"); // 重要:退出su shell
|
|
|
|
os.flush();
|
|
|
|
// os.flush();
|
|
|
|
int exitValue = process.waitFor();
|
|
|
|
// int exitValue = process.waitFor();
|
|
|
|
|
|
|
|
|
|
|
|
// Process downProcess = Runtime.getRuntime().exec("/system/xbin/su root ifconfig " + iface + " down");
|
|
|
|
String downCommand = "/system/xbin/su root ifconfig " + iface + " down";
|
|
|
|
// downProcess.waitFor();
|
|
|
|
Process downProcess = Runtime.getRuntime().exec(downCommand);
|
|
|
|
|
|
|
|
exitValue = downProcess.waitFor();
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 配置IP地址和子网掩码
|
|
|
|
// 2. 配置IP地址和子网掩码
|
|
|
|
// String ipCommand = "/system/xbin/su root ifconfig " + iface + " " + ip + " netmask " + netmask + " up";
|
|
|
|
String ipCommand = "/system/xbin/su root ifconfig " + iface + " " + ip + " netmask " + netmask + " up";
|
|
|
|
// Process ipProcess = Runtime.getRuntime().exec(ipCommand);
|
|
|
|
Process ipProcess = Runtime.getRuntime().exec(ipCommand);
|
|
|
|
// if (ipProcess.waitFor() != 0) {
|
|
|
|
exitValue = ipProcess.waitFor();
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
String gwCommand = "/system/xbin/su root /system/bin/ip route add default via " + gateway + " dev " + iface;
|
|
|
|
|
|
|
|
Process gwProcess = Runtime.getRuntime().exec(gwCommand);
|
|
|
|
|
|
|
|
exitValue = gwProcess.waitFor();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String routeCommand = "/system/xbin/su root /system/bin/ip route delete 192.168.68.0/24 table 20";
|
|
|
|
|
|
|
|
Process routeProcess = Runtime.getRuntime().exec(routeCommand);
|
|
|
|
|
|
|
|
exitValue = routeProcess.waitFor();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routeCommand = "/system/xbin/su root /system/bin/ip route add 192.168.68.0/24 dev eth0 proto static scope link table 20";
|
|
|
|
|
|
|
|
Process routeProcess2 = Runtime.getRuntime().exec(routeCommand);
|
|
|
|
|
|
|
|
exitValue = routeProcess2.waitFor();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routeCommand = "/system/xbin/su root /system/bin/ip rule add from all to 192.168.68.0/24 lookup eth0 prio 1000";
|
|
|
|
|
|
|
|
Process routeProcess3 = Runtime.getRuntime().exec(routeCommand);
|
|
|
|
|
|
|
|
exitValue = routeProcess3.waitFor();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (exitValue != 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// os.writeBytes("/system/bin/ip route delete 192.168.68.0/24 table 20\n");
|
|
|
|
// os.writeBytes("/system/bin/ip route delete 192.168.68.0/24 table 20\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 add 192.168.68.0/24 dev eth0 proto static scope link table 20\n");
|
|
|
|