Commit Graph

248 Commits

Author SHA1 Message Date
bigbiff bigbiff
584b977489 TWRP device version string
For building through jenkins. Export a variable to the shell
so that we don't monkey patch variables.h and keep the git tag
clean in the version string.
Jenkins will export the variable TW_DEVICE_VERSION=n where n > 0.
The makefile will use this variable to show the device string
in twrp startup. For mass production builds, omit the
environment variable to default to 0.

Change-Id: I0d6eb764255d7069c0fb4a378522a009cfe4054f
2017-01-18 09:44:17 -06:00
Hashcode
5733215112 build: AOSP/CM14 fixes (API 24/25, mainly BusyBox-less environment)
These changes are needed by any ROM where devices are configured to
use TOOLBOX/TOYBOX instead of BUSYBOX (i.e., TW_USE_TOOLBOX := true).

Change-Id: I68b88cc9fb857f32864556c4b6c9c8e6ee744051
2017-01-12 12:50:18 -05:00
D. Andrei Măceș
b29a5e27c3 build: Consolidate the crypto_utils presence tests
No point checking filesystem repeatedly/check may change in future

Change-Id: I0413b07b850f785eb5150c6ed18836cc56e94d6f
2017-01-11 10:56:21 -06:00
Ethan Yonker
bd7492de28 Support File Based Encryption
Change-Id: Ib688ddd0c32d3999590cacd86b6d9b18eac336e9
2016-12-13 21:16:42 +01:00
Ethan Yonker
1b190166eb Add boot slot support
Change-Id: I7eaf80e327985f53791f90fbdebad022a9650d31
2016-12-13 14:04:48 -06:00
Ethan Yonker
941a899695 Support new AB OTA zips
Change-Id: I1ff883375a0a769bf27a834c9bf04c6cdbb42117
2016-12-05 14:54:32 -06:00
Ethan Yonker
3fdcda4662 Improve backup & wipe exclusion handling
Rename twrpDU.* to exclude.*
Remove global variable for du and replace with partition specific
variables.
Use separate exclusion lists for backups and wiping.
Clean up some includes
Fix some parenthesis in twrp.cpp that I messed up.

Note: twrpTarMain command line utility compiles but probably does
not work correctly yet due to not properly setting part_settings

Change-Id: Idec9c3e6a8782ba53f3420fa79ba33394f4f85fb
2016-11-30 13:19:08 -06:00
Ethan Yonker
0a8a7cebf1 Fix adb shell in 7.0 tree
busybox sh does not seem to work properly in 7.0 trees so use
mksh for sh instead.

Change-Id: Ia33bc3894f929b1348c8714d4ddd00a2671c7e94
2016-11-30 16:47:20 +01:00
Ethan Yonker
b523650c8e Update to android-7.1 2016-11-29 21:27:39 -06:00
Ethan Yonker
99af766668 Fix libcrypto dependency in 6.0 trees
Change-Id: Ie230ed5f3db38a62305e03e4f9819e4aca816e16
2016-09-15 14:57:39 -05:00
Humberto Borba
443af214ff twrp: Use the correct lib name
Now ART uses LZ4 and the lib name should be liblz4.
https://github.com/omnirom/android_external_lz4/blob/android-7.0/lib/Android.mk

Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: Ifce783ecb6af10d43bbeabd614d12e8e6b3b4270
2016-08-31 20:10:45 +02:00
Ethan Yonker
4bf259fab7 Make naming scheme more meaningful
Change-Id: Ifcaf00c760ff452b0e85a88b54e91ca0f2f4644a
2016-08-29 11:50:34 -05:00
Ethan Yonker
534d4e0612 Fix compatibility across the board
Change-Id: I6376920775ddabb4d4af505fffd86e404403a64a
2016-08-26 10:05:03 -05:00
Ethan Yonker
df681841e3 Fix compatibility with 5.1
Change-Id: I83704ce3a669239e0acb936e50e6eae080b28173
2016-08-25 15:49:40 -05:00
Ethan Yonker
f117962eb2 Make it backwards compatible with 4.4
Change-Id: I668604cddc8e8afbf78709f3f872bea4e9f4aa06
2016-08-25 15:36:13 -05:00
Ethan Yonker
34ae483e02 Update to 7.0
Change-Id: I621cc47352f7ac552d9602485825ae3a6f9ae516
2016-08-24 15:32:18 -05:00
Jason Riordan
6c28ee8355 NTFS-3g: migrate to PLATFORM_SDK check instead
android-6.0 branch of ntfs-3g matches the cm-13.0 version now,
check platform version instead of CM_SDK version.

Change-Id: Ic4aed613084d530c814611678f70d75260b9adc4
2016-08-22 21:09:34 +02:00
that
0e2140e931 Add git revision to startup message in recovery.log
This should make it easier to find the exact source for
a specific version of the binary.

Change-Id: I7e04dd9a3205cc643150a588b69b4bd691212ecb
2016-08-22 16:46:09 +02:00
bigbiff
ce8f83c48d ADB: Add adb backup for TWRP.
Functionality for client side to backup
tar and image streams over adbd to the client under backup.ab.

Using adb backup on the client side you can backup the partitions
TWRP knows about.

On the client side you can do the following:
adb backup -f <filename> --twrp <options> where options are
--compress: compress data
system: backup system
cache: backup cache
data: backup data
boot: backup boot
etc for each partition.

You can string multiple options,
i.e. adb backup -f <filename> --twrp --compress cache system data

adb backup in TWRP will take any option corresponding
to TWRP fstab partitions, e.g. efs boot as well.

If you do not specify the filename with the -f option,
adb will backup your data to a filename backup.ab on the client.
You can then rename the file and encrypt it with desktop tools.

If you don't want to use command line arguments:
adb backup --twrp

will bring up the gui and allow you to choose partitions
from the backup page.

To restore the backup use the following convention:
adb restore <filename>

Structures are used to store metadata in binary inside
of the file itself. If the metadata structure is modified,
update the adb version so that it will invalidate older
backups and not cause issues on restore. When restoring,
we currently do not support picking specific partitions.
It's all or nothing.

Change-Id: Idb92c37fc9801dc8d89ed2a4570e9d12e76facf8
2016-07-31 22:20:18 -05:00
Yabin Cui
2f272c0551 Create bootloader_message static library.
bootloader_messages merges bootloader_message_writer
and bootloader.cpp, so we can use the same library to
manage bootloader_message in normal boot and recovery mode.

Bug: 29582118

Change-Id: I9efdf776ef8f02b53911ff43a518e035e0c29618
2016-06-30 11:02:38 -07:00
Elliott Hughes
01fcbe160b Disable the meaningless parts of the UI for A/B.
Bug: http://b/28748484
Change-Id: Ie86a265f4699503471e7c717d65677a916dbd25b
2016-05-24 00:44:50 +00:00
Elliott Hughes
8febafa67e Use BoringSSL instead of mincrypt to speed up package verification.
This changes the verification code in bootable/recovery to use
BoringSSL instead of mincrypt.

Cherry-pick of 452df6d99c, with
merge conflict resolution, extra logging in verifier.cpp, and
an increase in the hash chunk size from 4KiB to 1MiB.

Bug: http://b/28135231
Change-Id: I1ed7efd52223dd6f6a4629cad187cbc383d5aa84
2016-04-13 16:39:56 -07:00
Ethan Yonker
308b1cadc4 Really remove all old SP* flags and code
Change-Id: I5ece02a8721e1b7541fb5182366a55fd0f037a7a
2016-04-01 22:39:22 -05:00
Mark Salyzyn
13aca598f8 recovery: use __android_log_pmsg_file_write for log files
(cherry-pick from commit a4f701af93)

- Add call to __android_log_pmsg_file_write for recovery logging.
- Add call to refresh pmsg if we reboot back into recovery and then
  allow overwrite of those logs.
- Add a new one-time executable recovery-refresh that refreshes pmsg
  in post-fs phase of init. We rely on pmsg eventually scrolling off
  to age the content after recovery-persist has done its job.
- Add a new one-time executable recovery-persist that transfers from
  pmsg to /data/misc/recovery/ directory if /cache is not mounted
  in post-fs-data phase of init.
- Build and appropriately trigger the above two as required if
  BOARD_CACHEIMAGE_PARTITION_SIZE is undefined.
- Add some simple unit tests

NB: Test failure is expected on systems that do not deliver either
the recovery-persist or recovery-refresh executables, e.g. systems
with /cache. Tests also require a timely reboot sequence of test
to truly verify, tests provide guidance on stderr to direct.

Bug: 27176738
Change-Id: I17bb95980234984f6b2087fd5941b0a3126b706b
2016-03-31 13:52:54 -07:00
Ethan Yonker
472f506817 Improve progress bar handling for backup / restore / image flash
The progress bar will now be updated during image backups, restores
and during image flashing (except for sparse images which will require
significant changes to libsparse, and except for mtd nand using
flash_utils).

The progress bar will now be updated mid-file for file systems (tar) so
the user will see changes even during large file backup / restore.

Add a new progress tracking class to simplify handling of progress bar
updates. The class will only update the progress bar 5 times a second to
reduce the CPU load from updating the GUI frequently which does affect
backup times.

Change-Id: Iff382faef3df1f86604af336c1a8ce8993cd12c5
2016-03-31 15:44:24 +01:00
Prashant Malani
9020e0f141 recovery: Move SwipeDetector into common location
The SwipeDetector class is used almost unchanged in all locations.

This patch moves it into the recovery module, from which devices can
reference it if required.

The class is now renamed to WearSwipeDetector.

Bug: 27407422
Change-Id: Ifd3c7069a287548b89b14ab5d6d2b90a298e0145
2016-03-18 06:03:21 +00:00
Ethan Yonker
a60c78602d Remove busybox modprobe to fix slow performance for some devices
bionic process initialization calls personality
(specifically personality-8)
personality wants to load a kernel module
loading a kernel module calls /sbin/modprobe
loading /sbin/modprobe is a bionic process initialization
bionic process initialization calls personality
personality wants to load a kernel module
loading a kernel module calls /sbin/modprobe . . .

Before you know it, it takes 0.5 seconds to do anything.
Note: modprobe is still technically available, but the symlink
has been removed, so you can still call it directly by running
busybox modprobe if you like.

From what I can tell, this issue only affects 32 bit devices
with CONFIG_MODULES=y in the defconfig. The problem can be also
patched out of the kernel by commenting or otherwise removing
the block of code in kernel/exec_domain.c inside the CONFIG_MODULES
ifdef block

It is also possible to patch the problem in bionic libc by commenting
out or otherwise removing the __initialize_personality in bionic/libc/
bionic/libc_init_common.cpp file.

Change-Id: Iebac314616080ac18320d73b087980ac1b98b951
2016-02-29 15:22:48 +01:00
Yabin Cui
99281df8e2 recovery: check battery level before installing package.
Bug: 26879394

Change-Id: I63dce5bc50c2e104129f1bcab7d3cad5682bf45d
(cherry picked from commit 53e7a0628f)
2016-02-23 11:03:10 -08:00
Ethan Yonker
e5a288c96b Fix up logd make file rules
logd, the init.recovery.logd.rc, and other related files were
included by default if your device configs specified
TARGET_USES_LOGD := true which would be the case for any device
that has a full ROM tree instead of a minimal TWRP tree.

Change-Id: Ia1e55703631f0f22beab2f4d4479599b88539e1a
2016-02-15 09:27:02 -06:00
Ethan Yonker
34741d9cef Fix no exfat-fuse rules
If we set TW_NO_EXFAT then we should not try to build exfat-fuse

Change-Id: I836ed6082cfbfb51bfb862b79c0182f36de88a9c
2016-02-06 13:22:53 -06:00
Tao Bao
e284cd58c8 Merge "Refactor existing tests to use gtest" am: 38b02cc6a0
am: 9865c55254

* commit '9865c55254a1583e18a7e8ac502f2c2143ed8b82':
  Refactor existing tests to use gtest
2016-02-05 18:47:14 +00:00
Jed Estep
432918603f Refactor existing tests to use gtest
Bug: 26962907
Change-Id: I5f80636af1740badeff7d08193f08e23f4e4fee1
2016-02-04 10:11:30 -08:00
Captain Throwback
1f12775707 Add TWRP flags to enable logd and/or logcat in recovery
Developers and device maintainers may find it useful to have access
to logcat in recovery. This patch set adds the following build flags:

TARGET_USES_LOGD - This is an Android build flag that enables logd
support. Devices that don't have built in kernel logging to dev/log/*
will need this flag for logcat. We'll also use this to include the
necessary support files for logd in TWRP.

TWRP_INCLUDE_LOGCAT - This enables logcat support in recovery.

I pulled the init entries from my HTC One M8 GPE boot.img,
so I'm not certain whether these will work for all devices
or if they're all necessary.

Feedback is welcome.

PS2: Use "TARGET_USES_LOGD" instead as this flag already exists, and
previous flag was named incorrectly (logd isn't kernel logging)

PS3: Start logd service on load_persist_props action, needed for 6.0+

PS4: More info on "TARGET_USES_LOGD" flag as related to liblog
compilation can be found at the below links:

https://android.googlesource.com/platform/system/core/+/android-6.0.1_r10/liblog/Android.mk#27
https://android.googlesource.com/platform/system/core/+/android-6.0.1_r10/liblog/Android.mk#50

Whether or not this flag is needed for logcat in TWRP is dependent
on whether liblog was compiled with this flag.

PS5: Update commit message to better describe "TARGET_USES_LOGD" flag

PS6: Another commit message update

Change-Id: Iaac6c6c822dc93fbe4b6eadcf24eef6995dd6b50
2016-02-04 15:09:58 +01:00
HashBang
ed974bb87a allow flashing sparse images
if the image has the right magic bytes to be a sparse image,
use simg2img to flash the image

create a rule to make a fully dynamic simg2img which results in a
much smaller increase in gzip ramdisk size (2KB vs 40KB)

Change-Id: I1b0f6bc127da46103888b1154a9bddd8ac02c01d
2016-02-03 16:05:56 -06:00
Ethan Yonker
b5fab76bea Replace fix permissions with fix contexts for emulated storage
Fix permissions rarely fixed anything on more recent versions of
Android and usually made things worse. Instead we will replace it
with a more dumbed down option that should fix contexts on
/data/media with a few improvements to ensure that contexts get
fixed for multiple users and on adopted storage.

Change-Id: If5523781936a0b04196e2ad871cae767ebae2583
2016-01-29 21:58:33 +01:00
Ethan Yonker
66a1949df9 Adopted Storage support
-Detects, decrypts, and mounts an adopted SD card if a
  secondary block device is defined (usually mmcblk1)
 -Handles unified storage
 -Displays the adopted storage in MTP along with internal
 -Factory Reset - wiped just like a data media device, we
  retain the keys folder and the storage.xml during a
  factory reset
 -Backup / Restore
 -Disable mass storage when adopted storage is present
 -Read storage nickname from storage.xml and apply it to
  display names in the GUI
 -Read storage.xml and determine what storage location is in
  use for /sdcard and remap accordingly

libgpt_twrp is source code mostly kanged from an efimanager
project. It is GPL v2 or higher, so we will opt for GPL v3.

Change-Id: Ieda0030bec5155ba8d2b9167dc0016cebbf39d55
2016-01-25 23:59:17 +01:00
dianlujitao
ce608ab7d2 Add zip and unzip when using toybox
Change-Id: I75500bfe4e7adf66c5538597d79ed0539e7bb551
Signed-off-by: dianlujitao <dianlujitao@gmail.com>
2016-01-22 11:30:22 -06:00
Ethan Yonker
b82422a6c3 Fix SuperSU local dependencies
Change-Id: Ia5fadd8254340b21a54565e2c7d2b54aa70f19f3
2016-01-20 08:48:49 -06:00
Ethan Yonker
483e9f45b7 Improve sdcard partitioning process
-Improve code for partitioning sdcards
-Allow user to select a device for partitioning (must be removable)
-Use sgdisk to partition sdcards
-Set default sizes for ext and swap to 0
-Change increments for ext to 256MB and swap to 64MB

Note: sgdisk is included in 6.0. I have included a static prebuilt
sgdisk for trees that do not have sgdisk, however the prebuilt
sgdisk is a decent bit larger than the old parted binary. The old
parted binary is quite old at this point and we only have it for
armv7a. sgdisk should be maintained by AOSP and can be built from
source so it should work across architectures.

Change-Id: Ib80882d9b5776e5e9358b11340fba392e6f1ae09
2016-01-14 17:40:43 +01:00
Jed Estep
f1fc48c6e6 IO fault injection for OTA packages
Bug: 25951086
Change-Id: I31c74c735eb7a975b7f41fe2b2eff042e5699c0c
2016-01-06 12:23:42 -08:00
Greg Wallace
b39e6c6047 ntfs-3g: Fix cm-13 compatibility
CM-13 tree completely changes the names of the binaries that are created
for ntfs-3g.  If we are using a CM-13 tree (CM SDK 4) make sure the
dependencies and relinking are adjusted accordingly.

Also, adapt partition code so it can make use of whichever set of
binaries are present.

Change-Id: I810caafa818f18281fd29dcf8f31b3053133b5ed
2016-01-04 07:25:24 -06:00
Olivier K.
94b06502b2 Remove no-op
Change-Id: I2bb2c44dd97974fa3cc19ccb6c6c7f0c3ef9bc58
2016-01-04 15:16:19 +02:00
Xing
0af1ac13d1 do not include stlport headers unless link to it
Change-Id: I8344d270ddb601694b5fef0fa7b22ea437030728
2015-12-23 22:36:41 +02:00
Greg Wallace
36ade45b1b Add default brightness control
This lets user set the default brightness so user doesn't cook
their phone on first boot or loss of settings file, while
still maintaining the ability to turn brightness to max if
desired.

Change-Id: Ia801fba46014335148ec573a0b0bbdf0a3ca60ae
2015-12-23 12:30:24 -06:00
Matt Mower
09ef1e4109 exfat: Update to 1.2.2
Change-Id: I160389afa074270c398aeb771845500f2445838a
2015-12-23 09:56:56 -06:00
Matt Mower
80f7b361f0 exfat: Build fsck and update path to mkfs
* Usage of fsck.exfat is already included in partition.cpp, but the
  tool is missing.
* Update the path to mkexfatfs so the button is available when changing
  filesystem.

Change-Id: I5f4e27357c6b5a8606043d1bdc2488cc83e55d90
2015-12-22 15:26:01 -06:00
Matt Mower
047723c5aa selinux: Only union sepolicy in SDKs 21,22
Manual union is not needed in Android 6.0+.

Change-Id: I7e321fb90b4333da349cc8ad8d2d78d990258b65
2015-12-22 11:59:27 -06:00
Matt Mower
1777cdc93c Remove unnecessary quoting from twres path
The C flag defines already use -DVAR=\"..\", so stripping these extra quotes
should not affect those defines.

The makefile does not need the quoting at all.

Makefile example output...
before: mkdir -p (omitted)/recovery/root"/twres/"
after:  mkdir -p (omitted)/recovery/root/twres/

Change-Id: I8f557662eb18b5ea40b63bc055d12be4440251e6
2015-12-22 11:46:04 -06:00
Matt Mower
582949125c f2fs: Update make rules for CM compatibility
* Make sure fsck.f2fs and mkfs.f2fs are built for CM12.1/13.0
* Add CM13.0 rule for relinking mkfs.f2fs
* Minor cleanup of nested if/else in prebuilts

Note on CM SDKs: 3=cm-12.1, 4=cm-13.0
I'm not yet sure whether it is possible that the CMSDK increments
within the same branch of CM.

Change-Id: I7b521159a8b5d0e0ea639f5e0fdd885100612df0
2015-12-22 11:25:34 -06:00
Ethan Yonker
74db157b94 Multiple Language Support
This is similar to https://gerrit.omnirom.org/#/c/14014

A lot of the features built in the older patch set have been split
out into separate patches, most of which have already been merged.
The remaining functionality here should all be directly related to
language selection and loading. We always load English as a base
before loading other languages over the top of the base. The idea
is that if another language is missing a translation, then we will
still display the English.

Maybe still to do: read the /cache/recovery/last_locale file and
load a language based on that. For me, this file contains just:
en_US
We probably won't bother with region specific translations so we
would have to look at either trimming off the _US or using some
other method like perhaps a symlink or a combination of the two.

Thanks to _that for twmsg.cpp class

Change-Id: I9647a22e47883a3ddd2de1da51f64aab7c328f74
2015-12-19 08:31:01 -06:00