|
|
|
@ -193,6 +193,14 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
public MicroPhotoService() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void sleep(long ms) {
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(ms);
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void convertDngToPng(String dngFile, String pngFile) {
|
|
|
|
|
ImageDecoder.Source src = ImageDecoder.createSource(new File(dngFile));
|
|
|
|
|
Bitmap bmp = null;
|
|
|
|
@ -732,11 +740,7 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
} else if (TextUtils.equals(ACTION_RESTART, action)) {
|
|
|
|
|
String reason = intent.getStringExtra("reason");
|
|
|
|
|
MicroPhotoService.infoLog("Recv RESTART APP cmd, reason=" + (TextUtils.isEmpty(reason) ? "" : reason));
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(100);
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
sleep(100);
|
|
|
|
|
restartSelfImpl(context, reason);
|
|
|
|
|
} else if (TextUtils.equals(Intent.ACTION_TIME_CHANGED, action)) {
|
|
|
|
|
mService.notifyTimeUpdated(mService.mNativeHandle);
|
|
|
|
@ -1672,19 +1676,26 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
boolean success = false;
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
// Process process = Runtime.getRuntime().exec("/system/xbin/su root");
|
|
|
|
|
// DataOutputStream os = new DataOutputStream(process.getOutputStream());
|
|
|
|
|
Process process = Runtime.getRuntime().exec("/system/xbin/su root");
|
|
|
|
|
DataOutputStream os = new DataOutputStream(process.getOutputStream());
|
|
|
|
|
|
|
|
|
|
// os.writeBytes("/system/bin/ifconfig " + iface + " down\n");
|
|
|
|
|
// os.writeBytes("/system/bin/ifconfig " + iface + " " + ip + " netmask " + netmask + " up\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 add 192.168.68.0/24 dev eth0 proto static scope link table 20\n");
|
|
|
|
|
os.writeBytes("/system/bin/ifconfig " + iface + " down\n");
|
|
|
|
|
os.writeBytes("/system/bin/ifconfig " + iface + " " + ip + " netmask " + netmask + " up\n");
|
|
|
|
|
// os.writeBytes("/system/bin/ip route add default via " + gateway + " dev " + iface + "\n");
|
|
|
|
|
os.writeBytes("/system/bin/ip route delete 192.168.68.0/24 table eth0 2>/dev/null || true\n");
|
|
|
|
|
os.writeBytes("/system/bin/ip route add 192.168.68.0/24 dev eth0 proto static scope link table eth0\n");
|
|
|
|
|
os.writeBytes("/system/bin/ip route flush cache\n");
|
|
|
|
|
// os.writeBytes("echo 'nameserver 8.8.8.8' > /etc/resolv.conf\n");
|
|
|
|
|
// os.writeBytes("exit\n"); // 重要:退出su shell
|
|
|
|
|
// os.flush();
|
|
|
|
|
// int exitValue = process.waitFor();
|
|
|
|
|
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 eth0 prio 1000");
|
|
|
|
|
os.writeBytes("/system/bin/ip route flush cache\n");
|
|
|
|
|
os.writeBytes("exit\n"); // 重要:退出su shell
|
|
|
|
|
os.flush();
|
|
|
|
|
exitValue = process.waitFor();
|
|
|
|
|
if (exitValue != 0) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
String downCommand = "/system/xbin/su root ifconfig " + iface + " down";
|
|
|
|
|
Process downProcess = Runtime.getRuntime().exec(downCommand);
|
|
|
|
|
exitValue = downProcess.waitFor();
|
|
|
|
@ -1698,30 +1709,42 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
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";
|
|
|
|
|
// String routeCommand = "/system/xbin/su root /system/bin/ip route delete 192.168.68.0/24 table 20";
|
|
|
|
|
String routeCommand = "/system/xbin/su root /system/bin/ip route delete 192.168.68.0/24 table eth0";
|
|
|
|
|
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";
|
|
|
|
|
// routeCommand = "/system/xbin/su root /system/bin/ip route add 192.168.68.0/24 dev eth0 proto static scope link table 20";
|
|
|
|
|
routeCommand = "/system/xbin/su root /system/bin/ip route add 192.168.68.0/24 dev eth0 proto static scope link table eth0";
|
|
|
|
|
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";
|
|
|
|
|
for (int idx = 0; idx < 3; idx++) {
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
sleep(100);
|
|
|
|
|
String routeCommand = "/system/xbin/su root /system/bin/ip rule add from all to 192.168.68.0/24 lookup eth0 prio 1000";
|
|
|
|
|
for (int idx = 0; idx < 10; idx++) {
|
|
|
|
|
Process routeProcess3 = Runtime.getRuntime().exec(routeCommand);
|
|
|
|
|
exitValue = routeProcess3.waitFor();
|
|
|
|
|
if (exitValue == 0) {
|
|
|
|
|
if (exitValue == 0 || exitValue == 2) {
|
|
|
|
|
infoLog("Add route successfully");
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(100);
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
sleep(500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (exitValue != 0) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// os.writeBytes("/system/bin/ip route delete 192.168.68.0/24 table 20\n");
|
|
|
|
|