Commit Graph

169 Commits

Author SHA1 Message Date
bigbiff
df8436b51a fastboot: implement fastbootd in twrp
fastbootd is a userspace daemon that runs in the recovery
ramdisk. It allows writing single partitions to the super
partition via fastboot CLI. When TWRP sees the fastboot option
in the misc partition during startup, it will start with
the fastbootd page and fastbootd running. Otherwise it will
run recovery normally.

Change-Id: Id7b12d29ef21dbd5950dc884dd1cd788f25357f0
2020-10-21 17:47:27 -04:00
Captain Throwback
12673e2a4c prebuilt: make paths consistent and remove some redundacies
Change-Id: I46d1a66622245ad61026e402bacc36924ff0e642
2020-10-20 12:15:29 -04:00
Captain Throwback
57db2cc8ac f2fs: add back fsck.f2fs to recovery build
- Fixes issue of rebooting device when data filesystem
  is set to f2fs

Change-Id: I9de815e12be57773712d4acfa0b634ce909ea820
2020-09-09 15:40:13 -04:00
bigbiff
20edca8f34 minui: fix bad merge from aosp10.
Tested charger on flame and graphics show properly when device is
powered off.

Change-Id: Ic1a46497a6bce88992b2d1a9052cba2a1a6af8b7
2020-09-08 15:08:53 +00:00
bigbiff
ad58e1bfae repack: move sbin to /system ramdisk and update repacking
for android-10

This will support updating the ramdisk to a different
compression format and co-exist with magisk.

We are also cleaning up and removing non android-10
api makefile actions.

We are also moving twrp repacking to its own class. We
check the new ramdisk format and if it's different
we have magisk compress using the new ramdisk format.

Change-Id: I770030aae7797e75817178b2f0fccd9f39dc23af
2020-09-08 10:08:33 -04:00
bigbiff
7124009f9d fastbootd: relink for startup
Change-Id: Ica7dfbfd46c06618240fb06fce9c4b31103ec506
2020-07-03 18:55:21 +00:00
bigbiff
7ba7500953 decrypt: AOSP 10 requires the use of fscrypt
fscrypt aosp doc: https://source.android.com/security/encryption/file-based
kernel fscrypt doc: https://www.kernel.org/doc/html/v4.18/filesystems/fscrypt.html

This commit implements the ability for TWRP to use fscrypt to decrypt
files on the fscrypt implementation. It has been implemented mostly
in a new successor library to e4crypt called libtwrpfscrypt. Most of the
code was ported from AOSP vold.

Notable updates include:
 - updated policy storage by libtar
 - lookup of fbe policies by libtwrpfscrypt
 - threaded keystore operations

Big thanks to Dees_Troy for the initial trailblazing
of encryption in TWRP.

Change-Id: I69cd2eba3693a9914e00213d4943229635d0cdae
2020-06-22 12:17:22 +02: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:

a30625f80a

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
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
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
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
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
437b93a087 Merge remote-tracking branch 'origin/android-9.0' into android-10.0
Change-Id: Ie850f431f0d2c39c86b9c10701676a24770ab447
2020-05-10 20:06:41 -04: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
mauronofrio
76ef9f3c04 Create a flag to include resetprop in the TWRP
The flag is:
TW_INCLUDE_RESETPROP := true

Change-Id: I4d4d25a6d5bbd2330efd7f184d0f878a8cf0346e
2020-04-30 16:42:03 +08:00
bigbiff
973167aff3 ramdisk: move uevent link that build creates
Add missing init.rc files for recovery.
Cleanup init symbolic links.
Comment out removing the source file in relink.sh because we need
to retain files in /system in the ramdisk.
Change-Id: Ie959024296738538f3b3161e38027a44525b0696

Change-Id: I5b1a744414b88a9a15c56bd81f37091664d5cdf1
2020-04-09 16:47:23 -04:00
bigbiff
4721a5a1a3 unzip: relink unzip binary from system/bin
Change-Id: I69a8c86c3c817f0a539be53a52f33b8bb6813fdf
2020-04-05 10:32:40 -04:00
bigbiff
36f088ac7c adbd: relink sh properly
Change-Id: Ifb4eba0cded949db66a9d3b77bb185828425d197
2020-04-04 19:58:19 -04:00
bigbiff
63d7add7cf logd: make logd run and relink logcat
Change-Id: I5a2984ea2649bebd923d42e6b984856b36b18fbd
2020-03-31 18:00:59 -04:00
mauronofrio
cb163e0b14 Relink update_engine_sideload
Change-Id: Ifb95d94a5804f0d490bc8c2c19cab7b03c8f1432
2020-03-30 16:46:35 +02:00
bigbiff
416fe3a18a toybox: deprecate busybox and toolbox utils
Starting with android-10.0 we should only use tools from toybox.
Toyxbox in android-10.0 is specified as a recovery target, so
we just move the symlinks in our relink target.

Change-Id: Ic0116a7d583519b39422ac4d82d30e00918eb29d
2020-03-28 14:13:43 -04:00
theimpulson
d95dcd207c bootable: Move to optional tags everywhere
FAILED:
bootable/recovery/etc/Android.mk: error: init.recovery.ldconfig.rc: LOCAL_MODULE_TAGS := eng is obsolete. See https://android.googlesource.com/platform/build/+/master/Changes.md#LOCAL_MODULE_TAGS
build/make/core/base_rules.mk:171: error: done.
18:29:38 ckati failed with: exit status 1

Change-Id: I056f019aa3249c185b808140bcef45a4777d21b3
Signed-off-by: theimpulson <aayushgupta219@gmail.com>
2020-03-23 15:09:31 -04:00
bigbiff
d58ba18272 AOSP10 TWRP Merge: fix conflicts and update libraries needed
This allows flame to boot TWRP. Still will need to work on
super partition for vendor and system access.

The plan will be to cherry-pick any updates to android-9.0
through gerrit.twrp.me to this branch as a WIP.
2020-03-23 11:18:29 -04:00
Captain Throwback
8d70eb617e ldconfig: add /sbin to search.paths
- Move commands from prebuilt to root Android.mk
- Hotfix for linker errors after https://git.io/JerWD merge
  on some Samsung device(s)

Change-Id: If628ab486689878885b696c2f5a107987092aeba
2019-11-14 11:14:06 -05:00
Captain Throwback
170964d5bb Add ld.config.txt for Android 8.x+ trees
- Fixes the ld.config.txt errors in recovery log which may prevent
  decryption and shell commands from working properly

Change-Id: I0e057525cdda39e8ac10115d37e2cb882b9c4844
2019-10-21 19:46:30 -04:00
Andreas Schneider
b0a0dbbab0 prebuilt: Add android.hardware.confirmationui@1.0 for /sbin/keystore
Change-Id: I62e68c137e9790392dd2fc44c2add990c2f408d6
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-07-04 00:39:02 +02:00
big biff
117c64785b Merge "NTFS-3G: use newer libfuse-light in pie." into android-9.0 2019-05-09 01:48:45 +02:00
bigbiff bigbiff
52f868b5d9 NTFS-3G: use newer libfuse-light in pie.
Change-Id: I66dc38a19524f1eaac8cc5afc1110c5d11fc74eb
2019-05-05 16:13:08 -04:00
bigbiff bigbiff
6af36a4f37 bsd dd: include prebuilt bsd dd in twrp for Nougat and greater
- Cleaned up toolbox/Android.mk so that BSD dd builds
  with correct Android versions

Change-Id: Idb15811480ec03b05336d54b866233b5ac99dfaf
2019-05-04 19:55:16 -04:00
big biff
5f177ae4c7 Merge "awk: add awk for trees including one-true-awk" into android-9.0 2019-05-03 02:16:29 +02:00
big biff
a525f3bc79 Merge "mkshrc: remove post-install cmd and use LOCAL_MODULE_STEM" into android-9.0 2019-05-03 02:09:53 +02:00
Captain Throwback
93804dd50e awk: add awk for trees including one-true-awk
Change-Id: I5458a3ecc69b60cc249f598b0250428fc414f34b
2019-04-30 16:38:49 -04:00
Captain Throwback
bb016729b1 mkshrc: remove post-install cmd and use LOCAL_MODULE_STEM
Change-Id: I2e0c7fda8cb39dd2a607f7ab2fdfe744e75fb3cd
2019-04-29 17:46:41 -04:00
Captain Throwback
3c565b568d Use BSD grep for builds with toybox
- Include symlinks for egrep and fgrep

Change-Id: I78e27f95efa143fa63def02c9e72af567833aefe
2019-04-29 17:44:24 -04:00
Ethan Yonker
53796e7333 Use magiskboot to repack the boot partition
Set TW_INCLUDE_REPACKTOOLS := true

Must also have:
AB_OTA_UPDATER := true

Use magiskboot and provide GUI options to allow users to repack
their existing boot image to install TWRP (or kernels) so we can
stop having to provide installation zips for AB devices. There is
also an option to try to fix a recovery bootloop if the kernel
has been patched to always boot the ramdisk for root, etc.

You will need to pull the below repo into external/magisk-prebuilt
https://github.com/TeamWin/external_magisk-prebuilt

Change-Id: I74196cc6f095a7576d61886dc96cbc18deba9b04
2019-04-03 16:44:00 -05:00
Michael Bestas
9bb7c225a4 Don't copy local mke2fs.conf for O-MR1
* It is now copied from system/extras/ext4_utils

Change-Id: Ibddcad4928c17bc174390d75708a5382a9262441
2019-03-23 14:39:53 +02:00
Simon Shi
e682598480 prebuilt: Support ubsan libraries of all architectures
According to the file under './prebuilts/clang/host/linux-x86/clang-4691093/lib64/clang/6.0.2/lib/linux/*.so', these files are supported under different target architectures. This commit would add support to every architecture.

Change-Id: I1f88bc06c3f30e6d2f2083ba9b6350b2376d83f2
2019-03-22 16:33:47 -05:00
dianlujitao
4879b37b5d Fix the long broken format function
* For EXT2/3:
   * Align mke2fs options with Android 9.0 fs_mgr_format.cpp.
 * For EXT4:
   * Note that make_ext4fs is still in use on Android 8.1 to workaround
     a FDE encryption bug even though mke2fs has become the default
     choice. The bug is fixed in Android 9.0+.
 * For F2FS:
   * Drop the broken "-r" option, it's never ported to O, explicitly
     pass number of sectors instead.
   * Keep all options aligned with Pie fs_mgr.
   * Check existence before start wiping, as Wipe_EXT4 does.
 * For all:
   * Calculate block size at runtime, and reserve the space specified
     via negative "length" option from fstab. Note that positive length
     will be ignored.
   * If the partition has crypto footer, and "length" is not specified
     in fstab, automatically reverse CRYPT_FOOTER_OFFSET (16384).
   * Remove the default crypto key location: footer, this is a bad
     assumption since most partitions don't use encryption! We need to
     know the real situation to decide whether to reserve crypto footer
     on format.
   * If the current action is "wipe" or "change filesystem", wipe crypto
     footer or block device after mkfs if the partition is
     unencrypted or undecrypted (e.g., wrong password).
   * If the current action is "format data", unconditionally wipe crypto
     footer or block device.

Change-Id: I7304a8ee703131ea4a08ab7c60334af28cac28b3
2019-03-21 16:15:52 -05:00
Dees Troy
908442dfb5 Merge "Update FDE decrypt to pie from CAF" into android-9.0 2019-03-20 21:40:44 +01:00
Ethan Yonker
98661c1a29 Update FDE decrypt to pie from CAF
cryptfs.cpp based on CAF tag LA.UM.7.3.r1-05900-sdm845.0
Used CAF because AOSP no longer contains code for qcom's hardware
crypto.

Change-Id: I921cbe9bed70989f91449e23b5ac3ec1037b7b97
2019-03-20 15:33:48 -05:00
bigbiff bigbiff
af32bb9c4f MTP FFS updates:
This update splits old MTP code and new MTP code from Google
into two trees, legacy and ffs. Depending on the SDK level,
the build system will select the correct version. The reason
for separating the versions out are due to older android trees
not supporting the updated MTP code from Google.

Most MTP code is from Google, with additions needed from
implementing the Java functions in C++ for TWRP and FFS.

We assume if you are in android-9.0 or above, your kernel
has support for FFS over MTP. Verify that your init.rc
is mounting the MTP FFS driver to the proper location.

Change-Id: I4b107b239bd9bc5699527f9c8c77d9079f264a7e
2019-03-20 14:28:21 -05:00
lambdadroid
eff335d850 prebuilt: Avoid re-linking ARM64 specific library on other architectures
libclang_rt.ubsan_standalone-aarch64-android.so is a library for
arm64 and is therefore not available on other architectures, causing
the build to fail because there is no rule to build it.

Change-Id: Ia4af38f42ba46a233d40e936d43e4c97c449d059
2019-03-18 18:17:16 +01:00
Dees Troy
5f8394ca88 Merge "slot management: add library for slot management." into android-9.0 2019-03-17 16:09:56 +01:00
big biff
7812dd49e1 Merge "vold_decrypt: Add android 9.0 support" into android-9.0 2019-03-08 00:52:21 +01:00
Captain Throwback
5ab596451a mksh: add mkshrc when using TW_USE_TOOLBOX
Fixes broken shell prompt in Terminal and adb shell

Before: https://del.dog/7vphlkc
After: https://del.dog/vhkjgo8

Add as prebuilt with suffix "_twrp" to avoid conflict
with original mkshrc and rename via POST_INSTALL_CMD

Prebuilt version adjusts TMPDIR variable from
"/data/local/tmp" to "/tmp" for TWRP

Change-Id: I42a1b2a8c114f66dbe659c07485f1dfae8a5d314
2019-03-07 18:34:15 +01:00
bigbiff bigbiff
c630cee1ae slot management: add library for slot management.
Change-Id: I7d0a67bc8e237866485680a5c54443435e7d2737
2019-02-20 18:06:55 -05:00
nijel8
2c821a8c0a vold_decrypt: Add android 9.0 support
* build modified vdc_pie binary with 'checkpw' command support
  if building with Android 9.0 platform. That command and others
  we don't care about, are removed from Pie vdc. Our vdc_pie will
  run if system sdk version is > 27, otherwise system vdc is used.
  Code adapted from Android 9.0 system/vold/vdc.

* include prebuilt vdc_pie(arm, arm64) binary if building with lower
  than Android 9.0 platform - vdc_pie cannot be build from source
  with those platforms without additional imports from Android 9.0

* skip vdc "getpwtype" command for Pie - vds communicates with vold
  directly, no need for connection retries first

* add /system/bin/servicemanager to required services

* mount per-devive additional partitions needed for decryption
  listed with device BoardConfig.mk TW_CRYPTO_SYSTEM_VOLD_MOUNT
  flag like(space separated):
  TW_CRYPTO_SYSTEM_VOLD_MOUNT := vendor cust odm

* add function to backup crypto footer before running vdc commands
  and restore it after - on Xiaomi Mi Max 3 both Oreo and Pie stock
  roms vold alters cripto footer when decrypting data in recovery
  which causes system to ask for crypto password at next reboot
  although password stays unchanged. Crypto footer backup/restore
  added as workaround for systems whit ro.build.version.sdk > 25.
  Also to preserve crypto footer integrity decryption attempts are
  skipped if footer backup fails to ensure no data loss.
  Code adapted from
  https://gerrit.omnirom.org/#/c/android_bootable_recovery/+/31206/

Change-Id: I0a383f3843578fa55595cfea3b7c9c4431646a1a
2019-02-01 21:36:23 -05:00