Commit graph

192 commits

Author SHA1 Message Date
Tao Bao
44820ac1e3 minui: Add a protected GRSurface ctor.
This prepares for the removal of the default and copy ctors, by making
GRSurface::Create() as the only way to get GRSurface instances.

Test: mmma -j bootable/recovery
Test: Run recovery_unit_test on marlin.
Change-Id: I0c34c3f3967e252deb020907c83acbac8a8f36b9
2018-10-31 11:19:28 -07:00
Tao Bao
d096d7e5a9 minui: Cleanup GRSurfaceDrm and MinuiBackendDrm.
This CL adds a dtor to GRSurfaceDrm that handles the resource
deallocation. It also manages MinuiBackendDrm::GRSurfaceDrms with smart
pointers.

Test: Build and boot into recovery on blueline. `Run graphics test`.
Change-Id: Iff7bbdddbc0b5ab16483d00870794fca9f832bd5
2018-10-24 09:38:34 -07:00
Tao Bao
92bdb5a389 minui: Move GRSurface into a class.
This CL adds GRSurface::Create() and dtor for managing the allocated
memory in GRSurface class. It also adds GRSurface::data() that hides the
underlying implementation, with both of const and non-const overloads.
This allows `const GRSurface&` to be more useful - previously it only
ensured a const member variable of `data`, instead of a read-only buffer
it points to.

It also marks the parameters in gr_texticon() and gr_blit() as const, as
they're incoming source that shouldn't be altered. It corrects the type
of gr_draw, which is the sink to be painted on (an earlier attempt was
made in [1], but didn't get the full picture correctly).

[1] https://android-review.googlesource.com/c/platform/bootable/recovery/+/704757/

Test: mmma -j bootable/recovery
Test: recovery_unit_test on marlin
Test: Run graphics test on marlin (fbdev).
Test: Run graphics test on blueline (drm).
Change-Id: I7904df084cd6c08fa04a9da97d01b4b1a6e3a20c
2018-10-22 18:18:02 -07:00
Tao Bao
050feb0153 minui: Track the name change to minui related properties.
These properties need to be exposed to both of charger and recovery.
This CL tracks the name change.

Bug: 113567255
Test: Build along with other CLs in the topic (for Makefile and
      sepolicy changes). Boot into charger mode.
Test: Boot into recovery. Run graphics test.
Change-Id: I4d90778c1767c9bd7e00830a34ee2d4875ce0b83
2018-09-05 21:47:19 -07:00
Tao Bao
818f938188 recovery uses more shared libraries.
Bug: 110380063
Test: `m -j installclean && mmma -j bootable/recovery` with
      aosp_taimen-userdebug
Test: Build (`m -j bootimage`) and boot into recovery. Check that
      `adb sideload` and `Run graphics test` both work.
Test: Run recovery_unit_test and recovery_component_test on marlin.
Change-Id: Ie6ed0e7cafa352d5faff9d1b6ccef724a0415e65
2018-08-08 14:26:27 -07:00
Tao Bao
60924fa89a Merge "minui: Track libsync module name change." 2018-08-08 00:26:38 +00:00
Tao Bao
1c4d4bf4f4 minui: Track libsync module name change.
Needs the matching change to libsync_recovery.

Test: `mmma -j bootable/recovery`
Change-Id: I69b5c978e9b4d16957ffecd360796b29cd95865c
2018-08-07 11:04:27 -07:00
tangrobin
13bec76662 Fix the DRM_FORMAT match with corresponding PixelFormat
The DRM_FORMAT settings in DrmCreateSurface should match with the
correct PixelFormat

Bug: 112245291
Test: build and flash boot image to device.
Change-Id: I3ee0de38256d1109cd5174b666e2f47dceb637e6
2018-08-07 10:10:33 -07:00
Tao Bao
7ee83f627e minui: Move to Soong.
Note that although libminui says "shared_libs" in Android.bp file,
`recovery` binary will still statically link the libs, until we drop the
`LOCAL_FORCE_STATIC_EXECUTABLE := true` flag from `recovery` module.

Bug: 110380063
Test: `mmma -j bootable/recovery` with aosp_taimen-userdebug
Test: Boot into recovery and `Run graphics test`.
Change-Id: I48785d161dfe52eb01667e938d9c3f0a497b61a2
2018-08-05 14:42:26 -07:00
Tao Bao
ed876a7175 minui: Use runtime properties instead of build time vars.
This CL removes the use of the following build time macros, and uses the
runtime property values instead.
- TARGET_RECOVERY_PIXEL_FORMAT
- TARGET_RECOVERY_OVERSCAN_PERCENT
- TARGET_RECOVERY_DEFAULT_ROTATION

Bug: 110380063
Test: Set up taimen with `TARGET_RECOVERY_DEFAULT_ROTATION := ROTATION_LEFT`.
      Build and check recovery UI.
Test: Set up taimen with `TARGET_RECOVERY_PIXEL_FORMAT := ABGR_8888`.
      Build and check recovery UI.
Change-Id: I4439556a03fde4805a18011ef72eff1373f31d47
2018-08-01 15:36:41 -07:00
Tao Bao
44478dfb7d minui: Clean up the use of rotation.
This CL uses scoped enum for GRRotation. It also refactors the previous
comparisions to improve readability -- it was hard to tell the meaning
of `if (rotation % 2)` unless by checking the exact values.

It also temporarily adds STRINGFY to expand the macro of
DEFAULT_ROTATION. This will be removed once minui is changed from
reading build time vars to runtime properties.

Test: Build and boot into recovery image on marlin.
Test: Set `TARGET_RECOVERY_DEFAULT_ROTATION := ROTATION_LEFT` and check
      the display under recovery with `Run graphics test`.
Change-Id: Ieb08b1cd13c284f8dcf906cb2a1430c6bae2835b
2018-08-01 12:30:27 -07:00
Jeremy Compostella
955da1e26d minui/drm: wait for page flip completion
If two consecutive call are made to drmModePageFlip, the second call
may fail with -EBUSY because the first flip is not completed yet.

This patch adds a wait for completion mechanism based on
drmHandleEvent.

Change-Id: Ied13ebefc7523003431b1b307bae70d1a70cb24b
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
Signed-off-by: Benoit Fradin <benoit.fradin@intel.com>
2018-07-03 17:43:06 +00:00
Tao Bao
9f4263346b minui: Add constness to GRSurface* in gr_get_{width,height}.
Also free gr_font in gr_exit(), as it's owned by minui.

Test: mmma -j bootable/recovery system/core/healthd
Test: recovery_unit_test on marlin
Test: Boot into recovery. Run graphics test.
Change-Id: I00457bb97ed3dc95ef5aad493827fb5a62a258dc
2018-06-13 13:24:58 -07:00
Tianjie Xu
ccf00a2007 minui: Handle the failures from the drm backend in gr_init
In a charger mode manual test, we encounter failures from the
MinuiBackendDrm when calling DrmEnableCrtc and Flip. To make the minui
more robust, we should fall back to another backend if drm's SetCrtc
fails. And check the value of gr_draw before dereferencing.

Bug: 80249440
Test: boot to recovery
Change-Id: Ibd1ca1fb1115fe1132684586c54eccd8fb4c3ad9
2018-06-05 17:10:23 -07:00
Tianjie Xu
842f2a3dca Let gr_init proceed even if we failed to load a font file
Some users of minui don't need to draw texts; and we should let them
still be able to use the library without providing a font file. Also add
check for null pointers in gr_measure() and gr_font_size().

Bug: 80535212
Test: boot into recovery without a font file, and the buttons still work
Change-Id: I848e4410f2ce09ea0ab433573e6827b7e9b2c575
2018-05-31 21:42:58 -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
3d0cd1d036 Expose PngHandler via resources.h.
As a private header for testing purpose. PngHandler additionally loads a
given filename if the one with '/res/images' prefix is not available. It
also provides color_type/bit_depth that are parsed from the PNG file.

This allows reusing the same code for the ResourcesTest (renamed from
ResourceTest).

Test: Run recovery_manual_test on marlin.
Change-Id: I3f939d79a1cb1b83a899847dbe2d51bde15d16d8
2018-04-13 15:25:50 -07:00
Tianjie Xu
55a2c4eaae Remove the obsolete mkfont.c and font_10x18.h
The font_10x18.h is used as a fall back for fonts if the
$(recovery_font) under bootable/recovery/fonts failed to reload. This
font looks very small on the screen and we haven't used it in a while.
Plus, fonts in header doesn't have many benefits if we support only
ascii characters. So we decide to remove this header along with the mkfont.c
that generates the header.

For reference, here's the steps to use mkfont:
1. Generate a picture of fonts with apps on host
2. Open the pic with GIMP
3. Export the pic as '.c' file, and rename it into '.h' file
4. Compile the generated '.h' file with mkfont.c

Bug: 76420958
Test: build and check the recovery menu on angler
Change-Id: I6c108aa43a07bf4994115ef764275bd84df725e1
2018-03-30 06:42:35 +00:00
Elliott Hughes
1d65c95fe8 StartsWith allows a std::string prefix now.
Bug: N/A
Test: builds
Change-Id: I5183ec8133f5dc9a81a438223c6d3d2ea11ef0ec
2017-12-20 12:36:31 -08:00
Dan Willemsen
2ee9266827 libdrm_platform is now libdrm
Since it's converted to Soong and is using vendor_available.

Test: mmma bootable/recovery
Change-Id: I57b40c26abc2f6031241de893b3184ed1283e1fe
2017-10-19 22:30:57 -07:00
Jiyong Park
647e396445 Build libminui with BOARD_VNDK_VERSION
Use libdrm_platform which is a platform variant of libdrm.

Bug: 63741047
Bug: 37342627
Test: BOARD_VNDK_VERSION=current m -j libminui
Test: ryu recovery graphics test shows various graphics
Change-Id: Ifd2c1432781a96538585cdf818aa728d628a2f5a
Merged-In: Ifd2c1432781a96538585cdf818aa728d628a2f5a
2017-10-19 16:45:23 -07:00
Tao Bao
a0e9742796 Merge "Drop -Wno-unused-parameter." 2017-10-12 03:22:17 +00:00
Tao Bao
99f0d9e52b Drop -Wno-unused-parameter.
The only one left is libedify. Will handle that in a separate CL.

Test: mmma bootable/recovery
Change-Id: I732a5f85229da90fd767bee2e46c5c95f529c396
2017-10-11 16:56:12 -07:00
Dan Albert
c8686b493c Add missing includes.
Test: mma
Bug: None
Change-Id: I8b588dfbc00ef67557622d44700b331c7a31bde3
2017-10-11 11:47:54 -07:00
Tao Bao
9baa19012a Merge "graphics: add rotation logic" 2017-10-05 19:00:50 +00:00
Tianjie Xu
acba38c288 Move the png open and destroy functions into a class
The open_png() function used to open the png file but didn't close it;
and this caused the leak of fd. However, we cannot close the file inside
open_png() because the png file needs to remain open until the outer
function finishes parsing the file and destroys the png struct.

This CL addresses this issue by implementing a PngReader class to handle
the creation/destruction of the png struct.

Bug: 67010912
Test: Run graphic tests; also run locale tests and check fd.
Change-Id: I9a803b3cd8c16f16a9ffe8f0acc7fe0f42e95eb0
2017-09-28 15:29:37 -07:00
Luke Song
846012fc44 graphics: add rotation logic
Bug: 65556996
Bug: 63541890
Test: Tried 4 rotations, viewed logs and graphics test
Change-Id: I2a6c18c28df03f0461663f63bf16db32c45211ec
2017-09-28 14:11:35 -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
Tianjie Xu
c89d1e7e2a Turn on -Wall for recovery modules
Turn on -Wall for all modules. Also remove the obsolete file_cmp() in
apply_patch test and now() in wear_ui.

The only exception is lib_edify due to the unused functions in the
intermediate cpp files generated from the lex files. It will be handled
in a seperate CL.

Bug: 64939312
Test: mma, unit tests pass
Change-Id: Ic53f76b60b6401ab20db3d98130d674c08e3702f
2017-08-28 21:56:33 -07:00
Tao Bao
5daa000068 Merge "ui: Move the support for touch inputs into RecoveryUI."
am: faa5b1f773

Change-Id: Id81f4dca012f5af9000409e93c76a176f4f5b4d3
2017-08-03 18:24:22 +00:00
Tao Bao
5f8dd9951d ui: Move the support for touch inputs into RecoveryUI.
- Added detection for EV_ABS events in minui/events.cpp, if it's
  allowed;
- Added listening and processing touch inputs in ui.cpp;
- Fixed an issue in recognizing swipe with multi-touch protocol A;
- Changed the logic in RecoveryUI::ProcessKey() to be swipe-aware. It
  now allows turning on text mode with <power> + <swipe-up>.

The last change also fixed an issue on devices with protocol A: prior
to this CL, user may accidentally toggle the text mode during an OTA.
Because it was considered as a single-button device, a long tap that
sent BTN_TOUCH event would turn on text mode.

Test: Allow detecting touch inputs. Swiping (up, down, enter) works on
      angler, angelfish, dorado respectively.
Bug: 36169090
Change-Id: I4bc882b99114ce4ab414f8bdb8f4f7a525b8a8fd
2017-08-01 18:30:48 -07:00
Tianjie Xu
6d8827e0d3 Merge "Fix the android-cloexec-* warnings in bootable/recovery"
am: 94a8ea1797

Change-Id: I57ae57bab58f603540654bb24df9facca9a7d625
2017-07-19 23:06:50 +00:00
Tianjie Xu
de6735e80c Fix the android-cloexec-* warnings in bootable/recovery
Add the O_CLOEXEC or 'e' accordingly.

Bug: 63510015
Test: recovery tests pass
Change-Id: I7094bcc6af22c9687eb535116b2ca6a59178b303
2017-07-19 12:17:41 -07:00
Tao Bao
895e6fdf36 Merge "minui: Fix breakage in graphics_adf." am: 54da112277 am: d66f05b82c
am: 4cc6889da8

Change-Id: Id405586d2ff8a94a49c9cb649483dbb7ec645fd1
2017-04-29 18:55:26 +00:00
Alistair Strachan
4697d8b11b minui: Fix breakage in graphics_adf.
When graphics_adf was refactored in 557fa1f, a class member was introduced
that was not initialized to zero. This meant that the first time Flip()
was called, current_surface would have a junk value and cause a bad
pointer rereference, crashing recovery.

Make sure current_surface is initialized to 0 for the first Flip().

Test: Ran recovery on a device using the ADF backend.
Change-Id: I9b8fac0a4d48cac990e5e9808a071c232de1ebfb
2017-04-28 16:13:02 -07:00
Tianjie Xu
9166f66eee Merge "Add the missing sr-Latn into png files and rename the png locale header" am: 713d915636 am: dc235b5ab9
am: 5ec12126f0

Change-Id: Ia6b861c91958d3be23a4a7456d6d5d8e4a1607c8
2017-03-28 20:11:15 +00:00
Tianjie Xu
2078b22e41 Add the missing sr-Latn into png files and rename the png locale header
Switch the locale header in the png files from Locale.toString() to
Locale.toLanguageTag(). For example, en_US --> en-us and sr__#Latn
--> sr-Latn. Also clean up recovery a bit to expect the new locale
format.

Bug: 35215015
Test: sr-Latn shows correctly under graphic tests && recovery tests pass
Change-Id: Ic62bab7756cdc6e5f98f26076f7c2dd046f811db
2017-03-24 16:54:52 -07:00
Tao Bao
edc96fdc44 Merge "Add the missing #include of <functional>." am: dd553d280f am: 965021ab8d
am: 26d00e87f9

Change-Id: Ib707f1282c3280374a014fadd7f27580f8bedaf0
2017-03-17 15:55:49 +00:00
Tao Bao
9468fc0429 Add the missing #include of <functional>.
For the use of std::function and std::bind. They were relying on the
transitive inclusion from <minui/minui.h>.

Test: mmma bootable/recovery
Change-Id: Ia138e1cbdd035b11d6cdca9e16c5591303b6ee13
2017-03-17 01:00:25 -07:00
Elliott Hughes
1de1c7124e Merge "Add a missing #include for openat(2)." am: 3ac0dd2a56 am: cdfe2895b4
am: a82df97dd8

Change-Id: Ie157634ac0e83d168a980fe1b3c72664179551ce
2017-02-24 17:03:37 +00:00
Elliott Hughes
25a29d452e Add a missing #include for openat(2).
Bug: https://code.google.com/p/android/issues/detail?id=64374
Test: builds
Change-Id: I7d7650463197710657820a1adce51f71c1b01415
2017-02-23 10:45:42 -08:00
Tao Bao
16b509535b Merge "minui: Move graphics_{adf,drm,fbdev} into classes." am: 0d14cc279c am: 6585a3c368 am: b8997adc20
am: 1cb8964aac

Change-Id: I8b1fb8ba115f7313f7382b7669e35184eaea3a79
2017-02-13 18:42:16 +00:00
Tao Bao
557fa1f45e minui: Move graphics_{adf,drm,fbdev} into classes.
This CL defines minui_backend as an interface, and expresses the three
backends (adf, drm and fbdev) as subclasses to the interface.

Test: 'Run graphics test' on N9, Pixel C and N5X.
Change-Id: I0e23951c7b2e2ff918957a8d9fc8b0085b6e5952
2017-02-10 17:05:15 -08:00
Tao Bao
70cbe1d2e7 Merge "minui: Save errno before calling close()." am: df464dbe79 am: 8075089ca1 am: 30c164411f
am: 0b4641724b

Change-Id: I494ad8c5749290645f9850410789247e35d3bd41
2017-02-10 00:31:29 +00:00
Tao Bao
f04592ba23 minui: Save errno before calling close().
Otherwise errno would be overwritten when calling close(2).

Test: mmma bootable/recovery
Change-Id: I661e46b1b040f550639a728aa2683e91621b4307
2017-02-09 12:59:19 -08:00
Tao Bao
6812a80433 Merge "minui: Clean up graphics_fbdev.cpp." am: 5121961421 am: e91a2d23ca am: c441edd1c3
am: e799840d8d

Change-Id: I4d9b1ddb2819b59234a32cca15009adf018c91e6
2017-02-09 20:43:49 +00:00
Treehugger Robot
5121961421 Merge "minui: Clean up graphics_fbdev.cpp." 2017-02-09 20:31:02 +00:00
Tao Bao
3a683a0272 Merge "minui: Clean up graphics_adf.cpp." am: d592e1d5e1 am: 46829c326e am: ffd5c03711
am: ff7a320971

Change-Id: I5d6139d8ffd8f65f19caf24d3c17b090fe59bb4b
2017-02-09 20:18:47 +00:00
Tao Bao
d592e1d5e1 Merge "minui: Clean up graphics_adf.cpp." 2017-02-09 20:07:09 +00:00
Tao Bao
a40303bafc Merge "minui: Clean up graphics_drm.cpp." am: 648f252c71 am: f6b6b75916 am: ed5ee5292c
am: 0f38c6da12

Change-Id: I20e3c6b46345df5035d7077dbd3aaf0a2be58670
2017-02-09 20:01:17 +00:00