Commit Graph

150 Commits

Author SHA1 Message Date
Ethan Yonker
308b1cadc4 Really remove all old SP* flags and code
Change-Id: I5ece02a8721e1b7541fb5182366a55fd0f037a7a
2016-04-01 22:39:22 -05: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
Ethan Yonker
fe91611cb1 DataManager Updates
The goal of this change is to make DataManager use InfoManager to reduce
code duplication.

Change-Id: Ia4f4c4324453a192995e0f442db0a03628c13e46
2016-03-31 15:43:53 +01:00
James Christopher Adduono
fddbdfa45f Don't add subpartitions to restore list
Their parents will take care of them.
Good parents.

Fixes double restoration of subpartitions when they are
also set to backup in the recovery fstab.

Change-Id: I876c179135e0cb00754e9a8cfc8eac164c4b7fd4
2016-03-03 18:05:46 +01:00
Matt Mower
9a561dd2b3 partitions: Fix path based Find_Next_Storage
If a path is specified for Find_Next_Storage() and datamedia is
excluded, the function currently runs to the end of available
partitions and reports no other storage is available. Fix this by
restoring the original mount_point == search_path check to break the
loop. The subsequent partitions loop will skip data-media storage as
needed.

Change-Id: I92baed866cd36f13d851bd58ba5346e47edb142e
2016-02-24 15:03:25 -06:00
Ethan Yonker
fcf3f24856 Fix adopted storage when andsec flag is present
Change-Id: If903d838abc920f952f243482338188c15bb1dbf
2016-02-18 11:38:33 -06:00
Matt Mower
1fdcdb7c76 partitions: Avoid duplicate UMS mounts
If a device has several LUN but only one storage volume TWRP
recognizes (e.g. lun0 for microsd and lun1 for emulated cdrom), then
avoid mounting the same partition twice by checking the mount point.

Change-Id: Ie23b88acca1818873792e9f65b73b125a15e4a5d
2016-02-05 18:56:14 +01:00
z31s1g
2053fe0bc9 gui: add german translation
also correct typo in all language files
also remove dummy language files for ES and FI

german translation was done on omni crowdin by multiple translators:
https://crowdin.com/project/OmniROM/de#

result was updated in line with latest changes (as of 02032016) to en.xml


Change-Id: Iddd8dbee7e050833a4dc61174288514d408267f7
Signed-off-by: z31s1g <z31s1g@googlemail.com>
2016-02-05 03:58:31 +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
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
Ethan Yonker
4adc33ebff Fix (Auto Generate) handling for backup names
Change-Id: I29f3823d03c005fb55a0e0a98818d40bd1eb039d
2016-01-22 16:08:07 -06:00
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
b78fbdfabc Improve flash image handling of mounting
Flashing an image does not always require storage to be mounted.

Change-Id: I9d2a69cee9053f7829e51486d727e2e0b522c5da
2016-01-18 16:15:26 +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
dianlujitao
7d304c71f8 Generate new format /etc/fstab
* Toybox's mount can't work with the old-fashioned fstab.
 * Busybox mount is compatible with the new one.

Change-Id: I16b7d6424a4424c2a92d82846a706733bf58f8e1
Signed-off-by: dianlujitao <dianlujitao@gmail.com>
2016-01-04 07:39:49 -06:00
Matt Mower
2d50cada06 Remove dead code: TW_HAS_DUAL_STORAGE
Nothing sets TW_HAS_DUAL_STORAGE. Remove this dead code.

Change-Id: Id5d10c9ee3883dad6beef69e09d16b0f1350c91d
2015-12-22 15:15:54 -06:00
Ethan Yonker
56db1c4e7f Fix gui_msg %s to {1} call
Change-Id: I39f032e0cad5d482d11e0e8d1c4c7c3e7ec6d041
2015-12-20 22:49:00 -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
Ethan Yonker
a1de1496a9 Minor update to decrypt device routine for Nexus 6P decrypt
Move property setting of ro.crypto.state to after mounting any
needed partitions so that we can use this property as a trigger
for running services in init. Check to see if the property is
already set so that we do not set it and sleep multiple times if
the user enters an incorrect password.

Change-Id: I55558c5e227377381101b6305569d9eb31040790
2015-11-05 21:08:02 +02:00
HandyMenny
37d42994cd Properly set sys.usb.config when ums is enabled.
Use sys.usb.config also for ums, but leave sys.storage.ums.enabled for compatibility with custom init.rc that use it.

PS2: Rebased - moved updates to init.recovery.usb.rc

Change-Id: Iad3441d23ac37612e58f63e4038d05c5c1a37b25
2015-10-15 16:04:16 +02: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
89583ef00f Fix up some TW_OEM_BUILD things
Fix factory reset now properly formats data as expected
Change text for ORS processing
Disable system read only check, SuperSU, and patch system
Stop copying fstab and version to cache

Change-Id: I20f5cae390afbb8d2d88e01b8d9b9bf4ff0fdea1
2015-08-26 22:36:16 +02: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
203bcc97f7 partitionmanager: remove broken and unused progress calculation code
img_bps and file_bps were uninitialized (the values are only calculated
at the end of the backup), and occasionally could be 0.

Don't divide by zero, it's bad for the program's health.

Change-Id: I3f6f5a144c24f32508ca25de49491261c7f6e674
2015-05-19 20:54:43 +02:00
Matt Mower
2b18a53dc8 Address a few compiler warnings
Change-Id: I6e063fba8d58c8c53da6bca6292c84e3392aee50
2015-03-05 04:11:44 +01:00
bigbiff
bf1d67245e Theme: Add ability to disable size checking before backup
(for compressed backup users with low space).
Clean up backup folder and copy only recovery.log for debugging.

Conflicts:
	gui/devices/watch/res/watch.xml

Change-Id: If8aa3580dbc082d0fe4882d4af8dc3cdb362a8b5
2015-02-23 15:49:02 +01:00
Ethan Yonker
1b03920ca7 MTP: make MTP work even if unplugged and replugged
Set up a loop to keep trying to open / read the MTP device so that
MTP will work even if the device is unplugged during boot or
unplugged and replugged in.

Change-Id: I0d3a3b7c91ce84a8cbed16caa4b15efee35b3641
2015-02-02 15:45:51 +01: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
d9ff3c5dd0 Hide some non critical error messages
Change-Id: I6e43242e44ce63cea9472c75a9f7fedf1b34fbbe
2015-01-22 17:57:29 +01: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
Ethan Yonker
df7abac1a6 Do not toggle USB ID during MTP startup if not needed
In most cases MTP is enabled so it is better to start our init.rc
with MTP enabled and try not to toggle USB IDs during TWRP boot so
that we can keep adb running to make debugging easier.

Change-Id: Idf122c5ad4deeef7e1ed775d495989c502ddfb19
2015-01-02 10:22:58 -06:00
Ethan Yonker
abb5c4ead0 Move sleep during MTP startup to MTP thread
Some devices are very slow to respond to the sysfs requests. To
prevent delaying the main GUI from booting during TWRP startup, we
move the sleep delay to just before we open the MTP device and
into the MTP thread so that it does not hold up the main TWRP
thread.

Change-Id: Ic931ef317d0fb7ef4dfdef46a32f68a014ff62c0
2014-12-29 17:01:41 +01:00
Ethan Yonker
4bfabab005 Check for valid MTP_Storage_ID before adding or removing
Attempting to add a storage ID of 0 was causing a seg fault.

Change-Id: If8797186405be36ee70dbca63bd1063a62ba2812
2014-12-29 16:25:32 +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
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
Matt Mower
b6ef4781d2 Revert "Fix USB Mass Storage on some devices"
This reverts commit 9eb1cd4752.

Change-Id: I66d3d6bb5633e6df3e8f7db250fc6d62817a5489
2014-12-12 15:21:28 +01:00
bigbiff
d5c6069287 This fixes kernel panic on find7 when disabling MTP before flashing zips.
Change-Id: Id11a0fb1a88424d9dd70190c313781607bad3bb8
2014-12-11 18:48:08 -05:00
Ethan Yonker
0bc17c6fd3 Fix occasional MTP kernel panic
Add a short sleep between setting up the sysfs entries for MTP and
actually sending MTP data to the MTP device. In some cases a
kernel panic was happening because we were sending data too soon.

Change-Id: Ie5e05690846fc84f161c91829de448bc049f87e2
2014-12-10 18:55:35 +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
ec0fa4ad68 Properly set tw_settings_path after decrypt on data media devices
When tw_settings_path is not set correctly for /data/media/0 when
present, custom themes will not load (and who knows what else may
also be broken) so set it properly after decrypting the device.

Change-Id: Id3dff04f62cf9c953c8a2ca07fe9ac597dcda20f
2014-11-20 09:51:06 -06:00
Ethan Yonker
2b556013bf Add /firmware to the mount list for L decrypt
Needed by Nexus 6 and possibly others

Change-Id: I3309e2141a21a94dce90e34cced16450b591a92c
2014-11-19 16:15:21 -06: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
Ethan Yonker
9eb1cd4752 Fix USB Mass Storage on some devices
On some devices we need to set the sys.storage.ums_enabled
property before we write to the lun file. Also sleep for a bit
after setting the propery before writing to the lun file.

Change-Id: I77ac853fde14ffc3adf20571c132f91ed85196df
2014-11-04 15:40:05 +01:00
that
39b7c16d28 add "done" after "Updating partition details..."
This addresses a usability problem. Some users are confused when they
switch to the console and see this message, thinking they have to wait.

Examples:
http://forum.xda-developers.com/showthread.php?t=2498492
http://androidforums.com/verizon-galaxy-s3-all-things-root/718376-twrp-recovery-update-question.html

Change-Id: Ib44773998c2ef1b8b821f3b8876218e11a7de357
2014-11-04 15:35:16 +01:00