1## 7.1\. Display and Graphics
2
3Android includes facilities that automatically adjust application assets and UI
4layouts appropriately for the device to ensure that third-party applications
5run well on a [variety of hardware configurations](http://developer.android.com/guide/practices/screens_support.html).
6Devices MUST properly implement these APIs and behaviors, as detailed in this
7section.
8
9The units referenced by the requirements in this section are defined as follows:
10
11*   **physical diagonal size**. The distance in inches between two opposing
12corners of the illuminated portion of the display.
13*   **dots per inch (dpi)**. The number of pixels encompassed by a linear
14horizontal or vertical span of 1”. Where dpi values are listed, both horizontal
15and vertical dpi must fall within the range.
16*   **aspect ratio**. The ratio of the pixels of the longer dimension to the
17shorter dimension of the screen. For example, a display of 480x854 pixels would
18be 854/480 = 1.779, or roughly “16:9”.
19*   **density-independent pixel (dp)**. The virtual pixel unit normalized to a
20160 dpi screen, calculated as: pixels = dps * (density/160).
21
22### 7.1.1\. Screen Configuration
23
24#### 7.1.1.1\. Screen Size
25
26The Android UI framework supports a variety of different logical screen layout
27sizes, and allows applications to query the current configuration's screen
28layout size via `Configuration.screenLayout` with the `SCREENLAYOUT_SIZE_MASK`
29and `Configuration.smallestScreenWidthDp`.
30
31*    [C-0-1] Device implementations MUST report the correct layout size for the
32 `Configuration.screenLayout` as defined in the Android SDK documentation.
33 Specifically, device implementations MUST report the correct logical
34 density-independent pixel (dp) screen dimensions as below:
35
36     *   Devices with the `Configuration.uiMode` set as any value other than
37     UI_MODE_TYPE_WATCH, and reporting a `small` size for the
38     `Configuration.screenLayout`, MUST have at least 426 dp x 320 dp.
39     *   Devices reporting a `normal` size for the `Configuration.screenLayout`,
40     MUST have at least 480 dp x 320 dp.
41     *   Devices reporting a `large` size for the `Configuration.screenLayout`,
42     MUST have at least 640 dp x 480 dp.
43     *   Devices reporting a `xlarge` size for the `Configuration.screenLayout`,
44     MUST have at least 960 dp x 720 dp.
45
46*   [C-0-2] Device implementations MUST correctly honor applications' stated
47 support for screen sizes through the [<`supports-screens`>](
48 https://developer.android.com/guide/topics/manifest/supports-screens-element.html)
49 attribute in the AndroidManifest.xml, as described
50 in the Android SDK documentation.
51
52#### 7.1.1.2\. Screen Aspect Ratio
53
54While there is no restriction to the screen aspect ratio value of the physical
55screen display, the screen aspect ratio of the logical display that third-party
56apps are rendered within, as can be derived from the height and width values
57reported through the [`view.Display`](
58https://developer.android.com/reference/android/view/Display.html)
59APIs and [Configuration](
60https://developer.android.com/reference/android/content/res/Configuration.html)
61API, MUST meet the following requirements:
62
63*   [C-0-1] Device implementations with the `Configuration.uiMode` set as
64    `UI_MODE_TYPE_NORMAL` MUST have an aspect ratio value between 1.3333 (4:3)
65    and 1.86 (roughly 16:9), unless the app can be deemed as ready to be
66    stretched longer by meeting one of the following conditions:
67
68     *  The app has declared that it supports a larger screen aspect ratio
69     through  the [`android.max_aspect`](
70     https://developer.android.com/guide/practices/screens_support.html#MaxAspectRatio)
71     metadata value.
72     *  The app declares it is resizeable via the [android:resizeableActivity](
73     https://developer.android.com/guide/topics/ui/multi-window.html#configuring)
74     attribute.
75     *  The app is targeting API level 24 or higher and does not declare a
76     [`android:MaxAspectRatio`](
77     https://developer.android.com/reference/android/R.attr.html#maxAspectRatio)
78     that would restrict the allowed aspect ratio.
79
80
81*   [C-0-2] Device implementations with the `Configuration.uiMode` set as
82    `UI_MODE_TYPE_WATCH` MUST have an aspect ratio value set as 1.0 (1:1).
83
84#### 7.1.1.3\. Screen Density
85
86The Android UI framework defines a set of standard logical densities to help
87application developers target application resources.
88
89*    [C-0-1] By default, device implementations MUST report only one of the
90following logical Android framework densities through the
91[DENSITY_DEVICE_STABLE](
92https://developer.android.com/reference/android/util/DisplayMetrics.html#DENSITY_DEVICE_STABLE)
93API and this value MUST NOT change at any time; however, the device MAY report
94a different arbitrary density according to the display configuration changes
95made by the user (for example, display size) set after initial boot.
96
97    *   120 dpi (ldpi)
98    *   160 dpi (mdpi)
99    *   213 dpi (tvdpi)
100    *   240 dpi (hdpi)
101    *   260 dpi (260dpi)
102    *   280 dpi (280dpi)
103    *   300 dpi (300dpi)
104    *   320 dpi (xhdpi)
105    *   340 dpi (340dpi)
106    *   360 dpi (360dpi)
107    *   400 dpi (400dpi)
108    *   420 dpi (420dpi)
109    *   480 dpi (xxhdpi)
110    *   560 dpi (560dpi)
111    *   640 dpi (xxxhdpi)
112
113*    Device implementations SHOULD define the standard Android framework density
114     that is numerically closest to the physical density of the screen, unless that
115     logical density pushes the reported screen size below the minimum supported. If
116     the standard Android framework density that is numerically closest to the
117     physical density results in a screen size that is smaller than the smallest
118     supported compatible screen size (320 dp width), device implementations SHOULD
119     report the next lowest standard Android framework density.
120
121
122If there is an affordance to change the display size of the device:
123
124*  [C-1-1] The display size MUST NOT be scaled any larger than 1.5 times the native density or
125   produce an effective minimum screen dimension smaller than 320dp (equivalent
126   to resource qualifier sw320dp), whichever comes first.
127*  [C-1-2] Display size MUST NOT be scaled any smaller than 0.85 times the native density.
128*  To ensure good usability and consistent font sizes, it is RECOMMENDED that the
129   following scaling of Native Display options be provided (while complying with the limits
130   specified above)
131   *  Small: 0.85x
132   *  Default: 1x (Native display scale)
133   *  Large: 1.15x
134   *  Larger: 1.3x
135   *  Largest 1.45x
136
137### 7.1.2\. Display Metrics
138
139If device implementations include a screen or video output, they:
140
141*    [C-1-1] MUST report correct values for all display metrics defined in the
142 [`android.util.DisplayMetrics`](
143 https://developer.android.com/reference/android/util/DisplayMetrics.html) API.
144
145If device implementations does not include an embedded screen or video output,
146they:
147
148*    [C-2-1] MUST report reasonable values for all display metrics defined in
149 the [`android.util.DisplayMetrics`](
150 https://developer.android.com/reference/android/util/DisplayMetrics.html) API
151 for the emulated default `view.Display`.
152
153
154
155### 7.1.3\. Screen Orientation
156
157Device implementations:
158
159*    [C-0-1] MUST report which screen orientations they support
160     (`android.hardware.screen.portrait` and/or
161     `android.hardware.screen.landscape`) and MUST report at least one supported
162     orientation. For example, a device with a fixed orientation landscape
163     screen, such as a television or laptop, SHOULD only
164     report `android.hardware.screen.landscape`.
165*    [C-0-2] MUST report the correct value for the device’s current
166     orientation, whenever queried via the
167     `android.content.res.Configuration.orientation`,
168     `android.view.Display.getOrientation()`, or other APIs.
169
170If device implementations support both screen orientations, they:
171
172*    [C-1-1] MUST support dynamic orientation by applications to either portrait or landscape screen
173     orientation. That is, the device must respect the application’s request for a specific screen
174     orientation.
175*    [C-1-2] MUST NOT change the reported screen size or density when changing orientation.
176*    MAY select either portrait or landscape orientation as the default.
177
178
179### 7.1.4\. 2D and 3D Graphics Acceleration
180
181#### 7.1.4.1 OpenGL ES
182
183Device implementations:
184
185*   [C-0-1] MUST correctly identify the supported OpenGL ES versions (1.1, 2.0,
186    3.0, 3.1, 3.2) through the managed APIs (such as via the
187    `GLES10.getString()` method) and the native APIs.
188*   [C-0-2] MUST include the support for all the corresponding managed APIs and
189    native APIs for every OpenGL ES versions they identified to support.
190
191If device implementations include a screen or video output, they:
192
193*   [C-1-1] MUST support both OpenGL ES 1.0 and 2.0, as embodied and detailed
194    in the [Android SDK documentation](
195    https://developer.android.com/guide/topics/graphics/opengl.html).
196*   [SR] are STRONGLY RECOMMENDED to support OpenGL ES 3.0.
197*   SHOULD support OpenGL ES 3.1 or 3.2.
198
199If device implementations support any of the OpenGL ES versions, they:
200
201*   [C-2-1] MUST report via the OpenGL ES managed APIs and native APIs any
202    other OpenGL ES extensions they have implemented, and conversely MUST
203    NOT report extension strings that they do not support.
204*   [C-2-2] MUST support the `EGL_KHR_image`, `EGL_KHR_image_base`,
205    `EGL_ANDROID_image_native_buffer`, `EGL_ANDROID_get_native_client_buffer`,
206    `EGL_KHR_wait_sync`, `EGL_KHR_get_all_proc_addresses`,
207    `EGL_ANDROID_presentation_time`, `EGL_KHR_swap_buffers_with_damage` and
208    `EGL_ANDROID_recordable` extensions.
209*   [SR] are STRONGLY RECOMMENDED to support EGL_KHR_partial_update.
210*   SHOULD accurately report via the `getString()` method, any texture
211    compression format that they support, which is typically vendor-specific.
212
213If device implementations declare support for OpenGL ES 3.0, 3.1, or 3.2, they:
214
215*   [C-3-1] MUST export the corresponding function symbols for these version in
216    addition to the OpenGL ES 2.0 function symbols in the libGLESv2.so library.
217
218If device implementations support OpenGL ES 3.2, they:
219
220*    [C-4-1] MUST support the OpenGL ES Android Extension Pack in its entirety.
221
222If device implementations support the OpenGL ES [Android Extension Pack](
223https://developer.android.com/reference/android/opengl/GLES31Ext.html) in its
224entirety, they:
225
226*   [C-5-1] MUST identify the support through the `android.hardware.opengles.aep`
227    feature flag.
228
229If device implementations expose support for the `EGL_KHR_mutable_render_buffer`
230extension, they:
231
232*   [C-6-1] MUST also support the `EGL_ANDROID_front_buffer_auto_refresh`
233    extension.
234
235#### 7.1.4.2 Vulkan
236
237Android includes support for [Vulkan](
238https://www.khronos.org/registry/vulkan/specs/1.0-wsi&lowbarextensions/xhtml/vkspec.html)
239, a low-overhead, cross-platform API for high-performance 3D graphics.
240
241If device implementations support OpenGL ES 3.0 or 3.1, they:
242
243*    [SR] Are STRONGLY RECOMMENDED to include support for Vulkan 1.0 .
244
245If device implementations include a screen or video output, they:
246
247*    SHOULD include support for Vulkan 1.0.
248
249Device implementations, if including support for Vulkan 1.0:
250
251*   [C-1-1] MUST report the correct integer value with the
252    `android.hardware.vulkan.level` and `android.hardware.vulkan.version`
253    feature flags.
254*   [C-1-2] MUST enumarate, at least one `VkPhysicalDevice` for the Vulkan
255    native API [`vkEnumeratePhysicalDevices()`](
256    https://www.khronos.org/registry/vulkan/specs/1.0/man/html/vkEnumeratePhysicalDevices.html)
257    .
258*   [C-1-3] MUST fully implement the Vulkan 1.0 APIs for each enumerated
259    `VkPhysicalDevice`.
260*   [C-1-4] MUST enumerate layers, contained in native libraries named as
261    `libVkLayer*.so` in the application package’s native library directory,
262    through the Vulkan native APIs [`vkEnumerateInstanceLayerProperties()`](
263    https://www.khronos.org/registry/vulkan/specs/1.0/man/html/vkEnumerateInstanceLayerProperties.html)
264    and [`vkEnumerateDeviceLayerProperties()`](
265    https://www.khronos.org/registry/vulkan/specs/1.0/man/html/vkEnumerateDeviceLayerProperties.html)
266    .
267*   [C-1-5] MUST NOT enumerate layers provided by libraries outside of the
268    application package, or provide other ways of tracing or intercepting the
269    Vulkan API, unless the application has the `android:debuggable` attribute
270    set as `true`.
271*   [C-1-6] MUST report all extension strings that they do support via the
272    Vulkan native APIs , and conversely MUST NOT report extension strings
273    that they do not correctly support.
274
275Device implementations, if not including support for Vulkan 1.0:
276
277*   [C-2-1] MUST NOT declare any of the Vulkan feature flags (e.g.
278    `android.hardware.vulkan.level`, `android.hardware.vulkan.version`).
279*   [C-2-2] MUST NOT enumarate any `VkPhysicalDevice` for the Vulkan native API
280    `vkEnumeratePhysicalDevices()`.
281
282#### 7.1.4.3 RenderScript
283
284*    [C-0-1] Device implementations MUST support [Android RenderScript](
285     http://developer.android.com/guide/topics/renderscript/), as detailed
286     in the Android SDK documentation.
287
288#### 7.1.4.4 2D Graphics Acceleration
289
290Android includes a mechanism for applications to declare that they want to
291enable hardware acceleration for 2D graphics at the Application, Activity,
292Window, or View level through the use of a manifest tag
293[android:hardwareAccelerated](
294http://developer.android.com/guide/topics/graphics/hardware-accel.html)
295or direct API calls.
296
297Device implementations:
298
299*    [C-0-1] MUST enable hardware acceleration by default, and MUST
300     disable hardware acceleration if the developer so requests by setting
301     android:hardwareAccelerated="false” or disabling hardware acceleration
302     directly through the Android View APIs.
303*    [C-0-2] MUST exhibit behavior consistent with the
304     Android SDK documentation on [hardware acceleration](
305     http://developer.android.com/guide/topics/graphics/hardware-accel.html).
306
307Android includes a TextureView object that lets developers directly integrate
308hardware-accelerated OpenGL ES textures as rendering targets in a UI hierarchy.
309
310Device implementations:
311
312*    [C-0-3] MUST support the TextureView API, and MUST exhibit
313     consistent behavior with the upstream Android implementation.
314
315#### 7.1.4.5 Wide-gamut Displays
316
317If device implementations claim support for wide-gamut displays through
318[`Configuration.isScreenWideColorGamut()`
319](https://developer.android.com/reference/android/content/res/Configuration.html#isScreenWideColorGamut%28%29)
320, they:
321
322*   [C-1-1] MUST have a color-calibrated display.
323*   [C-1-2] MUST have a display whose gamut covers the sRGB color gamut entirely
324    in CIE 1931 xyY space.
325*   [C-1-3] MUST have a display whose gamut has an area of at least 90% of NTSC
326    1953 in CIE 1931 xyY space.
327*   [C-1-4] MUST support OpenGL ES 3.0, 3.1, or 3.2 and report it properly.
328*   [C-1-5] MUST advertise support for the `EGL_KHR_no_config_context`,
329    `EGL_EXT_pixel_format_float`,`EGL_KHR_gl_colorspace`,
330    `EGL_EXT_colorspace_scrgb_linear`, and `EGL_GL_colorspace_display_p3`
331    extensions.
332*   [SR] Are STRONGLY RECOMMENDED to support `GL_EXT_sRGB`.
333
334Conversely, if device implementations do not support wide-gamut displays, they:
335
336*   [C-2-1] SHOULD cover 100% or more of sRGB in CIE 1931 xyY space, although
337    the screen color gamut is undefined.
338
339### 7.1.5\. Legacy Application Compatibility Mode
340
341Android specifies a “compatibility mode” in which the framework operates in a
342'normal' screen size equivalent (320dp width) mode for the benefit of legacy
343applications not developed for old versions of Android that pre-date
344screen-size independence.
345
346### 7.1.6\. Screen Technology
347
348The Android platform includes APIs that allow applications to render rich
349graphics to the display. Devices MUST support all of these APIs as defined by
350the Android SDK unless specifically allowed in this document.
351
352Device implementations:
353
354*   [C-0-1] MUST support displays capable of rendering 16-bit color graphics.
355*   SHOULD support displays capable of 24-bit color graphics.
356*   [C-0-2] MUST support displays capable of rendering animations.
357*   [C-0-3] MUST use the display technology that have a pixel aspect ratio (PAR)
358    between 0.9 and 1.15\. That is, the pixel aspect ratio MUST be near square
359    (1.0) with a 10 ~ 15% tolerance.
360
361### 7.1.7\. Secondary Displays
362
363Android includes support for secondary display to enable media sharing
364capabilities and developer APIs for accessing external displays.
365
366If device implementations support an external display either via a wired,
367wireless, or an embedded additional display connection, they:
368
369*   [C-1-1] MUST implement the [`DisplayManager`](
370    https://developer.android.com/reference/android/hardware/display/DisplayManager.html)
371    system service and API as described in the Android SDK documentation.
372