Skip to content

[MS-1493] Image injection in Debug versions for E2E tests - #1780

Open
alexandr-simprints wants to merge 7 commits into
mainfrom
feature/MS-1493-image-injection-impl
Open

[MS-1493] Image injection in Debug versions for E2E tests#1780
alexandr-simprints wants to merge 7 commits into
mainfrom
feature/MS-1493-image-injection-impl

Conversation

@alexandr-simprints

Copy link
Copy Markdown
Contributor

JIRA ticket
Will be released in: 2026.3.0

Notable changes

We can now easily inject images in Debug builds for any screen that uses camera. The images are injected by uploading the image to the device using adb push and notifying the app about the injection via the broadcast. Once an image is injected it overrides the image output from the camera until cleared.

  • InjectedImageCache - in-memory cache that keeps a single injected image
  • ImageInjectionReceiver - a broadcast receiver that listens for the com.simprints.automation.INJECT_FRAME broadcast with a frame attribute containing path to the image on the device.
  • FramePreProcessUseCase - once image is injected, we pre-process it to place it exactly in the middle of the area of interest. For instance, during the MFID document scan, the app only looks for the text in a certain rectangular area of the screen. This pre-processor scales the image to the area-of-interest size, and places the image in the middle of it.
image-injection.mp4

Testing guidance

There are two steps for image injection:

  1. Upload the image to the device in app directory
  2. Send a broadcast telling the app to inject said image

Example:

Uploading the face.jpg image from your laptop to device using adb

adb push /my-path/face.jpg /sdcard/Android/data/com.simprints.id/files/face.jpg

Sending broadcast:

adb shell am broadcast -a com.simprints.automation.INJECT_FRAME -p com.simprints.id --es frame face.jpg

After this, all screens will have this image injected on processed.

Additional work checklist

  • Effect on other features and security has been considered
  • Design document marked as "In development" (if applicable)
  • External (Gitbook) and internal (Confluence) Documentation is up to date (or ticket created)
  • Test cases in Testiny are up to date (or ticket created)
  • Other teams notified about the changes (if applicable)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a debug-only “image injection” pathway to the shared camera infrastructure so E2E tests can override camera frames by pushing an image to device storage and sending a broadcast, while keeping release behavior unchanged.

Changes:

  • Introduces a debug-only ImageInjectionReceiver + InjectedImageCache and a debug FramePreProcessUseCase that composites the injected image into the preview frame.
  • Adds isInjected to Frame and updates CameraFrameProvider to pre-process frames and show an overlay when frames are injected.
  • Replaces PreviewView usage in affected screens with a new CameraPreviewView wrapper so the overlay can be displayed.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
infra/camera/src/testDebug/java/com/simprints/infra/camera/usecase/FramePreProcessUseCaseTest.kt Adds debug-variant tests for injected-frame preprocessing behavior.
infra/camera/src/release/java/com/simprints/infra/camera/usecase/FramePreProcessUseCase.kt Adds release-variant no-op wrapper use case to keep API consistent across build types.
infra/camera/src/main/java/com/simprints/infra/camera/Frame.kt Extends Frame with isInjected flag (default false).
infra/camera/src/main/java/com/simprints/infra/camera/CameraPreviewView.kt Introduces wrapper view containing PreviewView plus injection overlay ImageView.
infra/camera/src/main/java/com/simprints/infra/camera/CameraFrameProvider.kt Routes frames through FramePreProcessUseCase and toggles overlay display based on isInjected.
infra/camera/src/debug/java/com/simprints/infra/camera/usecase/FramePreProcessUseCase.kt Implements injected-image compositing/scaling for debug builds.
infra/camera/src/debug/java/com/simprints/infra/camera/repository/InjectedImageCache.kt Adds debug-only singleton cache to hold a single injected bitmap.
infra/camera/src/debug/java/com/simprints/infra/camera/ImageInjectionReceiver.kt Adds exported debug receiver to load injected image from external files dir.
infra/camera/src/debug/AndroidManifest.xml Registers the debug-only broadcast receiver and action filter.
feature/login/src/main/res/layout/fragment_qr_scanner.xml Switches camera preview widget to CameraPreviewView.
feature/login/src/main/java/com/simprints/feature/login/screens/qrscanner/QrScannerFragment.kt Updates camera initialization call for CameraPreviewView.
feature/external-credential/src/main/res/layout/fragment_external_credential_scan_qr.xml Switches camera preview widget to CameraPreviewView.
feature/external-credential/src/main/res/layout/fragment_external_credential_scan_ocr.xml Switches camera preview widget to CameraPreviewView.
feature/external-credential/src/main/res/layout-sw600dp-land/fragment_external_credential_scan_qr.xml Switches camera preview widget to CameraPreviewView (sw600dp-land).
feature/external-credential/src/main/res/layout-sw600dp-land/fragment_external_credential_scan_ocr.xml Switches camera preview widget to CameraPreviewView (sw600dp-land).
feature/external-credential/src/main/res/layout-land/fragment_external_credential_scan_qr.xml Switches camera preview widget to CameraPreviewView (land).
feature/external-credential/src/main/res/layout-land/fragment_external_credential_scan_ocr.xml Switches camera preview widget to CameraPreviewView (land).
feature/external-credential/src/main/java/com/simprints/feature/externalcredential/screens/scanqr/ExternalCredentialScanQrFragment.kt Updates camera initialization call for CameraPreviewView.
feature/external-credential/src/main/java/com/simprints/feature/externalcredential/screens/scanocr/ExternalCredentialScanOcrFragment.kt Updates camera initialization call for CameraPreviewView.
face/capture/src/main/res/layout/fragment_live_feedback.xml Switches camera preview widget to CameraPreviewView.
face/capture/src/main/res/layout-land/fragment_live_feedback.xml Switches camera preview widget to CameraPreviewView (land).
face/capture/src/main/java/com/simprints/face/capture/screens/livefeedback/LiveFeedbackFragment.kt Updates camera initialization call for CameraPreviewView.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@alexandr-simprints
alexandr-simprints marked this pull request as ready for review August 12, 2026 11:15
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
33.3% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants