从Android 4.2的应用程序中读取Android上所有应用程序的日志
作者:互联网
我相信应用程序可以在android 4.2中读取日志的方式发生了变化.但我想知道我是否可以从当前版本的android的应用程序中读取logcat中的所有日志,包括系统日志?如果是,是否需要一些许可?
解决方法:
除非你扎根,否则你不能这样做,因为果冻豆.看到这个Android bug report和这个related discussion. Quote:
The change is that third party applications can no longer get the read
logs permission, however every app can read the logs containing only
the lines they have written, without needing any permission.Keep in mind that access to the logs has never been part of the SDK,
and is still not part of the SDK. If you are relying on it then, even
after this change, you run the risk of breaking in the future. (And
that is partly why this got lost for documentation, it is not part of
the SDK, so there isn’t really a place to document it, in fact
documenting it would kind-of make it a part of the SDK which we don’t
want. :p)Also we really really hope that developers don’t take this as license
to further abuse the system logs and spew increasing amounts of stuff
into it from their app. Log noise has been a continual problem on
Android (not just for third party apps, we always struggle to ship the
open source platform without a lot of noise), and if things continue
to get worse we will probably make further changes to it to better
control it.
编辑:如果您有权访问该设备,那么您可以在那里查看日志,甚至尝试向您的应用授予所述权限:
adb shell pm grant <pkg> android.permission.READ_LOGS
但对于其他情况,你运气不好(除非你发现框架中的错误)
标签:android,android-permissions,logcat,android-logcat 来源: https://codeday.me/bug/20190923/1814099.html