1 ## 7.5\. Cameras 2 3 If device implementations include at least one camera, they: 4 5 * [C-1-1] MUST declare the `android.hardware.camera.any` feature flag. 6 * [C-1-2] MUST be possible for an application to simultaneously allocate 7 3 RGBA_8888 bitmaps equal to the size of the images produced by the 8 largest-resolution camera sensor on the device, while camera is open for the 9 purpose of basic preview and still capture. 10 11 ### 7.5.1\. Rear-Facing Camera 12 13 A rear-facing camera is a camera located on the side of 14 the device opposite the display; that is, it images scenes on the far side of 15 the device, like a traditional camera. 16 17 Device implementations: 18 19 * SHOULD include a rear-facing camera. 20 21 If device implementations include at least one rear-facing camera, they: 22 23 * [C-1-1] MUST report the feature flag `android.hardware.camera` and 24 `android.hardware.camera.any`. 25 * [C-1-2] MUST have a resolution of at least 2 megapixels. 26 * SHOULD have either hardware auto-focus or software auto-focus implemented 27 in the camera driver (transparent to application software). 28 * MAY have fixed-focus or EDOF (extended depth of field) hardware. 29 * MAY include a flash. 30 31 If the camera includes a flash: 32 33 * [C-2-1] the flash lamp MUST NOT be lit while an 34 `android.hardware.Camera.PreviewCallback` instance has been registered 35 on a Camera preview surface, unless the application has explicitly enabled 36 the flash by enabling the `FLASH_MODE_AUTO` or `FLASH_MODE_ON` attributes 37 of a `Camera.Parameters` object. Note that this constraint does not apply to the 38 devices built-in system camera application, but only to third-party 39 applications using `Camera.PreviewCallback`. 40 41 ### 7.5.2\. Front-Facing Camera 42 43 A front-facing camera is a camera located on the same side of the device 44 as the display; that is, a camera typically used to image the user, such 45 as for video conferencing and similar applications. 46 47 Device implementations: 48 49 * MAY include a front-facing camera. 50 51 If device implementations include at least one front-facing camera, they: 52 53 * [C-1-1] MUST report the feature flag `android.hardware.camera.any` and 54 `android.hardware.camera.front`. 55 * [C-1-2] MUST have a resolution of at least VGA (640x480 pixels). 56 * [C-1-3] MUST NOT use a front-facing camera as the default for the 57 Camera API and MUST NOT configure the API to treat a front-facing camera as 58 the default rear-facing camera, even if it is the only camera on the device. 59 * [C-1-4] The camera preview MUST be mirrored horizontally relative to the 60 orientation specified by the application when the current application has 61 explicitly requested that the Camera 62 display be rotated via a call to the 63 [`android.hardware.Camera.setDisplayOrientation()`]( 64 http://developer.android.com/reference/android/hardware/Camera.html#setDisplayOrientation(int)) 65 method. Conversely, the preview MUST be mirrored along the devices default 66 horizontal axis when the current application does not explicitly request 67 that the Camera display be rotated via a call to the 68 [`android.hardware.Camera.setDisplayOrientation()`]( 69 http://developer.android.com/reference/android/hardware/Camera.html#setDisplayOrientation(int)) 70 method. 71 * [C-1-5] MUST NOT mirror the final captured still image or video streams 72 returned to application callbacks or committed to media storage. 73 * [C-1-6] MUST mirror the image displayed by the postview in the same manner 74 as the camera preview image stream. 75 * MAY include features (such as auto-focus, flash, etc.) available to 76 rear-facing cameras as described in [section 7.5.1](#7_5_1_rear-facing_camera). 77 78 If device implementations are capable of being rotated by user (such as 79 automatically via an accelerometer or manually via user input): 80 81 * [C-2-1] The camera preview MUST be mirrored horizontally relative to 82 the devices current orientation. 83 84 ### 7.5.3\. External Camera 85 86 Device implementations: 87 88 * MAY include support for an external camera that is not necessarily 89 always connected. 90 91 If device impelmentations include support for an external camera, they: 92 93 * [C-1-1] MUST declare the platform feature flag 94 `android.hardware.camera.external` and `android.hardware camera.any`. 95 * [C-1-2] MUST support USB Video Class (UVC 1.0 or higher) if the external 96 camera connects through the USB port. 97 * SHOULD support video compressions such as MJPEG to enable transfer of 98 high-quality unencoded streams (i.e. raw or independently compressed picture 99 streams). 100 * MAY support multiple cameras. 101 * MAY support camera-based video encoding. 102 103 If camera-based video encoding is supported: 104 105 * [C-2-1] A simultaneous 106 unencoded / MJPEG stream (QVGA or greater resolution) MUST be accessible to 107 the device implementation. 108 109 ### 7.5.4\. Camera API Behavior 110 111 Android includes two API packages to access the camera, the newer 112 android.hardware.camera2 API expose lower-level camera control to the app, 113 including efficient zero-copy burst/streaming flows and per-frame controls of 114 exposure, gain, white balance gains, color conversion, denoising, sharpening, 115 and more. 116 117 The older API package,`android.hardware.Camera`, is marked as deprecated in 118 Android 5.0 but as it should still be available for apps to use. Android device 119 implementations MUST ensure the continued support of the API as described in 120 this section and in the Android SDK. 121 122 All features that are common between the deprecated android.hardware.Camera class 123 and the newer android.hardware.camera2 package MUST have equivalent performance 124 and quality in both APIs. For example, with equivalent settings, 125 autofocus speed and accuracy must be identical, and the quality of captured images 126 must be the same. Features that depend on the different semantics of the two APIs 127 are not required to have matching speed or quality, but SHOULD match as closely 128 as possible. 129 130 Device implementations MUST implement the following behaviors for the 131 camera-related APIs, for all available cameras. Device implementations: 132 133 * [C-0-1] MUST use `android.hardware.PixelFormat.YCbCr_420_SP` for preview 134 data provided to application callbacks when an application has never called 135 `android.hardware.Camera.Parameters.setPreviewFormat(int)`. 136 * [C-0-2] MUST further be in the NV21 encoding format when an application 137 registers an `android.hardware.Camera.PreviewCallback` 138 instance and the system calls the `onPreviewFrame()` method and the preview 139 format is YCbCr_420_SP, the data in the byte[] passed into `onPreviewFrame()`. 140 That is, NV21 MUST be the default. 141 * [C-0-3] MUST support the YV12 format (as denoted by the 142 `android.graphics.ImageFormat.YV12` constant) for camera previews for both 143 front- and rear-facing cameras for `android.hardware.Camera`. (The hardware 144 video encoder and camera may use any native pixel format, but the device 145 implementation MUST support conversion to YV12.) 146 * [C-0-4] MUST support the `android.hardware.ImageFormat.YUV_420_888` and 147 `android.hardware.ImageFormat.JPEG` formats as outputs through the 148 `android.media.ImageReader` API for `android.hardware.camera2` devices that 149 advertise [`REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE`]( 150 https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE) 151 capability in [`android.request.availableCapabilities`]( 152 https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#REQUEST_AVAILABLE_CAPABILITIES). 153 * [C-0-5] MUST still implement the full [Camera API]( 154 http://developer.android.com/reference/android/hardware/Camera.html) 155 included in the Android SDK documentation, regardless of whether the device 156 includes hardware autofocus or other capabilities. For instance, cameras that 157 lack autofocus MUST still call any registered 158 `android.hardware.Camera.AutoFocusCallback` instances (even though this has no 159 relevance to a non-autofocus camera.) Note that this does apply to front-facing 160 cameras; for instance, even though most front-facing cameras do not support 161 autofocus, the API callbacks must still be faked as described. 162 * [C-0-6] MUST recognize and honor each parameter name 163 defined as a constant on the 164 [`android.hardware.Camera.Parameters`]( 165 http://developer.android.com/reference/android/hardware/Camera.Parameters.html) 166 class. 167 Conversely, device implementations MUST NOT honor or recognize string constants 168 passed to the `android.hardware.Camera.setParameters()` method other than those 169 documented as constants on the `android.hardware.Camera.Parameters`. That is, 170 device implementations MUST support all standard Camera parameters if the 171 hardware allows, and MUST NOT support custom Camera parameter types. 172 For instance, device implementations that support image capture 173 using high dynamic range (HDR) imaging techniques MUST support camera parameter 174 `Camera.SCENE_MODE_HDR`. 175 * [C-0-7] MUST report the proper level of support with the 176 [`android.info.supportedHardwareLevel`]( 177 https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#INFO_SUPPORTED_HARDWARE_LEVEL) 178 property as described in the Android SDK and report the appropriate 179 [framework feature flags]( 180 http://source.android.com/devices/camera/versioning.html). 181 * [C-0-8] MUST also declare its individual camera capabilities of 182 `android.hardware.camera2` via the 183 `android.request.availableCapabilities` property 184 and declare the appropriate [feature flags]( 185 http://source.android.com/devices/camera/versioning.html); 186 MUST define the feature flag if any of its attached camera devices 187 supports the feature. 188 * [C-0-9] MUST broadcast the `Camera.ACTION_NEW_PICTURE` 189 intent whenever a new picture is taken by the camera and the entry of the 190 picture has been added to the media store. 191 * [C-0-10] MUST broadcast the `Camera.ACTION_NEW_VIDEO` 192 intent whenever a new video is recorded by the camera and the entry of the 193 picture has been added to the media store. 194 195 ### 7.5.5\. Camera Orientation 196 197 If device implementations have a front- or a rear-facing camera, such camera(s): 198 199 * [C-1-1] MUST be oriented so that the long dimension of the camera 200 aligns with the screens long dimension. That is, when the device is held in the 201 landscape orientation, cameras MUST capture images in the landscape orientation. 202 This applies regardless of the devices natural orientation; that is, it applies 203 to landscape-primary devices as well as portrait-primary devices. 204