Commit Graph

154 Commits

Author SHA1 Message Date
Matt Mower
3c36697b2d Fix a bunch of messages
* Find and rename/remove duplicate string variable names
* Add missing string variables to en language file
* Fix display of some strings missing @ in front of variable name
* Fix several %s --> {1}
* Be consistent in usage of cancelled vs. canceled (both spellings
  acceptable)

Tip for finding strings missing from language files:

1) Find all messages:
egrep -hr "gui_msg.+=" > /tmp/msgs.txt

2) Regex replace to trim them down
WHAT: ^\s+gui_msg(?:[^"]+)"([a-zA-Z0-9_]+)=([^"]+).+
WITH: $1
Note that $2 can be used to retain the message

3) Find missing strings:
for i in $(cat /tmp/msgs.txt); do
    if ! grep -q $i gui/theme/common/languages/en.xml; then
        echo $i;
    fi
done

Change-Id: Ic193162e4b5468bf027472928a370be39840ea1d
2016-01-22 05:29:04 +01: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
2d65340c0f gui: Fix partition repair message
The message was named something non-existent.  Fix the spelling error
and add the default message into the language files.

Change-Id: I4e9e10d2705b1edf75b185d3badba59eb86ffb8b
2016-01-04 07:29:15 -06:00
Greg Wallace
4b44fef5ca gui: Fix typo of formatting_using message
Change-Id: I6df4937658815350366ed3dd2cf92156f98c96c4
2016-01-04 07:26:43 -06: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
Ethan Yonker
d18a821e00 Use ioctl to get block device size
AMLogic based device uses paths like /dev/block/recovery and the
stock init binary either deletes or does not create mmcblk0p12
which breaks TWRP because TWRP cannot match up the path / name.
The ioctl method is probably more reliable anyway and certainly
should be faster.

Change-Id: I73f981dcec637cdf5b189bdefa00ea15b924b500
2015-12-19 08:38:12 -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
Ketut Putu Kumajaya
bfb72b062a Fix broken fsflags support
Process_FS_Flags Flags parameter is just a copy not a reference,
not get updated, Mount_Flags always 0 - fix it now.

Thanks to SHM @ XDA-Developers

Change-Id: Ib044db905febfedefee493cfc04fd1cad6f61f8e
2015-11-26 06:16:52 +02: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
Matt Mower
13a8f0b294 Free some memory allocations
Change-Id: Ifb6c186e43e1eb068e8075def16924ced04bb23d
2015-11-11 19:42:27 -06:00
Ethan Yonker
1673e3d4ea Treat /vendor like /system for read only
The vendor partition is verity checked just like system so we
should treat vendor as read only same as system.

Change-Id: Ida65c9f44d8610e52fcdcef0b4a50faf5c7110d2
2015-11-05 21:07:21 +02:00
Ethan Yonker
d0514ba806 Fix a bunch of warnings
Mostly adding __unused where needed.

Change-Id: Ia4f675b9b360782728c361ed1699db0cc277c3a5
2015-10-24 17:36:24 -05:00
Ethan Yonker
bc85b63e78 Wipe crypto key when formatting data
Change-Id: I032fabb383b4063e3b31b6044ce39966b8c617d0
2015-08-09 12:48:14 -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
Xuefer
bfce504167 fix settingsstorage mark
Change-Id: I60755ca66f048d1484c3d55dc60099679ba987f6
2015-06-17 17:06:41 -05:00
xiaolu
9416f4f9d6 partition: recreate tw_internal_path(/data/media/0), after wipe media from data or format /data.
Change-Id: I3671d7a5759260a4e74952168483a6816eb28f5d
2015-06-17 23:17:06 +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
Ethan Yonker
eb32b1ff00 Mount system as read-only by default
Mounting system as rw can prevent future OTA updates. The purpose
of this patch set is to prevent TWRP from mounting sytem as rw on
the first boot. Device maintainers should update their twrp.fstab
files on these devices to include an additional line:
/system_image emmc /dev/block/../system

This line will allow TWRP to create a raw system image backup to
ensure that the user can return to an original state for future
OTA updates.

Change-Id: I8929d85bc3a5b96cc564bc7f734b58d5612ec833
2015-05-27 09:22:49 -05:00
that
c7572eb87a partition: support texfat module
Change-Id: I21d0498fc16fdb29d09d6e6fe715e57d1f35e72b
2015-05-19 20:50:00 +02:00
codelover
352b75eddb Backup: fix 'out of memory' issue when backing up large partition as image
Restore: improve image restoration speed

* Workaround for devices that need to backup partition as image, eg: dm-verity
* Increased block size used for partition restore, now using 8M instead of 4K

Change-Id: Ie7e7ff3283d71a7e459d76f72caea9f57e71c628
2015-05-19 20:43:53 +02:00
Dees Troy
c657cc0037 Support Qualcomm hardware decrypt
Change-Id: I121ef0f5da209be48f6d87559d539c7fc6d85336
2015-05-15 10:52:46 -05:00
codelover
2a3d4ce3ca Fix TWRP not mounting /data/media type storage if built with toolbox utils
* ONLY Applicable when building with 'TW_USE_TOOLBOX := true'
* toolbox's 'mount' expects the first argument to be a block device, but /data/media is a dir.
* Technically we don't 'mount' a dir to another, we 'bind' it instead.
* So we define the mount option explicitly with '-o bind'. (supported by busybox 'mount' too)

Change-Id: If97c9096167fb723150b949f4336005b3313a174
2015-03-19 17:43:09 +01:00
Vojtech Bocek
7e11ac5d3c Add UI for entering pattern for device decryption
Change-Id: Ia2d3268a96423e9ca3846500c57e674c4f8fa60b
Signed-off-by: Vojtech Bocek <vbocek@gmail.com>
2015-03-13 12:12:58 -05:00
Matt Mower
2b18a53dc8 Address a few compiler warnings
Change-Id: I6e063fba8d58c8c53da6bca6292c84e3392aee50
2015-03-05 04:11:44 +01:00
dhacker29
a3fa75fd66 Allow wiping f2fs to reserve space for a crypto footer
We will convert a -16384 to 16384 if needed because mkfs.f2fs
does not like negative numbers like make_ext4fs does. Also enable
trim by default on f2fs.

Change-Id: I8b41e65d1ff894433665c65d0569a51803c67891
2015-02-02 11:19:51 -06:00
bigbiff
7abc5fe195 Add cancel backup capability.
This will stop the iteration of the partition objects, kill the
current twrpTar thread and remove the backup directory.

Implement TWAtomicInt class to give us a wrapper that automatically
uses mutexes before the read and write to help ensure that the
reads and writes will be atomic based on documentation.

Change-Id: I645b22bc980a292e9c7202acb24ffd22ebe68c63
2015-01-27 15:07:19 +01:00
Ethan Yonker
f66324ffbb Fix restore of images for mtd and bml nand
Change-Id: I843ddf7a5bca3ca7670dd6f19644b37cf017e5b1
2015-01-09 16:46:57 -06:00
Ethan Yonker
96af84a409 Allow flashing of images via the GUI
- Use the Images... button in the lower right of the zip install
  page
- Unify image flashing functions between restore and image flash
- boot and recovery partitions are flashable by default
- use fstab flag flashimg=1 or 0 to override defaults
- file system partitions are currently not flashable

Change-Id: I822dc446030543c55d2153e219d67a1292374ffc
2015-01-09 23:07:07 +01: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
bigbiff
0c53203efe Fix else if and maxFileSize initializer.
Change-Id: Iac7852a4fb2add5744d5ea424d6ad5a82828f102
2014-12-22 04:52:56 +01:00
that
a3d31fbe38 fixPermissions: simplify code, fix bugs
- avoid parsing permission strings
- fix memory leaks, a fix new/free mismatch and a compiler warning
- fix that only first updated-package was processed
- fix a potential stack overflow if packages.xml is huge
- minor refactoring for reducing duplicated code
- don't process packages without codePath
- fix path for deleting app data (currently unused anyway)
- fix file ownership on libs
- try not to mess up Android 5.0 app permissions

Patch set 4

- make fixing SELinux contexts an option with a check box
- add some notes / text to the themes

Patch set 6

- decouple "fix permissions" from "fix contexts"

Change-Id: Icc77ecc581befc5ce6e419b1f3b8ca189208c234
2014-12-22 04:52:37 +01:00
Ethan Yonker
d79d9bceb3 Allow non datamedia devices to wipe encryption
With 5.0 L, we decrypt automatically if the default_password is
used. Non datamedia devices do not get the format data button so
they cannot wipe encryption off the device. This patch add a wipe
encryption button where the format data button would normally be
located on the Wipe page.

This patch also attempts to remove / delete the dm-crypt block
device before formatting.

Change-Id: I100d5d154d6c49254fd48e23279df973db5f23ae
2014-12-21 23:30:17 +01:00
Ethan Yonker
726a020632 MTP add/remove storage instead of disabling MTP
Implement a pipe between TWRP and MTP to allow TWRP to tell MTP
to remove storage partitions as they become unavailable (e.g.
during a wipe, unmount, etc) instead of disabling MTP completely.
This includes some fixes and improvements in destructors to
properly remove / delete various items. This also means that we
will not be toggling adb off and on quite as often.

I do not like that we had to add another thread, but we were
unable to use select() on the mtp_usb character device because
this device does not support polling. Select always returned
indicating that the mtp file descriptor was ready to be read and
the resulting read would block. The read block prevented us from
being able to include reading of the pipe between TWRP and MTP in
the main MTP thread.

We might want to add a return pipe letting TWRP know if the
removal of the storage device was successful, but I am not sure
how we want to implement this. It would invovle timeouts in both
TWRP and MTP to ensure that we returned a failure indicator in a
timely manner to TWRP and prevent deleting the storage device in
the case of a failure. Right now we make no attempt to ensure that
an MTP operation is underway like a large file transfer, but we
were not doing anything like this in the past. In some respects we
have limited control over what happens. If the user installs a
zip that unmounts a storage partition, we will not know about the
change in storage status anyway. Regular Android does not have
these troubles because partitions rarely get unmounted like in
recovery. At some point, we have to hold the user accountable for
performing actions that may remove a storage partition while they
are using MTP anyway.

Ideally we do not want to toggle the USB IDs and thus toggle adb
off and on during early boot, but I am not sure what the best way
to handle that at this time.

Change-Id: I9343e5396bf6023d3b994de1bf01ed91d129bc14
2014-12-19 16:27:34 -06:00
Ethan Yonker
4b94cfd391 Attempt to set the proper uid/gid/contexts on new files and dirs
Files and folders that we create during backups, copy log, or MTP
operations often do not have the proper uid/gid/contexts assigned.
We will attempt to read the proper contexts from the settings
storage path and assign those same contexts to any files or dirs
that we create.

Change-Id: I769f9479854122b49b499de2175e6e2d026f8afd
2014-12-12 09:20:42 -06:00
Ethan Yonker
448c8dc4c1 Fix png graphics load / display on AArch64
This is mostly kang from AOSP resources.c for loading png files
into RAM, but for ease of compatibility we retained the older
gr_surface data types throughout and ensured that we retain
support for alpha blended png files.

Change-Id: Ieea552173d3bfe885460407be73088bbad75663f
2014-12-09 04:46:00 +01:00
bigbiff
7cb4c3322b add function to partition.cpp to return max file size to mtp responder
Change-Id: If8114b5eac741db6c512fb35cb48e3825c2ff098
2014-12-04 17:32:27 +01:00
Ethan Yonker
253368a072 Reduce libs needed for decrypt and clean up old decypt files
Trim cryptfs.c to remove functions that TWRP does not use for
decrypt and remove the need for libfs_mgr from cryptfs.c by
passing some items to cryptfs.c from the partition manager.

Add support for new fstab flags:
encryptable and forceencrypt=/path/to/cryptokey
For example:
flags=forceencrypt=/dev/block/platform/sdhci-tegra.3/by-name/MD1
Note that "footer" is the default, so you do not need to set this
flag on devices that use the footer for the crypto key.
Also add mounttodecrypt if you need to mount a partition during
the decrypt cycle for firmware of proprietary libs.

Clean up decrypt and only support one version

Android 5.0 lollipop decrypt should be backwards compatible with
older versions so we will only support one version, 1.3 that came
with 5.0 lollipop.

Remove support for Samsung TouchWiz decrypt. It does not work with
the latest versions of Samsung encryption anyway and it has not
been updated to work with any AOSP decryption higher than 1.1

Change-Id: I2d9c6e31df50268c91ee642c2fa090f901d9d5c9
2014-12-04 17:30:16 +01:00
Ethan Yonker
cceebb8189 Tweak 5.0 L decrypt
Mount the vendor partition if it exists so we can use any
proprietary files we may need.
Relocate auto decrypt when default_password is in use to after all
partitions are added so that we can mount the vendor partition.

Change-Id: I93455a35695779f53ef57a82d3d45c7216c13639
2014-11-18 10:18:14 -06:00
Ethan Yonker
4eca40d7d8 Add lollipop decrypt support
Kang in cryptfs.c and cryptfs.h from vold.
Use TW_INCLUDE_L_CRYPTO := true to enable.
Ramdisk must contain the normal fstab file in the root in the
usual format of:
fstab.{ro.hardware}
For examble for Nexus 5:
fstab.hammerhead
Or on many Qualcomm devices:
fstab.qcom

Tested against Android 5.0 lollipop on Nexus 7 2012 grouper. Not
sure if or how this will work when we are dealing with a device
with a hardware keystore. Long term we need to add a GUI element
to allow entering a pattern. For now you can decrypt a pattern
unlock by converting the dots to numbers in the following format:
123
456
789

So an upper-case L would translate to 14789 as a password entered
on the keyboard.

Change-Id: I02c29e1f1c2eb29bf002c9fe0fc118357300b5b3
2014-11-12 18:07:24 +01:00
that
d43bf2dc77 fix some compiler warnings
Change-Id: I23c490e6228b0fcf656c76ac314c69508ba2329d
2014-11-04 15:33:04 +01:00
Ethan Yonker
5ef301ec95 Do not set contexts during a factory reset
We should not need to set or change the contexts of the media
folder when doing a factory reset. We should only do this when
we need to recreate the media folder.

Change-Id: I9f9918743d687b0aa0eb1e50747677f883037047
2014-10-20 14:42:47 +02:00
Ethan Yonker
25f20c1928 Fix wiping crash when block device is not present
Especially with /sd-ext, trying to wipe when the device is not
present causes a seg fault in the make_ext4fs function. Check to
make sure that the block device is present before trying to wipe.

Change-Id: I91973b5b832c9edbce81d61a271e84363c19e6c5
2014-10-14 09:04:54 -05:00
that
9e0593eaf6 mtp: cleanup, fixes and performance improvements
- use std::map instead of linked list
- read directories on demand
- fix writing zip files to storage root
- fix creating directories
- lots of minor fixes
- simplify generation of storage IDs and make them spec compliant

Change-Id: I2137c27549ddbdc58466f2e3aeda464fac70a3c5
2014-10-08 18:34:39 +02:00
Captain Throwback
ff5935f7ef Attempt to fix md5 issue with backups
thanks @bigbiff for the suggestion

Change-Id: Ie9b55537b7fa300461b015d2b9523d4250e755a9
2014-10-08 18:22:08 +02:00
Ethan Yonker
6277c79727 Attempt to automatically identify data/media devices
Change-Id: Ia3007fbced9ce3bc94efdb3dacc582a5e68a49a4
2014-09-19 22:34:09 -05:00
bigbiff bigbiff
c7eee6fef0 add mtp responder to TWRP.
Big thanks to Dees_Troy for helping with the implementation.

Change-Id: I6c9c522b9c9de5dc139e2ecb0141008182ba07f0
2014-09-02 21:44:49 -04:00
Ethan Yonker
1b7a31bd65 Track backup and restore progress
Track backup and restore progress based on the sizes of the files
as they are being added to the tar backup file. Update the
progress bar based on the sizes of the files.

Change-Id: Idf649efa1db3e91830b4b2add86203a3f30042ff
2014-07-09 08:52:18 -05:00
Ethan Yonker
5eac222cfe Do not restore file system on data/media devices
Change-Id: I600e7e9ce89621400531bceb472387aafc0d6ed8
2014-06-13 08:57:48 -05:00
Matt Mower
fb1c4ffaaf Whitespace and minor code cleanup
This is by no means comprehensive, but is quite a bit better already.

Change-Id: Ibc8654a5dfb0eec39cbd0b64bdb52bb4fbfe2f7e
2014-06-04 09:13:37 -05:00
Ethan Yonker
87c7bac9c9 Add options to repair or change file system
Change-Id: I9043e98e1e1ed4722f05c13a60b43d2d0bf739f6
2014-06-04 15:46:32 +02:00