Commit Graph

9610 Commits

Author SHA1 Message Date
Simon Shi f4c1553789 super: emmc shouldn't be mount-only.
Bugs:
E:Cannot restore super -- mounted read only.

Change-Id: I07891b3f45a8601c1cafa45f9dd2a7a94482ac06
2020-06-18 02:38:24 +08:00
Simon Shi 407437ed39 super: Don't mount while prepare
Some of the partitions will not be unmount automatically. They shouldn't
be mounted by default.

Bugs:
DM_DEV_REMOVE failed for [product]: Device or resource busy
Cannot unmap product before removing group qti_dynamic_partitions.
script aborted: assert failed: update_dynamic_partitions(package_extract_file("dynamic_partitions_op_list"))
assert failed: update_dynamic_partitions(package_extract_file("dynamic_partitions_op_list"))error: 25
Updater process ended with ERROR: 7

Change-Id: I7cbd5c29456ca2731b94a69bbf9ad77058cef09c
2020-06-16 00:06:48 +08:00
mauronofrio 6d3bf891c4 Add ozip decryption for Oppo/Realme device
This function will automatically decrypt .ozip file in a .zip and it will
save the .zip in the same folder of the .ozip and with the same name.
After the decryption, the flash will start.

To enable this function you have to set a Boardconfig flag with the
decryption key like i did here:

https://github.com/mauronofrio/android_device_realme_RMX1901/commit/a30625f80a31b9b85e4948fc9f9beeb61d5bcb8a

Original projects:
https://github.com/sabpprook/ozip2zip
https://github.com/bkerler/oppo_ozip_decrypt

Change-Id: Ic93243a565008c442bcf2992069b2801532ac7c1
(cherry picked from commit 0ff59845f2f8dddedb4cee9a9faf86a6294cce66)
2020-06-10 22:31:49 +00:00
Captain Throwback 87d73d6620 FBE: set TW_IS_FBE based on whether key version path exists
- Should not be determined by whether support exists in TWRP
- Set to 0 by default if FBE is not detected

This also prevents the wrappedkey check from running
on FDE devices

Change-Id: I85d1952facdfafdaa1571fc1b11d4b4b7d9ba48e
(cherry picked from commit cf0dffce3413261f149a3565d8f27cb32490ae54)
2020-06-10 16:33:52 -04:00
mauronofrio 38ed6a7e82 Allow Gui File Selector filter to check among more extensions
For example now in Install menu we are seeing all files with .zip
extension, after this commit we can see also files with .ZIP extension.
Just add the extension between ";" separator.

Change-Id: I6ddd2a812a182570af3d76711b1e3e13740a466b
(cherry picked from commit 27020944c2472c28b12ceccf676d58c2709af890)
2020-06-10 15:34:28 +00:00
Patrick Zacharias 0edce1a2a4 gui: Repair OEM build
Building with TW_OEM_BUILD results in errors during compilation:

error: unused label 'error' [-Werror,-Wunused-label]
error: unused parameter 'allow_commands' [-Werror,-Wunused-parameter]

These changes are required to allow compilation to complete.

Change-Id: Iddc5bf1b90120de19a472c48b21d3531b758cacf
(cherry picked from commit 0cd6be903b3129b30d5abe40d3a0f30545eef27d)
2020-06-10 14:38:39 +00:00
Mohd Faraz f9ded0665b fix flashing issue after restore policy issue
* since commit: https://github.com/TeamWin/android_bootable_recovery/commit/a2bd7b7758a4585814f642d55301043276d8a002
   after factory reset /data/recovery doesn't recreates in A-only devices.

 * so fixes issue flashing newer roms need access to /data/recovery

Signed-off-by: Mohd Faraz <androiabledroid@gmail.com>
Change-Id: I02cb67f7161571b1aa02784049231d42872a3587
Signed-off-by: Mohd Faraz <androiabledroid@gmail.com>
(cherry picked from commit bcbe94e2b5ef83fe65a5c9767287802365b5ee4e)
2020-06-10 14:24:25 +00:00
bigbiff 325e0a2cca ext4crypt: fix include location for recovery-twrp in lineage
Change-Id: Iefa73425fc13f41f5a267cce0c5d4047edc25e9e
(cherry picked from commit 186eb7002d95e28325f2d2e42637c989e08ac618)
2020-06-08 23:28:07 +00:00
LameMonster82 4ef96a6f9a add support for TSPDRV vibration
* Needed for the LG V30, G7, V35, V40

* Use TW_HAPTICS_TSPDRV in your BoardConfig.mk to enable it.

Change-Id: I0970ed5c046e851f7e6f562283523c7214c8d2b5
(cherry picked from commit 314cbd5698d1750a31c9cf4284d3ce8dfadce157)
2020-06-08 22:36:41 +00:00
bigbiff 32cbabe413 apex: mount up apex files into /sbin for library access
This patch uses the loop device to mount files under
/sbin/ from /system/apex in order for the device to
use libraries or other files store inside these files.

Each apex file is mounted over a loop device into a
directory correpsonding to the apex filename under
/sbin/.

Once apex mounting is completed, TWRP will set a
property twrp.apex.loaded to true so that init
can use them as a LD_LIBARY_PATH source.
Change-Id: I69f14a969123ac9cf1afc85b6cf76836cb092fb2

Change-Id: Ica6a7d8e479bcaec8bec4483b5e8d2b45ee105fb
2020-06-08 20:38:04 +00:00
bigbiff ee7b7ffba4 super partition: mount super partitions using fs_mgr
We are now requiring fstab v2 for android-10+ trees. You can
specify twrp flags using /etc/twrp.flags to label and
annotate partitions.

This patchset uses fs_mgr to load the super partition and build
device mapper blocks off vendor and system depending on the slot
in use. These are mapped to partitions in TWRP and allowed to
be mounted read-only. The super partition is also mapped into a
TWRP partition in order to backup the entire partition. You cannot
backup individual device mapper blocks due to the device can only
be read-only. Therefore you cannot write back to the device mapper.

Change-Id: Icc1d895dcf96ad5ba03989c9bf759419d83673a3
2020-06-08 20:37:29 +00:00
bigbiff 3a299dcc32 relink: use relinked files as required modules
Change-Id: I18bffa454ad64d70c5efedbf174887571e95b734
2020-06-08 20:35:01 +00:00
Mohd Faraz bc576cde4b TWRP: Enable qti input haptics vibrators support
* these type of vibrators are present in newer devices based on
   board sm8150 & above. Like Oneplus 7 series, Redmi K20 Pro, etc.
 * to enable it add TW_SUPPORT_INPUT_1_2_HAPTICS := true in Boardconfig.mk
 * you will need to add the vendor vibrator service to init and run it in your device tree
Change-Id: I0fe6612def149e70808ca41829b6f7ba0b23cd62
Signed-off-by: Mohd Faraz <androiabledroid@gmail.com>
(cherry picked from commit 909daa959c99cf3a6abbe224ec3fc45669df4440)
2020-06-08 01:43:05 +00:00
bigbiff f654e8483b twrpapp: modules in 10 should be optional
Change-Id: I465eb02bfeb1feeb087458955241c1456b0ef496
2020-06-05 21:03:23 -04:00
bigbiff 50aa4adcee twrp version update: update to 3.4.0 release notes are on twrp.me
Change-Id: I3762fb3e2c3ffb4cbdc6d93ce424cacc7e0ef418
(cherry picked from commit e0e43403b9bdd9261e733aa0448d7689a9f23ced)
2020-06-05 19:42:50 +00:00
Chaosmaster 4ee7cbddde Remove /system -> /system_root/system symlink in ZIP-install
when unmounting system /system_root/system is symlinked to
/system on devices built with BOARD_BUILD_SYSTEM_ROOT_IMAGE

Some ZIPs don't play well with a symlink when trying to mount to
/system.

Change-Id: Ifb0a105ddc0337353a7e1ac234c9f1e5b387e992
(cherry picked from commit 589daae9ccd2951263bd183125c0ad6de454e277)
2020-06-05 19:39:59 +00:00
Stefan Tauner 6ad1457332 Add and install permission file for Android 9+
Without this, installing the twrp app as system app leads to
reboot loops into recovery with log messages like:
java.lang.IllegalStateException: Signature|privileged permissions not in privapp-permissions whitelist: {me.twrp.twrpapp: android.permission.READ_PRECISE_PHONE_STATE, me.twrp.twrpapp: android.permission.BATTERY_STATS, me.twrp.twrpapp: android.permission.PACKAGE_USAGE_STATS}

Change-Id: I6156323ea0d23512b0d7eefbd03aa627f3002ae8
(cherry picked from commit 86a4370e6fe4bb20033b0de3a261aec4bf3573db)
2020-06-05 18:39:36 +00:00
Mohd Faraz b98b4f7b96 partitionmanager: magisk update sytnax as per new binaries
Change-Id: I51994b991472cf103de067b9856ff3df1bf35a90
Signed-off-by: Mohd Faraz <androiabledroid@gmail.com>
(cherry picked from commit 5738e760646d67791e938954a8873da41209d58c)
2020-05-30 20:05:43 +00:00
Mohd Faraz fb62b1806e crypto: Update crypto fde
* Some missed in https://github.com/TeamWin/android_bootable_recovery/commit/191a6948d9f1f627cc53c38d72d4bce2e7897753

* Crypto msg from https://source.codeaurora.org/quic/la/platform/system/vold/commit/cryptfs.cpp?h=LA.UM.8.1.r1-13500-sm8150.0&id=e1a7e772699216121dd8fa774381ffeedb076139

* As devices required to update 'Upgraded key' through keymaster in v4.0.

Change-Id: Ia66be6917c4690f0d70ba89ea33ebfa2fcb6974a
Signed-off-by: Mohd Faraz <androiabledroid@gmail.com>
(cherry picked from commit b51f4af5286750bf15ffe61fd85e8600cbfd15c5)
2020-05-29 14:07:53 +00:00
bigbiff adc599e005 Revert "Add support for multi-user decryption"
This reverts commit 0b25b1d79b.

Reason for revert: Changes need to be made to libtwrpfscrypt to include this patchset. Will cherry-pick this patch later and make necessary modifications.

Change-Id: I7601d7b820129709b05d9b4368573b6f1048de02
2020-05-28 19:36:30 +00:00
Noah Jacobson 0b25b1d79b Add support for multi-user decryption
* Add CLI support using the command "twrp decrypt <PASSWORD> [USER ID]"
* Add GUI support using the menu Advanced --> Decrypt User

Change-Id: Id2681bc2b1012a0571417f7a6e0b980b1b25c61c
(cherry picked from commit 5a79f67a1b1bd1bcadeca0a4896a871646652534)
2020-05-20 19:11:15 -04:00
Mohd Faraz 784073e9fe relink: relink reboot
Signed-off-by: Mohd Faraz <mohd.faraz.abc@gmail.com>
Change-Id: Ie64dad38f1382df5f7bc64f4d21a0602f23b07b1
2020-05-20 00:09:55 +02:00
bigbiff bb5d66889f relink: make dependent on libtar compilation
Change-Id: I51ef2918e6aacb3078a38cc9ec7fae2dfb9e73ee
2020-05-19 14:45:24 -04:00
bigbiff d4aed46c04 vold_decrypt: add missing includes for ext4 policies
Change-Id: Ic68360a13ee8b54cff1f7ec01d4ab1be00673266
(cherry picked from commit 5db50ded70efcea4fe8286689a764860861fdc16)
2020-05-19 14:53:54 +00:00
mauronofrio babc15ef61 Set toolbox as default for android 9+ TWRPs
I created also a new flag for who wants to use busybox
on android 9+ trees.

To use busybox set the flag like this:

TW_FORCE_USE_BUSYBOX := true

Change-Id: If2231e71c008b36e9ae09857539b82d77e2a9a06
(cherry picked from commit 8ff93eb2234f31298d4f3cfe903887c3f6ecc583)
2020-05-19 14:52:04 +00:00
Chaosmaster d5364a0b21 Rework progressbar logic, implement scoped/split progressbar
Rework progressbar according to AOSP, this should fix various
issues with progressbar.

From AOSP:

   progress <frac> <secs>
       fill up the next <frac> part of of the progress bar over <secs> seconds. If <secs> is
       zero, use `set_progress` commands to manually control the progress of this segment of the
       bar.

   set_progress <frac>
       <frac> should be between 0.0 and 1.0; sets the progress bar within the segment defined by
       the most recent progress command.

Change-Id: I7f92359046288f3529cb2e98e6d54d410a248f1d
(cherry picked from commit ab16437de14fd9f1203b7e0ce82ea18eb56cae78)
2020-05-19 14:45:22 +00:00
Chaosmaster 7b66bf503f Replace "Reboot System" with "Reboot" for A/B devices
Users may want to reboot to recovery or bootloader after flashing
A/B zips to switch slots and install additional zips.

Change-Id: I128ceff6d0b361921c7ad7623eab93044e942d18
(cherry picked from commit 90df3de75ef05e014ba363d65a59421a04375e5a)
2020-05-19 14:27:39 +00:00
Chaosmaster a6da6565a0 Add info that flashing AB zip will flash to the inactive slot
Also inform user, that a reboot is required to switch slots

Change-Id: I7d609ee3d231e5d38d9145962e979e012d9a0ac8
(cherry picked from commit 5343a3ca2afcdd895677c5c3ff16a83af372c7b7)
2020-05-19 10:03:54 -04:00
mauronofrio c79f86ef94 installcommand: port https://gerrit.twrp.me/c/android_bootable_recovery/+/1680
to install/installcommand.cpp

Change-Id: I96384bbc92b202a8a5561229488052d488ca6bc1
2020-05-18 16:49:11 -04:00
bigbiff 8a45a1883c merge conflict: remove merge conflict message
Change-Id: Ife2ff7082494f9cc933a9f22e596ca0716c2ced6
2020-05-18 15:46:39 -04:00
Fabrice Bellet 72bcc2030c twrptar: fix backup freeze with pigz and openaes
The filedescriptors must be opened with the close-on-exec flag, so
child processes don't keep opened parent fd around, that prevents
the processing pipe to be properly closed.

Change-Id: I285d57d04d13452383f1b81910a8eda02f17a156
(cherry picked from commit 7884eac0fcda4a13373766a4df3dd19f53d18f95)
2020-05-18 19:14:59 +00:00
mauronofrio d8ee9dde72 Make the twrp verify the pre-device among several props
This is really usefull for that devices that have multiple names, for 
example for zenfone 6 that is called WW_I01WD and also ASUS_I01WD, with 
this commit all roms also with a different pre-device will be successfully
flashed. I decided to use ro.product.model and ro.product.name because
these pros are also used in some roms updater-script to check the device
model before start the rom flashing.

Change-Id: I3b4cd3a13e3fff5c5a6c35bf1a0ed146d2b4c3ec
(cherry picked from commit 1913bf32042c380af3c33c5157341db5963ba281)
2020-05-15 23:11:53 +00:00
mauronofrio fc79aa6375 Encryption: don't try wrapped key if not needed
This commit is used to directly use the wrapped key
decryption when the "wrappedkey" flag is set in the
fstab.

Change-Id: I74310c3bbec378ee684a8f6d0395a9776dd22abf
(cherry picked from commit 1db943295de9728e364bf0e75bfe9f1a98d413a1)
2020-05-13 00:40:25 +00:00
Peter Cai 28ea7b000a partition: set fbe.data.wrappedkey automatically via flag
In change I79c2855d577156670b45c10c7c7b1fcd9fece8d9 we introduced a
property to enable wrappedkey mode. This change supports an extra
`wrappedkey` flag in fstab to automatically set the property to true.

Change-Id: I4f060d4ed6b2a5680649b8746dfa7fd903fe2d35
(cherry picked from commit 40ed06e850de2dc7cc06c2e647688212563f1ec2)
2020-05-13 00:39:19 +00:00
Chaosmaster 6c1477d974 Mount system and vendor for A/B installs for backuptool to work
Also bind mount a copy of /sbin/sh over /system/bin/sh

Change-Id: I58026af425b07b50a4377ab843192578e0d45587
(cherry picked from commit 7bf8df5086c561cbc9da9b32afa678ebe966f5c1)
2020-05-11 18:16:56 +00:00
bigbiff a34befa5c8 system mount: unmount system after checking for TWRP app
Change-Id: I9ab74c9839b50e399432d19839191b7de2d1bf60
(cherry picked from commit 07f991a3ed1457d4774078219e828e6d63756777)
2020-05-11 15:23:32 +00:00
Captain Throwback 89a03ccd36 vold_decrypt: automatically set Android version & patch level
- Requires TW_INCLUDE_LIBRESETPROP
  (set automatically if TW_OEM_BUILD is not set)
- Set based on installed system (if present)
- Will set values back to TWRP defaults
  after decryption completes
- Only included/run on Oreo+ systems

Change-Id: I41fcc1af8cd4b15329574f7403f7491320199f48
(cherry picked from commit 3284a66e23fbc6e1a82df668b497ef931d9c0081)
2020-05-11 15:22:14 +00:00
bigbiff 437b93a087 Merge remote-tracking branch 'origin/android-9.0' into android-10.0
Change-Id: Ie850f431f0d2c39c86b9c10701676a24770ab447
2020-05-10 20:06:41 -04:00
dianlujitao b76a73a1a9 Fix backup and restore after autodetection for SAR
This reverts commit 8a411c8d25.

 * Always use "/system" to interact with the frontend and replace it
   with the detected path before taking actions.
 * Don't replace the pretty display name and backup name set during
   processing fstab after wipe. This improves UX and ensures that the
   system backup is always named system.ext4.win despite the actual
   mount point is /system_root so TWRP is able to recover either SAR or
   non-SAR backups.

Change-Id: Ie2594d2678d0c75ce25c0d1087d47b035b3f10e9
2020-05-10 21:35:01 +00:00
Chaosmaster 65633a46d0 Add optional PartitionManager and Mount_Point to
Get_System_Properties for use during SAR-detect

Change-Id: Ie1ffba53459b7bb77ca47d9cb928b2626c704a05
2020-05-10 21:30:50 +00:00
Mohd Faraz 0d9a62e409 Remove Extra spaces occured while using multiline string variable
* On multiline string variable it adds spaces

Change-Id: I0f9140f3840b0238009af2271ac67b25754f76c9
Signed-off-by: Mohd Faraz <androiabledroid@gmail.com>
2020-05-10 21:24:00 +00:00
Chaosmaster 97c4541415 libresetprop: not available for Android < 7
Change-Id: I5cf384b472e43ee8d380ac08aeed1a8567844d7e
2020-05-10 21:21:47 +00:00
Chaosmaster 01a17998da Add flag for overwriting properties with system values
This adds the flag TW_OVERRIDE_SYSTEM_PROPS which can contain
a ";" separated list of properties that should be overriden.

A different source property can be defined by separating
target and source using "="

Example:

TW_OVERRIDE_SYSTEM_PROPS := "ro.build.product;ro.build.fingerprint=ro.system.build.fingerprint"

This will override ro.build.product with the value of ro.build.product from system/build.prop.
And also override ro.build.fingerprint with the value of ro.system.build.fingerprint.

with their corresponding values from the system partition.

Change-Id: Ibcd3e6ed51fa7f7195ad524e606a2b9542687e55
2020-05-10 21:19:32 +00:00
Chaosmaster 461e39fe89 Add TWFunc::Property_Override(name, value) to override properties
using libresetprop

Change-Id: Ic49e187698c714f8a629d20ceddc40e823555477
2020-05-10 17:17:56 -04:00
bigbiff aaa9e64b81 Merge "Create a flag to include resetprop in the TWRP" into android-9.0 2020-05-10 20:37:09 +00:00
Chaosmaster f6e42ce390 Implement autodetection for SAR, based on the installed system
This will detect whether SAR is present in the currently installed
OS and set the property ro.twrp.sar accordingly.
After setting the property it will call the bootscript
/sbin/sarsetup.sh (if present) to give device maintainers the
option to do setup operations depending on SAR-status, such
as modifiyng the fstab.

If no system is detected and AB_OTA_UPDATER is defined or built with
Android 10 and upwards, it will fallback to using SAR, otherwise it
will use ro.build.system_root_image as basis for deciding whether SAR
is required or not.

The property ro.twrp.sar will also be used by
TWPartitionManager::Get_Android_Root_Path()

This allows maintaining a single TWRP-build for devices switching
to SAR for Android 10.

The default behavior (when no system is installed)
is determined by the build-flags AB_OTA_UPDATER and
BOARD_BUILD_SYSTEM_ROOT_IMAGE

Change-Id: I2a48c6c81a6ea6fad6e452c06bfbe4d9da0f1e5c
2020-05-10 15:43:56 -04:00
Chaosmaster da97480567 Create/Remove system_root/system bind mount, when mounting System
This will automatically create and remove a bind mount
/system -> /system_root/system
everytime "System" is mounted via the GUI or ORS.
This should get rid of issues with ZIPs trying to mount
the system-partition to /system on SAR-devices, while keeping
the filesystem-layout in sync with AOSP from a user-perspective.

Change-Id: I7f531d113b07c31b39d8f87edac76a7fc79075e7
2020-05-10 15:43:55 -04:00
Chaosmaster ff4f958182 Add option to automatically unmount system before installing ZIP
This adds the option to automatically unmount the system partition
before installing a ZIP-file.
This option is enabled by default, This is usefull on SAR-devices
where system is mounted as system_root and ZIPs (i.e. Magisk)
try to unmount system instead of system_root and fail to install.

Change-Id: Id94ae658964679e23aa7fa137e07edf74ee073df
2020-05-10 15:43:55 -04:00
Chaosmaster 3b3b634365 ORS Make mount/unmount system mount system_root on SAR
Change-Id: Ibf8d4d61e6cbb132786f5f9aa23ec91b49bcab89
2020-05-10 15:43:54 -04:00
Chaosmaster 3b6827372e Set system-partition mount point to proper location
This sets the system mount point to either /system_root or /system
depending on whether SAR is detected or not irregardless of what
is specified in fstab.

This removes the need to edit fstab for SAR-builds and simplifies
building unified (SAR/non-SAR) builds.

Change-Id: I154fd76f842702be9e5d09005463c8e5f1d289a4
2020-05-10 15:43:54 -04:00