从 Android 13 开始,相机 ITS 包含对可折叠设备的测试支持。可折叠设备的摄像头是否可用取决于设备是处于折叠状态还是展开状态。
摄像头 ID 因设备类型、型号和品牌而异,而物理前置摄像头的可用性则取决于设备的状态。因此,相机 ITS 会动态确定用于测试的场景和摄像头组合。由于摄像头需要在折叠和展开状态下分别进行测试,所以可折叠设备测试需要在测试过程中重新装载 DUT。
前置和后置摄像头测试
可折叠设备上的可用摄像头传感器因设备是处于折叠状态还是展开状态而异。对于可折叠设备,前置摄像头的可用性取决于设备的状态。例如,前置摄像头在折叠状态下不可用。由于前置摄像头的可用性会视情况而异,所以前置摄像头必须在折叠和展开状态下分别进行测试。相机 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"]],["最后更新时间 (UTC):2025-05-08。"],[],[],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. |"]]