Add dual concurrent camera for devices that support it (#258)

* Refactor camera coroutine into separate session types for concurrent camera

 Also sets concurrent camera to on if supported by device.

 Refactors some camera utility code into its own file, CameraExt

* Replace LLB toggle with concurrent camera mode toggle

 LLB toggle currently isn't hooked up, so use its slot for
 concurrent camera toggle.

* Apply concurrent camera mode constraints

 Disable UI components such as HDR and Capture mode toggle when
 concurrent camera mode enabled

 Show image/video toggle when concurrent camera mode enabled

* Only enable dual camera mode when device supports it

* Disable concurrent camera in image-only capture mode

* Fix VIDEO_CAPTURE_EXTERNAL_UNSUPPORTED_TAG String

* Ensure debug info only shows for primary camera in concurrent camera mode

* Fix screen flash events

 Replaced unnecessary coroutine scope with a buffered channel.
 This has equivalent functionality to the old implementation but
 doesn't need an extra coroutine scope to send events.

 Using a Channel rather than a SharedFlow is also more
 representative of how these events should be handled, since
 only a single consumer should handle each event.

 Also ensured we're checking the lens facing direction for whether
 we initially turn on front flash
26 files changed
tree: bca4c08f2557f587d0268a84fe3424bab4f278eb
  1. .github/
  2. .idea/
  3. app/
  4. benchmark/
  5. core/
  6. data/
  7. docs/
  8. feature/
  9. gradle/
  10. hooks/
  11. spotless/
  12. .editorconfig
  13. .gitignore
  14. build.gradle.kts
  15. gradle.properties
  16. gradlew
  17. gradlew.bat
  18. LICENSE
  19. README.md
  20. settings.gradle.kts
README.md

Video Capture with Jetpack Camera App

Jetpack Camera App ๐Ÿ“ธ

Jetpack Camera App (JCA) is a camera app, focused on features used by app developers, and built entirely with CameraX, Kotlin and Jetpack Compose. It follows Android design and development best practices and it's intended to be a useful reference for developers and OEMs looking to validate their camera feature implementations.

Development Environment โš’๏ธ

This project uses the gradle build system, and can be imported directly into Android Studio.

Currently, Jetpack Camera App is built using the Android Gradle Plugin 8.4, which is only compatible with Android Studio Jellyfish or newer.

Architecture ๐Ÿ“

JCA is built with modern android development (MAD) principles in mind, including architecture and testing best practices.

The app is split into multiple modules, with a clear separation between the UI and data layers.

Testing ๐Ÿงช

Thorough testing is a key directive of JCA. We use Compose Test and UI Automator to write instrumentation tests that run on-device.

These tests can be run on a connected device via Android Studio, or can be tested on an Android Emulator using built-in Gradle Managed Device tasks. Currently, we include Pixel 2 (API 28) and Pixel 8 (API 34) emulators which can be used to run instrumentation tests with:

$ ./gradlew pixel2Api28DebugAndroidTest and $ ./gradlew pixel8Api34DebugAndroidTest

Source Code Headers

Every file containing source code must include copyright and license information. This includes any JS/CSS files that you might be serving out to browsers. (This is to help well-intentioned people avoid accidental copying that doesn't comply with the license.)

Apache header:

Copyright (C) 2024 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.