|
|
|
@ -8,12 +8,15 @@ import android.content.ComponentName; |
|
|
|
import android.content.Context; |
|
|
|
import android.content.Intent; |
|
|
|
import android.content.ServiceConnection; |
|
|
|
import android.graphics.Bitmap; |
|
|
|
import android.graphics.Rect; |
|
|
|
import android.net.ConnectivityManager; |
|
|
|
import android.net.NetworkInfo; |
|
|
|
import android.os.Binder; |
|
|
|
import android.os.Environment; |
|
|
|
import android.os.IBinder; |
|
|
|
import android.util.Log; |
|
|
|
import android.view.View; |
|
|
|
|
|
|
|
import androidx.core.app.NotificationCompat; |
|
|
|
|
|
|
|
@ -42,6 +45,7 @@ import org.greenrobot.eventbus.ThreadMode; |
|
|
|
import java.io.BufferedInputStream; |
|
|
|
import java.io.BufferedReader; |
|
|
|
import java.io.File; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.FileReader; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
@ -62,6 +66,7 @@ import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Timer; |
|
|
|
import java.util.TimerTask; |
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
import java.util.concurrent.Executors; |
|
|
|
|
|
|
|
|
|
|
|
@ -652,47 +657,39 @@ public class MQTTService extends Service { |
|
|
|
if(!b){ |
|
|
|
return; |
|
|
|
} |
|
|
|
Executors.newSingleThreadExecutor().execute(() -> { |
|
|
|
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(); |
|
|
|
singleThreadExecutor.execute(() -> { |
|
|
|
try { |
|
|
|
|
|
|
|
uploadScreenShot(path,DeviceData.getDeviceInfo(DeviceData.HINT_DEVICE_CODE),String.valueOf(time)); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
}); |
|
|
|
singleThreadExecutor.shutdown(); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
String cmd = "screencap -p " + path; |
|
|
|
Executors.newSingleThreadExecutor().execute(() -> { |
|
|
|
try { |
|
|
|
Process process = Runtime.getRuntime().exec("su");//不同的设备权限不一样
|
|
|
|
PrintWriter pw = new PrintWriter(process.getOutputStream()); |
|
|
|
pw.println(cmd); |
|
|
|
pw.flush(); |
|
|
|
pw.println("exit"); |
|
|
|
pw.flush(); |
|
|
|
try { |
|
|
|
process.waitFor(); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
// TODO Auto-generated catch block
|
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
pw.close(); |
|
|
|
process.destroy(); |
|
|
|
|
|
|
|
if(!new File(path).exists()){ |
|
|
|
LoggerUtil.e("screenShot","截屏失败"); |
|
|
|
return; |
|
|
|
} |
|
|
|
uploadScreenShot(path,DeviceData.getDeviceInfo(DeviceData.HINT_DEVICE_CODE),String.valueOf(time)); |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
View decorView = MyApplication.getInstance().getCurrentActivity().getWindow().getDecorView(); |
|
|
|
decorView.setDrawingCacheEnabled(true); |
|
|
|
decorView.buildDrawingCache(); |
|
|
|
Bitmap bmp = decorView.getDrawingCache(); |
|
|
|
Rect frame = new Rect(); |
|
|
|
decorView.getWindowVisibleDisplayFrame(frame); |
|
|
|
int statusBarHeight = frame.top; |
|
|
|
Bitmap screenBitmap = Bitmap.createBitmap(bmp, 0, statusBarHeight, decorView.getWidth(), decorView.getHeight() - statusBarHeight); |
|
|
|
decorView.setDrawingCacheEnabled(false); |
|
|
|
//保存
|
|
|
|
try (FileOutputStream fos = new FileOutputStream(file)) { |
|
|
|
screenBitmap.compress(Bitmap.CompressFormat.PNG, 100, fos); |
|
|
|
fos.flush(); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
if(!new File(path).exists()){ |
|
|
|
LoggerUtil.e("screenShot","截屏失败"); |
|
|
|
return; |
|
|
|
} |
|
|
|
uploadScreenShot(path,DeviceData.getDeviceInfo(DeviceData.HINT_DEVICE_CODE),String.valueOf(time)); |
|
|
|
} |
|
|
|
|
|
|
|
//上传截屏
|
|
|
|
|