优化网络设置

lowmem
Matthew 1 month ago
parent d36d0d916d
commit c104f26f7d

@ -1602,7 +1602,7 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
if(!GpioControl::GetSelftestStatus(waitTime)) if(!GpioControl::GetSelftestStatus(waitTime))
{ {
m_isSelfTesting.store(true); m_isSelfTesting.store(true);
waitTime = (waitTime != 0) ? (waitTime * 1024) : 10240; waitTime = (waitTime != 0) ? (waitTime * 1000) : 10000;
std::this_thread::sleep_for(std::chrono::milliseconds(waitTime)); std::this_thread::sleep_for(std::chrono::milliseconds(waitTime));
m_isSelfTesting.store(false); m_isSelfTesting.store(false);
} }
@ -1809,7 +1809,7 @@ bool CPhoneDevice::TakeVideoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
if(!GpioControl::GetSelftestStatus(waitTime)) if(!GpioControl::GetSelftestStatus(waitTime))
{ {
m_isSelfTesting.store(true); m_isSelfTesting.store(true);
waitTime = (waitTime != 0) ? (waitTime * 1024) : 10240; waitTime = (waitTime != 0) ? (waitTime * 1000) : 10000;
std::this_thread::sleep_for(std::chrono::milliseconds(waitTime)); std::this_thread::sleep_for(std::chrono::milliseconds(waitTime));
m_isSelfTesting.store(false); m_isSelfTesting.store(false);
} }
@ -1931,7 +1931,7 @@ bool CPhoneDevice::StartPushStreaming(IDevice::PHOTO_INFO& photoInfo, const std:
if(!GpioControl::GetSelftestStatus(waitTime)) if(!GpioControl::GetSelftestStatus(waitTime))
{ {
m_isSelfTesting.store(true); m_isSelfTesting.store(true);
waitTime = (waitTime != 0) ? (waitTime * 1024) : 10240; waitTime = (waitTime != 0) ? (waitTime * 1000) : 10000;
std::this_thread::sleep_for(std::chrono::milliseconds(waitTime)); std::this_thread::sleep_for(std::chrono::milliseconds(waitTime));
m_isSelfTesting.store(false); m_isSelfTesting.store(false);
} }
@ -2234,7 +2234,7 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
{ {
uint32_t waitTime = localPhotoInfo.selfTestingTime; uint32_t waitTime = localPhotoInfo.selfTestingTime;
XYLOG(XYLOG_SEVERITY_INFO, "Camera is SelfTesting Time=%u s", waitTime); XYLOG(XYLOG_SEVERITY_INFO, "Camera is SelfTesting Time=%u s", waitTime);
waitTime = (waitTime <= 5 ) ? 0 : ((waitTime - 5) * 1024); waitTime = (waitTime <= 5 ) ? 0 : ((waitTime - 5) * 1000);
if (waitTime > 0) if (waitTime > 0)
{ {
std::this_thread::sleep_for(std::chrono::milliseconds(waitTime)); std::this_thread::sleep_for(std::chrono::milliseconds(waitTime));
@ -2340,7 +2340,7 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
pThis->m_isSelfTesting.store(true); pThis->m_isSelfTesting.store(true);
time_t remaintime = GpioControl::GetSelfTestRemain(waitTime); time_t remaintime = GpioControl::GetSelfTestRemain(waitTime);
XYLOG(XYLOG_SEVERITY_INFO, "Camera is SeltTesting,remaining selfTestingtime=%u", remaintime); XYLOG(XYLOG_SEVERITY_INFO, "Camera is SeltTesting,remaining selfTestingtime=%u", remaintime);
remaintime = (remaintime != 0) ? (remaintime * 1024) : 10240; remaintime = (remaintime != 0) ? (remaintime * 1000) : 10000;
std::this_thread::sleep_for(std::chrono::milliseconds(remaintime)); std::this_thread::sleep_for(std::chrono::milliseconds(remaintime));
pThis->m_isSelfTesting.store(false); pThis->m_isSelfTesting.store(false);
XYLOG(XYLOG_SEVERITY_INFO, "Camera SeltTesting is over"); XYLOG(XYLOG_SEVERITY_INFO, "Camera SeltTesting is over");
@ -2397,7 +2397,7 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
pThis->m_isSelfTesting.store(true); pThis->m_isSelfTesting.store(true);
time_t remaintime = GpioControl::GetSelfTestRemain(waitTime); time_t remaintime = GpioControl::GetSelfTestRemain(waitTime);
XYLOG(XYLOG_SEVERITY_INFO, "Camera is SeltTesting,remaining selfTestingtime=%u", remaintime); XYLOG(XYLOG_SEVERITY_INFO, "Camera is SeltTesting,remaining selfTestingtime=%u", remaintime);
remaintime = (remaintime != 0) ? (remaintime * 1024) : 10240; remaintime = (remaintime != 0) ? (remaintime * 1000) : 10000;
std::this_thread::sleep_for(std::chrono::milliseconds(remaintime)); std::this_thread::sleep_for(std::chrono::milliseconds(remaintime));
pThis->m_isSelfTesting.store(false); pThis->m_isSelfTesting.store(false);
XYLOG(XYLOG_SEVERITY_INFO, "Camera SeltTesting is over"); XYLOG(XYLOG_SEVERITY_INFO, "Camera SeltTesting is over");
@ -2432,7 +2432,7 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
pThis->m_isSelfTesting.store(true); pThis->m_isSelfTesting.store(true);
time_t remaintime = GpioControl::GetSelfTestRemain(waitTime); time_t remaintime = GpioControl::GetSelfTestRemain(waitTime);
XYLOG(XYLOG_SEVERITY_INFO, "Camera is SeltTesting,remaining selfTestingtime=%u", remaintime); XYLOG(XYLOG_SEVERITY_INFO, "Camera is SeltTesting,remaining selfTestingtime=%u", remaintime);
remaintime = (remaintime != 0) ? (remaintime * 1024) : 10240; remaintime = (remaintime != 0) ? (remaintime * 1000) : 10000;
std::this_thread::sleep_for(std::chrono::milliseconds(remaintime)); std::this_thread::sleep_for(std::chrono::milliseconds(remaintime));
pThis->m_isSelfTesting.store(false); pThis->m_isSelfTesting.store(false);
XYLOG(XYLOG_SEVERITY_INFO, "Camera SeltTesting is over"); XYLOG(XYLOG_SEVERITY_INFO, "Camera SeltTesting is over");

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

Loading…
Cancel
Save