I am investigating behavior of android's View traversals and measure cache, using the AOSP source code and emulator.
I would like to emit debug log messages from each of the functions View.measure(), View.layout(), View.draw(), from all processes in which they are called.
Sounds straightforward, right? But I haven't found a mechanism that works reliably, yet.
What I tried:
The standard logging mechanism: java.util.Log (and view using logcat).
FAIL: Drops messages at random when there are too many of them.
Creating and appending to a file in directory Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).
FAIL: This only works for some processes (those with WRITE_EXTERNAL_STORAGE permission, presumably).
Creating and appending to a file in directory view.getContext().getCacheDir().
FAIL: The call to getCacheDir() fails in system_process, with: "java.lang.RuntimeException: No data directory found for package android".
Creating and appending to a file in directory view.getContext().getExternalCacheDir().
FAIL: This seems to work for all processes except system_process, in which getExternalCacheDir() returns /storage/emulated/0/Android/data/android/cache, but attempting to write to a file in there gives AccessDeniedException.
Creating and appending to a file in directory view.getContext().getExternalFilesDir(null).
FAIL: Same result as (4), except the directory name ends with "files" instead of "cache".
Creating and appending to a file in /data/local/tmp.
FAIL: Gives AccessDeniedException in all processes.
How can I do this logging??
I'd be interested in concrete solutions along any of the following lines:
- Hack AOSP source to keep java.util.Log from dropping messages
- Write an alternative logging daemon, which doesn't drop messages and must be made available during system startup (so that it will be available to processes such as system_process and com.android.systemui).
- Just find a directory/file that system_process is allowed to write to (I think that's the only process for which I couldn't find such a file)
- Hack AOSP source to make it so system_process has permission to write to some file.