Android Studio 3.0 Profiler Injects Files Into Data Directory
After upgrading to Android Studio 3.0, I discovered a few mysterious new files
in my app’s data directory (/data/data/org.mozilla.focus.debug/
, in this
case):
- libperfa_x86.so
- perfa.jar
- perfd (binary file)
After some investigation, I discovered these files are a product of Android Studio 3.0’s newly rewritten profiler and are added under the following conditions:
- Built with Android Studio 3.0+ (i.e. not Gradle)
- Running on an API 26+ device 1
- Have opened the “Android Profiler” tab at least once since the AS process started
The new Android profiler documentation supports these conditions:
To show you advanced profiling data, Android Studio must inject monitoring logic into your compiled app.
It provides some instructions to enable it, after which I see the “Enable advanced profiling” checkbox is disabled and states “required for API level < 26 only”:
I originally started investigating this in Firefox Focus for Android issue #1842 so you can find more investigation details in that issue.
You can try it out for yourself by downloading my WhatsInMyDataDirectory Android project (essentially an empty Android app) and notice that the files are only added after meeting the conditions above.
Why might you care? In our case, as part of Firefox Focus, we verify there are no unknown files left over on disk after a browsing session ends, just in case they leak user data. These new files were unknown to our test, triggering our assertion. We confirmed these files would not leak user data because they do not appear for users on release builds.
Notes
1: You can enable advanced debugging on older devices, which may also inject these files - I didn’t test this. To do so, see the “Enable advanced profiling” on the new Android profiler overview page.