Reading ActivityManager Logs on a Jelly Bean Device?

Jelly Bean removed the ability to read the logs of other applications (in accordance with this I / O conversation), which is a reasonable security improvement. However, I need to read ActivityManager -logs for my application to work (to find out which application is currently running). For this I used

 private static final String clearLogcat = "logcat -c"; private static final String logcatCommand = "logcat ActivityManager:I *:S"; //... 

which no longer works, as I can only read my own application logs in Bean Jelly. Is there an alternative solution to find out when another application (other than root) starts? I understand why we cannot read the logs of other applications (it seems - it should be the compatibility of other developers so that personal information is not logged, and not mine if I could not read the log), but I do not understand why ActivityManager , class framework included in this policy ...

Thanks,
Nick

+6
source share
2 answers

This is discussed in detail here . Unfortunately, this is the "expected behavior" and as such will not be fixed. The only current solution (for reading logs from an application in JB and above) is to manually grant permission to the application via adb:

adb shell pm grant <pkg> android.permission.READ_LOGS

A such permission:

  • reboot survives.
  • saves application updates (ie "adb install -r")
  • not saved if application was uninstalled and then installed again

Obviously, this is not what you would expect from a regular user. The GUI solution (where users can provide this permission from the Settings menu of their device) was promised by the Android team, but, unfortunately, the functionality was removed before the "fix" was implemented.

+7
source

First of all, an ActivityManager not an application ... it is a class that forms part of the Android application platform.

Secondly, if the Android team intentionally went astray to prevent this, I doubt there is a security loophole around it. The fact is that third-party applications should not rely on logcat logs to work properly. If you tell us in detail about your reason for reading these magazines, we may be able to help you find the best solution.

0
source

Source: https://habr.com/ru/post/919915/


All Articles