UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Installing Android after Ubuntu Touch: Fix sensors issue

    Scheduled Pinned Locked Moved Fairphone 4
    2 Posts 2 Posters 45 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • flohackF Offline
      flohack
      last edited by

      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.placement
      

      Unfortunately 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

      My languages: πŸ‡¦πŸ‡Ή πŸ‡©πŸ‡ͺ πŸ‡¬πŸ‡§ πŸ‡ΊπŸ‡Έ

      adorsazA 1 Reply Last reply Reply Quote 1
      • adorsazA Offline
        adorsaz @flohack
        last edited by

        @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 πŸ˜€

        1 Reply Last reply Reply Quote 1

        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
        • First post
          Last post