private void makeScreenshot() { if (FileUtil.isExternalStorageAvailable() && FileUtil.hasExternalStorageFreeMemory()) { if (RootTools.isAccessGiven()) { try { String path = FileUtil.getExternalFullPath(mContext, "screenshot.jpg"); MakeScreenshotCommand command = new MakeScreenshotCommand(path); RootTools.getShell(true).add(command); } catch (Exception e) { ACRA.getErrorReporter().handleSilentException(e); } } } if (mSettings.isScreenshotEnabled()) { mHandler.sendEmptyMessageDelayed(0, mSettings.screenshotInterval()); } }
@Override public void commandCompleted(int id, int exitcode) { Bitmap bmp = null; FileOutputStream out = null; try { int size = mSettings.screenshotSize(); bmp = ImageUtil.getResizedImage(path, size); if (bmp != null) { Date dt = new Date(); String date = SimpleDateFormat.getDateTimeInstance( SimpleDateFormat.SHORT, SimpleDateFormat.MEDIUM, sLocale) .format(dt); date = date.replace(':', '-'); // .replace(' ', '_'); String fName = PREFIX + "[" + date + "]" + "[" + dt.getTime() + "]" + ".jpg"; out = new FileOutputStream(FileUtil.getExternalFullPath(mContext, fName)); bmp.compress(Bitmap.CompressFormat.JPEG, 60, out); File del = new File(path); del.delete(); new FileSender(mContext, FileType.SCREENSHOT).start(); } } catch (Exception e) { ACRA.getErrorReporter().handleSilentException(e); } finally { if (bmp != null && !bmp.isRecycled()) { bmp.recycle(); bmp = null; } if (out != null) { try { out.close(); } catch (IOException e) { Debug.exception(e); } out = null; } } }