Commit Graph

65 Commits

Author SHA1 Message Date
bigbiff
1f780663cf minuitwrp ev_init: delay start if specified in board
This setting in the board will help if it takes longer
for the touchscreen driver to initialize.

Use TW_DELAY_TOUCH_INIT_MS := nnnn where nnnn is in MS.

Change-Id: I0a5c602edfe1214d64adadc980921a7bc0aa2bc5
(cherry picked from commit c6e2cfecce019d70ed5de74611761a2546e34828)
2020-06-29 15:50:54 +00:00
bigbiff
7ba7500953 decrypt: AOSP 10 requires the use of fscrypt
fscrypt aosp doc: https://source.android.com/security/encryption/file-based
kernel fscrypt doc: https://www.kernel.org/doc/html/v4.18/filesystems/fscrypt.html

This commit implements the ability for TWRP to use fscrypt to decrypt
files on the fscrypt implementation. It has been implemented mostly
in a new successor library to e4crypt called libtwrpfscrypt. Most of the
code was ported from AOSP vold.

Notable updates include:
 - updated policy storage by libtar
 - lookup of fbe policies by libtwrpfscrypt
 - threaded keystore operations

Big thanks to Dees_Troy for the initial trailblazing
of encryption in TWRP.

Change-Id: I69cd2eba3693a9914e00213d4943229635d0cdae
2020-06-22 12:17:22 +02:00
Patrick Zacharias
0edce1a2a4 gui: Repair OEM build
Building with TW_OEM_BUILD results in errors during compilation:

error: unused label 'error' [-Werror,-Wunused-label]
error: unused parameter 'allow_commands' [-Werror,-Wunused-parameter]

These changes are required to allow compilation to complete.

Change-Id: Iddc5bf1b90120de19a472c48b21d3531b758cacf
(cherry picked from commit 0cd6be903b3129b30d5abe40d3a0f30545eef27d)
2020-06-10 14:38:39 +00:00
bigbiff
d58ba18272 AOSP10 TWRP Merge: fix conflicts and update libraries needed
This allows flame to boot TWRP. Still will need to work on
super partition for vendor and system access.

The plan will be to cherry-pick any updates to android-9.0
through gerrit.twrp.me to this branch as a WIP.
2020-03-23 11:18:29 -04:00
Ethan Yonker
64e0a6525f Use listbox for device-specific advanced menu items
This patch allows items to have more than one action surrounded
by the <actions> tags like other GUI elements. The patch also
adds new twrp command line options that let you reload the theme
and switch to a specific page from the command line:

adb shell twrp reloadtheme
adb shell twrp changepage=advanced

Change-Id: I838ea380a508be07b9fa617034d1954e116febd6
2019-03-20 15:42:49 -05:00
Ethan Yonker
6e8c27a52b Support v2 fstab format
Auto detect and support both the v1 and v2 fstab formats
Support putting TWRP style flags in a separate /etc/twrp.flags file

twrp.flags format is the same as twrp.fstab (v1 with TWRP flags)

Support using a wildcard in a block device and find all partitions:
/usb-otg vfat /dev/block/sda*

Support using sysfs entries (voldmanaged) and read uevents and scan for
wildcard partitions from uevent data. (twvold?)

May not be complete for some of the newer flags found in fstabs in newer
build trees and there is a slim chance of a crash if the user removes a
removable device while TWRP is performing actions. May need to add some
kind of mutex to prevent the 2 threads from causing this crash. We need
to start somewhere though and this change is pretty innocuous when not
using a v2 fstab.

Change-Id: I617d97c7db332cbe671a9d2b8ad98b3d9c4f03cc
2017-11-28 00:20:51 +01:00
bigbiff bigbiff
19fb79c722 ADB Backup: add ability for TWRP GUI to restore
Restore adb backup files that TWRP made to your PC.
Put files in your backup directory to see them.

e.g. /sdcard/TWRP/BACKUPS/<sn>

Change-Id: I2c57970d77b64c39a302159041456e761c185259
2017-11-27 09:32:30 -06:00
Matt Mower
b68bff01d3 GUI: Mark local flip() function as static
Change-Id: Ib92e294872c1408cc749fdb0db3bbf56579eb070
2017-01-18 13:04:35 -06:00
Matt Mower
9472ba1d39 gui: Actions: Toggle backlight on power key
Create GUIAction to handle KEY_POWER with a screen backlight toggle.

Change-Id: Iad0a7923b4a776e0336722db74d6fc46cd0107a2
2017-01-18 19:55:33 +01:00
Matt Mower
a8a89d1961 Whitespace cleanup
Change-Id: I93c65973679894bb8587da4b38b410d38036b8bd
2017-01-18 17:41:17 +01: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
Ethan Yonker
86404bda2c Stop trying to load /script/ui.xml
I think this feature was used way back in the very early days of
TWRP 2.0 on the Kindle Fire and has not been used since. I see no
reason to keep it around for now and we can always reinstate it
later if for some reason we need this feature again.

Change-Id: Ie9f3e5db7190732f813ae1e152aab2d85a4ca98c
2016-03-31 08:01:12 -05:00
Ethan Yonker
07926a3845 Fix OEM compile
Change-Id: I39218f2485a2c2c95f0e400c31356bedc4973f6c
2016-02-19 03:58:06 +01:00
Matt Mower
b26c1167fc GUI: Set brightness after gr_init()
On at least one device I've tested (htc msm8960), setting the
brightness after gr_init() is necessary for the splash to show.

Note that at this point in the boot process, the settings file has
not yet been read, so tw_brightness has its default value of max
brightness. When settings are finally loaded, the correct brightness
is loaded for the GUI.

Change-Id: Ifc58c1dc80ed9e6f6b2a269a9bb6764038626c84
2016-02-05 12:18:55 -06:00
Ethan Yonker
fbb4353a24 Update minuitwrp graphics in line with latest minui
Note: events.cpp is still old code renamed to cpp to make it
easier to call functions like gr_fb_width().

I had to modify AOSP fbdev code to provide a separate memory
surface for drawing to as drawing directly to the framebuffer
resulted in rendering taking about 5 times longer.

I also modified AOSP adf code to provide a separate memory surface
for drawing for the same performance reasons. The Nexus 9 supports
adf graphics.

Overlay graphics work on at least one device. Overlay provides a
separate memory buffer already so performance is good.

I do not have a drm device yet that I know of. I made some attempt
to update the drm code to determine the correct pixel format based
on the drm graphics format, but what is available in pixel flinger
and what is available in drm do not line up all that well. Reports
are that the Pixel C is using drm graphics, but performance is
slow, likely due to the use of a mmap instead of a memory buffyer.

Change-Id: Ibd45bccca6ac2cb826037aa9b2aa5065cf683eed
2016-01-27 10:53:13 -06:00
that
235c648a68 gui: use XML-based page for splash screen instead of a static jpg
For devices with an unusual aspect ratio, stretching a bitmap to
the screen resolution is sub-optimal. So let's reuse our XML engine
that allows assembling the splash screen from individual parts.

The splash page is loaded from a separate XML file for quick loading.

Change-Id: I2d3dad26e42fcefaf563dacdf0ffa61f209dada1
2016-01-25 19:25:34 +01:00
Ethan Yonker
afde0983df Update mStartPage to make language selection work on other pages
We should offer language selection on any start page such as
decrypt or system read only. However, if the mStartPage variable
was not being updated properly so selecting a different language
was dumping the user back on either the decrypt prompt or the
system read only page. This patch set fixes the problem and places
the user back on the proper page when they choose a new language.

Change-Id: I5153d3b9525d8c93d3863f4b17ecf55b5209e3c7
2016-01-23 08:56:07 -06:00
that
1964d19c46 gui: add terminal emulator
Emulates enough of a VT-100 to run busybox vi.

Change-Id: I99c829c6c9de2246194ecb8b8b3cdf4ac34a0606
2016-01-07 22:30:39 +01:00
that
10ae24ff94 get rid of console thread for OpenRecoveryScript
- CLI commands run in a threaded action "twcmd"
- Console is displayed via "singleaction_page"
- move ORS execution code from GUI action to OpenRecoveryScript class
- remove unused function gui_changePackage
- don't change PageManager package in home action
- fix that /tmp/openrecoveryscript was not deleted after execution

Change-Id: Ic688c0b04647ce09e9db979b0bc5123f47cf4f70
2015-12-29 15:39:57 -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
e0f1f3b4d1 Move reloading of theme outside of the action thread
Reloading the GUI while the GUI is running and rendering is very
dangerous as we may be deleting GUI resources before or while we
are trying to render those same items. This change will allow us
to safely load new resources and delete the old ones.

Fixed a double free situation that was causing a crash on every
other theme reload.

Clear parsed xml documents when we are done loading the theme
instead of keeping them in memory for the life of the theme to
help save a little memory.

Store starting page so that if we request a reload, we can enter
the theme at the same starting point, which may come in handy if
we allow for language selection on alternate starting pages such
as the decrypt prompt or the system read only prompt.

Change-Id: I45a7e3fb3daeefac56d70f8d4936938eb1244b99
2015-11-09 14:57:23 -06: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
1c273318c7 Allow multiple overlays
This effectively allows us to support popup dialogs and the like.

Change-Id: Iafb3fa60ed635287cb59dce118f74dc8f2a4e60a
2015-03-19 12:32:39 -05:00
Ethan Yonker
30fa335a85 Allow touch to use a key code to sync touch events
This is needed to make touch work on the x86-64 emulator target
though I have seen the key code used on other devices as a way to
synchronize touch events.

Change-Id: I31a3cc56e6470f2c707641b537140e44f5e686aa
2015-03-13 11:37:03 -05:00
Ethan Yonker
591b920536 Reduce themes to 5 and rely on scaling
This will significantly reduce theme maintainence and should be a
lot more sustainable over time. Eliminate most themes leaving only
5 remaining in 3 categores:
 * watch_mdpi: 320x320
 * portrait_mdpi: 480x800
 * portrait_hdpi: 1080x1920
 * landscape_mdpi: 800x480
 * landscape_hdpi: 1920x1200

Add handling to map the old DEVICE RESOLUTION to the new TW_THEME
build flag. New devices should specify a theme using the new
TW_THEME build flag using one of the 5 values from the list above.
Long term we will eliminate the use of the DEVICE_RESOLUTION flag
in favor of the new flag.

Change the way sliders render so that they completely follow the
placement="5". This will probably break some custom themes but is
necessary so that we can retain the aspect ratio on slider images
and still have them rendered at the center of the screen.

Add code to the console slideout button so that it can be centered.
Centering the slideout button allows us to keep the button at the
center of the screen when retaining aspect ratios on the image.

Add more retain aspect ratios for home, back, slideout, folder,
file, and lock screen images.

Change the way we build the top bar in TWRP. It is now mostly
drawn using fill objects and the TWRP logo is a separate image so
that we can retain its aspect ratio during scaling. Thanks to Mark
Norelus for providing the TWRP logo.

Change-Id: I801a7b3163cad9ef353461f4c327690a9ccbb3aa
2015-03-12 18:41:34 -05:00
that
b2e8f672f3 gui: support string resources
storing strings in a map (for fast lookup) in resource manager

To define a string resource in <resources>:
<string name="foo">Hello</string>

To use a string, e.g.:
<text>%@foo%</text>

Not yet done: language-specific resources (should be solved not only for
strings, but for all kinds of resources - e.g. for localized images)

Change-Id: I3ba5cf5298c09e0d28a83973e9662f179271b33f
2015-03-11 07:38:37 -05:00
that
ba75a0e73b gui: don't truncate values to 0 after scaling
Avoids invisible lines (e.g. input cursor) when scaling down.

Change-Id: I595e8bdb2fa468c30f104867ad77be2423ec287f
2015-02-23 15:39:15 +01:00
Ethan Yonker
63e414fc8a Scale the GUI to fit the screen
With this patch set, if needed, we scale the images during early
boot. TTF support is needed to properly scale the font. No font
scaling is done on the old style fixed width font used in the
console.

Special thanks to _that for figuring out the scaling and blending
function calls to make this possible.

Change-Id: If2f79bef16d6db2e1298bfc3d00c9bcca2bee37a
2015-02-10 14:11:50 -06:00
that
de72b6d4d8 gui: avoid high CPU usage while waiting for input
- add a timeout to ev_get
- set timeout to 1 second when idle
- delay timeout for 15 frames to keep animation objects working
- stop kinetic scrolling immediately at end of list

Change-Id: I77138055c464b65b71e296f9c7ef63ea06809bc1
2015-02-09 16:53:21 +01:00
Ethan Yonker
3f15be40aa Reset data manager variables before running runPages
Fixes a problem where, if you decrypt the device, the promtp for
installing SuperSU appears briefly before it automatically
reboots without letting you confirm or deny.

Change-Id: I6f7b1c7096e788ccabd8f5aac9eb01d38bfbc0f7
2015-02-09 09:42:00 -06:00
that
c5837f3997 gui: fix lag (and event logging)
- Process multiple input events per frame even if rendering takes longer
than 33 ms. Limit minimum frames per second to 2 instead, allowing us
to catch up with the input events. The lag was especially visible when
using the mouse.

- Move blankTimer calls to the main input function so that moving
the mouse also unblanks.

- Fix a compile error with event logging.

Change-Id: If9e0360f5cc0562c4356611afc61b6d583fb1ec4
2015-02-01 01:59:43 +01:00
that
9fa5153aed gui: move input handling into a class
Change-Id: I97e08a23369af0112875af84b3fb529cf42e929e
2015-01-30 16:11:58 +01:00
Ethan Yonker
e13fa63dc0 Move input handling into the main thread
This also makes the hardwarekeyboard.cpp file that I created for
the Asus Transformer tablets with a keyboard dock the default
hardware keyboard handler. USB keyboards should work properly now
if present for keyboard input.

Change-Id: I724606e91ffe2a55265a9d1cb1ec714de244d38b
2015-01-30 16:11:31 +01:00
Ethan Yonker
045369540d Use TWAtomicInt in gui.cpp to make it thread safe
Change-Id: If05202355d3773e73541288c922fa6c69b1a9ad7
2015-01-27 08:41:28 -06: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
Ethan Yonker
fd0439ed59 Move ORS command line into main thread
Also eliminate the mostly similar runPage function in favor of
using a single runPages function to avoid code duplication.

Change-Id: I46ef414beb4009fee16d4de13d8a5ab2b9678409
2015-01-22 17:51:57 +01:00
Ethan Yonker
cf50da5742 Fix handling of custom themes after decrypt
Loading a custom theme from the decrypt action was preventing the
runPage function from exiting. This moves the loading of a custom
theme out of the action.

Change-Id: I86904b63a67a25ded56e3e1e569fe906264dc055
2015-01-12 22:08:35 -06:00
that
fb759d45f5 gui: simplify blanktimer
- get rid of separate thread, check timer in rendering thread instead
- use an enum for the blanking state instead of magic integers
- move #ifdefs for TW_NO_SCREEN_TIMEOUT inside blanktimer class
- move some #includes and enum TOUCH_STATE to pages.hpp

Change-Id: Id4b104e3680dc5db41d8ba85e32d722cf4086299
2015-01-11 12:16:53 +01:00
Ethan Yonker
751a85e759 Allow for X and Y offsets in GUI
These can be used to center a lower resolution theme onto a
higher resolution screen. May be useful for Nexus 9 unless or
until we decide to do a 1536x2048 theme or on devices like the
Moto 360 and LG G Watch R.

The build flags will only affect the stock theme. If a custom
theme wishes to apply an offset, it can be done by setting
tw_x_offset and / or tw_y_offset in the variables section of the
XML.

Change-Id: I2390769ed861b96a4a3bb8a0f06d9021ec91b6b9
2015-01-09 23:37:04 +01:00
Ethan Yonker
738be7a3ff Use one mizip for all
The new minzip did not compile in older trees due to needing
mmap64. For older trees we will just use mmap instead. Remove all
files and code pertaining to minzipold. Updater should now build
properly in older trees as well.

Eliminate use of PLATFORM_VERSION in favor of PLATFORM_SDK_VERSION
which should be more consistent and reliable.

Change-Id: I38d2b604a73d1b17a2072c7d60e990b81ece0c10
2014-12-10 11:54:02 -06:00
Ethan Yonker
ffbd6ffc21 Fix crash when rapid firing command line commands
Change-Id: I0caaa51720fe3608b8c4cb02f046afb3cbaa54f9
2014-10-22 10:48:16 -05:00
Ethan Yonker
03a42f6c6a Add command line capabilities
Allows sending openrecoveryscript commands to TWRP via shell.
This may be handy for visually impaired users, for various one
click utilities to drive TWRP commands from a computer, for using
TWRP when a catastrophic hardware failure like a shattered screen
prevents you from being able to use touch, or even on devices like
a TV stick where touch and USB mouse input is unavailable.

This patch also includes a few minor changes to openrecoveryscript
including proper support for rebooting via the script and for
decrypting the device via the command line.

Change-Id: I796ad168efdd2da9c25334ac93d1079daaa7b0bc
2014-08-09 07:49:35 -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
Vojtech Bocek
0b7fe504dc Add support for actions triggered by key combination
Change-Id: I9dfa7de40229f00412d63fc9c1eb3a809a6eb2e6
Signed-off-by: Vojtech Bocek <vbocek@gmail.com>
2014-04-16 17:51:17 +02:00
Dees Troy
1eba56f577 Fix touch on Sprint HTC One m8
Change-Id: Ia9fba3be16a33b3cb0c4a3458398a2e60ba7f001
2014-04-15 15:26:14 +02:00
Ethan Yonker
83e82578af Allow building of an OEM friendly TWRP
Disable theming
Disable creating the TWRP folder for the settings file
Change factory reset on data/media devices to a full wipe

Change-Id: I3104282b5dd3f55dfff7c8cf39c72750af08563d
2014-04-04 10:59:52 -05:00
Dees Troy
3b2be98ca4 Merge "Add option to print render time of each frame to log file" into android-4.4 2014-02-07 19:46:59 +01:00
Vojtech Bocek
1fc30fc77b Implement mouse cursor
Signed-off-by: Vojtech Bocek <vbocek@gmail.com>

Change-Id: I66d6db7b3ed9cca50b469d125b36224332e06913
2014-02-07 12:37:13 -06:00
Vojtech Bocek
e5ffcd1af2 Add option to print render time of each frame to log file
Signed-off-by: Vojtech Bocek <vbocek@gmail.com>

Change-Id: Id158a6375fbadf4cdf0a8c7d143759e602419e7f
2014-02-06 21:18:08 +01:00
Dees Troy
3be70a897e Update licenses to all match 2013-10-22 14:25:12 +00:00