If I remember correctly what has changed is that atleast one file was mislabeled in a previous android version (sensors_persist_file ← → persist_sensors_file). That is one thing I found while skimming through some commits.
As far as I’m aware some partitions are automatically relabeled, but the persist partition only gets relabeled under certain specific conditions which are not triggered by a reboot/flash but only by some specific changes.
Hello, Florian from UBports here. This happens, unexpectedly for us to say, for the following reasons:
Ubuntu Touch does not use SELinux but Apparmor to secure processes, files, isolate Apps etc.
When doing a port for Ubuntu TOuch therefore SELinux is turned off in kernel, and so any SELinux context information that was stored with files may be tampered/removed if the file gets written.
Sensors probably store calibration, metadata whatever on /persist in this case
When Android is reinstalled, its not supposed to reset anything on persist
But also, Android refuses access to those files since they fail SELinux checks now
At the end, sensors do not work anymore
We will work with Fairphone to see if this can be fixed in a better way. Until then, please use the manual workaround psoted a few comments above.
Are there plans to use SELinux? I only have advanced experience with SELinux (Fedora/RHEL user) and some regular experience with AppArmor (OpenSUSE/Debian). But from what I can tell is that SELinux is, when enabled, really strict. While AppArmor, when enabled, it could only be just protecting a CUPS service. That sort of gives me the impression that SELinux is more like a firewall where you have the default rule to drop traffic, and then allow selective traffic. While AppArmor feels more like a firewall where the default is to allow everything, and you specify some behavior you don’t want.
This may be a topic of it’s own though. But just wondering if Ubuntu Touch is considering SELinux. Fedora Silverblue shows how a Linux environment can be quite locked down in terms of security at the level of iOS/Android, by using SELinux (and some other stuff).
I’m having the same issues and have now successfully installed Magisk. Probably missing something and it’s late so gonna go bed! Root is now working and tries to get restorecon -FR /mnt/vendor/persist to work via termux
I suspect reading further I need to use the command via adb in windows
Hey. this solution worked for me thank you!. i want to note that i couldnt find the magisk app on the appstore so you have to google it and got it myself from magiskmanager.com and installed the apk.
For other people you can find the fairphone 4 rom on the official website which contains the boot.img also when patched it will look a little like this “magisk_patched-26100_qXhxI.img”
If someone is technical enough to do this but is strugging to get it working ill offer my assistance for a short while.
Never download Magisk from some random 3rd party site, this is software that can do everything on your phone, you can’t be sure that it hasn’t been tampered with!
The only safe place to get it is from Magisk’s GitHub releases, the official instructions are here.
I bought my FP4 from murena with e/OS, installed Android 11, Ubuntu Touch, PostmarketOS and then Android 13. The magnet and proximity sensors didn’t seem to work and the app SatStat confirmed this: no data.
I followed this procedure of using magisk to root and restorecon -FR /mnt/vendor/persist and things work again! Hooray!
Oh dang… I did an ls -lZ /mnt/vendor/persist/ before and after restorecon but don’t see a change. I guess it was a change on the directory itself.
Hi, trying to revive this old thread, i’m in this exact situation two years later ^^
just followed your guide (thanks for this btw), but got restorecon command not found…
I tried this with fp os (last build) stock
if anyone have an idea, this would be a life saver
Hmm, having a hard time remember what I did 2 years ago
But from the conversation above the message you replied to, it seems like I was (and I still am) running DivestOS, and had to modify the boot image to enable root(?). Just checked now through adb on my phone, and I still have the restorecon command available. Maybe the stock ROM don’t include it? Might be possible to compile it manually for the stock image I guess, but I assume you would have to cross compile it somehow, and I have no idea how to do that.
If you don’t have anything you want to lose on your phone, maybe try installing DivestOS and get root access in it? I seem to remember that once I got the sensors working again, I tested that they still worked after flashing stock os again as well, but I’m not 100% sure. Installation instructions are here: Bootloader - DivestOS Mobile
thanks for your quick answer !
I solved the issue, it was a misunderstanding from me :
to run this command, i had to sudo/su, not used to root, my bad !
And the “command not found” threw me off hehe !
Anyway thanks for this thread, it worked like a charm and i have now a working fp4 again !
cheers
Hello there! I just bought a second hand FP4 and noticed a bunch of sensors aren’t working (gyro, lightmeter, acceleration…). I guess the vendor should have played with the OS as well… Could you please explain me the method you used ? To be fair I don’t understand a lot about what you describe… I’m not familiar at all with Ubuntu and OS manipulations…
Hey folks, I bought a second hand FP4 and none of the sensors are working (the old user installed Ubuntu before doing the factory reset). By reading the comments, I don’t understand that much how to heal the sensors… Could someone explain how to do it with more details please ? That would be awesome!!
Hi @Paul_Fischer !
Is your booloader unlocked? (if yes you have a warning at boot)
What is your current OS version? (settings > about phone > build number )
Hi :))) I’m under Android 13 at the moment and I guess I have no bootloader unlocked as I don’t have any notifications when booting.
Here is the build number : FP4.TP2U.C.0136.20250530
Ok so here are the steps.
If one is not detailed enough just tell me
Make a full backup of everything that is on your phone, because unlocking the bootloader will perform a factory reset. So copy all your files/apps/pictures/contacts/… on your PC or on the cloud.
Unlock the bootloader. Just follow the official guide and everything should be fine. During the process you will install the ADB and Fastboot drivers on your PC so for the next steps I’ll consider you have it already
Let’s Root the boot.img
download the C.136 android image FP4-TP2U-factory.zip on the official website, following only “Step 2: Download the relevant package.” and not the other steps.
unzip the files using your preferred app (7-zip, …)
copy the file “boot.img” (in folder FP4-TP2U-factory/images/ ) on your phone if you made the previous steps on your PC.
(on the phone) install Magisk app from topjohnwu github : download the latest stable apk, then install it allowing unknown sources.
open the Magisk app, in front of Magisk click on install, select the file “boot.img” we extracted earlier
this will generate a magisk_patched-xxx.img file. Copy this file on your PC.
One-time booting with root
shutdown your FP4
start in fastboot mode by pressing volume Down and plugging your USB cable
fastboot boot magisk_patched-xxx.img
Run the command mentioned by mhv.
either by adb shell with root, or by terminal app → restorecon -FR /mnt/vendor/persist
Reboot and check if sensors are OK.
(optional and risky) Relock the bootloader only if fastboot flashing get_unlock_ability returns 1.
Amazing man thank you so much ! I’ll try that in a week when I’ll have access to a computer. Everything sounds clear at this point but maybe I’ll ask again later