Since the graphene os camera is becoming pretty good, instead of dealing with the legacy code here, I would recommend contributing to their codebase.
A fork of open camera. Making use of API 30 (requires Android 11) to support multiple camera better.
- Download and install the apk from latest release
- Select Camera 2 API in the setting
- If it works, when you zoom in/out, your phone should switch to different camera automatically
- Pixel 4a 5G: Zooming with the dual camera works
- Samsung Galaxy S10: Does not work, need to switch camera manually