I'm a researcher looking into studying temperature on smartphones. My work requires me to track CPU temperature on Android devices.
I've observed that on newer versions of Android, access to /sys/class/thermal seems to be denied to my app with a message on these lines:
avc: denied { search } for name="thermal" dev="sysfs" ino=17530 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:sysfs_thermal:s0 tclass=dir permissive=0
I understand that this is a SELinux message telling me that my (untrusted) app has been denied access to a file of type sysfs_thermal.
So far, I have tried the following with no luck:
- Attempt to read file via a simple cat-like binary packed along with the app
- Attempt to read file via Runtime.getRuntime().exec("cat ...")
- Attempt to read file via Java APIs (tried both File and RandomAccessFile)
What I find confusing is that other apps such as CPU-Z are able to read various temperature sensors under /sys/class/thermal without difficulty.
For the record, I'm using a Nexus 6P running stock Android 6.0.1 kernel version: 3.10.73-g8c0675f.
How can I read temperature sensor values on these devices and/or android versions?