Commit Graph

117 Commits

Author SHA1 Message Date
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
that
78d0c5fc25 partitionmanager: remove unused By_Block and By_Name methods
Change-Id: Ia6eefd23f6671428221e35642f01534bc9fff6ad
2014-11-04 15:29:06 +01:00
Tom Hite
5a9267283c performance profile support
Many device trees support the recovery.perf.mode property to
set various core frequencies and online/offline mode. TWRP is
highly threaded, and support for multiple cores on many operations
dramatically recudes the time, e.g., backups, zip flashes, etc.

p2: removed user notifications

Change-Id: I957b8ca40b241c0af0471327eeb329cce1816017
2014-10-08 19:35:32 +02: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
Ethan Yonker
6277c79727 Attempt to automatically identify data/media devices
Change-Id: Ia3007fbced9ce3bc94efdb3dacc582a5e68a49a4
2014-09-19 22:34:09 -05:00
Ethan Yonker
1eff6cd5d1 Additional checks to prevent partitioning internal storage
Change-Id: I9fcd7e0169fbdd52405c0c86aafbef091f69411e
2014-09-15 13:30:42 -05:00
Ethan Yonker
8613dc0278 Fix handling of MTP fork/child process
Change-Id: Iacd8a38d21e9c8b0dfafefbeb646f46cd3ba02a1
2014-09-11 09:28:20 -05:00
Ethan Yonker
8dfa77780f MTP: Use fork instead of pthread
Change-Id: I95cf6f4def0c86f40c775738f0712323f0a0f146
2014-09-04 21:59:20 -05:00
Ethan Yonker
6d154c4fe2 Allow toggle of MTP debug
Via command line in TWRP:
twrp set tw_mtp_debug 1

This will enable debugging for MTP. You will need to disable and
re-enable MTP in order to see the debug logging.

Change-Id: Ia7bb0c584e10a4322b65ecf80a67ed7ee836b38e
2014-09-03 14:22:50 -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
bf2cb1c4d8 Color in the console
Allow each gui_print command to specify a color
Change LOGERR to use the error color
Theme should specify colors for error, warning, and highlight

Change-Id: Ie8ece34111f604e25fcb79e5b731cd4e61038ff9
2014-07-09 15:46:35 +02: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
Vojtech Bocek
93cb1ef2eb Fix crash while loading config due to incorrect tw_storage_path
Change-Id: Ia5957efe616defa4272501cd8f31d26d394077bb
Signed-off-by: Vojtech Bocek <vbocek@gmail.com>
2014-05-31 14:26:12 +02:00
Matt Mower
ee71706ad1 Fix multiple lun file USB mounting
Both the incorrect mount point and the incorrect lun file were being
passed as the second storage volume.

Change-Id: If9c7d92d1992ec022a2c89a82b2ea05c9150d635
2014-05-31 14:23:51 +02:00
Matt Mower
ed71fa3e82 Only setup settings,andsec partitions if available
Change-Id: Iafedcec9e6ba368e29e32ab7a92d774cdd3f64e1
2014-04-16 21:58:07 +02:00
Matt Mower
bf4efa39e4 Support alternative .android_secure location
Some devices (jewel, m8) have .android_secure at a non-standard
location. Allow a different partition to be specified as the home of
.android_secure using the fstab flag 'andsec'.

Using the /data/media variant of jewel as an example, recovery.fstab or
twrp.fstab could be edited like follows:

/external_sd  vfat  /dev/block/mmcblk1p1  flags=display="MicroSD";andsec

Note, this is NOT a method to move .android_secure in your ROM. Your ROM
must already write to this alternative location.

Change-Id: I3a6e4e63aaddb35870b79e80938b0f9c2c902443
2014-04-16 17:30:26 +02:00
Dees Troy
e65e35cc37 Merge "Fix display of .android_secure size in Backup" into android-4.4 2014-04-02 16:05:02 +02:00
Ethan Yonker
74a149bfcb Merge changes Ia75c34ab,I5743d9b9 into android-4.4
* changes:
  Support Qualcomm overlay graphics in recovery
  Improve USB Storage handling
2014-04-02 16:04:02 +02:00
Matt Mower
ed426904e6 Fix display of .android_secure size in Backup
Setup_Settings_Storage_Partition() needs to be called before
Update_System_Details() in order for the /and-sec mount point to be
setup and size read correctly.

Change-Id: Id5394c90b6d095027c1b852764676dc6080a871d
2014-04-02 00:28:30 -05:00
Ethan Yonker
47360be11c Improve USB Storage handling
Change-Id: I5743d9b967a8227c4bb87da01a9c67c574bf9876
2014-04-01 10:43:59 -05:00
bigbiff bigbiff
0733881369 if md5 check is not selected for subpartitions, don't check it.
Change-Id: I7248c75f17c6f82e098831c297c0662ef6ea289f
2014-03-30 14:56:41 -04:00
Dees Troy
02a6453b75 Re-arrange handling of settings storage partition
Sometimes we received an error about being unable to locate
storage partition because the DataManager would attempt to access
the PartitionManager before we finished adding the storage
partitions to the vector.

Change-Id: I0ce1778938d308b1eb17de46a192ecd52489cad3
2014-03-19 15:24:01 +00:00
Ethan Yonker
c05c598b73 Improve handling of settings storage and android secure
Change-Id: I8af92543c2f0c201e7220267c417d74e4561038d
2014-03-13 09:19:56 -05:00
Dees Troy
4159aedfaa Restore capabilities to run-as binary
Change-Id: I9e2b8e9b69c94b94c57143c04b950530490ec33e
2014-02-28 17:59:04 +00:00
Ethan Yonker
71413f4ee9 Check crypto footer before offering to decrypt
Verify that we have a valid footer with proper magic before
setting things up for decryption to help prevent user confusion
when dealing with data partitions that fail to mount. Also check
to make sure that the block device for /data is present.

Change-Id: Ie87818fe4505a8bf71df7d3934c114e7328ef3ca
2014-02-26 13:37:35 -06:00
bigbiff bigbiff
f08ada8483 Allow recovery to be restored if backup=1 flag is present in recovery.fstab
Change-Id: I426c8da8ae586004011ec4a103e1d7a1f23b3599
2014-02-12 17:30:51 +01:00
Ethan Yonker
d4d107388c Improve android secure handling
Change-Id: I9e1c7f4a8353b7be51e1a54bf5d506c9dce70da2
2014-02-03 15:27:52 -06:00
Dees Troy
6f6441da58 Fix include of cutils
Change-Id: I9868298908ce501d3043326862057e8a637544af
2014-01-23 02:07:03 +00:00
Dees Troy
a6a26429f6 Merge changes I4c369222,I8a8ad4b3 into android-4.4
* changes:
  Enable UMS mounting of storage drives
  Set listener properties for UMS mount/unmount
2014-01-21 15:58:42 +01:00
Dees Troy
98fb46c6e2 Fix handling of storage after decryption
Change-Id: I0c2614f841a225699be9d4a52c60e9456241659b
2014-01-21 15:39:45 +01:00
Matt Mower
d9cb90660a Set listener properties for UMS mount/unmount
Some kernels require the usb functions be defined before UMS mounting
of storage partitions will work. This sets the sys.storage.ums_enabled
property upon mount/unmount which can be listened for in init.rc.

Example routines to include in init.rc:

on property:sys.storage.ums_enabled=1
    write /sys/class/android_usb/android0/enable 0
    write /sys/class/android_usb/android0/functions adb,mass_storage
    write /sys/class/android_usb/android0/enable 1

on property:sys.storage.ums_enabled=0
    write /sys/class/android_usb/android0/enable 0
    write /sys/class/android_usb/android0/functions adb
    write /sys/class/android_usb/android0/enable ${service.adb.root}

Change-Id: I8a8ad4b392abbaa173d402714bcb4049ba84ccca
2014-01-20 20:13:48 -05:00
bigbiff bigbiff
34684ff313 Create a TWRP Disk Usage Class to retain state about a directory and whether we should skip it in other classes like twrpTar.
Moved Get_Folder_Size to this new class.

Change-Id: If0a0220f900eb109581f2eeaf7b76e3f7d6886f1
2013-12-19 18:02:44 +00:00