0
當鯊魚android手機時有一個應用程序捕獲屏幕。Android根屏幕截圖(服務或後臺線程)
1)當應用程序處於活動狀態時,捕獲屏幕沒有根。
2)當應用程序返回堆棧時,如返回HOME,需要root權限才能捕獲屏幕。
我想知道具有root權限的函數的實現2)。
在我看來,root權限意味着得到一個root shell,刷新一些命令和exec。所以我混淆瞭如何在shell命令中捕獲屏幕。
當鯊魚android手機時有一個應用程序捕獲屏幕。Android根屏幕截圖(服務或後臺線程)
1)當應用程序處於活動狀態時,捕獲屏幕沒有根。
2)當應用程序返回堆棧時,如返回HOME,需要root權限才能捕獲屏幕。
我想知道具有root權限的函數的實現2)。
在我看來,root權限意味着得到一個root shell,刷新一些命令和exec。所以我混淆瞭如何在shell命令中捕獲屏幕。
如果你有根,甚至外殼許可,您可以使用截圖或擷取畫面命令,供大家參考:
[email protected]:/system/bin # screenshot -h
unknown option -- husage: screenshot [-s soundfile] filename.png
-s: play a sound effect to signal success
-i: autoincrement to avoid overwriting filename.png
[email protected]:/system/bin # screencap -h
usage: screencap [-hp] [-d display-id] [FILENAME]
-h: this message
-p: save the file as a png.
-d: specify the display id to capture, default 0.
If FILENAME ends with .png it will be saved as a png.
If FILENAME is not given, the results will be printed to stdout.
如果您的設備沒有在本地這些程序,你可以簡單地寫一個由你自己。源代碼在這裏:https://android.googlesource.com/platform/frameworks/base/+/master/cmds/screencap/screencap.cpp
非常感謝,我找到了另一種解決方案。 chmod/dev/graphics/fb0 – fazhang
這不是改變設備權限的好主意。但是你可以堅持任何你感覺舒服的解決方案。但是,我的問題是,如果您只有權訪問幀緩衝區,您仍然需要自己完成圖像編碼。但是這些任務都在screencap中處理,這將爲您節省大量的工作量。我強烈建議你接受我的答案。 – Robin
是的。並且我讀了screencap.cpp,這個文件通過讀取設備文件來捕獲屏幕。該chmod的想法適用於2.3或更早版本。非常感謝你 。 – fazhang