Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 2f71bdb4 authored by Pi-Hsun Shih's avatar Pi-Hsun Shih
Browse files

Centerly crop QR preview and better handling on camera orientation.

In Camera API, front camera is by default mirrored in preview but the
returned image isn't mirrored. This wasn't handled correctly by QR
camera, such that the image passed to QR scanner is cropped at a
different region as the preview.

To fix this, change QR camera to crop the preview at the center of the
camera frame instead. This ensure that the preview is the same as what's
passed to the QR scanner.

Also fix several assumption in the original code:
* The `setDisplayOrientation` calculation didn't take account of front
  camera mirroring.
* `setTransformationMatrix` didn't handle the case when the camera
  orientation isn't the same as the display orientation.
* Multiple places that assumes the `getViewSize` returns a square view,
  in particular:
  * `setTransformationMatrix` assumed that the client viewSize is always
    a square.
  * The `getBestPreviewSize` incorrectly consider a 3:4 view "best
    match" with a 4:3 camera preview. This wasn't an issue since the
    viewSize was always 1:1.
* The `getFramePosition` is deprecated since the frame position is now
  directly calculated from the view size and the preview size.

Note that this would need further change if/when we need to support
device with only external camera, since the display orientation won't be
directly related to the camera orientation in that case.

Flag: EXEMPT bugfix
Bug: 389207330
Test: manually, check preview is centered with the camera.
Test: manually, check the QR code can be scanned when placed on each
corner of the preview.
Test: manually, check the QR code can't be scanned when placed partially
outside of each corner of the preview.
Test: manually, check QR scanning works fine if the client view aspect
ratio isn't 1:1.
Test: `atest SettingsRoboTests` passed.
Test: `atest SettingsLibRoboTests` and check all failure are unrelated.

Change-Id: Ib0db547e58746e3102b93d0a0c2e3e2b7c76ee4c
parent 2fef05b4
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment