Browse Source

fix: ci

dejiAi
高志龙 2 months ago
parent
commit
ee7f1893ba
  1. 11
      app/src/main/java/qianmu/container/mqtt/MQTTService.java

11
app/src/main/java/qianmu/container/mqtt/MQTTService.java

@ -647,27 +647,21 @@ public class MQTTService extends Service {
EventBus.getDefault().post(messageEvent); EventBus.getDefault().post(messageEvent);
return; return;
} }
String path = StringUtil.strSplice(BitmapUtil.SAVE_SCREEN_SHOT_PATH, "/screenShot.png"); String path = StringUtil.strSplice(BitmapUtil.SAVE_SCREEN_SHOT_PATH, "/screenShot.png");
// ====================== 修复点3:子线程内安全创建file ======================
File file = new File(path); File file = new File(path);
File parent = file.getParentFile(); File parent = file.getParentFile();
if (!parent.exists()) parent.mkdirs(); if (!parent.exists()) parent.mkdirs();
if (file.exists()) file.delete(); if (file.exists()) file.delete();
boolean shotSuccess = false; boolean shotSuccess = false;
// 亿晟主板 // 亿晟主板
if (SignWayUtil.getgetAndroidModle().equals("t982")) { if (SignWayUtil.getgetAndroidModle().equals("t982")) {
shotSuccess = SignWayUtil.ysTakeScreenshot(path); shotSuccess = SignWayUtil.ysTakeScreenshot(path);
} else if (!"".equals(Constant.androidBoardType)) { } else if (!"".equals(Constant.androidBoardType)) {
SignWayUtil.takeScreenshot(path); SignWayUtil.takeScreenshot(path);
int retryCount = 0; int retryCount = 0;
final int MAX_RETRY = 15; final int MAX_RETRY = 15;
final long SLEEP_MS = 300; final long SLEEP_MS = 300;
long lastSize = 0; long lastSize = 0;
while (retryCount < MAX_RETRY) { while (retryCount < MAX_RETRY) {
File f = new File(path); File f = new File(path);
if (f.exists()) { if (f.exists()) {
@ -681,7 +675,6 @@ public class MQTTService extends Service {
} }
lastSize = currentSize; lastSize = currentSize;
} }
try { try {
Thread.sleep(SLEEP_MS); Thread.sleep(SLEEP_MS);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -689,7 +682,6 @@ public class MQTTService extends Service {
} }
retryCount++; retryCount++;
} }
} else { } else {
LoggerUtil.e("screenShot", "root截屏"); LoggerUtil.e("screenShot", "root截屏");
String[] cmd = {"su", "-c", "screencap -p " + path}; String[] cmd = {"su", "-c", "screencap -p " + path};
@ -713,7 +705,6 @@ public class MQTTService extends Service {
LoggerUtil.e("screenShot", "截屏失败"); LoggerUtil.e("screenShot", "截屏失败");
} }
} catch (Exception e) { } catch (Exception e) {
// ====================== 修复点6:全局捕获所有异常,绝不崩溃 ======================
LoggerUtil.e("screenShot", "截屏异常:" + e.getMessage()); LoggerUtil.e("screenShot", "截屏异常:" + e.getMessage());
} }
}); });
@ -721,7 +712,6 @@ public class MQTTService extends Service {
//上传截屏 //上传截屏
public static void uploadScreenShot(String filePath,String code,String timestamp) { public static void uploadScreenShot(String filePath,String code,String timestamp) {
File file = new File(filePath); File file = new File(filePath);
if (!file.exists()||code.isEmpty()) return; if (!file.exists()||code.isEmpty()) return;
if(SignWayUtil.getgetAndroidModle().equals("t982")){ if(SignWayUtil.getgetAndroidModle().equals("t982")){
@ -746,7 +736,6 @@ public class MQTTService extends Service {
LoggerUtil.e("uploadScreenShot", StringUtil.getThrowableStr(t)); LoggerUtil.e("uploadScreenShot", StringUtil.getThrowableStr(t));
} }
}); });
} }
/** /**

Loading…
Cancel
Save