I need some help. I have an app that is mostly written in native C code. I use the __system_property_get(const char * name, char * value)
method to read the serial nr. of the device at various points in my native code. With Android 8 I always get a "Access denied" message now.
libc: Access denied finding property "ro.serialno"
Is there a way for me to still be able to read the serial nr. in Android 8? I tried switching to targetSDKversion < 26 but it still gives me a "Access denied" message. I do get the correct values if I use Java with Build.SERIAL
(regardless of SDK version) and Build.getSerial()
in SDK version 26 if I grant the READ_PHONE_STATE
permission. But I cannot read these values in Java and pass them to the native code without a huge rewrite of the native code.
Any help?
I met this problem too. Finally I find the root cause of the problem. In Android O, SELinux sets a lot of limitations in system property. In this case, There is a neverallow to limit read serial number except some domain in whitelist.
For more specific information, you can read code in system/sepolicy/public/domain.te
:
neverallow {
domain
-adbd
-dumpstate
-hal_drm
-init
-mediadrmserver
-recovery
-shell
-system_server
} serialno_prop:file r_file_perms;
If you have the hand on AOSP:
android:sharedUserId="android.uid.system"
to AdnroidMainfest
system_app
. Android.mk
. LOCAL_MODULE_PATH := $(TARGET_OUT)/app
.Or you can duplicate the property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With