自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
相機擴充功能驗證工具
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
相機擴充功能驗證工具可讓裝置製造商驗證 Camera Extensions OEM 供應商程式庫 是否正確實作。這項工具包含自動和手動驗證測試。
自動化驗證測試:驗證供應商程式庫介面是否正確實作。舉例來說,如果圖像擷取作業需要 CaptureProcessor
,則測試會驗證 ImageCaptureExtenderImpl#getCaptureStages()
是否會傳回擷取圖像所需的 CaptureStage
例項。
手動驗證測試:驗證預覽和擷取圖片的圖片效果和品質。舉例來說,這些測試可讓裝置製造商手動驗證臉部修飾效果是否正確套用,或景深效果是否足夠。
驗證工具的原始碼是 Android Jetpack 存放區中的擴充功能測試應用程式的一部分。
建構相機擴充功能驗證工具
如要建構額外資訊驗證工具,請按照下列步驟操作:
下載 Android Jetpack 程式庫原始碼。詳情請參閱 Android Jetpack README 中的「檢查程式碼」一節。
建立 extensionstestapp
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. 相機可用的擴充功能模式
驗證預覽結果
如要驗證預覽結果,請輕觸所選攝影機的擴充模式,開始手動測試。接著會顯示含有預覽畫面的圖片擷取活動。
圖 5. 已啟用散景效果的預覽圖片
圖片拍攝活動支援下列功能:
- 放大/縮小
- 輕觸對焦
- 閃光燈模式切換鈕
- EV +/-
- 擴充功能已啟用/停用的切換按鈕
確認在預覽畫面中,縮放、輕觸對焦、閃光燈模式和 EV +/- 功能是否正常運作。
驗證擷取的圖像結果
如要擷取圖片,請輕觸圖片擷取活動中的「擷取」按鈕 (圓形按鈕)。這會啟動圖片驗證活動,顯示所拍攝的圖片。
圖 6. 已啟用散景效果的擷取圖片
圖片驗證活動包含下列函式:
- 雙指撥動可調整圖片顯示比例
- 向左/右滑動可切換已拍攝的圖片
- 重新拍攝
- 「儲存圖片」選單項目
確認拍攝的圖片是否正確,並符合拍攝圖片時設定的縮放、輕觸對焦、閃光燈模式和 EV +/- 設定。
如果擷取的結果正確無誤,請輕觸右下角的「PASS」按鈕 (勾號)。否則,請輕觸左下角的「失敗」按鈕 (驚嘆號)。
查看測試結果
在驗證擴充功能模式是否通過或失敗後,擴充功能模式的清單項目會顯示不同的背景顏色和指標。在所有攝影機的清單檢視畫面中,系統會以以下顏色顯示項目:
- 白色背景:相機支援至少一種擴充模式,但未完全驗證支援的擴充模式。
- 綠色背景:相機至少支援一種擴充模式。所有支援的擴充功能模式都會經過驗證,所有結果都會通過。
- 紅色背景:相機至少支援一種擴充功能模式。所有支援的擴充功能模式都會經過驗證,且至少有一個擴充功能模式的結果失敗。
- 灰色背景:無法使用這項功能。
圖 7. 用顏色標示相機和擴充模式的測試結果
其他驗證工具功能
所有測試完成後,攝影機清單活動會提供下列函式:
- 匯出測試結果:將測試結果匯出為 CSV 檔案,並儲存至
Documents/ExtensionsValidation
資料夾。
- 重設:清除所有快取的測試結果。
- 擴充功能範例應用程式:切換至擴充功能範例應用程式模式。
完成測試後,您可以匯出測試結果。如果您發現問題,且需要再次驗證供應商程式庫實作的新版本是否有解決方案,請重設先前的測試結果,並在所有相機上重新執行所有支援的擴充模式,以驗證問題是否已修正。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-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"]],["上次更新時間:2025-07-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."]]