SELinux restricting my system app even while it was signed with the same key as the previously shipped one! Well, I have something weird going on. I was thinking fiddling around with Dotcase.apk from CyanogenMod 13, so I was able to rebuild the apk. I even made sure to sign it with the Platform Android test key (I checked, the original APK was signed with this exact same key! I extracted the CERT.RSA and compared the certificates - they are the same!).

Then I replaced the APKs in /system/priv-app/Dotcase, swapping the Dotcase.apk for my own built - basically the same as the shipped one, no code changed, just built by myself.

The Dotcase app is using UEventObserver and opening a "DEVPATH=/devices/virtual/switch/cover"

And this is where the problem arises. SELinux is giving me a headache with the message:

07-29 01:07:56.918  4902  4902 W UEventObserver: type=1400 audit(0.0:1229): avc: denied { create } for scontext=u:r:platform_app:s0:c512,c768 tcontext=u:r:platform_app:s0:c512,c768 tclass=netlink_kobject_uevent_socket permissive=0


after that the app crashes, taking with him com.android.systemui, with:

07-29 01:07:56.960  2558  4902 E AndroidRuntime: java.lang.RuntimeException: Unable to open socket for UEventObserver


while the same app with the same code and the same signature key is fine.

I tried some tricks which involves usage of something like supolicy from SuperSU, etc, to no avail - seems like the app (which boots as android:sharedUserId="android.uid.systemui") is starting before anything else is kicking in.

Now the questions:


What I did wrong?
How to fix it?
Is there maybe a possibility to disable SELinux completely by patching something in /system - at least for the time being while I'm fiddling around with it?
Or the only option is to built the whole cyanogenmod rom image with my changes each time I need to test a small change? :(


PS: device is HTC M9 GSM (himaul)
Well I found out that I messed up. I was building it with the wrong manifest. It should had been android:sharedUserId="android.uid.system" instead of android:sharedUserId="android.uid.systemui". When I compared the manifests (thank you apktool for decrypting the manifest for me!) it become obvious. Replacing the related bits in the manifest fixed it. Problem solved. Probably I was just using the wrong repository.