|
|
|
@ -108,6 +108,7 @@ import qianmu.container.util.BitmapUtil; |
|
|
|
import qianmu.container.util.DeviceUtil; |
|
|
|
import qianmu.container.util.FileUtil; |
|
|
|
import qianmu.container.util.LoggerUtil; |
|
|
|
import qianmu.container.util.RootCmdUtil; |
|
|
|
import qianmu.container.util.SignWayUtil; |
|
|
|
import qianmu.container.util.StringUtil; |
|
|
|
import retrofit2.Call; |
|
|
|
@ -672,6 +673,7 @@ public class MQTTService extends Service { |
|
|
|
File file = new File(path); |
|
|
|
File parent = file.getParentFile(); |
|
|
|
if (!parent.exists()) parent.mkdirs(); |
|
|
|
if (file.exists()) file.delete(); |
|
|
|
|
|
|
|
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(); |
|
|
|
try { |
|
|
|
@ -690,6 +692,22 @@ public class MQTTService extends Service { |
|
|
|
} |
|
|
|
return false; |
|
|
|
}); |
|
|
|
}else if(RootCmdUtil.checkSuCommand()){ //root
|
|
|
|
LoggerUtil.e("screenShot","root截屏"); |
|
|
|
screenshotFuture = singleThreadExecutor.submit(() -> { |
|
|
|
String[] cmd = new String[]{"su", "-c", "screencap -p " + path}; |
|
|
|
Process process = Runtime.getRuntime().exec(cmd); |
|
|
|
boolean finished = process.waitFor(3, TimeUnit.SECONDS); |
|
|
|
if (!finished) { |
|
|
|
process.destroyForcibly(); |
|
|
|
return false; |
|
|
|
} |
|
|
|
if(new File(path).exists()){ |
|
|
|
LoggerUtil.e("screenShot","截屏完成"); |
|
|
|
return true; |
|
|
|
} |
|
|
|
return false; |
|
|
|
}); |
|
|
|
}else{ |
|
|
|
screenshotFuture = singleThreadExecutor.submit(() -> { |
|
|
|
Bitmap screenBitmap = null; |
|
|
|
@ -725,7 +743,7 @@ public class MQTTService extends Service { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
if (!screenshotFuture.get(12, TimeUnit.SECONDS)) { // 添加超时时间
|
|
|
|
if (!screenshotFuture.get(10, TimeUnit.SECONDS)) { // 添加超时时间
|
|
|
|
LoggerUtil.e("screenShot","截屏失败"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|