I'm trying to build a ROM for my phone (Xiaomi Mi A2 Lite) with SELinux enforcing. I've booted the phone successfully in permissive mode, however in the enforcing mode the Wi-fi won't work and SystemUI restarts every few minutes, displaying "Phone is starting..." instead of the launcher screen.
I used audit2allow
to grab SELinux denials from my phone and added the output to the list of SELinux policies. However, when I try to compile the ROM, I get the following error:
device/xiaomi/daisy/sepolicy/daisy.te:224:ERROR 'unknown type qemu_hw_mainkeys_prop' at token ';' on line 75538:
allow platform_app qemu_hw_mainkeys_prop:file read;
After getting that error, I declared the type in my property.te file:
type qemu_hw_mainkeys_prop, property_type;
And after trying to compile the ROM again I get this:
device/xiaomi/daisy/sepolicy/property.te:3:ERROR 'Duplicate declaration of type' at token ';' on line 75576:
type qemu_hw_mainkeys_prop, property_type;
Android will append all te files to one file. You need to add a blank line at the end of each te file, otherwise the last line of previous file and first line of current file will be mixed. And also, I prefer that you also add a blank line at the beginning of each te file to avoid format error from other te files.