Commit Graph

171 Commits

Author SHA1 Message Date
Matt Mower
874136434a SELinux can be assumed for Android 4.4+
Change-Id: I7410a0c8e439eec90a955ee9201efd9a92bb9635
2017-01-18 12:40:26 -06:00
Matt Mower
028995512b Do not disable performance mode too early for backup
Include SetPerformanceMode(false) just before every "return", and not
sooner.

Change-Id: Iefd5546865347dbd08cc9baeb98d58d26b7f4a3b
2017-01-18 17:50:35 +01:00
Matt Mower
23d8aaef29 Unused variable cleanup
Change-Id: I2397d0bd221dcf5c9d0f971ba157519bcf014a70
2017-01-18 17:50:05 +01:00
Matt Mower
029a82db6c Very minor code cleanup
Change-Id: Ie0b97da2cce7bb93307ed49b1138bc2f36df34d0
2017-01-18 17:49:23 +01:00
Matt Mower
a8a89d1961 Whitespace cleanup
Change-Id: I93c65973679894bb8587da4b38b410d38036b8bd
2017-01-18 17:41:17 +01:00
Ethan Yonker
ff2b7881c9 Change handling of /cache due to AB devices not having cache
Change-Id: Ia9b97ed19eb3d400d9d399255108cac79361bca4
2016-12-13 21:26:57 +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
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
e080c1f8fb Fix image flashing
PS2: full_filename is not a dir

PS3: use a consistent format of always assuming directory
     is missing the trailing / + fix whitespace alignment

Change-Id: Ib963473ae10571b3d069b326d024ca04c7224dda
(cherry picked from commit fa4ff144374474c541351d153549ad11d4396614)
2016-11-30 16:27:07 +01:00
Ethan Yonker
dcf2b674c4 Clean up PartitionSettings
The PartitionSettings struct contains some data elements that are duplicates
of data elements in the TWPartition class that is contained within the
PartitionsSettings.Part element. We will eliminate this duplication to help
reduce the chances for programming bugs.

Specifically, this fixes problems where the current file system does not
match the backed up file system.

Change-Id: I02f236e72093362050556a2e53a09d1dbb9a269d
2016-09-13 14:53:37 -05:00
Ethan Yonker
724c5148a5 Fix restore of subpartitions
Change-Id: If76cd08cdac7e2af4e0f5f00d420eed1f30897d3
2016-09-01 18:40:26 -05:00
bigbiff bigbiff
8fd4b096c4 MD5 checking: fix issues introduced with adb backup patchset
This patchset will fix issues with creating and checking
md5 checksums with single partitions and subpartitions.

Change-Id: Iddfaf46412e95635af958094726cf9e3eb5a4cc8
2016-08-30 20:52:02 -04:00
Matt Mower
bfccfb8822 Finish creating disable_free_space_check variable
* Create data manager variable for 'tw_disable_free_space'
* Make configurable through Settings
* Fix the "two presses needed to enable" issue for the checkbox on the
  backup screen
* No need to capitalize every word, but do specify precedes backup

Change-Id: Id436cef13e4ca9349618420aac03862ec4e3c35e
2016-08-19 10:35:10 -05:00
Ethan Yonker
9fa76ba147 Allow running of a custom script after factory reset
Change-Id: I33e6d72bf93103052551f33da51ba4af9a5f88c9
2016-08-19 17:19:57 +02:00
bigbiff bigbiff
a481d36402 Fix md5 creation from adb backup patch.
Change-Id: Id90da89c4eb50ed695a88f29859d1276ed8d032b
2016-08-08 21:02:39 -04:00
Captain Throwback
9643a80b02 Add typecode to sgdisk for proper detection in Android
- Fixes the "Unsupported SD Card" error when partitioning w/TWRP

PS2:
Use hex code instead of GUID to make code more succinct
Update typecode for Linux swap to be consistent

PS3: Revert PS2 changes

Change-Id: I5aec780aa4dfb7bd9025ae8cbceda13bfaaa0b03
2016-08-04 17:39:51 +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
Matt Mower
72c87ce347 Wait to mount until after fstab processed
The necessity to process fstab twice stems from mounting partitions
while still processing. Instead, wait to finish setup of /data, /cache
and storage parameters until after fstab has been processed (once).

Change-Id: Id77e1edbab5eb68a7cd4a1f34953d819a043d47a
2016-05-03 14:39:12 -05:00
Matt Mower
2b2dd15cbd Remove char/string conversions in fstab processing
There a few char->string conversions between functions which handle
different parts of fstab line processing, but there are no uses of
string functions. Pass char arrays/pointers around instead.

Change-Id: I976a9a54ee8dcfb6194cadcac6a34e467602003b
2016-05-03 18:48:38 +01:00
Matt Mower
4ab42b1831 Rewrite FS fstab flag processing
* If 'ro' fsflag detected, set Mount_Read_Only = true
* Only output human readable Mount_Options to log
* Match fsflags identically (not just first n chars) since there are
  no fs_flags which take arguments
* Match new processing method introduced in TW fstab flag processing

Change-Id: Iefdb76016be90a131b0d627d0cd3f18d2eb1a008
2016-05-03 18:21:43 +01:00
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