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