Commit graph

138 commits

Author SHA1 Message Date
Tao Bao
a00b449e1f screen_ui: Trivial fix to append newline when logging.
Noticed while debugging other issues.

Test: Boot and check recovery.log.
Change-Id: Id92265cff287b9de89efe5eea85581e63e31aeb2
2019-01-16 09:31:12 -08:00
xunchang
c7dbc735d2 Add a horizontal line at the end of the graphic menu
This is in line with the old behavior and the UI of TextMenu.

Bug: 121280655
Test: check the menu
Change-Id: I4b82b93187b2d02cfe5b31a9a8fb621d10dd5d8a
2018-12-20 11:36:55 -08:00
Tianjie Xu
1a0a30a16a Show wipe data confirmation text in recovery mode
After we generate the localized confirmation text images for certain dpi,
we can now load these images and display them under recovery. Devices that
cannot load the images will use the backup text strings as before.

Bug: 74397117
Test: check the menu with multiple locales, and check all the images locally
with locale test, check the fall back strings.
Change-Id: Ic31a55670026c909ec7a05cb0bb4a0fc1d5d15c7
2018-12-11 23:23:41 +00:00
Tao Bao
dd78982d58 minui: GRSurface::Create() computes data_size on its own.
GRSurface::Create() doesn't need to rely on caller specifying the buffer
size, as it can compute that info based on the given args.

This CL also uses `size_t` for all the parameters in
GRSurface::Create().

Test: Run recovery_unit_test on marlin.
Test: Build and boot into blueline recovery. `Run graphics test`.
Test: Build and boot into blueline charger mode.
Change-Id: Idec9381079196abf13553a475006fefcfca10950
2018-11-26 22:46:19 -08:00
Tao Bao
da409fb8d6 ui: Manage loaded resources with smart pointers.
Test: Run recovery_unit_test on marlin.
Test: `Run graphics test` on marlin.
Change-Id: I8239c3d9fb288f80ee11f615402768ff8ef8ecd0
2018-11-05 10:15:59 -08:00
Treehugger Robot
47b650b588 Merge "ui: Add constness to Draw- functions." 2018-10-24 00:28:21 +00:00
Tao Bao
65815b6d3a ui: Add constness to Draw- functions.
These functions take the given GRSurface instances as inputs, which
shouldn't be altered.

Test: mmma -j bootable/recovery
Test: Run recovery_unit_test.
Test: `Run graphics test` on marlin.
Change-Id: I51bf408e85faae2b497d4f148ab1dec22dd16c93
2018-10-23 10:56:54 -07:00
Tianjie Xu
b99e6069c1 Add function to show localized rescue party menu
Add a function in screenUI to display the pre-generated graphs for
rescue party. If these graphs are not valid, falls back to display
the old text strings.

Right now we haven't generated the localized graphs yet, so the UI
always shows the TextMenu.

Bug: 116655889
Test: check rescue party under recovery
Change-Id: I0558cb536b659cdc25c8b7946d3a39820935b003
2018-10-22 15:27:33 -07:00
Tianjie Xu
66dbf63080 Implement the graphic menus
As we plan to show localized rescue party dialogs under recovery mode
with pre-generated images, it becomes necessary to show the menu headers
and items with images.

This cl converts the menu class to a interface and derived TextMenu &
GraphicMenu classes. And the GraphicMenu uses GRSurfaces* as the menu header
and a list of GRSurfaces* as menu items.

Moreover, factor out the Draw* functions in the ScreenUI into a separate
DrawInterface. Therefore, the Menu class can access these draw functions and
use them to implement the DrawHeaders & DrawItems neatly.

Bug: 74397117
Test: unittests pass, boot into recovery and check menu
Change-Id: I95cee30f3e5eb666eb6fbcdfc873a7260fc177c1
2018-10-12 17:18:50 -07:00
Tao Bao
0bc88de7aa ui: Read custom recovery UI values via system property.
The matching change to build system now writes these values as build
properties for recovery image. This allows us dropping the dependency on
Android.mk (as well as having more flexibility to do UI customization).

Also rename a few constant names, as the naming doesn't fully follow the
style guide (which reads "whose value is fixed for the duration of the
program").

Bug: 110380063
Test: Build and flash recovery image on taimen, which uses custom margin
      height. Check the UI and choose `Run graphics test`.
Change-Id: I2c50326123639cb36022f51b62cdeed925d77ba7
2018-07-31 15:14:40 -07:00
Jerry Zhang
b76af93ab5 recovery: Add ability to interrupt UI
Normally calling a UI method will block
indefinitely until the UI is actually
used. This creates a method to interrupt
the UI, causing waitKey to return -2. This
in turn, will cause ShowMenu to return -2.
This allows switching between recovery and
fastbootd via usb commands.

Test: adb shell /data/nativetest64/recovery_unit_test/recovery_unit_test
Bug: 78793464
Change-Id: I4c6c9aa18d79070877841a5c9818acf723fa6096
2018-07-30 20:17:27 +00:00
Tao Bao
ba4edb3e82 screen_ui: Move the call to gr_init() into Init().
gr_init() does general initialization works, in addition to loading font
file. InitTextParams() handles text related works.

Also check the font initialization result before using, as gr_init()
would ignore font initialization failures.

Test: recovery_unit_test on marlin.
Test: Boot into recovery. Run graphics test.
Change-Id: I12da22dfe8d13448cfbc83dbc51cd96f23c2deee
2018-06-13 16:18:46 -07:00
Tao Bao
60ac622245 screen_ui: Call gr_exit() from dtor.
ScreenRecoveryUI calls gr_init() during Init(), and should release any
allocated resource upon destructing. It's a no-op to call gr_exit() if
gr_init() was not called or didn't finish successfully.

Test: recovery_unit_test on marlin.
Test: Boot into recovery. Run graphics test.
Change-Id: Ib9632170174cdacd51d382f23c8daf6a9bc59f7a
2018-06-13 16:17:53 -07:00
Tao Bao
94371fd012 ui: join only if joinable.
The threads in RecoveryUI only get initialized if their Init()s finish
successfully.

Test: recovery_unit_test on marlin.
Change-Id: Ic4b62300a3cbd47887d9f4a90dc26f8a7deab616
2018-06-06 07:49:47 -07:00
Jerry Zhang
b31f9ce6d1 recovery: c++ify pthread use in UI
Change pthread usage to std::mutex,
lock_guard, unique_lock, thread, or
condition_variable as appropriate.

Test: Recovery works, recovery_component_test pass
Bug: 78793464
Change-Id: Ibf0b1bbedcf0b6e32fc4ee6aaadd17f21b4d7077
2018-05-29 15:20:58 -07:00
Tao Bao
26ea9591bc ui: Use std::thread to create input/progress threads.
Test: Build and boot into recovery on walleye. Check the long press
      detection; `Run graphics test`.
Change-Id: Ic3e9b0652fc3ff6fb3ad118df5ebb9bb4abda2cd
2018-05-21 16:37:07 -07:00
Jerry Zhang
0e577ee424 recovery: Add ability to set title lines
Add the ability to change the contents of
the title lines, displayed at the top of
the screen. Once set, the same lines are
displayed for all menus until changed again.

Test: Recovery works
Bug: 78793464
Change-Id: I7ef5594b0d76dbbd2e01ad7508863af1270b2a2a
2018-05-21 16:37:07 -07:00
Treehugger Robot
13d56e9bed Merge "screen_ui: Fix an issue in RTL locale detection." 2018-05-11 21:46:52 +00:00
Tao Bao
8c6f699b36 Merge "tests: Add tests for ScreenRecoveryUI." 2018-05-11 20:06:22 +00:00
Tao Bao
551d2c3181 Device owns the RecoveryUI instance.
Test: mmma -j bootable/recovery
Test: Build and boot into recovery, w/ and w/o enabling quiescent mode
      respectively.
Change-Id: I5d9bb945a6c3c9a3b96199fa0c8071a2f91339a0
2018-05-09 21:22:26 -07:00
Tao Bao
452b487f31 screen_ui: Fix an issue when displaying wrapped text.
The last character at EOL is cut when showing the prompt-for-data-wipe
message on angler. Address the issue by keeping symmetrical margins
based on the given offset.

Test: Trigger prompt-and-wipe-data menu. No cutout character at EOL.
Change-Id: Id6e8dc7815bf681435bcaf13e7bdd09cf870d95f
2018-05-09 12:32:27 -07:00
Tao Bao
347a659d9b screen_ui: Fix an issue in RTL locale detection.
The CL in [1] moved android.os.RecoverySystem to send the locale
argument in well-formed BCP 47 language tags (e.g. "en-US" instead of
"en_US"), with the matching changes to recovery code in [2]. However,
the one in ScreenRecoveryUI::SetLocale() was missed, which broke RTL
locale detection when using new format.

[1] commit 38715228 in platform/frameworks/base
[2] commit 2078b22e in platform/bootable/recovery

Test: Set the locale to "ar-EG". `Run graphics test` under recovery.
      Check the progress bar.
Test: Run recovery_unit_test on marlin.
Change-Id: I7c7f5e0725bfb096109c7192c19f3f008e8e47e3
2018-05-08 17:56:33 -07:00
Tao Bao
6cd816859e tests: Add tests for ScreenRecoveryUI.
In order to support that, this CL adds Paths::set_resource_dir() to
override the default resource dir ("/res/images/") that's only available
under recovery. Note that since there're external modules depending on
libminui, it adds a separate function of res_set_resource_dir(), instead
of requiring the dependency on libotautil for everyone.

Test: mmma -j bootable/recovery
Test: Run recovery_unit_test on marlin.
Change-Id: I0a7dcf4476808bea9e634eaffc9676f6cbaf92b7
2018-05-08 15:53:56 -07:00
Tao Bao
39c4918a40 screen_ui: Drop the parameter in CheckBackgroundTextImages.
ScreenRecoveryUI already has the info in locale_.

Also when showing "Current locale: X/Y" on screen, use 1-based index for
X, so that we have 1 <= X <= Y.

Test: Build anf flash recovery image on aosp_bullhead-userdebug. Choose
      `Run locale test` from UI.
Change-Id: I5dd4de82e63890ddf755f4e23cd2290ad5d50ece
2018-05-07 23:50:50 -07:00
Jerry Zhang
2dea53ef2b recovery: Get UI and locale from device.
This removes some reliance on the global
locale and ui variables.

Test: Recovery works
Bug: 78793464
Change-Id: I78f1a2b321f5d50aa58b10735a73ae137283353a
2018-05-08 06:09:54 +00:00
Tao Bao
1fe1afe863 Move menu headers/items to std::vector<std::string>.
Test: mmma -j bootable/recovery
Test: Run recovery_unit_test on marlin.
Test: Build and boot into recovery image on angler. Check the UI that
      shows menu ('View recovery log', 'Wipe data', 'Run locale test').
Test: Start recovery with '--prompt_and_wipe_data'. Check the UI.
Change-Id: If8a4209e0bb4ca64f719f9f9465d3b3589a69cdc
2018-05-03 12:31:18 -07:00
Tao Bao
e02a5b248b screen_ui: Merge Menu::Start() into its ctor.
Since we instantiate a Menu object each time for a given set of
header/items, we don't have a use case of re-populating an existing Menu
with different data (which is what Menu::Start() does).

Test: mmma -j bootable/recovery
Test: Run recovery_unit_test on marlin.
Test: Build and boot into recovery image on angler. Check the UI.
Change-Id: Iaa2ba9d406ebd74c015e43198c17c5335b38df53
2018-05-02 19:30:15 -07:00
Tao Bao
93e46ad426 screen_ui: Use std::string in DrawTextLine() and siblings.
Test: mmma -j bootable/recovery
Test: Build and boot into recovery image on angler. Check the UI.
Test: Repeat the same test on devices using wearable UI.
Change-Id: I1a67ff4ae8de4d7a8dc66326cf07f95c89e95152
2018-05-02 15:32:48 -07:00
Tao Bao
1d156b9882 screen_ui: Drop the dependency on common.h.
Remove the use of fopen_path() in screen_ui.cpp, as this is the only
place that requires the dependency on common.h. The mounting work should
be done by the caller.

Also change the parameter in RecoveryUI::ShowFile() from const char* to
const std::string&.

Test: mmma -j bootable/recovery
Test: Build and boot into recovery image on angler. Choose 'View
      recovery logs'.
Change-Id: I8e63f14a8e2b12b856e5a92476e4226cd6ea39fb
2018-05-02 12:46:21 -07:00
Tao Bao
3aec6965bf Add ScreenRecoveryUI::ShowMenu().
From caller's PoV, RecoveryUI::{Start,Select,End}Menu should always be
used together, i.e. to show a menu and get user's selection. This CL
provides ShowMenu() as one-stop service (which is based on
get_menu_selection() from recovery.cpp).

Also move RecoveryUI::{Start,Select,End}Menu into ScreenRecoveryUI, with
a dropped access level from public to protected.

Due to the dependency on recovery / librecovery refactoring, will add
testcases in follow-up CLs.

Test: Build and boot into recovery image. Check the menus (main menu,
      'View recovery logs', 'Wipe data/factory reset').
Change-Id: Ie17aa78144871a12affd6f9075e045f76608a0ba
2018-05-01 10:27:40 -07:00
Tianjie Xu
5fe5eb67ef Factor out a menu class for screen ui
Also consolidate the duplicate codes to draw the menu in ScreenRecoveryUI
and WearRecoveryUI. This helps us to support text icons as menu in the
future.

Bug: 74397117
Test: Check the menu under recovery on bullhead and a wear device.
Change-Id: Iba9b646c3828670f0e78a7e07d1a94a44e96bb0b
Merged-In: Iba9b646c3828670f0e78a7e07d1a94a44e96bb0b
2018-03-23 23:57:29 -07:00
Luke Song
92eda4db6c vr_ui: drawing changes
Change drawing of horizontal bars.
Implement image and background drawing.

Bug: 65556996
Test: Viewed graphics test
Change-Id: I68ddd997123607dbebf972af5a455ce8ef0c7075
2017-10-05 12:02:13 -07:00
Luke Song
eee1e7656f screen_ui: stage marker positioning
Small fix to position stage markers above screen margin.

Bug: 65556996
Test: Viewed graphics test
Change-Id: Idb4a56b06b8ec4e6653b3d3f3a446fa491f5ccb7
2017-09-29 14:19:23 -07:00
Tianjie Xu
29d5575fa8 Add a new option in recovery menu to test the background texts
Add a new option "Run locale test" to check the background text
images (i.e. texts for "erasing", "error", "no_command" and "installing"
with different locales.)

Use volume up/down button to cycle through all the locales embedded in
the png file, and power button to go back to recovery main menu.

Test: Run locale test with bullhead.
Change-Id: Ib16e119f372110cdb5e611ef497b0f9b9b418f51
2017-09-27 00:27:38 -07:00
Tao Bao
efb49add97 ui: Move locale and friends into ScreenRecoveryUI class.
Localized texts only make sense on devices with screens.

Test: Run fake OTA on angler; check the on-screen texts.
Change-Id: I3a644294c8b1f2056cfb78b2d61a598b8ddf2acf
2017-09-11 12:19:32 -07:00
Tao Bao
568644197f Merge "ui: Remove text_top_." 2017-09-11 19:06:12 +00:00
Tao Bao
7577965ba1 ui: Refactor the declaration orders.
By grouping similar kinds together, in an order of types, constants,
ctor/dtor, all other methods and data members.

Also rename ScreenRecoveryUI::density_ to ScreenRecoveryUI::kDensity to
align with others.

Test: mmma bootable/recovery
Change-Id: I1ba2d15c05ba7be8c39762f3d9dadf1fb2130de4
2017-09-10 11:36:54 -07:00
Tao Bao
cb5524c23a ui: Remove text_top_.
After the cleanup to WearRecoveryUI, text_top_ now always equals to
((text_row_ + 1) % text_rows_).

Test: Check the recovery UI and 'View recovery logs'.
Change-Id: I69a7f377bbd990db2194f9d3efae257c323c06a8
2017-09-08 23:31:31 -07:00
Tao Bao
e15d7a5104 ui: Manage menu_ with std::vector.
Prior to this CL, menu_ is allocated with a fixed length of text_rows_.
However, because we support scrollable menu in wear_ui, there might be
more menu entries than text_rows_, which would lead to out-of-bounds
array access. This CL addresses the issue by switching to std::vector.

Bug: 65416558
Test: Run 'View recovery logs' on angler.
Test: Set large margin height that leaves text_rows less than 21. Then
      run 'View recovery logs' with 21 menu entries.
Change-Id: I5d4e3a0a097039e1104eda7d494c6269053dc894
2017-09-08 10:50:07 -07:00
Tao Bao
89ad02206a Merge changes I5d7a6baa,Id0fb2d4e
* changes:
  wear_ui: Expose menu_unusable_rows via Makefile var.
  Allow customizing WearRecoveryUI via Makefile variables.
2017-08-22 17:44:16 +00:00
Tao Bao
13aa4a902b screen_ui: Fix a case that may truncate the last char.
ScreenRecoveryUI::DrawWrappedTextLines() should be called with
kMarginWidth only. Because it's using a line limit of text_cols_,
which is unaware of kMenuIdent.

Bug: 64293520
Test: No missing char with long header text.
Change-Id: Ib4d08de2c56473a483ff9964eb6cec31f8a74c9a
2017-08-16 13:38:17 -07:00
Tao Bao
2bbc6d642d screen_ui: Word-wrap menu headers.
This CL adds ScreenRecoveryUI::DrawWrappedTextLines() to better handle
long menu header texts. It does a word wrap at spaces, if available.
This avoids fixed-length menu headers being truncated on small screens.

Bug: 64293520
Test: On bullhead, boot into recovery with --prompt_and_wipe_data, and
      check the prompt texts.
Change-Id: Ia22746583516dd230567a267584aca558429395e
2017-08-15 15:10:21 -07:00
Tao Bao
0470ceea38 Allow customizing WearRecoveryUI via Makefile variables.
With the following Makefile variables, we can reduce the work of writing
(copy/pasting) device-specific WearRecoveryUI classes.

The list of Makefile variables (the ones useful for Wear devices):
- TARGET_RECOVERY_UI_MARGIN_HEIGHT (default: 0)
- TARGET_RECOVERY_UI_MARGIN_WIDTH (default: 0)
  Specify the margin space that we don't want to display texts. They
  replace the former outer_width and outer_height.

- TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD (default: 50)
- TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD (default: 90)
  Specify the sensitivity of recognizing a swipe. Devices give absolute
  positions, so for some devices we need to adjust the thresholds.

- TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE
  Specify the progress bar vertical position, which should be adjusted
  to the actual height of a device. It replaces the former
  progress_bar_y.

- TARGET_RECOVERY_UI_ANIMATION_FPS (default: 30)
  Specify the animation FPS if using device-specific animation images.
  It replaces the former animation_fps.

Devices can specify "TARGET_RECOVERY_UI_LIB := librecovery_ui_wear",
with optionally defined Makefile vars above, in BoardConfig.mk to
customize their WearRecoveryUI.

Also remove the obsolete wear_touch.{cpp,h}, which has been merged into
ui.cpp in commit 5f8dd9951d.

Bug: 64307776
Test: Change the device BoardConfig.mk and test recovery image.
Change-Id: Id0fb2d4e3977ab5ddd31e71f9535470cab70e41b
2017-08-10 09:31:17 -07:00
Tao Bao
ca6ce2c848 Fix the missing char when showing recovery logs.
This is a regression when adding support for margin space in commit
171b4c4c.

We're losing one char when showing long log lines. Because text_ is
aware of kMarginWidth, but not the the added indent (TEXT_INDENT).

Test: 'View recovery logs' on angler, with no missing character.
Change-Id: I284d54681d603e85e69d8e9c25173b1437a704df
2017-07-13 11:44:11 -07:00
Tao Bao
ea78d86b44 Update ScreenRecoveryUI::Draw* function signatures.
Move away from taking int* for the Y-offset. Change it to int and return
the offset instead.

Test: Check the recovery menu and 'Wipe data' menu.
Change-Id: Ib15e070a0d576a0f8f66f35605cb8479e7071f26
2017-07-01 17:41:24 -07:00
Tao Bao
3250f72360 screen_ui: Compute the top and bottom gaps.
We're not actually following the gaps as in the comments. For example,
Nexus 6P is supposed to use 220dp and 194dp gaps (top and bottom
respectively), but the actual numbers are 185dp and 194dp. Because the
animation icon and text sizes don't match the ones claimed (animation:
expected 200dp or 700px, actual 800px; text: claimed 14sp, actual 76px).
The top gap changes (shrinks) as we compute the baselines bottom-up.

This CL switches to using computed gaps: the major UI elements always
stay vertically centered, with identical top and bottom gaps.

Bug: 63093285
Test: 'Run graphics test' on angler/volantis/fugu/ryu.
Change-Id: I3cadbb34f728cf034afa47ac02a6deba8cb6b4e7
2017-06-29 14:59:08 -07:00
Tao Bao
99b2d77475 Add override specifier and member constness to RecoveryUI classes.
Test: mmma bootable/recovery
Change-Id: I66e328614423488a4027d7878f4569fbf3a3721e
2017-06-23 23:06:01 -07:00
Tao Bao
5d2e3bd109 Formatting RecoveryUI related files.
All cosmetic changes about indentation reformatting in this CL.

Test: mmma bootable/recovery
Change-Id: I4539e6244697d1f356b7eb10b961b52d7db561f7
2017-06-23 23:05:56 -07:00
Luke Song
9d4839c60f Restructure vr_ui
Get rid of pixel offset variables, and use makefile variables in
BoardConfigs.

Bug: 37779982
Test: Verified vr ui has same behavior.
Change-Id: Ifbf44e27d7101aedbe3c0e6db4b8181d56efadfd
(cherry picked from commit 81a8e4cab2)
2017-06-23 16:51:00 -07:00
Tao Bao
4521b7027f Use Makefile variables to specify margin settings.
Instead of defining device-specific UI class, this CL allows using
Makefile variables to specify margin values directly.

Values explicitly defined via TARGET_RECOVERY_UI_MARGIN_HEIGHT and
TARGET_RECOVERY_UI_MARGIN_WIDTH will be used. Otherwise they will
default to zero.

Bug: 62732748
Test: Specify the height and width and check recovery texts.
Change-Id: Icb6f7466c8d407f877b93da38aebfdf7e6b41be7
(cherry picked from commit a92d8fb456)
2017-06-23 09:22:34 -07:00