mosen 201 Posted August 12, 2022 Share Posted August 12, 2022 (edited) It is highly advised to take a backup of your device specific partitions right after you receive the device.Update 20220829: tl:dr: Community has not found a safe way to restore backups as of yet. Making below described backups is still highly advised for a future where some wizard found a reliable way to restore those backups. For now, if you have broken sensors from flashing another OS, the restorecon method described in the "Repair sensors/ folder..." section does 100% work to fix those while retaining your attestation keys. While restoring any backup has a high chance to make the keys inaccessible in Android and can make your situation worse currently.Ideally, backup before flashing an alternate operating system to your Pro¹ X. This has nothing to do with a data backup (e.g. using adb backup or backup apps) you might not mind too loose since you got no daily driver data on a device yet. We are about to backup all the partitions that can be needed to restore a fully working stock android. E.g. for the case you want to resell the device. Or just re decide and want to use stock android again after having tested an alternate OS. Problemscape: - When flashing and using SailfishOS or Ubuntu Touch (no info for LineageOS yet), the sensors folder in the persist partition gets altered. Since both OS are not in SELinux context when writting, causing the security context to break. - This will lead to non working sensors in stock Android like described in this thread. - The persist partition additionally contains device specific hardware attestation keys and EFS values generated during first setup of stock android. - To be able to use Key Attestation and working sensors after a flash back to stock android, we can NOT just flash the stock persist.img since it misses our keys. - We need a backup of persist with our keys and the correct sensor data. Ideally taken when you receive the device.WARNING: Do not flash the stock persist manually like advised in deprecated XDA posts. You will loose your keys and a method to re-provision them is not yet found.If you have no backup but your persist partition is broken already from booting UT or SFOS. Check with the android app "Key Attestation" if your keys are still visible to android. It will show "Not supported by this device" to indicate your keys are not present and are sadly not restore able with the offered method. If however the app indicates a trusted environment (TEE), just follow from here on, do a backup now, saving your keys. Then head to the last section "Repair sensors/ folder in persist.img". This guide assumes you are using linux and have edl.py installed. I will not be able to test this on windows. Someone else might translate the tasks to windows applications like QFIL for the flashing. The official QFIL full reflash guide does not contain this backup method yet.@EskeRahnshows how to Backup using ADB in a comment below. Note tht this only works after rooting the device following this guide.Details of the EDL installation and the 2.1.2 EDL image links are to be found in this "How to flash to stock" post. You can anytime use the EDL full flash method to switch back to stock android from any soft-bricked state. It will retain your keys since it does not flash the persist partition when it contains keys. A full flash will however not solve the android sensor problems. Backup of partitions Be sure to not work in the folder you extracted the stock images too. To avoid mixing them up with your backups. We are interested in all partitions that have potential to need a restore later, so lets grab all of these: fsg, fsc, modemst1, modemst2 and persist. The EDL commands to dump the partitions into image files are executed as root/sudo as following edl r persist persist_backup.img edl r modemst2 modemst2_backup.img edl r modemst1 modemst1_backup.img edl r fsc fsc_backup.img edl r fsg fsg_backup.img Restore a partitionWARNING: This method does not reliably work to restore. Only for educational purpose for now. To fix the stock android sensor problems, we only need to flash the persist partition back. If your persist has broken sensor config, obviously skip this step for now and do it after repairing the sensors folder. edl w persist persist_backup.img Repair sensors/ folder in persist.imgRoot the Pro¹-X following this guide. adb shell into the device and become root via su. adb shell su Restore the SELinux security context for the sensors folder using restorecon. First using the -n option if you just want to see what restorecon would do, but not alter anything yet. restorecon -nvRF /mnt/vendor/persist/sensors/ And apply those changes by omitting the -n option, -v verbosity should generate the same output like when using the -n option. restorecon -vRF /mnt/vendor/persist/sensors/ You are all set for reboot You should notice the fixed sensor after reboot by just folding out the keyboard and see it force landscape. Edited September 13, 2022 by mosen 1 13 Quote Link to post Share on other sites
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.