Home | History | Annotate | Download | only in 3_software
      1 ## 3.3\. Native API Compatibility
      2 
      3 Device implementers are:
      4 
      5 Native code compatibility is challenging. For this reason,
      6 device implementers are:
      7 
      8 *   [SR] STRONGLY RECOMMENDED to use the implementations of the libraries
      9 listed below from the upstream Android Open Source Project.
     10 
     11 ### 3.3.1\. Application Binary Interfaces
     12 
     13 Managed Dalvik bytecode can call into native code provided in the application
     14 `.apk` file as an ELF `.so` file compiled for the appropriate device hardware
     15 architecture. As native code is highly dependent on the underlying processor
     16 technology, Android defines a number of Application Binary Interfaces (ABIs) in
     17 the Android NDK.
     18 
     19 Device implementations:
     20 
     21 *   [C-0-1] MUST be compatible with one or more defined ABIs and implement
     22     compatibility with the Android NDK.
     23 *   [C-0-2] MUST include support for code running in the managed environment to
     24     call into native code, using the standard Java Native Interface (JNI)
     25     semantics.
     26 *   [C-0-3] MUST be source-compatible (i.e. header-compatible) and
     27     binary-compatible (for the ABI) with each required library in the list
     28     below.
     29 *   [C-0-4] MUST support the equivalent 32-bit ABI if any 64-bit ABI is
     30     supported.
     31 *   [C-0-5]  MUST accurately report the native Application Binary Interface
     32     (ABI) supported by the device, via the `android.os.Build.SUPPORTED_ABIS`,
     33     `android.os.Build.SUPPORTED_32_BIT_ABIS`, and
     34     `android.os.Build.SUPPORTED_64_BIT_ABIS` parameters, each a comma separated
     35     list of ABIs ordered from the most to the least preferred one.
     36 *   [C-0-6] MUST report, via the above parameters, only those ABIs documented
     37     and described in the latest version of the
     38     [Android NDK ABI Management documentation](
     39     https://developer.android.com/ndk/guides/abis.html), and MUST include
     40     support for the [Advanced SIMD](
     41     http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0388f/Beijfcja.html)
     42     (a.k.a. NEON) extension.
     43 *   [C-0-7] MUST make all the following libraries, providing native APIs,
     44     available to apps that include native code:
     45 
     46     *   libaaudio.so (AAudio native audio support)
     47     *   libandroid.so (native Android activity support)
     48     *   libc (C library)
     49     *   libcamera2ndk.so
     50     *   libdl (dynamic linker)
     51     *   libEGL.so (native OpenGL surface management)
     52     *   libGLESv1\_CM.so (OpenGL ES 1.x)
     53     *   libGLESv2.so (OpenGL ES 2.0)
     54     *   libGLESv3.so (OpenGL ES 3.x)
     55     *   libicui18n.so
     56     *   libicuuc.so
     57     *   libjnigraphics.so
     58     *   liblog (Android logging)
     59     *   libmediandk.so (native media APIs support)
     60     *   libm (math library)
     61     *   libOpenMAXAL.so (OpenMAX AL 1.0.1 support)
     62     *   libOpenSLES.so (OpenSL ES 1.0.1 audio support)
     63     *   libRS.so
     64     *   libstdc++ (Minimal support for C++)
     65     *   libvulkan.so (Vulkan)
     66     *   libz (Zlib compression)
     67     *   JNI interface
     68 
     69 *   [C-0-8] MUST NOT add or remove the public functions for the native libraries
     70     listed above.
     71 *   [C-0-9] MUST list additional non-AOSP libraries exposed directly to
     72     third-party apps in `/vendor/etc/public.libraries.txt`.
     73 *   [C-0-10] MUST NOT expose any other native libraries, implemented and
     74     provided in AOSP as system libraries, to third-party apps targeting API
     75     level 24 or higher as they are reserved.
     76 *   [C-0-11] MUST export all the OpenGL ES 3.1 and [Android Extension Pack](
     77     http://developer.android.com/guide/topics/graphics/opengl.html#aep)
     78     function symbols, as defined in the NDK, through the `libGLESv3.so` library.
     79     Note that while all the symbols MUST be present, section 7.1.4.1 describes
     80     in more detail the requirements for when the full implementation of each
     81     corresponding functions are expected.
     82 *   [C-0-12] MUST export function symbols for the core Vulkan 1.0 function
     83     symobls, as well as the `VK_KHR_surface`, `VK_KHR_android_surface`,
     84     `VK_KHR_swapchain`, `VK_KHR_maintenance1`, and
     85     `VK_KHR_get_physical_device_properties2` extensions through the
     86     `libvulkan.so` library.  Note that while all the symbols MUST be present,
     87     section 7.1.4.2 describes in more detail the requirements for when the full
     88     implementation of each corresponding functions are expected.
     89 *   SHOULD be built using the source code and header files available in the
     90     upstream Android Open Source Project
     91 
     92 Note that future releases of the Android NDK may introduce support for
     93 additional ABIs.
     94 
     95 ### 3.3.2. 32-bit ARM Native Code Compatibility
     96 
     97 If device implementations are 64-bit ARM devices, then:
     98 
     99 *    [C-1-1] Although the ARMv8 architecture deprecates several CPU operations,
    100      including some operations used in existing native code, the following
    101      deprecated operations MUST remain available to 32-bit native ARM code,
    102      either through native CPU support or through software emulation:
    103 
    104      *   SWP and SWPB instructions
    105      *   SETEND instruction
    106      *   CP15ISB, CP15DSB, and CP15DMB barrier operations
    107 
    108 If device implementations include a 32-bit ARM ABI, they:
    109 
    110 *    [C-2-1] MUST include the following lines in `/proc/cpuinfo` when it is read
    111      by 32-bit ARM applications to ensure compatibility with applications built
    112      using legacy versions of Android NDK.
    113 
    114      *   `Features: `, followed by a list of any optional ARMv7 CPU features
    115      supported by the device.
    116      *   `CPU architecture: `, followed by an integer describing the device's
    117      highest supported ARM architecture (e.g., "8" for ARMv8 devices).
    118 
    119 *    SHOULD not alter `/proc/cpuinfo` when read by 64-bit ARM or non-ARM
    120      applications.