Installing Android after Ubuntu Touch: Fix sensors issue
-
Hi there,
if you ever want to install an Android-based distro after Ubuntu Touch was installed, you will notice that no sensors work anymore. The root cause was already identified by guys on the Fairphone forum some time ago description is more to the end of the thread, so be patient and read it in full - but here in UT side nobody of course noticed that, as sensors keep working correctly in UT

What happens is that the necessary Android selinux contexts are being somehow removed from the sensor folder in the persist partition. We would need to analyze why this happens, but probably the files are being rewritten from the Android container in UT and as UT does not use selinux, they are set to unlabeled, like so:
./sensors/registry/registry: total 668 drwxr-xr-x 2 system system u:object_r:vendor_persist_sensors_file:s0 12288 2023-11-21 22:10 . drwxr-xr-x 3 system system u:object_r:vendor_persist_sensors_file:s0 4096 2023-11-21 22:10 .. -rw------- 1 system system u:object_r:unlabeled:s0 78 2023-11-21 22:10 ak0991x_0 -rw------- 1 system system u:object_r:unlabeled:s0 131 2023-11-21 22:10 ak0991x_0.mag -rw------- 1 system system u:object_r:unlabeled:s0 233 2023-11-21 22:10 ak0991x_0.mag.config -rw------- 1 system system u:object_r:unlabeled:s0 181 2023-11-21 22:10 ak0991x_0.mag.config_2 -rw------- 1 system system u:object_r:unlabeled:s0 222 2023-11-21 22:10 ak0991x_0_platform -rw------- 1 system system u:object_r:unlabeled:s0 866 2023-11-21 22:10 ak0991x_0_platform.config -rw------- 1 system system u:object_r:unlabeled:s0 142 2023-11-21 22:10 ak0991x_0_platform.mag -rw------- 1 system system u:object_r:unlabeled:s0 146 2023-11-21 22:10 ak0991x_0_platform.mag.fac_cal -rw------- 1 system system u:object_r:unlabeled:s0 204 2023-11-21 22:10 ak0991x_0_platform.mag.fac_cal.bias -rw------- 1 system system u:object_r:unlabeled:s0 508 2023-11-21 22:10 ak0991x_0_platform.mag.fac_cal.corr_mat -rw------- 1 system system u:object_r:unlabeled:s0 148 2023-11-21 22:10 ak0991x_0_platform.mag.fac_cal_2 -rw------- 1 system system u:object_r:unlabeled:s0 206 2023-11-21 22:10 ak0991x_0_platform.mag.fac_cal_2.bias -rw------- 1 system system u:object_r:unlabeled:s0 510 2023-11-21 22:10 ak0991x_0_platform.mag.fac_cal_2.corr_mat -rw------- 1 system system u:object_r:unlabeled:s0 176 2023-11-21 22:10 ak0991x_0_platform.orient -rw------- 1 system system u:object_r:unlabeled:s0 622 2023-11-21 22:10 ak0991x_0_platform.placementUnfortunately the solution to this is, as described in the Fairphone forum thread, a bit cumbersome:
- The bootloader needs to be unlocked. If you happen to have all your data already in this Android installation and you have locked the bootloader again, you will loose all your data during this process.
- You have to install Magisk. Depending on the Android version this involves patching the boot.img file or creating a custom recovery
- With Magisk you can obtain a root shell and the execute the necessary restorecon command
It would be awesome to find out if we can avoid this situation somehow. Unfortunately I just dont have the time for the moment, but I can confirm the fix worked as described over there.
BR Florian
-
@flohack Hello,
Last year I had to reinstall Android for some months and I used LineageOS. This Android version allows you to run the selinux commands without the need of Magisk. It allows you to run adb shell commands as root with a simple checkbox in the developper settings.
I was happy to discover this possibility with LineageOS as I had already restored my data on the phone

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register Login