Phone sensors stopped working after installing experimental image [Ubuntu]

You don’t need a proper Magisk setup for this, just install the app and use fastboot boot patched_boot.img, make your adjustments, reboot.
I have uploaded some prepatched boot.imgs in this folder, if you want to skip patching the image.

1 Like

I wouldn’t do that as you need the correct file_contexts. You can relabel everything manually, but it will be a lot easier when file_contexts is known, because else you will have to specify everything by hand

Will your prepatched boot.img work if I’m running DivestOS, or would I have to go back to the Stock OS?

In that case I would suggest extracting and patching the boot.img that’s shipped with DivestOS, just to be safe.

Edit: I had an extracted one lying around already, here you go :slightly_smiling_face:

3 Likes

Thank you, but I just did it myself, a great learning experience. Downloaded yours and it has the exact same md5sum as mine even, so I think I did it right :joy:

2 Likes

AND IT WORKED!

So in summary:

  • You need to get a root shell in your currently installed Android flavour, either via permanent or one-time booting to a magisk image
  • Run restorecon -FR /mnt/vendor/persist
  • Reboot

As people have mentioned here and elsewhere MESSING WITH THE PERSIST IMAGE CAN BRICK YOUR DEVICE, so do this at your own risk!

I’m not sure if or how I could get into contact with the right people, but maybe this is something the default OS package should fix automatically? I won’t make a very hard argument for this, as it will probably only affect people who should be able to fix it themself now that this thread exist.

Thank you very much everyone in this thread!

8 Likes

If there’s any interest from fairphone developers or others, I extracted an image of my persist partition before and after the restorecon operation, so one could see exactly what changed to make it work again. (This is after a DivestOS install, but from my understanding “persist” should be the same for all Android installations?)

1 Like

Maybe ask @lucaweiss :wink:

2 Likes

Even if I probably won’t know what to do with that information, I would love to have a look and see the difference :smiley:

Not sure if there’s privacy-sensitive data in there :thinking: (somebody knowledgeable should answer that)
If there isn’t, please upload it somewhere :pray:

2 Likes

That is exactly what I would like to know as well, if not I could just upload the files. I have to go out for a few hours, but I’ll look into it.

A quick diff shows me the only differences are in these (binary) files:

/hvdcp_opti/soh_info.txt
/time/ats_1
/time/ats_12
/time/ats_13
/time/ats_15
/time/ats_16
/time/ats_2
(yes the .txt also contain both text and binary data)

A low hanging fruit method would be to run the command strings on those files and see if you notice anything personal there. But this is just a very basic check.

2 Likes

Be aware that the persist partition is unique per device and using someone others persist will result in wrong sensor calibration and you will also have wrong DRM keys and MAC-addresses as those are stored in persist as well.

Its not the content of the files itself that has changed but just the labeling that is wrong… you could check those with ls -Z

1 Like

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.

1 Like

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.

4 Likes

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 had the same exact problem and it worked for me too. Thanks :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

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.

1 Like