從 Android 13 開始,相機 ITS 就包含折疊式裝置的測試支援功能。折疊式裝置的相機可用或不可用,取決於裝置處於折疊或展開狀態。
攝影機 ID 會因裝置類型、型號和品牌而異;實體前置攝影機的可用性則會因狀態而異。因此,相機 ITS 會動態判斷要用於測試的場景和相機組合。由於相機需要在折疊和展開狀態下進行測試,因此折疊式裝置測試需要在測試過程中重新安裝 DUT。
前置和後置鏡頭測試
折疊式裝置可用的相機感應器會因裝置處於折疊或展開狀態而異。對於折疊式裝置,前置鏡頭的可用性會因狀態而異。舉例來說,前置相機在折疊狀態下無法使用。由於前置鏡頭的使用情形有所變更,因此必須在折疊和展開的狀態下測試前置鏡頭。相機 ITS 會假設後置鏡頭的使用情形在裝置折疊或展開時都相同,因此只需測試一次後置鏡頭。
視裝置狀態而定,Camera ITS 會篩除無法使用的相機裝置,且相機裝置不會顯示在相機和場景組合清單中。
[[["容易理解","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-30 (世界標準時間)。"],[],[],null,["# Test camera images on foldables\n\nFrom Android 13, Camera ITS includes testing support\nfor foldable devices. Foldable devices have cameras that are available or\nunavailable depending on whether the device is in a folded or unfolded state.\n\nThe camera IDs change depending on the device type, model, and brand; and the\navailability of physical front cameras change depending on the state. Because of\nthis, Camera ITS dynamically determines the scene and camera combinations to use\nfor testing. As cameras need to be tested in both the folded and unfolded\nstates, foldables testing requires the DUT to be remounted during the testing\nprocess.\n\nFront and rear camera testing\n-----------------------------\n\nThe camera sensors available on a foldable device are different depending on\nwhether the device is in a folded or unfolded state. For foldables, the front\ncamera availability changes depending on the state. For example, the front\ncamera isn't available in the folded state. Because of this change in front\ncamera availability, front cameras must be tested in both the folded and\nunfolded states. Camera ITS assumes the rear camera's availability remains the\nsame whether the device is folded or unfolded, so rear cameras only need to be\ntested once.\n\nDepending on the state of the device, Camera ITS filters out the unavailable\ncamera devices and the camera devices don't appear in the list of camera and\nscene combinations.\n\nThe following table describes the Camera ITS test behavior for each camera\norientation.\n\n| Camera orientation | Camera ITS test behavior |\n|-----------------------|-----------------------------------------------------------------------|\n| Rear camera | Tests camera once in either the folded or unfolded state |\n| Primary front camera | Tests camera once in the folded state and once in the unfolded state. |\n| Physical front camera | Tests camera only in states where the camera is available. |\n\nTest procedure\n--------------\n\nThis section describes the steps to test cameras for foldable devices.\n\n### Set up device\n\nFor setup information, see\n[Setup](/docs/compatibility/cts/camera-its#setup).\n\n### Grant test API access\n\nFor Camera ITS to determine whether the device is foldable or not, you must\ngrant test API access before invoking the tests. If access isn't granted,\nrunning the Camera ITS tests results in the app crashing.\n\nTo grant access, run the following ADB command. This command needs to be run\nonce for a single device. If CTS Verifier is reinstalled with a different\nversion, you must run the command again. \n\n adb shell am compat enable ALLOW_TEST_API_ACCESS com.android.cts.verifier\n\n### Configuration file\n\nTo specify that the device is a foldable device, add the `foldable_device`\nparameter in both `tablet` and `sensor_fusion` testbeds in the `config.yml`\nfile. Camera ITS uses this parameter to determine the `camera_id` and scene\ncombinations for folded and unfolded states.\n\nThe following is an example of a `config.yml` file for a foldable device. \n\n TestBeds:\n - Name: TABLET_SCENES\n # Test configuration for scenes[0:4, 6]\n Controllers:\n AndroidDevice:\n - serial: 8A9X0NS5Z\n label: dut\n - serial: 5B16001229\n label: tablet\n\n TestParams:\n brightness: 192\n chart_distance: 22.0\n debug_mode: \"False\" # \"quotes\" needed\n chart_loc_arg: \"\"\n camera: 0\n scene: scene2_a\n lighting_cntl: arduino # can be \"arduino\" or \"None\"\n lighting_ch: 1\n foldable_device: \"True\" # \"False\" for non-foldable DUTs\n\n### Run tests\n\n| **Caution:** Do not change the state of the DUT after running `run_all_tests.py`. If the state of the DUT changes during test execution, the tests immediately fail.\n\nTo run the ITS tests on a foldable device, run the `run_all_tests.py` command.\nFor details see,\n[Invoking tests](/docs/compatibility/cts/camera-its#invoking-tests).\n\nWhen running Camera ITS on a foldable device, the primary front camera is tested\nin both states, folded and unfolded. If the device is folded, results are\ndisplayed under the `camera1_`\u003cvar translate=\"no\"\u003eSCENE_NAME\u003c/var\u003e`_folded`\noption in the CTS Verifier app. Depending on the device state, certain front\nphysical camera IDs are unavailable and aren't tested.\nThe rear camera only needs to be tested in one state, preferably the folded\nstate, and the results for the rear camera don't have the `_folded` suffix.\n\nTo ensure that the folded scenes are executed with the device folded and check\nthe state of the foldable DUT, run the following command. \n\n adb shell cmd device_state state\n\nWhen executing tests in a folded state, Camera ITS displays a message in the\nterminal to prompt the user to set up the device properly on the ITS\nbox. To continue executing the test after the prompt, hit **Enter**.\n\nIf you're running all scenes in both the folded and unfolded states, the folded\nscenes are executed first, followed by the unfolded scenes. This minimizes the\namount of remounting required during testing.\n\nCamera ITS also adds the `folded` suffix to the `tmp` directory\ncreated for folded state scenes.\n| **Note:** From Android, CTS Verifier includes a folded toggle button. This button isn't required for Camera ITS testing.\n\n### Sample commands\n\nThe following are sample commands for test execution on foldable devices.\n\n| Command | Description |\n|-----------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `python tools/run_all_tests.py` | Runs all the scenes. |\n| `python tools/run_all_tests.py scenes=scene0` | Runs scene0. If the device is folded and the user is testing the primary front camera, the script determines the device state and add the suffix `_folded` to the scene name. Users don't have to add the suffix to run the folded scenes. |\n| `python tests/scene0/` -c config.yml | Runs a specific test. |"]]