|
|
@ -271,6 +271,11 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (usingEthernet()) {
|
|
|
|
if (usingEthernet()) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File ethShellFile = new File(getFilesDir(), "eth.sh");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FilesUtils.copyAssetsFile(getApplicationContext(), "eth.sh", ethShellFile.getAbsolutePath());
|
|
|
|
|
|
|
|
|
|
|
|
mConnectivityManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
|
mConnectivityManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
|
|
|
|
|
|
|
|
|
Network[] nws = mConnectivityManager.getAllNetworks();
|
|
|
|
Network[] nws = mConnectivityManager.getAllNetworks();
|
|
|
@ -1174,11 +1179,7 @@ public class MicroPhotoService extends Service {
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
if (getCustomAppId() == 2 || getCustomAppId() == 1) {
|
|
|
|
|
|
|
|
setStaticNetwork(iface, "192.168.68.91", "192.168.68.91", "192.168.68.0", 24);
|
|
|
|
setStaticNetwork(iface, "192.168.68.91", "192.168.68.91", "192.168.68.0", 24);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
setEthernetRoute(iface, "192.168.68.0", 24);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
}).start();
|
|
|
|
|
|
|
|
|
|
|
@ -1918,20 +1919,53 @@ public class MicroPhotoService extends Service {
|
|
|
|
int exitValue = -1;
|
|
|
|
int exitValue = -1;
|
|
|
|
boolean success = false;
|
|
|
|
boolean success = false;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
File ethShellFile = new File(getFilesDir(), "eth.sh");
|
|
|
|
|
|
|
|
if (ethShellFile.exists()) {
|
|
|
|
|
|
|
|
Process process = Runtime.getRuntime().exec("/system/xbin/su");
|
|
|
|
|
|
|
|
DataOutputStream os = new DataOutputStream(process.getOutputStream());
|
|
|
|
|
|
|
|
os.writeBytes("/system/bin/sh " + ethShellFile.getAbsolutePath() + "\n");
|
|
|
|
|
|
|
|
os.writeBytes("exit\n"); // 重要:退出su shell
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
os.flush();
|
|
|
|
|
|
|
|
exitValue = process.waitFor();
|
|
|
|
|
|
|
|
if (exitValue != 0) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
|
|
|
|
|
|
|
|
String line = null;
|
|
|
|
|
|
|
|
StringBuilder error = new StringBuilder();
|
|
|
|
|
|
|
|
while ((line = reader.readLine()) != null) {
|
|
|
|
|
|
|
|
error.append(line);
|
|
|
|
|
|
|
|
error.append("\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log.e(TAG, error.toString());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
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("/system/bin/ip link set eth0 down\n");
|
|
|
|
os.writeBytes("/system/bin/ip link set eth0 down\n");
|
|
|
|
|
|
|
|
os.writeBytes("/system/bin/sleep 1\n"); // Add delay
|
|
|
|
|
|
|
|
os.writeBytes("/system/bin/ip addr flush dev eth0\n"); // Clear existing config
|
|
|
|
os.writeBytes("/system/bin/ip addr add 192.168.68.91/24 broadcast 192.168.68.255 dev eth0\n");
|
|
|
|
os.writeBytes("/system/bin/ip addr add 192.168.68.91/24 broadcast 192.168.68.255 dev eth0\n");
|
|
|
|
// os.writeBytes("/system/bin/ip link set eth0 up\n");
|
|
|
|
os.writeBytes("/system/bin/ip link set eth0 up\n");
|
|
|
|
// os.writeBytes("/system/bin/ip route delete 192.168.68.0/24 table 20 2>/dev/null || true\n");
|
|
|
|
os.writeBytes("/system/bin/sleep 2\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 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 flush cache\n");
|
|
|
|
os.writeBytes("/system/bin/ip route flush cache\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("/system/bin/ip rule del to 192.168.68.0/24 2>/dev/null || true\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\n");
|
|
|
|
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("/system/bin/ip route flush cache\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Verify routes were added
|
|
|
|
|
|
|
|
os.writeBytes("if ! /system/bin/ip rule | grep '192.168.68.0/24'; then\n");
|
|
|
|
|
|
|
|
os.writeBytes(" echo 'Route rule failed to apply, retrying...'\n");
|
|
|
|
|
|
|
|
os.writeBytes(" sleep 1\n");
|
|
|
|
|
|
|
|
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("fi\n");
|
|
|
|
|
|
|
|
|
|
|
|
os.writeBytes("exit\n"); // 重要:退出su shell
|
|
|
|
os.writeBytes("exit\n"); // 重要:退出su shell
|
|
|
|
os.flush();
|
|
|
|
os.flush();
|
|
|
|
exitValue = process.waitFor();
|
|
|
|
exitValue = process.waitFor();
|
|
|
@ -1981,8 +2015,9 @@ public class MicroPhotoService extends Service {
|
|
|
|
sleep(500);
|
|
|
|
sleep(500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (exitValue != 0) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
Log.e(TAG, "Failed to set interface down: " + e.getMessage());
|
|
|
|
Log.e(TAG, "Failed to set interface down: " + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1995,6 +2030,7 @@ public class MicroPhotoService extends Service {
|
|
|
|
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("/system/bin/ip addr add 192.168.68.91/24 broadcast 192.168.68.255 dev eth0\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 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 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("/system/bin/ip route flush cache\n");
|
|
|
|