Commit graph

204 commits

Author SHA1 Message Date
Tao Bao
835bf09a14 minui: Managed FDs with smart pointers.
Also clean up a few variable names.

Test: Boot into recovery. Check key inputs.
Change-Id: I058475ac22f3db8523bd8aa30ccb61be1ef45559
2019-03-11 15:59:09 -07:00
Tao Bao
dfdf63501e minui: Fix the wrong move of the callback.
The input_cb in ev_init() should be shared among the detected input
devices.

Test: Boot into recovery. Check key inputs.
Change-Id: I0315f6a23625bacedd333fefacbf4ac6797bc1fd
2019-03-11 12:07:11 -07:00
Tao Bao
b549243b27 Use O_CLOEXEC at a few places.
Found these FDs unintentionally propagated into forked processes (e.g.
updater) during my local debugging. Use O_CLOEXEC to avoid that.

Test: Dump open FDs in updater process.
Test: Sideload a package on taimen (which uses framebuffer).
Test: Run graphics test on taimen.
Change-Id: I1fb65dd4a103c47d28b15973def9e9359c251ca3
2019-03-01 14:24:41 -08:00
Nick Kralevich
39c53c8ac9 use epoll_create1
epoll_create leaks file descriptors. Use epoll_create1(EPOLL_CLOEXEC)
instead.

Bug: 120983106
Test: compiles and boots
Change-Id: I91f213ebb2dd05330dd25ec1ca1fec59b611e7f2
2018-12-17 08:51:38 -08: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
2201d08f8d minui: Fix a wrong arg in calling GRSurface::Create().
This is a bug introduced while refactoring init_display_surface(), in
[1]. As a result, user of res_create_multi_display_surface(), which is
effectively `charger` right now, crashes due to buffer overrun.

This CL fixes the wrong arg and adds a sanity test for
res_create_multi_display_surface(). The testdata (battery_scale.png) is
copied from system/core/healthd/images/battery_scale.png.

[1] commit 44820ac1e3.

Bug: 119122296
Test: Run recovery_unit_test on marlin.
Test: Build and boot into charger mode on blueline. Verify that
      `charger` no longer crashes.
Change-Id: Ib6d083e1512a9c3c6eb63874d26d22658921d693
2018-11-26 17:06:53 -08:00
Tao Bao
9cf163e673 minui: GRSurface manages data with std::unique_ptr.
Test: Run recovery_unit_test on marlin.
Test: `Run graphics test` on taimen.
Change-Id: I34bd862049900b0030f2840a92a7fa3e02fa2c10
2018-11-07 14:36:45 -08:00
Tao Bao
f65d48bb5a minui: Use android::base::unique_fd in MinuiBackendFbdev.
Test: mmma -j bootable/recovery
Test: `Run graphics test` on taimen.
Change-Id: I5b25cafbd0107943606a87f0619242cf950174ac
2018-11-02 09:35:08 -07:00
Tao Bao
63b59dcead minui: Add GRSurface::Clone().
Clone() allows duplicating the image that's stored in the GRSurface.

Test: Run recovery_unit_test.
Change-Id: Ia50d507c6200f2de5f17143775de805247a60e1f
2018-11-01 12:14:46 -07:00
Tao Bao
710bc535f4 minui: Remove the default and copy ctors for GRSurface.
As well as all the derived classes. Instances must be created with
Create(). A default copy ctor would mess up the ownership of the
mapped or allocated buffer in these classes, so that has been explicitly
removed.

Test: mmma -j bootable/recovery
Test: Run recovery_unit_test on marlin.
Test: `Run graphics test` on blueline.
Change-Id: I69ce001a9ec9e3ac851edb6ec4d3fa11f4aaea08
2018-10-31 20:28:29 -07:00
Tao Bao
1b18cf56e2 minui: Refactor GRSurfaceAdf.
Test: mmma -j bootable/recovery
Change-Id: I14514017aace4b7043a9db1f5a93ec130a6f89c4
2018-10-31 20:28:29 -07:00
Tao Bao
4a22b28bea minui: Refactor GRSurfaceFbdev.
- Adds Create() that returns a GRSurfaceFbdev instance.
- Moves away from using the copy ctor (precisely assignment operator) of
  GRSurfaceFbdev.
- Moves the GRSurfaceFbdev deallocation code into GRSurfaceFbdev's dtor.
- Manages MinuiBackendFbdev::gr_framebuffer with std::unique_ptr.

Test: mmma -j bootable/recovery
Test: `Run graphics test` on taimen.
Change-Id: I8e67cda7bc3a2feec0790124d035caa36fb58a89
2018-10-31 20:28:29 -07:00
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