Commit Graph

102 Commits

Author SHA1 Message Date
bigbiff bigbiff
56cf564658 twrpDigest refactor
This patch is to refactor twrpDigest using polymorphism
and inheritance to use the same call patterns for creating and
reading a digest. Now a library.
Use SHA2 from libcrypto. SHA2 is default if device has libcrypto.

Change string MD5 everywhere to use digest or Digest instead. Updated
string tags to digest. Translation will be required.

Switch out digest code into a driver class from partitionmanager.

SHA2 is better for digest creation due to decreased collision space
compared to MD5 and SHA1.

See https://en.wikipedia.org/wiki/SHA-2

Change-Id: I74b5546789990b12aa4ce2e389d25f80a3fe213f
2017-06-17 07:05:45 -05:00
Captain Throwback
a52891b6b3 Revert "Fix adb shell in 7.0 tree"
This reverts commit 0a8a7cebf1.

Change-Id: Icdb1f2e93aeaf35a66b6f67eaff51d9af5fd2e9a
2017-03-07 23:18:50 +01:00
TheStrix
09e8693b7a Fix missing libf2fs.so needed by mkfs.f2fs
* Relink libf2fs.so in all cases except PLATFORM_SDK_VERSION=23
   with no CM_PLATFORM_SDK_VERSION set as 4 or above.

Change-Id: I58bcc7daeb2d67d41b8912cea73690d94f26dd56
2017-03-06 17:06:56 +01:00
maxwen
e7c8856555 recovery: adjust mkfs.f2fs location
middle finger ahead

Change-Id: I14a036a5a79121056e6185f367fc6d61bcec46d2
2017-01-24 16:18:58 +01:00
Matt Mower
874136434a SELinux can be assumed for Android 4.4+
Change-Id: I7410a0c8e439eec90a955ee9201efd9a92bb9635
2017-01-18 12:40:26 -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
b4bff5e9d1 Add TWRP app install via TWRP recovery
Note: I will have to add a build flag for excluding the app later for
watches and maybe Android TV. I will also have to add support in the
tablet and watch layouts later. I will merge this for the initial roll out
to select devices and finish up later.

Change-Id: Ia4ce5522fae542afa1539b10c0691315392a19ab
2016-12-16 17:02:16 +01: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
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
534d4e0612 Fix compatibility across the board
Change-Id: I6376920775ddabb4d4af505fffd86e404403a64a
2016-08-26 10:05:03 -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
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
sndnvaps
a915ec4215 Fix RELINK of toybox for twrp
Change-Id: Ia609eec928278fc63e699d42799f74b4ada82221
Signed-off-by: sndnvaps <sndnvaps@gmail.com>
2016-03-18 00:31:51 +01: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
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
Greg Wallace
ace7623306 Flag to enable jpg support
Builder using a custom theme may have need for this.  Add a flag to
easily enable jpg support.

Change-Id: Ica74f8cb1312d3193105f2201a5cf8073e2edc82
2016-02-03 05:15:10 +01: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
e95c4868b9 ifdef and comment out libjpeg
Chances are there are not many themes in widespread use that are
using jpeg images, but this will be easy to revert back or even
just temporarily modify if we need jpeg support in a pinch.

Change-Id: If17b05ce3ebccce724fd74b26ed8ea91b287c3cf
2016-01-27 10:58:02 -06: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
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
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
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
dc3bc46a82 Rename libexfat target to prevent conflicts
Change-Id: I5d2774c273a90c1f02c074f3c947c13b265972b3
2015-12-08 15:13:35 -06:00
Matt Mower
18794c820f Update dosfstools
* Version 3.0.28
* Update filenames in source
* Remove unnecessary symlink to fsck
* Commit "Recode short filenames from DOS codepage (default 437)." has
  been reverted since we do not have access to iconv
* Commits cherry-picked on top of 3.0.28:
    - mkfs.fat: fix incorrect int type
    - Prevent out of bound array read in date_dos2unix()

Change-Id: I50310235c62ec2e6bc90afcd10f2814d3afb5113
2015-11-26 06:09:55 +02:00
Ethan Yonker
5235f5550b Fix mkfs.f2fs error in 6.0 trees
Change-Id: I1217094f0e336445eb4dd5f46242d9719525ffbd
2015-10-09 14:46:47 -05:00
Ethan Yonker
c798c9cd24 Merge up to AOSP marshmallow-release
In order to maintain compatibility with older trees, we now have
minadbd.old and minui.old. I had to use a TARGET_GLOBAL_CFLAG to
handle ifdef issues in minui/minui.d because healthd includes
minui/minui.h and there was no other alternative to make minui.h
compatible with older trees without having to modify healthd rules
which is outside of TWRP.

Note that the new minui does not currently have support for qcom
overlay graphics. Support for this graphics mode will likely be
added in a later patch set. If you are building in a 6.0 tree and
have a device that needs qcom overlay graphics, be warned, as off
mode charging may not work properly. A dead battery in this case
could potentially brick your device if it is unable to charge as
healthd handles charging duties.

Update rules for building toolbox and add rules for making toybox

Use permissive.sh in init.rc which will follow symlinks so we do
not have to worry about what binary is supplying the setenforce
functionality (toolbox, toybox, or busybox).

Fix a few warnings in the main recovery binary source code.

Fix a few includes that were missing that prevented compiling in
6.0

Change-Id: Ia67aa2107d260883da5e365475a19bea538e8b97
2015-10-09 11:15:29 -05:00
Ethan Yonker
b81d905165 Add ntfs-3g support
Add support for mounting ntfs via ntfs-3g and support for wiping
and repairing ntfs partitions.

Change-Id: I82dc4626f459bb93b86eb9ebba64ad3a6560781b
2015-07-14 16:54:04 +02:00
Captain Throwback
7fe1b3987a Update path for libcryptfs_hw to proper variable
Change-Id: Ie91d161f4e439a870534639f44a03df22f4fe39a
2015-07-14 16:38:50 +02:00
Ethan Yonker
a2719156c2 Add resize2fs and ability to run resize2fs via GUI
Note: Only works on ext2/3/4 partitions. Only tested on ext4.

We can use this in some cases to resize the data partition if an
incorrect fstab caused recovery to not reserve the 16KB for a
crypto footer.

Sometimes the BoardConfig for a custom ROM does not have the
correct size for the system partition and if the ROM flashes a
raw system image, that image will not take up the full block
device. Running resize2fs can fix the size and may allow more
room in the system partition for customizations like busybox or
a larger gapps package.

Sometimes flashing a factory image may flash userdata with an
image with a file system that does not take up the full size of
the block device (e.g. factory images for the Nexus 6 will flash
userdata with a ~24GB userdata image, wasting ~30GB of space).
Using resize2fs we can easily fix this issue without having to do
a full format data.

Change-Id: I631f5c6f567bbc6a9241e5dd95f1e435820a1b13
2015-05-28 09:47:25 -05:00
Dees Troy
c657cc0037 Support Qualcomm hardware decrypt
Change-Id: I121ef0f5da209be48f6d87559d539c7fc6d85336
2015-05-15 10:52:46 -05:00
Ethan Yonker
4f6a976212 Make TWRP compile for x86-64 CPU target
Also add a short while loop to wait for fb0 to be created as was
needed on the x86-64 target for the Android emulator.

Change-Id: Ib1b87bea028ac3eac0541283334a0157cdfbce11
2015-03-13 17:20:57 +01:00
mar-v-in
4142408225 Handle sdk version 22 as lollipop
Change-Id: I87c17715d7acdf6ae15f8a39e3e316715bade6f3
2015-03-11 09:50:45 -05:00
Dees Troy
3454ade92d Use /twres instead of /res for theme resources
AOSP and other ROM trees now do a rm -rf of the res folder during
the ramdisk creation process that removes the TWRP resources.
Using /twres instead of /res works around this issue making TWRP
more compatible with AOSP and other build trees.

Change-Id: I0d4c7e06ca381ac5aa0069b6f2b8c47f7dec49e7
2015-01-22 15:21:27 -06:00
Dees Troy
0f3aa1e157 Merge "Include libpcre if present" into android-5.0 2015-01-22 17:56:42 +01:00
Dees Troy
e176a65e3d Include libpcre if present
Change-Id: I51bdabbd5b2c2263f3f72cdd2ffcba2bc97e0c43
2015-01-22 10:56:07 -06:00
Dees Troy
4f4a7a524a Remove fibmap.f2fs from relinking
Change-Id: Ibf43367446782642f41d437d1d97d62fc7dbb185
2015-01-22 17:54:21 +01:00
Vojtech Bocek
41ae12482b Include libnetd_client in recovery
* Bionic tries to load it, and if it isn't in /sbin and /system
  is mounted, it loads it from there and prevents it from unmouting

Change-Id: I33d0b6ba4503f2822d96033fa26d53e10b8ce1c5
Signed-off-by: Vojtech Bocek <vbocek@gmail.com>
2015-01-06 11:36:58 -06:00
Ethan Yonker
d6786b898b Stop building unneeded libs for libblkid
Change-Id: I96d91f2d2e38380ff46a6ff6e2c8c9a245aa0431
2015-01-05 09:01:29 -06:00
Ethan Yonker
bcff146bc9 Build more needed libs for mke2fs
Change-Id: I473f5a0412bf35507a755d485bbdf53fd241748b
2015-01-04 22:01:33 -06:00
bigbiff
7b4c7a681c Update blkid to 2.25.0
Break libblkid into 4 libraries: libblkid, libuuid, libutil-linux and libfdisk.

This should help in later patch updates.

Change-Id: I680d9a7feb031e5c29a603e9c58aff4b65826262
2015-01-05 04:38:42 +01:00
that
183a6f88d0 crypto: remove unused libs and clean up makefile
libsoftkeymaster and its dependencies appear to be unused.

Change-Id: Ib720f5e4d2750a739ba6b65b346c0e167df279d3
2015-01-05 03:14:28 +01:00