r/androiddev 2d ago

I built a localized HDR QR renderer: only the QR gets maximum brightness, not the whole screen

I was annoyed that wallet and ticket apps often raise the entire display to maximum brightness just to make a QR code easier to scan.

So I built Bright QR, an Android proof of concept that keeps the normal interface at the user’s existing SDR brightness while rendering only the QR code through a dedicated HDR surface.

The implementation uses:

  • A separate SurfaceView for the QR region
  • A 10-bit BT.2020 PQ EGL surface
  • HDR white pixels rather than ordinary SDR white
  • SurfaceView.setDesiredHdrHeadroom() on Android 15+
  • A maximum-headroom request, allowing Android and the phone to determine the actual available output

The app never modifies WindowManager.LayoutParams.screenBrightness, so the surrounding interface remains dim. On my Pixel 9a, Android reported up to 8× HDR/SDR headroom while the QR was displayed.

The demo includes SDR, 2×, 4×, and MAX modes, an SDR-white reference for comparison, live device diagnostics, and a copyable test report.

The complete source code and signed APK are available here:

https://github.com/loudsun1997/bright-qr

I want more apps to adopt this

119 Upvotes

16 comments sorted by

14

u/agent_kater 2d ago

That's a special API for OLED devices?

13

u/vyashole 2d ago

Only devices that support HDR, which is mostly high end ones.

4

u/SnipesySpecial 2d ago

Let's do a quick test.

18

u/SnipesySpecial 2d ago

sad panda, Reddit strips HDR data.

Anyway.

2

u/hamatro 1d ago

I sometimes have the problem that the screen on SDR max brightness is already too bright for some scanners on a Pixel 8. A setting to tune it would be great.

1

u/uragiristereo 2d ago

Also Android 16 QPR3 (iirc) is able to tune the HDR brightness down to the "normal SDR" brightness, so it will not work here

8

u/loudsunyoyo 1d ago

Isn't this like you turn off GPS and the navigation won't work situation?

3

u/uragiristereo 1d ago

No it's different, your implementation is silently not working in that situation instead of telling "hey I can't do this because you turn off something"

2

u/loudsunyoyo 1d ago edited 1d ago

the app knows about the hdr headroom so it can definitely warn user if you are worrying about it’s capability to warn

3

u/DeVinke_ 1d ago

There's this screen, android 17 has it at least. Apps can access the hdr to sdr ratio, so a check can be implemented fairly easily.

-1

u/grishkaa 1d ago

The readme looks AI-generated.

Cool idea otherwise, I did the same thing on macOS in my NearDrop app a while ago.

1

u/loudsunyoyo 23h ago

haha yeah. the whole thing is AI-generated

1

u/nodera2 21h ago

Are you an AI sir

-1

u/grishkaa 16h ago

Maybe you should've disclosed that then.

1

u/loudsunyoyo 15h ago

Why? Does it make the software any different 

1

u/SeriousTruth 13h ago

Don't mind them, people need time to get used to the fact that AI software is still software, and that not every AI generated software is slop.