自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
相机扩展验证工具
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
借助相机扩展验证工具,设备制造商可以验证是否已正确实现相机扩展 OEM 供应商库。该工具包含自动和手动验证测试。
自动验证测试:验证是否已正确实现供应商库接口。例如,如果图片拍摄需要使用 CaptureProcessor
,该测试会验证 ImageCaptureExtenderImpl#getCaptureStages()
是否会返回图片拍摄所需的 CaptureStage
实例。
手动验证测试:验证预览和所拍摄图片的图片效果和画质。例如,设备制造商可以通过该测试手动验证是否正确应用了脸部照片修复效果,或者焦外成像强度是否足够。
Android Jetpack 代码库内的扩展测试应用中包含了该验证工具的源代码。
构建相机扩展验证工具
如需构建扩展程序验证工具,请按以下步骤操作:
下载 Android Jetpack 库源代码。如需了解详情,请参阅 Android Jetpack 自述文件中的检出代码部分。
构建 extensionstestapp
APK。此 APK 支持运行手动验证测试。
cd path/to/checkout/frameworks/support/
./gradlew camera:integration-tests:camera-testapp-extensions:assembleDebug
此 APK 会输出到以下路径:
path/to/checkout/out/androidx/camera/integration-tests/camera-testapp-extensions/build/outputs/apk/debug/camera-testapp-extensions-debug.apk
构建 androidTest
APK。此 APK 支持运行自动验证测试。
cd path/to/checkout/frameworks/support/
./gradlew camera:integration-tests:camera-testapp-extensions:assembleAndroidTest
此 APK 会输出到以下路径:
path/to/checkout/out/androidx/camera/integration-tests/camera-testapp-extensions/build/outputs/apk/androidTest/debug/camera-testapp-extensions-debug-androidTest.apk
运行自动验证测试
如需运行自动验证测试,请安装 extensionstestapp
和 androidTest
APK。
extensionstestapp
APK
adb install -r path/to/checkout/out/androidx/camera/integration-tests/camera-testapp-extensions/build/outputs/apk/debug/camera-testapp-extensions-debug.apk
androidTest
APK
adb install -r path/to/checkout/out/androidx/camera/integration-tests/camera-testapp-extensions/build/outputs/apk/androidTest/debug/camera-testapp-extensions-debug-androidTest.apk
运行所有自动化测试
安装 APK 后,如要运行所有自动化测试来验证供应商库实现,请运行以下命令:
adb shell am instrument -w -r androidx.camera.integration.extensions.test/androidx.test.runner.AndroidJUnitRunner
如果通过了所有测试,则会返回 OK 结果。否则,在所有测试完成后,最终测试报告会在终端显示失败结果。
图 1. 自动化测试结果“OK”
图 2. 存在失败情况的自动化测试结果
针对特定类运行自动化测试
如需针对特定类运行自动化测试,请指定目标类的名称和路径。以下示例展示了用于对 ImageCaptureTest
类运行测试的命令:
adb shell am instrument -w -r -e class **androidx.camera.integration.extensions.ImageCaptureTest** androidx.camera.integration.extensions.test/androidx.test.runner.AndroidJUnitRunner
运行手动验证测试
手动验证测试可在扩展程序测试应用中找到。安装并启动扩展程序测试应用后,点按右上角的菜单项,即可切换到验证工具模式。
切换到验证工具模式后,第一页上会列出包含 REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE
功能的所有摄像头。如果摄像头不支持任何扩展程序模式,其对应的列表项会显示为灰色。
图 3. 验证工具模式
点按其中一个相机,即可查看用于测试的扩展模式。所选相机不支持的扩展模式会显示为灰色。
图 4. 适用于某个摄像头的扩展程序模式
验证预览结果
如需验证预览结果,请点按所选相机的某个扩展模式,开始执行手动测试。系统随即会显示包含预览的图片拍摄 activity。
图 5. 启用了焦外成像的预览图片
图片拍摄 activity 支持以下功能:
- 缩放
- 点按对焦
- 闪光灯模式切换按钮
- 增/减曝光值
- 启用/停用扩展程序切换按钮
验证“缩放”“点按对焦”“闪光灯模式”和“增/减曝光值”功能在预览中是否能够正常工作。
验证拍摄的图片效果
如需拍摄图片,请在图片拍摄 activity 中点按拍摄按钮(圆形按钮)。这会启动一个显示所拍摄图片的图片验证 activity。
图 6. 启用了焦外成像时拍摄的图片
图片验证 activity 包含以下功能:
- 双指张合缩放图片
- 左右滑动切换拍摄的图片
- 重新拍摄
- “保存图片”菜单项
验证拍摄的图片是否正确,以及是否与拍摄图片时指定的“缩放”“点按对焦”“闪光灯模式”和“增/减曝光值”设置相符。
如果拍摄的结果正确无误,请点按右下角的PASS按钮(对勾标记)。否则,请点按左下角的失败按钮(感叹号)。
查看测试结果
验证扩展程序模式是否通过测试后,相应的列表项会显示不同的背景颜色和指示符。在包含所有摄像头的列表视图中,列表项会按以下颜色显示:
- 白色背景:相机至少支持一种扩展模式,并且所支持的扩展模式尚未全部验证。
- 绿色背景:相机至少支持一种扩展模式。所有受支持的扩展程序模式都已经过验证,并且所有结果都为通过。
- 红色背景:相机至少支持一种扩展模式。所有受支持的扩展模式都已经过验证,并且至少有一种扩展模式的结果为失败。
- 灰色背景:此功能不可用。
图 7. 指示摄像头和扩展程序模式测试结果的几种颜色
验证工具的其他功能
所有测试完成后,摄像头列表 activity 会提供以下功能:
- 导出测试结果:以 CSV 文件的形式将测试结果导出到
Documents/ExtensionsValidation
文件夹中。
- 重置:清除所有缓存的测试结果。
- 扩展程序示例应用:切换到扩展程序示例应用模式。
完成测试后,您可以导出测试结果。如果您发现了问题,并且需要重新验证解决方案的新版供应商库实现,请重置之前的测试结果,并对所有摄像头上重新运行所有受支持的扩展程序模式,以验证问题是否已解决。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-03-26。"],[],[],null,["# Camera extensions validation tool\n\nThe camera extensions validation tool allows device manufacturers to\nverify that the\n[Camera Extensions OEM vendor library](/docs/core/camera/camerax-vendor-extensions)\nis implemented correctly. The tool includes automated and manual validation\ntests.\n\n- **Automated validation tests:** validate that the vendor library\n interface is implemented correctly. For example, if `CaptureProcessor` is\n required for image capture, the tests validate that\n `ImageCaptureExtenderImpl#getCaptureStages()` returns the required\n `CaptureStage` instances for capturing the images.\n\n- **Manual validation tests:** Validate the image effects and quality of\n preview and captured images. For example, the tests allow device\n manufacturers to manually validate whether the face retouch effect\n is applied correctly or whether the bokeh strength is sufficient.\n\nThe source code of the validation tool is part of the\n[extensions test app](https://android.googlesource.com/platform/frameworks/support/+/androidx-main/camera/integration-tests/extensionstestapp/)\nin the\n[Android Jetpack repository](https://android.googlesource.com/platform/frameworks/support/+/androidx-main).\n\nBuild the camera extensions validation tool\n-------------------------------------------\n\nTo build the extensions validation tool, follow these steps:\n\n1. Download the Android Jetpack library source code. For details, see the\n [Checking out the Code](https://android.googlesource.com/platform/frameworks/support/+/androidx-main/README.md#checking-out-the-code)\n section of the\n [Android Jetpack README](https://android.googlesource.com/platform/frameworks/support/+/androidx-main/README.md).\n\n2. Build the\n [`extensionstestapp`](https://android.googlesource.com/platform/frameworks/support/+/androidx-main/camera/integration-tests/extensionstestapp/)\n APK. This allows for running manual validation tests.\n\n cd \u003cvar translate=\"no\"\u003epath/to/checkout\u003c/var\u003e/frameworks/support/\n ./gradlew camera:integration-tests:camera-testapp-extensions:assembleDebug\n\n The APK is output to the following path: \n\n \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003epath\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e/\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003eto\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e/\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003echeckout\u003c/span\u003e\u003c/var\u003e/out/androidx/camera/integration-tests/camera-testapp-extensions/build/outputs/apk/debug/camera-testapp-extensions-debug.apk\n\n3. Build the\n [`androidTest`](https://android.googlesource.com/platform/frameworks/support/+/androidx-main/camera/integration-tests/extensionstestapp/src/androidTest/java/androidx/camera/integration/extensions)\n APK. This APK allows for running automated validation tests.\n\n cd \u003cvar translate=\"no\"\u003epath/to/checkout\u003c/var\u003e/frameworks/support/\n ./gradlew camera:integration-tests:camera-testapp-extensions:assembleAndroidTest\n\n The APK is output to the following path: \n\n \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003epath\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e/\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003eto\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e/\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003echeckout\u003c/span\u003e\u003c/var\u003e/out/androidx/camera/integration-tests/camera-testapp-extensions/build/outputs/apk/androidTest/debug/camera-testapp-extensions-debug-androidTest.apk\n\nRun automated validation tests\n------------------------------\n\nTo run the automated validation tests, install the `extensionstestapp` and\n`androidTest` APKs.\n\n- **`extensionstestapp` APK**\n\n adb install -r \u003cvar translate=\"no\"\u003epath/to/checkout\u003c/var\u003e/out/androidx/camera/integration-tests/camera-testapp-extensions/build/outputs/apk/debug/camera-testapp-extensions-debug.apk\n\n- **`androidTest` APK**\n\n adb install -r \u003cvar translate=\"no\"\u003epath/to/checkout\u003c/var\u003e/out/androidx/camera/integration-tests/camera-testapp-extensions/build/outputs/apk/androidTest/debug/camera-testapp-extensions-debug-androidTest.apk\n\n### Run all automated tests\n\nAfter installing the APKs, to run all automated tests to validate the vendor\nlibrary implementation, run the following command: \n\n adb shell am instrument -w -r androidx.camera.integration.extensions.test/androidx.test.runner.AndroidJUnitRunner\n\nIf all tests pass, an **OK** result is returned. Otherwise, the final test\nreport shows failures in the terminal after all tests are complete.\n\n**Figure 1.** Automated tests OK result\n\n**Figure 2.** Automated tests result with failures\n\n### Run automated tests of a specific class\n\nTo run automated tests of a specific class, specify the name and path of the\ntarget class. The following example shows the command to run tests for the\n`ImageCaptureTest` class: \n\n adb shell am instrument -w -r -e class **androidx.camera.integration.extensions.ImageCaptureTest** androidx.camera.integration.extensions.test/androidx.test.runner.AndroidJUnitRunner\n\nRun manual validation tests\n---------------------------\n\nThe manual validation tests are found in the\n[extensions test app](https://android.googlesource.com/platform/frameworks/support/+/androidx-main/camera/integration-tests/extensionstestapp/).\nAfter installing and launching the extensions test app, switch to the\nvalidation tool mode by tapping the menu item at the top right.\n\nAfter switching to the validation tool mode, the first page lists all cameras\nthat contain the\n[`REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE`](https://developer.android.com/reference/android/hardware/camera2/CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE)\ncapability. If a camera doesn't support any extension mode, its corresponding\nlist item is gray.\n\n**Figure 3.** Validation tool mode\n\nTap one of the cameras to see the extension modes for testing. Extension\nmodes not supported by the selected camera are shown in gray.\n\n**Figure 4.** Extension modes available for a camera\n\n### Verify the preview results\n\nTo verify the preview results, start a manual test by tapping an\nextension mode for the selected camera. An image capturing activity containing\nthe preview is then shown.\n\n**Figure 5.** Preview image with bokeh enabled\n\nThe image capturing activity supports the following functions:\n\n- Zoom in/out\n- Tap-to-focus\n- Flash modes switch button\n- EV +/-\n- Extension enabled/disabled switch button\n\nVerify that the zoom in/out, tap-to-focus, flash modes, and\nEV +/- functions work as expected in the preview.\n\n### Verify the captured image results\n\nTo capture the image, tap the **CAPTURE** button (the round button) in the image\ncapturing activity.\nThis launches an image validation activity that shows the captured image.\n\n**Figure 6.** Captured image with bokeh enabled\n\nThe image validation activity includes the following functions:\n\n- Pinch in/out to scale the image\n- Slide left/right to switch the captured images\n- Recapture\n- Save image menu item\n\nVerify whether the captured image is correct and matches the zoom\nin/out, tap-to-focus, flash modes, and EV +/- settings that were set when\ncapturing the image.\n\nIf the captured results are correct, tap the **PASS** button (checkmark) in the\nbottom-right corner. Otherwise, tap the **FAIL** button (exclamation point) in\nthe bottom-left corner.\n\n### View test results\n\nAfter an extension mode is verified as a pass or a fail, the list item for the\nextension mode shows a different background color and indicator. In the list\nview of all the cameras, the items are displayed in the following colors:\n\n- **White background:** The camera supports at least one extension mode and the supported extension modes aren't validated completely.\n- **Green background:** The camera supports at least one extension mode. All supported extension modes are validated with all results passing.\n- **Red background:** The camera supports at least one extension mode. All supported extension modes are validated with at least one extension mode result failing.\n- **Gray background:** This feature is unavailable.\n\n\n**Figure 7.** Colors indicating test results for cameras and extension modes\n\n### Other validation tool functions\n\nAfter all the tests are complete, the camera list activity provides the\nfollowing functions:\n\n- **Export test results:** Exports the test results as a CSV file to the `Documents/ExtensionsValidation` folder.\n- **Reset:** Clears all cached test results.\n- **Extensions sample app:** Switches to the extensions sample app mode.\n\nAfter completing the testing, you can export the test results. If you find an\nissue and a new version of the vendor library implementation with the\nsolutions needs to be verified again, reset the previous test results and rerun\nall the supported extension modes on all cameras to verify that the issues\nare fixed."]]