summaryrefslogtreecommitdiff
path: root/libs/androidfw/AssetManager.cpp
diff options
context:
space:
mode:
author Pi-Hsun Shih <pihsun@google.com> 2025-02-20 17:04:26 +0800
committer Pi-Hsun Shih <pihsun@google.com> 2025-02-25 13:58:22 +0800
commit2f71bdb46b1080943764cafd2fd140be632251ac (patch)
tree60282625c828c79aeaada9b9fc308c9984fda99b /libs/androidfw/AssetManager.cpp
parent2fef05b45c373cced71e4920eb7f6f528f4e3347 (diff)
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
Diffstat (limited to 'libs/androidfw/AssetManager.cpp')
0 files changed, 0 insertions, 0 deletions