Skip to content

Fix the scanner torch on Android and keep its button clear of the navigation bar - #5972

Merged
shai-almog merged 1 commit into
masterfrom
fix-android-scanner-torch
Oct 9, 2026
Merged

shai-almog merged 1 commit into
masterfrom
fix-android-scanner-torch

Conversation

@shai-almog

Copy link
Copy Markdown
Collaborator

What was wrong

The torch button did nothing on Android. AndroidCameraImpl.setFlashMode only called ImageCapture.setFlashMode, which decides whether the flash fires for a still photo. FlashMode.TORCH fell through to "auto flash", so nothing lit and nothing was logged. iOS has a real torch path, which is why it worked there.

The torch button sat under the system navigation bar. The footer CodeScanner builds never opted into the safe area, so on an edge-to-edge display (Android 15 and later) it was drawn under the three-button bar and could not be tapped.

The fix

  • TORCH now goes through CameraX's CameraControl.enableTorch. It needs no permission beyond CAMERA, so there is no builder change.
  • setZoom had the same kind of silent failure and is fixed with it: it resolved getCameraControl on the bound camera's concrete class, LifecycleCamera, which is package-private, so Method.invoke refused the call and the error was swallowed. Both calls now resolve on the public Camera / CameraControl interfaces and log a warning on failure.
  • The scanner footer calls setSafeArea(true), which also keeps it clear of the iOS home indicator.

Verification

Compile-checked only. Not run on a device, and the SpotBugs gate and unit tests were not run locally.

🤖 Generated with Claude Code

…igation bar

FlashMode.TORCH was mapped onto ImageCapture's flash mode, which only decides
whether the flash fires for a still, so the torch never lit. It now goes through
CameraControl#enableTorch. setZoom had the same silent failure: it resolved
getCameraControl on the bound camera's concrete class, which is not public, so
Method#invoke refused it and the error was swallowed. Both now resolve on the
public CameraX interfaces and log on failure.

The scanner footer did not opt into the safe area, so on an edge-to-edge
display the torch button sat under the system navigation bar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Developer Guide build artifacts are available for download from this workflow run:

Developer Guide quality checks:

  • AsciiDoc linter: No issues found (report)
  • Vale: No alerts found (report)
  • Paragraph capitalization: No paragraph capitalization issues (report)
  • LanguageTool: No grammar matches (report)
  • Image references: No unused images detected (report)

@shai-almog

shai-almog commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

Compared 170 screenshots: 170 matched.

Native Android coverage

  • 📊 Line coverage: 16.03% (26023/162381 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 14.39% (122329/850200), branch 9.92% (8478/85437), complexity 7.82% (6533/83500), method 11.60% (4651/40093), class 19.80% (961/4853)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6367 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.ClassReader – 0.00% (0/1524 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.MethodWriter – 0.00% (0/922 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/736 lines covered)
      • com.google.common.cache.com.google.common.cache.LocalCache$Segment – 0.00% (0/726 lines covered)
      • okio.okio.Buffer – 0.00% (0/687 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/625 lines covered)
      • com.codename1.androidcompat.rt.com.codename1.androidcompat.rt.TextXmlPullParser – 0.00% (0/623 lines covered)
      • com.codename1.androidcompat.androidx.constraintlayout.core.widgets.com.codename1.androidcompat.androidx.constraintlayout.core.widgets.Flow – 0.00% (0/576 lines covered)

✅ Native Android screenshot tests passed.

Native Android coverage

  • 📊 Line coverage: 16.03% (26023/162381 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 14.39% (122329/850200), branch 9.92% (8478/85437), complexity 7.82% (6533/83500), method 11.60% (4651/40093), class 19.80% (961/4853)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6367 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.ClassReader – 0.00% (0/1524 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.MethodWriter – 0.00% (0/922 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/736 lines covered)
      • com.google.common.cache.com.google.common.cache.LocalCache$Segment – 0.00% (0/726 lines covered)
      • okio.okio.Buffer – 0.00% (0/687 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/625 lines covered)
      • com.codename1.androidcompat.rt.com.codename1.androidcompat.rt.TextXmlPullParser – 0.00% (0/623 lines covered)
      • com.codename1.androidcompat.androidx.constraintlayout.core.widgets.com.codename1.androidcompat.androidx.constraintlayout.core.widgets.Flow – 0.00% (0/576 lines covered)

Benchmark Results

Detailed Performance Metrics

Metric Duration
SIMD kernel backend scalar fallback (no native SIMD)
SIMD int-add (64K x300) java 49ms / native 68ms = 0.7x speedup
SIMD float-mul (64K x300) java 28ms / native 38ms = 0.7x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path gated to scalar (CPU autovectorizes scalar; explicit SIMD not beneficial here)
Base64 CN1 encode 38.000 ms
Base64 CN1 decode 43.000 ms
Base64 native encode 329.000 ms
Base64 encode ratio (CN1/native) 0.116x (88.4% faster)
Base64 native decode 251.000 ms
Base64 decode ratio (CN1/native) 0.171x (82.9% faster)
Image encode benchmark status skipped (SIMD unsupported)

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Cloudflare Preview

@shai-almog

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T10:57:46.985924Z 25bca3b Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 25bca3ba0d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@shai-almog

shai-almog commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

Compared 206 screenshots: 206 matched.
✅ JavaScript-port screenshot tests passed.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

✅ Continuous Quality Report

Test & Coverage

Static Analysis

  • SpotBugs [Report archive]
    • ✅ ByteCodeTranslator: 0 findings (no issues)
    • ✅ android: 0 findings (no issues)
    • ✅ android-compat: 0 findings (no issues)
    • ✅ android-res-compiler: 0 findings (no issues)
    • ✅ backend: 0 findings (no issues)
    • ✅ backend-test: 0 findings (no issues)
    • ✅ build-engine: 0 findings (no issues)
    • ✅ build-hint-catalog: 0 findings (no issues)
    • ✅ build-hint-tools: 0 findings (no issues)
    • ✅ codenameone-gradle-plugin: 0 findings (no issues)
    • ✅ codenameone-maven-plugin: 0 findings (no issues)
    • ✅ core-unittests: 0 findings (no issues)
    • ✅ ios: 0 findings (no issues)
    • ✅ javac: 0 findings (no issues)
    • ✅ project-model: 0 findings (no issues)
  • ❌ PMD: 2 findings (P2: 2) [HTML preview] [Download]
  • ✅ Checkstyle: 0 findings (no issues) [Report archive]

Generated automatically by the PR CI workflow.

@shai-almog
shai-almog merged commit d56944c into master Oct 9, 2026
@shai-almog
shai-almog deleted the fix-android-scanner-torch branch October 9, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant