diff --git a/docs/html/ndk/downloads/_book.yaml b/docs/html/ndk/downloads/_book.yaml deleted file mode 100644 index a5e92ce867c02..0000000000000 --- a/docs/html/ndk/downloads/_book.yaml +++ /dev/null @@ -1,6 +0,0 @@ -toc: -- title: Downloads - path: /ndk/downloads/index.html - -- title: Revision History - path: /ndk/downloads/revision_history.html diff --git a/docs/html/ndk/downloads/downloads_toc.cs b/docs/html/ndk/downloads/downloads_toc.cs deleted file mode 100644 index dbe8aec88cd24..0000000000000 --- a/docs/html/ndk/downloads/downloads_toc.cs +++ /dev/null @@ -1,28 +0,0 @@ - - -
- - - - diff --git a/docs/html/ndk/downloads/index.jd b/docs/html/ndk/downloads/index.jd deleted file mode 100644 index 28860b28894c0..0000000000000 --- a/docs/html/ndk/downloads/index.jd +++ /dev/null @@ -1,530 +0,0 @@ -ndk=true -page.template=sdk -page.title=NDK Downloads - -@jd:body - - - -Select, from the table above, the NDK package for your development platform. For information - about the changes in the newest version of the NDK, see Release Notes. For - information about earlier revisions, see - NDK Revision History.
- - - - -- Android NDK, Revision 12 (June 2016) -
- -ndk-build command will default to using
- Clang in an upcoming release. GCC will be removed in a later release.
- make-standalone-toolchain.sh script will be removed
- in an upcoming release. If you use this script, please plan to migrate to the
- make_standalone_toolchain.py as soon as possible.
-
- build/tools/make_standalone_toolchain.py. On Windows, you no longer
- need Cygwin to use this feature. Note that the bash flavor will be removed
- in an upcoming release, so please test the new one now.
- -fno-limit-debug-info
- option is enabled by default. This change enables better debugging with LLDB.
- --build-id as a default option. This option
- causes an identifier to be shown in native crash reports so you can easily
- identify which version of your code was running.
- NDK_USE_CYGPATH so that it no longer causes
- problems with libgcc
- (Issue 195486).
- -Wl,--warn-shared-textrel and -Wl,--fatal-warnings.
- If you have shared text relocations, your app does not load on Android 6.0
- (API level 23) and higher. Note that this configuration has never been
- allowed for 64-bit apps.
- INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED feature level or higher.
- For more information, see the
-
- CameraCharacteristics reference.
- __thread so that it works for real this time.
- libatomic to not use ifuncs (NDK Issue 31).
- --long-plt to fix an internal linker error
- when linking huge arm32 binaries.
- AArch64. This problem was
- causing jump addresses to be calculated incorrectly for very large
- dynamic shared objects (DSOs).
- --no-apply-dynamic to work around
- a dynamic linker bug for earlier Android releases.
- dynamic_cast was not
- working with Clang, x86, stlport_static and optimization.
- ndk-gdb.py script.
- c++_shared does not work for ARM on
- Android 2.3 (API level 9) or Android 4.0 (API level 14).
- NdkCameraMetadataTags.h header file, the camera metadata
- tag enum value ACAMERA_STATISTICS_LENS_SHADING_CORRECTION_MAP
- was listed by accident and will be removed in next release. Use
- the ACAMERA_STATISTICS_LENS_SHADING_MAP value instead.
- This page provides information on previous releases of the NDK, enumerating the changes that -took place in each new version.
- - -
-
Android NDK, Revision 11c (March 2016)
-
-
Android NDK, Revision 11b (March 2016)
-
-
Android NDK, Revision 11 (March 2016)
-
-
Android NDK, Revision 10e (May 2015)
-
-in add_stores, at var-tracking.c:6000 --
-.../ld: warning: creating a DT_TEXTREL in a shared object --
-
Android NDK, Revision 10d (December 2014)
-
NDK_TOOLCHAIN_VERSION=4.6 to ndk-build, or
- add --toolchain=arm-linux-androideabi-4.6 when executing
- make-standalone-toolchain.sh on the command line. GCC 4.9 remains the
- default for 64-bit ABIs.-mstackrealign by default. The
- NDK toolchain assumes a 16-byte stack alignment. The tools and options used by default
- enforce this rule. A user writing assembly code must make sure to preserve stack
- alignment, and ensure that other compilers also comply with this rule.
- (GCC bug 38496)-fPIE -pie
- when building. In API levels 16 and higher, ndk-build uses PIE
- when building. This change has a number of implications, which are discussed in
-
- Developer Preview Issue 888.
- These implications do not apply to shared libraries.--fix-cortex-a53-835769, when
- -mfix-cortex-a53-835769 (enabled by default) is specified.
- For more information, see this
- binutils message
- and this
- binutils message.
- sscanf/vsscanf hang that occurred in API level
- 21. The fix itself had been implemented in r10c.
- (Issue 77988)-fauto-profile) crash that occurred with GCC 4.9 when
- -Os was specified. (Issue 77571)posix_memalign to API level 16. Also, added a prototype in
- stdlib.h to API levels 16 to 19.
- (Issue 77861)stdatomic.h so that it includes <atomic> only for
- C++11.sys/user.h, and
- gl2ext.h, dlext.h, fts.h, sgidefs.h
- for API level 21.sys/user.h to rename mxcsr_mask as mxcr_mask,
- and to change the data type for u_ar0unsigned long
- to struct user_regs_struct*.
- sysconf() return value type from int to
- long.thumb for LOCAL_ARM_MODE: In
- r10d, ndk-build adds LOCAL_LDFLAGS+=-mthumb by default, unless one of the
- following conditions applies:LOCAL_ARM_MODE equal to arm.APP_OPTIM=debug and
- AndroidManifest.xml containing android:debuggable="true"),
- where ARM mode is the default in order to retain compatibility with earlier toolchains.
- (Issue 74040)LOCAL_SRC_FILES in ndk-build to use Windows absolute paths.
- (Issue 74333)make-standalone-toolchain.sh.
- (Issue 74145)System.loadLibrary() transitive
- dependencies. (Issue 41790)LOCAL_PCH to improve Clang support. (Issue
- 77575)
-
Android NDK, Revision 10c (October 2014)
-
Android-L to the official release
- designation: android-21.google branch
- of the GCC repository. Major differences from the upstream version of GCC 4.9 include:-O2 option now turns on vectorization, without loop peeling but with more
- aggressive unrolling.For more detailed information, see Important bug fixes below.
-NDK_TOOLCHAIN_VERSION=clang
- now picks Clang 3.5. Note that:-fno-integrated-as as a workaround.
- -finline-functions
- option that GCC supports.When migrating from projects using GCC, you can use
- -Wno-invalid-command-line-argument and -Wno-unused-command-line-argument
- to ignore the unused flags until you're able decide on what to do with them longer-term.
art-on option. For more information,
- see prebuilt/common/gdb/common.setup in the directory containing the NDK.--icf option.arm_neon.h support in x86 and x86_64, attaining coverage of ~93% of
- NEON intrinsics. For more information about NEON support:
- docs/Programmers_Guide/html/), and see
- Architectures and CPUs > Neon.hello-neon sample in samples/.
- _FORTIFY_SOURCE in headers/libs/android-21,
- which appeared in r10 (when android-21 was still called Android-L),
- but had no documentation.-internal compiler error: in simplify_const_unary_operation, at simplify-rtx.c:1539 --
x = (cond) ? y : x.
- (Issue 77569)-mno-fix-cortex-a53-835769.android-21:
- android/keycodes.handroid/sensor.h:
- ASensorManager_getDefaultSensorEx, ASensor_getFifoMaxEventCount,
- ASensor_getFifoReservedEventCount, ASensor_getStringType,
- ASensor_getReportingMode, and ASensor_isWakeUpSensor.stdatomic.h to improve compatibility with GCC 4.6, and provide support
- for the <atomic> header.sys/ucontext.h and sys/user.h to all API levels. The
- signal.h header now includes <sys/ucontext.h>. You may
- remove any existing definition of struct ucontext.posix_memalign to API levels 17, 18, and 19.android_set_abort_message, posix_fadvise,
- posix_fadvise64, pthread_gettid_np.native-media/AndroidManifest.xml
- sample.
- (Issue 106640)clock_nanosleep and clock_settime to API level 21. (Issue
- 77372)
- get_malloc_leak_info, free_malloc_leak_info,
- __srget, __swbuf, __srefill, __swsetup,
- __sdidinit, __sflags, __sfp,
- __sinit, __smakebuf, __sflush, __sread,
- __swrite, __sseek, __sclose,
- _fwalk, __sglue, __get_thread, __wait4,
- __futex_wake, __open, __get_tls,
- __getdents64, and dlmalloc.basename_r,
- dirname_r, __isthreaded, _flush_cache (mips64).__signalfd4.size_t to int in
- the following functions: strtoll_l, strtoull_l,
- wcstoll_l, and wcstoull_l.arc4random,
- arc4random_buf, and arc4random_uniform.cxa_* and the new and delete operators back
- to libstdc++.so. This change restores r9d behavior; previous versions of r10
- contained dummy files.--toolchain= in make-standalone-toolchain.sh so that it
- now properly supports use of a suffix specifying a version of Clang.strtod() functions.docs/.cpu-features to detect ARMv8 support for the following
- instruction sets: AES, CRC32, SHA2, SHA1, and 64-bit PMULL/PMULL2. (Issue
- 106360)*-gcc-ar, which is available in GCC 4.8, GCC 4.9, and
- Clang. Clang specifies it, instead of *-ar. This setting brings improved LTO
- support.include-fixed/linux/a.out.h and
- include-fixed/linux/compiler.h headers from the GCC compiler.
- (Issue 73728)-flto with GCC 4.8 on Mac OS X. The error message
- read:-.../ld: error: .../libexec/gcc/arm-linux-androideabi/4.9/liblto_plugin.so -Symbol not found: _environ -- -
build-binary.mk. (Issue
- 76992)-fauto-profile) in GCC4.9 may cause crashing.
- (Issue 77571)
-
Android NDK, Revision 10b (September 2014)
-
stdio.h from the include-fixed/ directories of all versions of GCC. (Issue 73728.)platforms/android-L/arch-*/usr/include/linux/netfilter*/ directories. (Issue 73704.)docs/ and sources/third_party/googletest/README.NDK. (Issue 74069.)ctype.h and wchar.h: dn_expand(), grantpt(), inet_nsap_addr(), inet_nsap_ntoa(), insque(), nsdispatch(), posix_openpt(), __pthread_cleanup_pop(), __pthread_cleanup_push(), remque(), setfsgid(), setfsuid(), splice(), tee(), twalk() (Issue 73719), and 42 *_l() functions.cmsg_nxthdr to __cmsg_nxthdr.__libc_malloc_dispatch.ptrace() prototype to long ptrace(int, ...);.sha1.h.android_dlextinfo in android/dlext.h.__NDK_FPABI__ for functions receiving or returning float- or double-type values in stdlib.h, time.h, wchar.h, and complex.h.mipsel-linux-android-4.9 and mips64el-linux-android-4.9, implementing a new multilib directory layout, and providing support for gdb-7.7cpu-features to detect more arm64 features. (Change list 100339.)
-
Android NDK, Revision 10 (July 2014)
-
NDK_TOOLCHAIN_VERSION=clang
- may not work for arm64-v8a and mips64.all32 and all64
-settings for APP_ABI.
- APP_ABI=all32 is equivalent to
-APP_ABI=armeabi,armeabi-v7a,x86,mips.APP_ABI=all64 is equivalent to
-APP_ABI=arm64-v8a,x86_64,mips64.APP_ABI=all selects all ABIs.<tr1/cmath>
-Before defining your own math function, check _GLIBCXX_USE_C99_MATH_TR1 to see a
-function with that name already exists, in order to avoid "multiple definition" errors from the
-linker.platforms/android-L/ API directory. It includes:Android.h header for SLES/OpenSLES, enabling support for
-single-precision, floating-point audio format in AudioPlayer.libGLESv3.so.NDK_TOOLCHAIN_VERSION=4.9 to Application.mk, or exporting it as an
-environment variable from the command line.--toolchain= option in the
-make-standalone-toolchain.sh script. For example: --toolchain=arm-linux-androideabi-4.9.NDK_TOOLCHAIN_VERSION=4.8 or 4.9 to enable ndk-gdb to select GDB 7.6.-mssse3 build option to provide SSSE3 support, and made it the default for ABI x86
-(upgrading from SSE3). The image released by Google does not contain SSSE3 instructions.-fno-strict-aliasing if you use <list>, because __list_imp::_end_ breaks
- TBAA rules. (Issue 61571.)LOCAL_PCH. (Issue 25412).std::feof, etc. (Issue 66668).-O3 assert on:llvm-3.2/llvm/include/llvm/MDBuilder.h:64: llvm::MDNode*
-llvm::MDBuilder::createBranchWeights(llvm::ArrayRef): Assertion Weights.size() >= 2
-&& "Need at least two branch weights!" (Issue 57381).
- Assertion failed: (!Fn && "cast failed but able to resolve overload expression!!"), function CheckCXXCStyleCast, file
-Volumes/data/ndk-toolchain/src/llvm-3.3/llvm/tools/clang/lib/Sema/SemaCast.cpp, line 2018.
-(Issue 66950).
- ssize_t to be int instead of long
-int.WCHAR_MIN and WCHAR_MAX so that they they take
-appropriate signs according to the architecture they're running on:-D__WCHAR_UNSIGNED__.wchar_t to be 16 bits, use -fshort-wchar.libc.so, and added pread64,
-pwrite64, ftruncate64 for
-Android API level 12 and higher. (Issue 69319). For more
-information, see the commit message accompanying AOSP change list
- 94137.putchar. Warning message reads:include/stdio.h:236:5: warning: conflicts with previous declaration here
-[-Wattributes] int putchar(int); (Change list 91185).
- make-standalone-toolchain.sh --stl=libc++ so that it:cxxabi.h. (Issue 68001).APP_PLATFORM
-environment variable.IsSystemLibrary() in crazy_linker so that it
-uses strrchr()
- instead of strchr() to find the library path's true basename.-Wl,-shared (as opposed to
--shared, which
- had no compilation issues). The problem was that Clang added -pie for Android
-targets if neither -shared nor -static existed. This behavior, which was
-incorrect, caused the linker to complain that -shared and -pie could not
-co-exist.arm_neon.h to the x86 toolchain so that it now emulates ~47% of
-Neon. There is currently no support for 64-bit types. For more information, see the section on ARM
-Neon intrinsics support in the x86 documentation.$NDK/tests/build/b14811006-GOT_PREL-optimization/.--toolchain=x86_64-linux-android-4.9, which is equivalent to
---toolchain=x86_64-4.9.
-
Android NDK, Revision 9d (March 2014)
-
NDK_TOOLCHAIN_VERSION=clang option now picks Clang 3.4. GCC 4.6 is
-still the default compiler.APP_ABI=armeabi-v7a-hard, with
-additional multilib option -mfloat-abi=hard. These options are for
-use with ARM GCC 4.6/4.8 and Clang 3.3/3.4 (which use 4.8's assembler, linker,
-and libs). When using these options, note the following changes:ndk-build script, add the
-following options for armeabi-v7a target:
-TARGET_CFLAGS += -mhard-float -D_NDK_MATH_NO_SOFTFP=1 -TARGET_LDFLAGS += -Wl,--no-warn-mismatch -lm_hard-The built library is copied to
libs/armeabi-v7a. For make to
-behave as expected, you cannot specify both armeabi-v7a and
-armeabi-v7a-hard as make targets (i.e., on the APP_ABI= line).
-Doing so causes one of them to be ignored. Note that APP_ABI=all
-is still equivalent to
-armeabi armeabi-v7a x86 mips.make-standalone-toolchain.sh script copies
-additional libaries under /hard directories.
- Add the above CFLAGS and LFLAGS to your
-makefile to enable GCC or Clang to link with
- libraries in /hard.LOCAL_ASMFLAGS
-and EXPORT_ASMFLAGS flags for x86
-targets. The ndk-build script uses
-prebuilts/*/bin/yasm* to build LOCAL_SRC_FILES that
-have the .asm extension.-gc-sections
-support.APP_STL := c++_static or APP_STL :=
-c++_shared in Application.mk.
- You may rebuild from source via LIBCXX_FORCE_REBUILD :=
-truemake-standalone-toolchain.sh --stl=libc++
-to create a standalone toolchain with libc++ headers/lib.CPLUSPLUS-SUPPORT.html.
-(Issue 36496)zlib, bz2,
-_curses, _curses_panel, _hashlib,
-_sslzlib, nis,
-crypt, _curses, and _curses_panelevent_getmsg_helper.#include <sys/types.h> in
-android/asset_manager.h for Android API level 13 and higher.
- (Issue 64988)#include in
-android/rect_manager.h for Android API level 14 and higher.JNICALL to JNI_OnLoad and
-JNI_OnUnload in jni.h. Note that JNICALL
- is defined as __NDK_FPABI__ For more information, see
-sys/cdefs.h.-android/tts.h -EGL/eglext.h -fts.h -GLES/glext.h -GLES2/gl2ext.h -OMXAL/OpenMAXSL_Android.h -SLES/OpenSLES_Android.h -sys/prctl.h -sys/utime.h --
sys/cachectl.h for all architectures. MIPS
-developers can now include this header instead of writing #ifdef
-__mips__.platforms/android-18/include/android/input.h
- by adding __NDK_FPABI__ to functions taking or returning
-float or double values.struct stat, which was incorrectly set
-to its 64-bit counterpart for Android API level 12 and later. This wrong
-setting was a
-regression introduced in release r9c.__PTHREAD_MUTEX_INIT_VALUE,
-__PTHREAD_RECURSIVE_MUTEX_INIT_VALUE,
- and __PTHREAD_ERRORCHECK_MUTEX_INIT_VALUE for Android API
-level 9 and lower.scalbln, scalblnf, and
-scalblnl to x86 libm.so for APIs 18 and later.sources/android/support/include/iconv.h.
- (Issue 63806)std::unexpected() to call
-std::terminate() so that
- a user-defined std::terminate() handler has a chance to run.
-std::nullptr.SYSTEM_UI_FLAG_IMMERSIVE_STICKY. Screen rotation does not
-trigger onSystemUiVisibilityChange, and so does not restore
-immersive mode.ndk-build script to add
--rpath-link=$SYSROOT/usr/lib and
--rpath-link=$TARGET_OUT in order to use ld.bfd to
-link executables. (Issue 64266)-Bsymbolic from all STL builds.ndk-gdb-py.cmd by setting SHELL as
-an environment variable
-instead of passing it to
- python.exe, which ignores the setting.
- (Issue 63054)make-standalone-toolchain.sh script so that
-the --stl=stlport option copies the gabi++ headers instead of
-symlinking them; the cmd.exe and MinGW shells do not understand
-symlinks created by cygwin.*cmd scripts
-previously intended for use only in the cmd.exe shell, in case
-developers prefer to use ndk-build.cmd in cygwin instead of the
-recommended ndk-build script.make-standalone-toolchain.sh
-script by moving instead of copying if the specified destination directory does
-not exist.
-
Android NDK, Revision 9c (December 2013)
-
This is a bug-fix-only release.
--fuse-ld=mcld, so that the following error no longer occurs:
-cc1: internal compiler error: in common_handle_option, at -opts.c:1774
-mhard-float support for
-__builtin math functions. For ongoing information on fixes for
--mhard-float with STL, please follow Issue 61784.poll to poll(struct
-pollfd *, nfds_t, int); in poll.h.utimensat to libc.so for Android
-API levels 12 and 19. These libraries are now included for all Android API
-levels 12 through 19.futimens into libc.so, for Android API
-level 19.clock_settime() and
-clock_nanosleep() to time.h for Android API level 8
-and higher.CLOCK_MONOTONIC_RAW, CLOCK_REALTIME_COARSE,
-CLOCK_MONOTONIC_COARSE, CLOCK_BOOTTIME, CLOCK_REALTIME_ALARM, and
-CLOCK_BOOTTIME_ALARM in time.h.CLOCK_REALTIME_HR and
-CLOCK_MONOTONIC_HR.source/android/ndk_helper:
- Check_ReleaseStringUTFChars in
-/system/lib/libdvm.so that was causing crashes on x86 devices.ndk-build fails that happen in cygwin when the NDK
-package is
-referenced via symlink.ndk-build.cmd fails that happen in windows
-cmd.exe when
-LOCAL_SRC_FILES contains absolute paths. (Issue 69992)ndk-stack script to proceed even when it can't parse
-a frame due to inability to find a routine, filename, or line number. In any of
-these cases, it prints ??.ndk-stack stack for windows-x64_64 targets so that
-it no longer erroneously matches a frame line with a line in the
-stack: section that doesn't contain pc,
-eip, or ip. For example:
-I/DEBUG ( 1151): #00 5f09db68 401f01c4 -/system/lib/libc.so
LOCAL_EXPORT_LDFLAGS.NDK_PROJECT_PATH=null setting for use in an
-integrated build system where options are explicitly passed to
-ndk-build. With this setting, ndk-build makes no
-attempt to look for NDK_PROJECT_PATH. This setting also prevents
-variables from deriving default settings from NDK_PROJECT_PATH. As a result,
-the following variables must now be explicitly specified (with their default
-values if such exist): NDK_OUT, NDK_LIBS_OUT, APP_BUILD_SCRIPT,
-NDK_DEBUG (optional, default to 0), and other APP_*'s
-contained in Application.mk.APP_ABI can now be enumerated in a comma-delimited list. For
-example:
-APP_ABI := "armeabi,armeabi-v7a"
android-ndk-r9c-cxx-stl-libs-with-debugging-info.zip, using the
--g option. This option
-helps the ndk-stack script provide better a stack dump across STL.
-This change should not affect the code/size of the final, stripped file.hello-jni samples to report APP_ABI at
-compilation.ar tool in Deterministic mode (option
--D) to build static libraries. (Issue 60705)
-
Android NDK, Revision 9b (October 2013)
-
-mhard-float in the existing armeabi-v7a ABI. For more
- information and current restrictions on Clang, see
- {@code tests/device/hard-float/jni/Android.mk}.-fdiagnostics-color=auto,
- -fdiagnostics-color=always, or export {@code GCC_COLORS} as shown below:
--GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' -- For more information, see - GCC - Language Independent Options. -
internal compiler error: verify_flow_info failed- (Issue 58916, - GCC Issue)
-external/icu4c/i18n/decimfmt.cpp:1322:1: -internal compiler error: in dbx_reg_number, at dwarf2out.c:10185 -- (GCC Patch) - -
-integrated-as option so it can pass
- tests for {@code ssax-instructions} and {@code fenv}.CPU-ARCH-ABIS.html. For more information, see
- NDK-DEPENDS.html. (Issue 60142)-LOCAL_CFLAGS += -fopenmp -LOCAL_LDFLAGS += -fopenmp -- For code examples, see {@code tests/device/test-openmp}
LOCAL_CONLYFLAGS and APP_CONLYFLAGS to specify
- options applicable to C only but not C++. The existing LOCAL_CFLAGS
- and APP_CFLAGS are also used for C++ compilation (to save trouble of
- specifying most options twice), so options such as -std=gnu99 may fail in
- g++ builds with a warning and clang++ builds with an error.-funwind-tables to allow the stack to be unwound past previously blocked
- points, such as __aeabi_idiv0.-mmxu
-option.-mldc1-sdc1 to control ldxc1/sdxc1 too
-
Android NDK, Revision 9 (July 2013)
-
Note: - The {@code -Wunused-local-typedefs} option is enabled by {@code -Wall}. Be - sure to add {@code __attribute__((unused))} if you use compile-time asserts like - {@code sources/cxx-stl/stlport/stlport/stl/config/features.h}, line #311. For more - information, see - Change 55460
-Note: - In the GCC 4.7 release and later, ARM compilers generate unaligned access code by - default for ARMv6 and higher build targets. You may need to add the - {@code -mno-unaligned-access} build option when building for kernels that do not support - this feature.
-Note: - Both GCC 4.4.3 and Clang 3.1 are deprecated, and will be removed from the next NDK - release.
-O values when using Boost
- 1.52.0. (Issue 42891)
- Note: - This feature requires jdb and produces warning about pending breakpoints. - Specify the {@code --nowait} option to restore previous behavior. -
-clang: for the -arm-enable-ehabi option: may only occur zero or one times!-
Note: - In GCC 4.7, {@code monotonic_clock} and {@code is_monotonic} have been renamed to - {@code steady_clock} and {@code is_steady}, respectively.
-
Android NDK, Revision 8e (March 2013)
-
-
Android NDK, Revision 8d (December 2012)
-
--toolchain=arm-linux-androideabi-4.7
- Note: This feature is experimental. Please try it and - report any issues.
-- Note: This feature is experimental and works better with the GCC - 4.6/4.7 compilers than with GCC 4.4.3 or Clang 3.1. Please try it and - report any issues.
-- Note: The {@code -mstack-protector-guard} setting itself does not - enable any {@code -fstack-protector*} options.
--dyld: lazy symbol binding failed: Symbol not found: _memmem -Referenced from: ...../arm-linux-androideabi/bin/ld -Expected in: /usr/lib/libSystem.B.dylib- This problem was caused by building on Mac OS X 10.7, which produced binaries that were - not compatible with Mac OS 10.6.x and the NDK. -
-
Android NDK, Revision 8c (November 2012)
-
Note: This feature is experimental. Please try it and - report any issues.
- Note: All API levels above 14 still link against {@code - platforms/android-14} and no new {@code platforms/android-N} have been added. -
./build/tools/make-release.sh --force --systems=linux-x86
If your project is linked with the {@code -nostdlib -Wl,--no-undefined} options, you - must provide your own {@code __dso_handle} because {@code crtbegin_so.o} is not linked in - this case. The content of {@code __dso_handle} does not matter, as shown in the following - example code:
-
-extern "C" {
- extern void *__dso_handle __attribute__((__visibility__ ("hidden")));
- void *__dso_handle;
-}
-
- -<path>/arm-linux-androideabi/include/c++/4.6.x-google - to: -<path>/include/c++/4.6/ -
-static const struct {
- int32_t namesz; /* = 8, sizeof ("Android") */
- int32_t descsz; /* = 1 * sizeof(int32_t) */
- int32_t type; /* = 1, ABI_NOTETYPE */
- char name[sizeof "Android"]; /* = "Android" */
- int32_t android_api; /* = 3, 4, 5, 8, 9, 14 */
-}
-
- The previous branding options in section {@code .note.ABI-tag} are deprecated.
-
-
Android NDK, Revision 8b (July 2012)
-
The main features of this release are a new GNU Compiler Collection (GCC) 4.6 toolchain and -GNU Debugger (GDB) 7.3.x which adds debugging support for the Android 4.1 (API Level 16) system -image.
- --LOCAL_DISABLE_NO_EXECUTE=true # disable "--noexecstack" and "-z noexecstack" -DISABLE_RELRO=true # disable "-z relro" and "-z now" --
See {@code docs/ANDROID-MK.html} for more details.
-
-static const struct {
- int32_t namesz; /* = 4, sizeof ("GNU") */
- int32_t descsz; /* = 6 * sizeof(int32_t) */
- int32_t type; /* = 1 */
- char name[sizeof "GNU"]; /* = "GNU" */
- int32_t os; /* = 0 */
- int32_t major; /* = 2 */
- int32_t minor; /* = 6 */
- int32_t teeny; /* = 15 */
- int32_t os_variant; /* = 1 */
- int32_t android_api; /* = 3, 4, 5, 8, 9, 14 */
-}
-
-
Android NDK, Revision 8 (May 2012)
-
This release of the NDK includes support for MIPS ABI and a few additional fixes.
- -By default, code is generated for ARM-based devices. You can add {@code mips} to - your {@code APP_ABI} definition in your {@code Application.mk} file to build - for MIPS platforms. For example, the following line instructs {@code ndk-build} - to build your code for three distinct ABIs:
- -APP_ABI := armeabi armeabi-v7a mips- -
Unless you rely on architecture-specific assembly sources, such as ARM assembly - code, you should not need to touch your {@code Android.mk} files to build MIPS - machine code.
-make-standalone-toolchain.sh. See
- {@code docs/STANDALONE-TOOLCHAIN.html} for more details.
- Note: To ensure that your applications are available -to users only if their devices are capable of running them, Google Play filters applications based -on the instruction set information included in your application ? no action is needed on your part -to enable the filtering. Additionally, the Android system itself also checks your application at -install time and allows the installation to continue only if the application provides a library that -is compiled for the device's CPU architecture.
-
-
Android NDK, Revision 7c (April 2012)
-
This release of the NDK includes an important fix for Tegra2-based devices, and a few -additional fixes and improvements:
- -This change forces the NDK build system to put most linker or archiver options - into list files, as a work-around for command-line length limitations. - See {@code docs/ANDROID-MK.html} for details.
-
-
Android NDK, Revision 7b (February 2012)
-
This release of the NDK includes fixes for native Windows builds, Cygwin and many other - improvements:
- -See {@code docs/STANDALONE-TOOLCHAIN.html} for more details about this fix.
-If you need these features, you must do one of the following:
-For complete details, see the commit log.
-
-
Android NDK, Revision 7 (November 2011)
-
This release of the NDK includes new features to support the Android 4.0 platform as well - as many other additions and improvements:
- -<OMXAL/OpenMAXAL.h> and
- <OMXAL/OpenMAXAL_Android.h> headers allow applications targeting
- API level 14 to perform multimedia output directly from native code by using a new
- Android-specific buffer queue interface. For more details, see
- docs/openmaxal/index.html and http://www.khronos.org/openmax/.docs/opensles/index.html and
- http://www.khronos.org/opensles/.NDK_CCACHE environment variable to ccache (or the path to
- your ccache binary). When declared, the NDK build system automatically
- uses CCache when compiling any source file. For example:
- -export NDK_CCACHE=ccache --
Note: CCache is not included in the NDK release - so you must have it installed prior to using it. For more information about CCache, see - http://ccache.samba.org.
-APP_ABI to all to indicate that
- you want to build your NDK modules for all the ABIs supported by your given NDK
- release. This means that either one of the following two lines in your
- Application.mk are equivalent with this release:
- -APP_ABI := all -APP_ABI := armeabi armeabi-v7a x86 -- -
This also works if you define APP_ABI when calling
- ndk-build from the command-line, which is a quick way to check that your
- project builds for all supported ABIs without changing the project's
- Application.mk file. For example:
-ndk-build APP_ABI=all --
LOCAL_CPP_FEATURES variable in Android.mk that
- allows you to declare which C++ features (RTTI or Exceptions) your module uses. This
- ensures that the final linking works correctly if you have prebuilt modules that depend
- on these features. See docs/ANDROID-MK.html and
- docs/CPLUSPLUS-SUPPORT.html for more details.$NDK/ndk-build from your project path, the paths to the source,
- object, and binary files that are passed to the build commands are significantly
- shorter now, because they are passed relative to the current directory. This is useful
- when building projects with a lot of source files, to avoid limits on the maximum
- command line length supported by your host operating system. The behavior is unchanged
- if you invoke ndk-build from a sub-directory of your project tree, or if
- you define NDK_PROJECT_PATH to point to a specific directory.ndk-build.cmd script from the command line from your project path. The
- script takes exactly the same arguments as the original ndk-build script.
- The Windows NDK package comes with its own prebuilt binaries for GNU Make, Awk and other
- tools required by the build. You should not need to install anything else to get a
- working build system.
-
- Important: ndk-gdb does not work on
- Windows, so you still need Cygwin to debug.
This feature is still experimental, so feel free to try it and report issues on the - public bug database or public forum. All samples and unit tests - shipped with the NDK succesfully compile with this feature.
-libs/<abi>) if APP_MODULES is not defined in
- your Application.mk. For example, if a top-level module foo
- imports a module bar, then both libfoo.so and
- libbar.so are copied to the install location. Previously, only
- libfoo.so was copied, unless you listed bar in your
- APP_MODULES too. If you define APP_MODULES explicitly, the
- behavior is unchanged.ndk-gdb now works correctly for activities with multiple categories in
- their MAIN intent filters.foo imports static library bar that imports static
- library zoo, the libfoo.so will now be linked against both
- libbar.a and libzoo.a.docs/NATIVE-ACTIVITY.HTML: Fixed typo. The minimum API level should be
- 9, not 8 for native activities.docs/STABLE-APIS.html: Added missing documentation listing EGL as a
- supported stable API, starting from API level 9.download-toolchain-sources.sh: Updated to download the toolchain
- sources from android.googlesource.com,
- which is the new location for the AOSP servers.gabi++. More details about it
- are available in the updated docs/CPLUSPLUS-SUPPORT.html.gnustl_shared that corresponds
- to the shared library version of GNU libstdc++ v3 (GPLv3 license). See more info at
- docs/CPLUSPLUS-SUPPORT.htmlLOCAL_CPP_EXTENSION. For
- example, to compile both foo.cpp and bar.cxx as C++ sources,
- declare the following:
- -LOCAL_CPP_EXTENSION := .cpp .cxx --
The extensions that are available depend on your actual device and GPU drivers,
- not the platform version the device runs on. The header changes simply add new
- constants and types to make it easier to use the extensions when they have been
- probed with eglGetProcAddress() or glGetProcAddress(). The
- following list describes the newly supported extensions:
GL_OES_vertex_array_objectGL_OES_EGL_image_externalGL_APPLE_texture_2D_limited_npotGL_EXT_blend_minmaxGL_EXT_discard_framebufferGL_EXT_multi_draw_arraysGL_EXT_read_format_bgraGL_EXT_texture_filter_anisotropicGL_EXT_texture_format_BGRA8888GL_EXT_texture_lod_biasGL_IMG_read_formatGL_IMG_texture_compression_pvrtcGL_IMG_texture_env_enhanced_fixed_functionGL_IMG_user_clip_planeGL_IMG_multisampled_render_to_textureGL_NV_fenceGL_QCOM_driver_controlGL_QCOM_extended_getGL_QCOM_extended_get2GL_QCOM_perfmon_global_modeGL_QCOM_writeonly_renderingGL_QCOM_tiled_renderingGL_OES_element_index_uintGL_OES_get_program_binaryGL_OES_mapbufferGL_OES_packed_depth_stencilGL_OES_texture_3DGL_OES_texture_floatGL_OES_texture_float_linearGL_OES_texture_half_float_linearGL_OES_texture_npotGL_OES_vertex_array_objectGL_OES_EGL_image_externalGL_AMD_program_binary_Z400GL_EXT_blend_minmaxGL_EXT_discard_framebufferGL_EXT_multi_draw_arraysGL_EXT_read_format_bgraGL_EXT_texture_format_BGRA8888GL_EXT_texture_compression_dxt1GL_IMG_program_binaryGL_IMG_read_formatGL_IMG_shader_binaryGL_IMG_texture_compression_pvrtcGL_IMG_multisampled_render_to_textureGL_NV_coverage_sampleGL_NV_depth_nonlinearGL_QCOM_extended_getGL_QCOM_extended_get2GL_QCOM_writeonly_renderingGL_QCOM_tiled_renderingEGL_ANDROID_recordableEGL_NV_system_time
-
Android NDK, Revision 6b (August 2011)
-
This release of the NDK does not include any new features compared to r6. The r6b release - addresses the following issues in the r6 release:
-APP_ABI="armeabi x86" is used for
- multi-architecture builds.atexit() usage in shared libraries with the x86standalone
- toolchain.make-standalone-toolchain.sh --arch=x86. It used to fail
- to copy the proper GNU libstdc++ binaries to the right location.__dso_handle symbol (ARM only).$(SYSROOT)/usr/include for x86 builds.
- See the bug for
- more information.ptrdiff_t and size_t in
- x86-specific systems when they are used with the x86 standalone toolchain.
-
Android NDK, Revision 6 (July 2011)
-
This release of the NDK includes support for the x86 ABI and other minor changes.
- For detailed information describing the changes in this release, read the
- CHANGES.HTML document included in the NDK package.
-
docs/CPU-X86.html in the NDK package.
-
- By default, code is generated for ARM-based devices, but you can add x86 to your
- APP_ABI definition in your Application.mk file to build
- for x86 platforms. For example, the following line instructs ndk-build
- to build your code for three distinct ABIs:
APP_ABI := armeabi armeabi-v7a x86- -
Unless you rely on ARM-based assembly sources, you shouldn't need to touch
- your Android.mk files to build x86 machine code.
--toolchain=x86-4.4.3
- option when calling make-standalone-toolchain.sh. See
- docs/STANDALONE-TOOLCHAIN.html for more details.
- ndk-stack tool lets you translate stack traces in
- logcat that are generated by native code. The tool translates
- instruction addresses into a readable format that contains things such
- as the function, source file, and line number corresponding to each stack frame.
- For more information and a usage example, see docs/NDK-STACK.html.
- arm-eabi-4.4.0, which had been deprecated since NDK r5, has been
- removed from the NDK distribution.
-
Android NDK, Revision 5c (June 2011)
-
This release of the NDK does not include any new features compared to r5b. The r5c release - addresses the following problems in the r5b release:
-ndk-build: Fixed a rare bug that appeared when trying to perform parallel
- builds of debuggable projects.LOCAL_WHOLE_STATIC_LIBRARIES to work
- correctly with the new toolchain and added documentation for this in
- docs/ANDROID-MK.html.gnustl_static crashed when run on
- platform releases older than API level 8 (Android 2.2).ndk-gdb: Fixed a bug that caused a segmentation fault when debugging
-Android 3.0
- or newer devices.<android/input.h>: Two functions that were introduced in API level
- 9 (Android 2.3) were incorrect and are fixed. While this breaks the source API, the
- binary interface to the system is unchanged. The incorrect functions were missing a
- history_index parameter, and the correct definitions are shown below:
--float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, - size_t pointer_index, - size_t history_index); - -float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, - size_t pointer_index, - size_t history_index); --
pthread_rwlock_init).LOCAL_SRC_FILES. This was not the case previously because the files were
- grouped by source extensions instead.import-module fails, it now prints the list of directories that
- were searched. This is useful to check that the NDK_MODULE_PATH definition
- used by the build system is correct.import-module succeeds, it now prints the directory where the
- module was found to the log (visible with NDK_LOG=1).ndk-gdb: Better detection of adb shell failures and improved
- error messages.<pthread.h>: Fixed the definition of
- PTHREAD_RWLOCK_INITIALIZER for API level 9 (Android 2.3) and higher.LOCAL_ARM_NEON was set to
- true (typo in build/core/build-binary.mk)..s assembly files
- (.S files were okay).
-
Android NDK, Revision 5b (January 2011)
-
This release of the NDK does not include any new features compared to r5. The r5b release -addresses the - following problems in the r5 release: -
-ndk-build issues:
- cygpath -m
- from GNU Make for every source or object file, which caused problems
- with very large source trees. In case this doesn't work properly, define
-NDK_USE_CYGPATH=1 in your
- environment to use cygpath -m again.NDK_MODULE_PATH environment variable from
-working properly when
- it contained multiple directories separated with a colon. prebuilt-common.sh script contains fixes to check the compiler for 64-bit
- generated machine code, instead of relying on the host tag, which
- allows the 32-bit toolchain to rebuild properly on Snow Leopard. The toolchain rebuild scripts
-now also support
- using a 32-bit host toolchain.INET_ADDRSTRLEN was added to
-<netinet/in.h>.IN6_IS_ADDR_MC_NODELOCAL and
-IN6_IS_ADDR_MC_GLOBAL were added to <netinet/in6.h>.<asm/byteorder.h> to allow
-compilation with -std=c99.
-
Android NDK, Revision 5 (December 2010)
-
This release of the NDK includes many new APIs, most of which are introduced to
- support the development of games and similar applications that make extensive use
- of native code. Using the APIs, developers have direct native access to events, audio,
- graphics and window management, assets, and storage. Developers can also implement the
- Android application lifecycle in native code with help from the new
- {@link android.app.NativeActivity} class. For detailed information describing the changes
-in this
- release, read the CHANGES.HTML document included in the downloaded NDK
-package.
-
.apk file../configure && make. See
- docs/STANDALONE-TOOLCHAIN.html for the details. The binaries for GCC 4.4.0 are still
-provided,
- but the 4.2.1 binaries were removed.cpufeatures helper library that improves
-reporting
- of the CPU type (some devices previously reported ARMv7 CPU when the device really was
-an ARMv6). We
- recommend developers that use this library to rebuild their applications then
- upload to Google Play to benefit from the improvements.native-plasma and
-native-activity,
- to demonstrate how to write a native activity.
-
Android NDK, Revision 4b (June 2010)
-
Includes fixes for several issues in the NDK build and debugging scripts — if - you are using NDK r4, we recommend downloading the NDK r4b build. For detailed - information describing the changes in this release, read the CHANGES.TXT document - included in the downloaded NDK package.
-ndk-build build
- command.ndk-gdb command.armeabi-v7a. The new ABI extends the existing armeabi ABI to
- include these CPU instruction set extensions:
-
- cpufeatures static library (with sources) that lets your
- app detect the host device's CPU features at runtime. Specifically, applications can
- check for ARMv7-A support, as well as VFPv3-D32 and NEON support, then provide separate
- code paths as needed.hello-neon, that illustrates how to use the
- cpufeatures library to check CPU features and then provide an optimized
- code path using NEON instrinsics, if supported by the CPU..apk.
-
Android NDK, Revision 3 (March 2010)
-
hello-gl2, that illustrates the use of
- OpenGL ES 2.0 vertex and fragment shaders.
-
Android NDK, Revision 2 (September 2009)
-
Originally released as "Android 1.6 NDK, Release 1".
- -san-angeles, that renders 3D graphics
- through the native OpenGL ES APIs, while managing activity lifecycle with a {@link
- android.opengl.GLSurfaceView} object.
-
Android NDK, Revision 1 (June 2009)
-
Originally released as "Android 1.5 NDK, Release 1".
- -Different Android handsets use different CPUs, which in turn support different instruction sets. -Each combination of CPU and instruction sets has its own Application Binary Interface, or -ABI. The ABI defines, with great precision, how an application's machine code is supposed to -interact with the system at runtime. You must specify an ABI for each CPU architecture you want -your app to work with.
- -A typical ABI includes the following information:
- -This page enumerates the ABIs that the NDK supports, and provides information about how each ABI -works.
- -Each ABI supports one or more instruction sets. Table 1 provides an at-a-glance overview of -the instruction sets each ABI supports.
- -- Table 1. ABIs and supported instruction sets.
- -| ABI | -Supported Instruction Set(s) | -Notes | -
|---|---|---|
| {@code armeabi} | -No hard float. | -|
| {@code armeabi-v7a} | -
- |
-Incompatible with ARMv5, v6 devices. | -
| {@code arm64-v8a} | -||
| -{@code x86} | -No support for MOVBE or SSE4. | -|
| {@code x86_64} | -
- |
-|
| {@code mips} | -Uses hard-float, and assumes a CPU:FPU clock ratio of 2:1 for maximum -compatibility. Provides neither micromips nor MIPS16. | -|
| {@code mips64} | -- | -
More detailed information about each ABI appears below.
- -This ABI is for ARM-based CPUs that support at least -the ARMv5TE instruction set. Please refer to the following documentation for -more details:
- -The AAPCS standard defines EABI as a family of similar -but distinct ABIs. Also, Android follows the little-endian - -ARM GNU/Linux ABI.
- -This ABI does not support hardware-assisted floating point -computations. Instead, all floating-point operations use software helper -functions from the compiler's {@code libgcc.a} static library.
- -The armeabi ABI supports ARM’s
-
-Thumb (a.k.a. Thumb-1) instruction set. The NDK generates Thumb
-code by default unless you specify different behavior using the
-LOCAL_ARM_MODE variable in your
-{@code Android.mk}
-file.
This ABI extends armeabi to include several - -CPU instruction set extensions. The instruction extensions that this Android-specific -ABI supports are:
- -Other extensions that the v7-a ARM spec describes, including - -Advanced SIMD (a.k.a. NEON), VFPv3-D32, and ThumbEE, are optional -to this ABI. Since their presence is not guaranteed, the system should check at runtime -whether the extensions are available. If they are not, you must use alternative code paths. This -check is similar to the one that the system typically performs to check or use -MMX, -SSE2, and other specialized -instruction sets on x86 CPUs.
- -For information about how to perform these runtime checks, refer to -The {@code cpufeatures} Library. -Also, for information about the NDK's support for building -machine code for NEON, see -NEON Support.
- -The {@code armeabi-v7a} ABI uses the {@code -mfloat-abi=softfp} switch to -enforce the rule that the compiler must pass all double values in core register pairs during -function calls, instead of dedicated floating-point ones. The system can perform all internal -computations using the FP registers. Doing so speeds up the computations greatly.
- -This ABI is for ARMv8-based CPUs that support AArch64. It also includes the NEON and -VFPv4 instruction sets.
- -For more information, see the -ARMv8 -Technology Preview, and contact ARM for further details.
- -This ABI is for CPUs supporting the instruction set commonly -referred to as "x86" or "IA-32". Characteristics of this ABI include:
- ---march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32 -- -
These flags target the the Pentium Pro instruction set, along with the -the MMX, -SSE, -SSE2, -SSE3, and -SSSE3 instruction set extensions. -The generated code is an optimization balanced across the top Intel 32-bit -CPUs.
-For more information on compiler flags, particularly related to performance optimization, -refer to GCC -x86 performance hints.
-The ABI does not include any other optional IA-32 instruction set -extensions, such as:
-You can still use these extensions, as long as you use runtime feature-probing to -enable them, and provide fallbacks for devices that do not support them.
-The NDK toolchain assumes 16-byte stack alignment before a function call. The default tools and -options enforce this rule. If you are writing assembly code, you must make sure to maintain stack -alignment, and ensure that other compilers also obey this rule.
- -Refer to the following documents for more details:
-This ABI is for CPUs supporting the instruction set commonly referred to as -"x86-64." It supports instructions that GCC typically generates with the following -compiler flags:
---march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel -- -
These flags target the x86-64 instruction set, according to the GCC -documentation. along with the -MMX, -SSE, -SSE2, -SSE3, -SSSE3, -SSE4.1, -SSE4.2, and -POPCNT -instruction-set extensions. The generated code is an optimization balanced -across the top Intel 64-bit CPUs.
- -For more information on compiler flags, particularly related to performance optimization, -refer to GCC -x86 Performance.
- -This ABI does not include any other optional x86-64 instruction set -extensions, such as:
- -You can still use these extensions, as long as you use runtime feature probing to -enable them, and provide fallbacks for devices that do not support them.
-Refer to the following documents for more details:
- -This ABI is for MIPS-based CPUs that support at least the MIPS32r1 instruction set. It includes -the following features:
- -For more information, please refer to the following documentation:
- -For more specific details, see -MIPS32 Architecture. -Answers to common questions are in the -MIPS FAQ. -
- - - -This ABI is for MIPS64 R6. For more information, see -MIPS64 Architecture.
- -By default, the NDK generates machine code for the armeabi ABI. You can -generate ARMv7-a-compatible machine code, instead, by adding the following line -to your {@code Application.mk} file.
--APP_ABI := armeabi-v7a -- -
To build machine code for two or more distinct ABIs, using spaces as delimiters. For -example:
- --APP_ABI := armeabi armeabi-v7a -- -
This setting tells the NDK to build two versions of your machine code: one -for each ABI listed on this line. For more information on the values you can specify for the -{@code APP_ABI} variable, see Android.mk. -
- -When you build multiple machine-code versions, the build system copies the libraries to your -application project path, and ultimately packages them into your APK, so creating -a fat binary. A fat binary -is larger than one containing only the machine code for a single system; the tradeoff is -gaining wider compatibility, but at the expense of a larger APK.
- -At installation time, the package manager unpacks only the most appropriate -machine code for the target device. For details, see Automatic -extraction of native code at install time.
- - -This section provides details about how the Android platform manages native -code in APKs.
- -Both the Play Store and Package Manager expect to find NDK-generated -libraries on filepaths inside the APK matching the following pattern:
- --/lib/<abi>/lib<name>.so -- -
Here, {@code
If the system does not find the native shared libraries where it expects them, it cannot use
-them. In such a case, the app itself has to copy the libraries over, and then
-perform dlopen().
In a fat binary, each library resides under a directory whose name matches a corresponding ABI. -For example, a fat binary may contain:
- --/lib/armeabi/libfoo.so -/lib/armeabi-v7a/libfoo.so -/lib/arm64-v8a/libfoo.so -/lib/x86/libfoo.so -/lib/x86_64/libfoo.so -/lib/mips/libfoo.so -/lib/mips64/libfoo.so -- -
Note: ARMv7-based Android devices running 4.0.3 or earlier -install native libraries from the {@code armeabi} directory instead of the {@code armeabi-v7a} -directory if both directories exist. This is because {@code /lib/armeabi/} comes after -{@code /lib/armeabi-v7a/} in the APK. This issue is fixed from 4.0.4.
- -The Android system knows at runtime which ABI(s) it supports, because build-specific system -properties indicate:
- -This mechanism ensures that the system extracts the best machine code from -the package at installation time.
- -For best performance, you should compile directly for the primary ABI. For example, a -typical ARMv5TE-based device would only define the primary ABI: {@code armeabi}. By contrast, a -typical, ARMv7-based device would define the primary ABI as {@code armeabi-v7a} and the secondary -one as {@code armeabi}, since it can run application native binaries generated for each of them.
- -Many x86-based devices can also run {@code armeabi-v7a} and {@code armeabi} NDK binaries. For -such devices, the primary ABI would be {@code x86}, and the second one, {@code armeabi-v7a}.
- -A typical MIPS-based device only defines a primary abi: {@code mips}.
- -When installing an application, the package manager service scans the APK, and looks for any -shared libraries of the form:
- --lib/<primary-abi>/lib<name>.so -- -
If none is found, and you have defined a secondary ABI, the service scans for shared libraries of -the form:
- --lib/<secondary-abi>/lib<name>.so -- -
When it finds the libraries that it's looking for, the package manager
-copies them to /lib/lib<name>.so, under the application's
-{@code data} directory ({@code data/data/
If there is no shared-object file at all, the application builds and installs, but crashes at -runtime.
diff --git a/docs/html/ndk/guides/android_mk.jd b/docs/html/ndk/guides/android_mk.jd deleted file mode 100644 index 1416d13c76640..0000000000000 --- a/docs/html/ndk/guides/android_mk.jd +++ /dev/null @@ -1,875 +0,0 @@ -page.title=Android.mk -@jd:body - -This page describes the syntax of the {@code Android.mk} build file, -which glues your C and C++ source files to the Android NDK.
- -The {@code Android.mk} file resides in a subdirectory of your project's {@code jni/} directory, -and describes your sources and shared libraries to the build system. It is really a tiny GNU -makefile fragment that the build system parses once or more. The {@code Android.mk} file is useful -for defining project-wide settings that {@code -Application.mk}, the build system, and your -environment variables leave undefined. It can also override project-wide settings for specific -modules.
- -The syntax of the {@code Android.mk} allows you to group your sources into -modules. A module is either a static library, a shared library, or a standalone -executable. You can define one or more modules in each {@code Android.mk} file, and -you can use the same source file in multiple modules. The build system only places shared libraries -into your application package. In addition, static libraries can generate shared libraries.
- -In addition to packaging libraries, the build system handles a variety of other details for you. -For example, you don't need to list header files or explicit dependencies between generated files in -your {@code Android.mk} file. The NDK build system computes these relationships automatically for -you. As a result, you should be able to benefit from new toolchain/platform support in future NDK -releases without having to touch your {@code Android.mk} file.
- -The syntax of this file is very close to that used in the {@code Android.mk} files distributed with -the full Android Open Source Project. While the -build system implementation that uses them is different, their similarity is an -intentional design decision aimed at making it easier for application -developers to reuse source code for external libraries.
- -Before exploring the syntax in detail, it is useful to start by understanding the basics -of what a {@code Android.mk} file contains. This section uses the {@code Android.mk} file in the -Hello-JNI sample toward that end, explaining the role that each line in the file plays.
- - -An {@code Android.mk} file must begin by defining the {@code LOCAL_PATH} variable: - -
-LOCAL_PATH := $(call my-dir) -- -
This variable indicates the location of the source files in the development tree. Here, the macro -function {@code my-dir}, provided by the build system, returns the path of the current directory -(the directory containing the {@code Android.mk} file itself).
- -The next line declares the {@code CLEAR_VARS} variable, whose value the build system provides. - -
-include $(CLEAR_VARS) -- -
The {@code CLEAR_VARS} variable points to a special GNU Makefile that clears many -{@code LOCAL_XXX} variables for you, such as {@code LOCAL_MODULE}, {@code LOCAL_SRC_FILES}, and -{@code LOCAL_STATIC_LIBRARIES}. Note that it does not clear {@code LOCAL_PATH}. This variable must -retain its value because the system parses all build control files in a single GNU Make execution -context where all variables are global. You must (re-)declare this variable before describing each -module.
- -Next, the {@code LOCAL_MODULE} variable stores the name of the module that you wish to build. -Use this variable once per module in your application.
- --LOCAL_MODULE := hello-jni -- -
Each module name must be unique and not contain any spaces. The build system, when it -generates the final shared-library file, automatically adds the proper prefix and suffix to -the name that you assign to {@code LOCAL_MODULE}. For example, the example that appears above -results in generation of a library called {@code libhello-jni.so}.
- -Note: If your module's name already starts with {@code lib}, the -build system does not prepend an additional {@code lib} prefix; it takes the module name as-is, and -adds the {@code .so} extension. So a source file originally called, for example, {@code libfoo.c} -still produces a shared-object file called {@code libfoo.so}. This behavior is to support libraries -that the Android platform sources generate from {@code Android.mk} files; the names of all such -libraries start with {@code lib}.
- -The next line enumerates the source files, with spaces delimiting multiple files:
- --LOCAL_SRC_FILES := hello-jni.c -- -
The {@code LOCAL_SRC_FILES} variable must contain a list of C and/or C++ source files to build -into a module.
- -The last line helps the system tie everything together:
- --include $(BUILD_SHARED_LIBRARY) -- -
The {@code BUILD_SHARED_LIBRARY} variable points to a GNU Makefile script that collects all the -information you defined in {@code LOCAL_XXX} variables since the most recent {@code include}. This -script determines what to build, and how to do it.
- -There are more complex examples in the samples directories, with commented -{@code Android.mk} files that you can look at. In addition, -Sample: native-activity provides -a detailed explanation of that sample's {@code Android.mk} file. Finally, -Variables and Macros provides further information on the variables from this section. - - -
The build system provides many possible variables for use in the the {@code Android.mk} file. -Many of these variables come with preassigned values. Others, you assign.
- -In addition to these variables, you can also define your own arbitrary ones. If you do so, keep -in mind that the NDK build system reserves the following variable names:
-If you need to define your own convenience variables in an {@code Android.mk} file, we -recommend prepending {@code MY_} to their names. - - -
This section discusses the GNU Make variables that the build system defines before parsing your -{@code Android.mk} file. Under certain circumstances, the NDK might parse your {@code Android.mk} -file several times, using a different definition for some of these variables each time.
- -This variable points to a build script that undefines nearly all {@code LOCAL_XXX} variables -listed in the "Developer-defined variables" section below. Use this variable to include -this script before describing a new module. The syntax for using it is:
- --include $(CLEAR_VARS) -- -
This variable points to a build script that collects all the information about the module -you provided in your {@code LOCAL_XXX} variables, and determines how to build a target shared -library from the sources you listed. Note that using this script requires that you have already -assigned values to {@code LOCAL_MODULE} and {@code LOCAL_SRC_FILES}, at a minimum (for more -information about these variables, see Module-Description Variables).
- -The syntax for using this variable is:
- --include $(BUILD_SHARED_LIBRARY) -- -
A shared-library variable causes the build system to generate a library file with a {@code .so} -extension.
- -A variant of {@code BUILD_SHARED_LIBRARY} that is used to build a static library. The build -system does not copy static libraries into your project/packages, but it can use them to build -shared libraries (see {@code LOCAL_STATIC_LIBRARIES} and {@code LOCAL_WHOLE_STATIC_LIBRARIES}, -below). The syntax for using this variable is:
- --include $(BUILD_STATIC_LIBRARY) -- -
A static-library variable causes the build system to generate a library with a {@code .a} -extension.
- -Points to a build script used to specify a prebuilt shared library. Unlike in the case of -{@code BUILD_SHARED_LIBRARY} and {@code BUILD_STATIC_LIBRARY}, here the value of -{@code LOCAL_SRC_FILES} cannot be a source file. Instead, it must be a single path to a prebuilt -shared library, such as {@code foo/libfoo.so}. The syntax for using this variable is:
- --include $(PREBUILT_SHARED_LIBRARY) -- -
You can also reference a prebuilt library in another module by using the -{@code LOCAL_PREBUILTS} variable. For more information about using prebuilts, see -Using Prebuilt Libraries.
- - -The same as {@code PREBUILT_SHARED_LIBRARY}, but for a prebuilt static library. For more -information about using prebuilts, see Using Prebuilt -Libraries.
- -The name of the target CPU architecture as the Android Open Source Project specifies it. -For any ARM-compatible build, use {@code arm}, independent of the CPU architecture revision or -ABI (see TARGET_ARCH_ABI, below).
- -The value of this variable is taken from the APP_ABI variable that you define in the -{@code Android.mk} file, which the system reads ahead of parsing the {@code Android.mk} file.
- -The Android API level number for the build system to target. -For example, the Android 5.1 system images correspond to Android API level 22: {@code android-22}. -For a complete list of platform names and corresponding Android system -images, see Android NDK Native APIs. -The following example shows the syntax for using this variable:
- --TARGET_PLATFORM := android-22 -- -
This variable stores the name of the CPU and architecture to target when the build system -parses this {@code Android.mk} file. You can specify one or more of the following values, using -a space as a delimiter between multiple targets. Table 1 shows the ABI setting to use for each -supported CPU and architecture. - -
- Table 1. ABI settings for different CPUs and architectures.
-| CPU and architecture | -Setting | -
|---|---|
| ARMv5TE | -{@code armeabi} | -
| ARMv7 | -{@code armeabi-v7a} | -
| ARMv8 AArch64 | -{@code arm64-v8a} | -
| i686 | -{@code x86} | -
| x86-64 | -{@code x86_64} | -
| mips32 (r1) | -{@code mips} | -
| mips64 (r6) | -{@code mips64} | -
| All | -{@code all} | -
The following example shows how to set ARMv8 AArch64 as the target CPU-and-ABI combination:
- --TARGET_ARCH_ABI := arm64-v8a -- -
Note: Up to Android NDK 1.6_r1, this variable is defined as -{@code arm}.
- -For more details about architecture ABIs and associated compatibility -issues, refer to -ABI Management.
- -New target ABIs in the future will have different values.
- -A concatenation of target Android API level and ABI, it is especially useful when you want to test against -a specific target system image for a real device. For example, to specify a 64-bit ARM device -running on Android API level 22:
- --TARGET_ABI := android-22-arm64-v8a -- -
Note: Up to Android NDK 1.6_r1, the default value was -{@code android-3-arm}.
- -The variables in this section describe your module to the build system. Each module description -should follow this basic flow: -
This variable is used to give the path of the current file. You must define -it at the start of your {@code Android.mk} file. The following example shows how to do so:
- --LOCAL_PATH := $(call my-dir) -- -
The script to which {@code CLEAR_VARS} points does not clear this variable. Therefore, you only need -to define it a single time, even if your {@code Android.mk} file describes multiple modules.
- -This variable stores the name of your module. It must be unique among all module names, -and must not contain any spaces. You must define it before including any scripts (other than -the one for {@code CLEAR_VARS}). You need not add either the {@code lib} prefix -or the {@code .so} or {@code .a} file extension; the build system makes these modifications -automatically. Throughout your {@code Android.mk} and -{@code Application.mk} files, refer to -your module by its unmodified name. For example, the following line results in the generation of a -shared library module called {@code libfoo.so}:
- --LOCAL_MODULE := "foo" -- -
If you want the generated module to have a name other than {@code lib} + the value of -{@code LOCAL_MODULE}, you can use the {@code LOCAL_MODULE_FILENAME} variable to give the -generated module a name of your own choosing, instead.
- -This optional variable allows you to override the names that the build system -uses by default for files that it generates. For example, if the name of your {@code LOCAL_MODULE} -is {@code foo}, you can force the system to call the file it generates {@code libnewfoo}. The -following example shows how to accomplish this:
- --LOCAL_MODULE := foo -LOCAL_MODULE_FILENAME := libnewfoo -- -
For a shared library module, this example would generate a file called {@code libnewfoo.so}.
- -Note: You cannot override filepath or file extension.
- -This variable contains the list of source files that the build system uses to generate the -module. Only list the files that the build system actually passes to the compiler, since the build -system automatically computes any associated depencies.
-Note that you can use both relative (to {@code LOCAL_PATH}) and absolute file paths. - -
We recommend avoiding absolute file paths; relative paths make your {@code Android.mk} file more -portable.
- -Note: Always use Unix-style forward slashes (/) in build files. -The build system does not handle Windows-style backslashes (\) properly.
- -You can use this optional variable to indicate a file extension other than {@code .cpp} for your -C++ source files. For example, the following line changes the extension to {@code .cxx}. -(The setting must include the dot.) - -
-LOCAL_CPP_EXTENSION := .cxx -- -
From NDK r7, you can use this variable to specify multiple extensions. For instance:
- --LOCAL_CPP_EXTENSION := .cxx .cpp .cc -- -
You can use this optional variable to indicate that your code relies on specific C++ features. -It enables the right compiler and linker flags during the build process. For prebuilt binaries, -this variable also declares which features the binary depends on, thus helping ensure the final -linking works correctly. We recommend that you use this variable instead of enabling -{@code -frtti} and {@code -fexceptions} directly in your {@code LOCAL_CPPFLAGS} definition.
- -Using this variable allows the build system to use the appropriate flags for each module. Using -{@code LOCAL_CPPFLAGS} causes the compiler to use all specified flags for all modules, regardless -of actual need.
- -For example, to indicate that your code uses RTTI (RunTime Type Information), write: - --LOCAL_CPP_FEATURES := rtti -- -
To indicate that your code uses C++ exceptions, write:
- --LOCAL_CPP_FEATURES := exceptions -- -
You can also specify multiple values for this variable. For example:
- --LOCAL_CPP_FEATURES := rtti features -- -The order in which you describe the values does not matter. - - -
You can use this optional variable to specify a list of paths, relative to the -NDK {@code root} directory, to add to the include search path when compiling all sources -(C, C++ and Assembly). For example:
- --LOCAL_C_INCLUDES := sources/foo -- -
Or even:
- --LOCAL_C_INCLUDES := $(LOCAL_PATH)/- -/foo -
Define this variable before setting any corresponding inclusion flags via {@code LOCAL_CFLAGS} -or {@code LOCAL_CPPFLAGS}.
- -The build system also uses {@code LOCAL_C_INCLUDES} paths automatically when launching native -debugging with ndk-gdb.
- - -This optional variable sets compiler flags for the build system to pass when building C -and C++ source files. The ability to do so can be useful for specifying additional macro -definitions or compile options.
- -Try not to change the optimization/debugging level in your {@code Android.mk} file. -The build system can handle this setting automatically for you, using the relevant information -in the {@code Application.mk} file. Doing it -this way allows the build system to generate useful data files used during debugging.
- -Note: In android-ndk-1.5_r1, the corresponding flags only applied -to C source files, not C++ ones. They now match the full Android build system behavior. -(You can now use {@code LOCAL_CPPFLAGS} to specify flags for C++ sources only.)
- -It is possible to specify additional include paths by writing: - -
-LOCAL_CFLAGS += -I<path>, -- -It is better, however, to use {@code LOCAL_C_INCLUDES} for this purpose, since -doing so also makes it possible to use the paths available for native debugging with ndk-gdb. - - -
An optional set of compiler flags that will be passed when building C++ -source files only. They will appear after the LOCAL_CFLAGS on the -compiler's command-line.
- - -Note: In android-ndk-1.5_r1, the corresponding flags applied to -both C and C++ sources. This has been corrected to match the full Android build system. -To specify flags for both C and C++ sources, use {@code LOCAL_CFLAGS}.
- - -This variable stores the list of static libraries modules on which the current module depends.
- -If the current module is a shared library or an executable, this variable will force -these libraries to be linked into the resulting binary.
- -If the current module is a static library, this variable simply indicates that other -modules depending on the current one will also depend on the listed -libraries.
- -This variable is the list of shared libraries modules on which this module depends at -runtime. This information is necessary at link time, and to embed the corresponding information -in the generated file.
- -This variable is a variant of {@code LOCAL_STATIC_LIBRARIES}, and expresses that the linker -should treat the associated library modules as whole archives. For more information -on whole archives, see the GNU linker's -documentation for the -{@code --whole-archive} flag.
- -This variable is useful when there are circular dependencies among -several static libraries. When you use this variable to build a shared library, it will force -the build system to add all object files from your static libraries to the final binary. The same -is not true, however, when generating executables.
- - -This variable contains the list of additional linker flags for use in building your shared -library or executable. It enables you to use the {@code -l} prefix to pass the name of specific -system libraries. For example, the following example tells the linker to generate a module that -links to {@code /system/lib/libz.so} at load time:
- --LOCAL_LDLIBS := -lz -- -
For the list of exposed system libraries against which you can link in this NDK release, see -Android NDK Native APIs.
- -Note: If you define this variable for a static library, -the build system ignores it, and {@code ndk-build} prints a warning.
- -The list of other linker flags for the build system to use when building your shared library -or executable. For example, the following example uses the {@code ld.bfd} linker on ARM/X86 GCC -4.6+, on which {@code ld.gold} is the default
- --LOCAL_LDFLAGS += -fuse-ld=bfd -- -
Note: If you define this variable for a static library, the build -system ignores it, and ndk-build prints a warning.
- -By default, when the build system encounters an undefined reference encountered while trying to -build a shared, it will throw an undefined symbol error. This error can help you catch -catch bugs in your source code.
- -To disable this check, set this variable to {@code true}. Note that this setting may cause the -shared library to load at runtime.
- -Note: If you define this variable for a static library, -the build system ignores it, and ndk-build prints a warning.
- -By default, the build system generates ARM target binaries in thumb mode, where each -instruction is 16 bits wide and linked with the STL libraries in the {@code thumb/} directory. -Defining this variable as {@code arm} forces the build system to generate the module's object -files in 32-bit {@code arm} mode. The following example shows how to do this:
- --LOCAL_ARM_MODE := arm -- -
You can also instruct the build system to only build specific sources in {@code arm} mode by -appending {@code .arm} suffix to the the source filenames. For example, the following example -tells the build system to always compile {@code bar.c} in ARM mode, but to build -{@code foo.c} according to the value of {@code LOCAL_ARM_MODE}.
- --LOCAL_SRC_FILES := foo.c bar.c.arm -- - - -
Note: You can also force the build system to generate ARM binaries -by setting {@code APP_OPTIM} in your -{@code Application.mk} file to {@code debug}. -Specifying {@code debug} forces an ARM build because the toolchain debugger does not handle Thumb -code properly.
- - -This variable only matters when you are targeting the {@code armeabi-v7a} ABI. It allows the -use of ARM Advanced SIMD (NEON) GCC intrinsics in your C and C++ sources, as well as NEON -instructions in Assembly files.
- -Note that not all ARMv7-based CPUs support the NEON instruction set extensions. For this reason, -you must perform runtime detection to be able to safely use this code at runtime. For more -information, see NEON Support and The {@code cpufeatures} Library.
- -Alternatively, you can use the {@code .neon} suffix to specify that the build system only -compile specific source files with NEON support. In the following example, the build system compiles -{@code foo.c} with thumb and neon support, {@code bar.c} with thumb support, and -{@code zoo.c} with support for ARM and NEON:
- --LOCAL_SRC_FILES = foo.c.neon bar.c zoo.c.arm.neon -- - -
If you use both suffixes, {@code .arm} must precede {@code .neon}.
- -Android NDK r4 added support for the "NX bit" security feature. It is -enabled by default, but you can disable it by setting this variable to {@code true}. We do not -recommend doing so without a compelling reason.
- -This feature does not modify the ABI, and is only enabled on kernels -targeting ARMv6+ CPU devices. Machine code with this feature enabled -will run unmodified on devices running earlier CPU architectures.
-For more information, see Wikipedia: NX bit -and The GNU stack kickstart. - -
By default, the NDK compiles code with read-only relocations and GOT -protection. This variable instructs the runtime linker to mark certain regions of memory -as read-only after relocation, making certain security exploits (such as GOT overwrites) -more difficult. Note that these protections are only effective on Android API level 16 and higher. -On lower API levels, the code will still run, but without memory protections.
- -This variable is turned on by default, but you can disable it by setting its value to -{@code true}. We do not recommend doing so without a compelling reason.
- -For more information, see -RELRO: -RELocation Read-Only and Security -enhancements in RedHat Enterprise Linux (section 6).
- -By default, the build system compiles code with format string protection. Doing so forces a -compiler error if a non-constant format string is used in a {@code printf}-style function.
-This protection is on by default, but you can disable it by setting the value of -this variable to {@code true}. We do not recommend doing so without a compelling reason.
- - -This variable records a set of C/C++ compiler flags to add to the {@code LOCAL_CFLAGS} definition -of any other module that uses this one via the {@code LOCAL_STATIC_LIBRARIES} or -{@code LOCAL_SHARED_LIBRARIES} variables.
- -For example, consider the following pair of modules: {@code foo} and {@code bar}, which depends -on {@code foo}:
- --include $(CLEAR_VARS) -LOCAL_MODULE := foo -LOCAL_SRC_FILES := foo/foo.c -LOCAL_EXPORT_CFLAGS := -DFOO=1 -include $(BUILD_STATIC_LIBRARY) - - -include $(CLEAR_VARS) -LOCAL_MODULE := bar -LOCAL_SRC_FILES := bar.c -LOCAL_CFLAGS := -DBAR=2 -LOCAL_STATIC_LIBRARIES := foo -include $(BUILD_SHARED_LIBRARY) -- -
Here, the build system passes the flags {@code -DFOO=1} and {@code -DBAR=2} to the compiler when -building {@code bar.c}. It also prepends exported flags to your your module's {@code LOCAL_CFLAGS} -so you can easily override them.
- -In addition, the relationship among modules is transitive: If {@code zoo} depends on -{@code bar}, which in turn depends on {@code foo}, then {@code zoo} also inherits all flags -exported from {@code foo}. - -Finally, the build system does not use exported flags when building locally (i.e., building the -module whose flags it is exporting). Thus, in the example above, it does not pass {@code -DFOO=1} -to the compiler when building {@code foo/foo.c}. To build locally, use {@code LOCAL_CFLAGS} -instead.
- -This variable is the same as {@code LOCAL_EXPORT_CFLAGS}, but for C++ flags only.
- -This variable is the same as {@code LOCAL_EXPORT_CFLAGS}, but for C include paths. It is useful -in cases where, for example, {@code bar.c} needs to include headers from module {@code foo}.
- -This variable is the same as {@code LOCAL_EXPORT_CFLAGS}, but for linker flags.
- -This variable is the same as {@code LOCAL_EXPORT_CFLAGS}, telling the build system to pass names -of specific system libraries to the compiler. Prepend {@code -l} to the name of each library you -specify.
- -Note that the build system appends imported linker flags to the value of your module's -{@code LOCAL_LDLIBS} variable. It does this due to the way Unix linkers work.
- -This variable is typically useful when module {@code foo} is a static library -and has code that depends on a system library. You can then use {@code LOCAL_EXPORT_LDLIBS} to -to export the dependency. For example:
- --include $(CLEAR_VARS) -LOCAL_MODULE := foo -LOCAL_SRC_FILES := foo/foo.c -LOCAL_EXPORT_LDLIBS := -llog -include $(BUILD_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := bar -LOCAL_SRC_FILES := bar.c -LOCAL_STATIC_LIBRARIES := foo -include $(BUILD_SHARED_LIBRARY) -- -
In this example, the build system puts {@code -llog} at the end of the linker command when it -builds {@code libbar.so}. Doing so tells the linker that, because {@code libbar.so} depends -on {@code foo}, it also depends on the system logging library.
- -Set this variable to {@code true} when your module has a very high -number of sources and/or dependent static or shared libraries. Doing so forces the -build system to use {@code @} syntax for archives containing intermediate object files -or linking libraries.
- -This feature can be useful on Windows, where the command line accepts a maximum of only -of 8191 characters, which can be too small for complex projects. It also impacts the compilation of -individual source files, placing nearly all compiler flags inside list files, too.
- -Note that any value other than {@code true} will revert to the -default behaviour. You can also define {@code APP_SHORT_COMMANDS} in your -{@code Application.mk} file to force this -behavior for all modules in your project.
- -We do not recommend enabling this feature by default, since it makes the build slower.
- - -Set this variable to {@code true} when building static libraries. -Doing so will generate a thin archive, a library file that does not contain -object files, but instead just file paths to the actual objects that it would normally -contain.
-This is useful to reduce the size of your build output. The drawback is that -such libraries cannot be moved to a different location (all paths -inside them are relative).
-Valid values are {@code true}, {@code false} or empty. A -default value can be set in your -{@code Application.mk} file through the {@code APP_THIN_ARCHIVE} - -variable.
-Note: This is ignored for non-static library modules, or prebuilt -static library ones.
- -Define this variable as a shell command that the build system will use to filter the -assembly files extracted or generated from the files you specified for {@code LOCAL_SRC_FILES}.
-Defining this variable causes the following things to occur:
- -For example:
- --LOCAL_SRC_FILES := foo.c bar.S -LOCAL_FILTER_ASM := - -foo.c --1--> $OBJS_DIR/foo.S.original --2--> $OBJS_DIR/foo.S --3--> $OBJS_DIR/foo.o -bar.S --2--> $OBJS_DIR/bar.S --3--> $OBJS_DIR/bar.o -- -
"1" corresponds to the compiler, "2" to the filter, and "3" to the assembler. The filter must -be a standalone shell command that takes the name of the input file as its first argument, and the -name of the output file as the second one. For example:
- --myasmfilter $OBJS_DIR/foo.S.original $OBJS_DIR/foo.S -myasmfilter bar.S $OBJS_DIR/bar.S -- -
This section explains GNU Make function macros that the NDK provides. Use
-{@code $(call
This macro returns the path of the last included makefile, which typically is the -current {@code Android.mk}'s directory. {@code my-dir} is useful for defining -{@code LOCAL_PATH} at the start of your {@code Android.mk} file. For example:
- --LOCAL_PATH := $(call my-dir) -- -
Due to the way GNU Make works, what this macro really returns is the -path of the last makefile that the build system included when parsing the build scripts. For this -reason, you should not call {@code my-dir} after including another file.
- -For example, consider the following example:
- --LOCAL_PATH := $(call my-dir) - -# ... declare one module - -include $(LOCAL_PATH)/foo/`Android.mk` - -LOCAL_PATH := $(call my-dir) - -# ... declare another module -- -
The problem here is that the second call to {@code my-dir} defines -{@code LOCAL_PATH} as {@code $PATH/foo} instead of {@code $PATH}, because that was where its -most recent include pointed.
- -You can avoid this problem by putting additional includes after everything -else in the {@code Android.mk} file. For example:
- --LOCAL_PATH := $(call my-dir) - -# ... declare one module - -LOCAL_PATH := $(call my-dir) - -# ... declare another module - -# extra includes at the end of the Android.mk file -include $(LOCAL_PATH)/foo/Android.mk - -- -
If it is not feasible to structure the file in this way, save the value of the first -{@code my-dir} call into another variable. For example:
- --MY_LOCAL_PATH := $(call my-dir) - -LOCAL_PATH := $(MY_LOCAL_PATH) - -# ... declare one module - -include $(LOCAL_PATH)/foo/`Android.mk` - -LOCAL_PATH := $(MY_LOCAL_PATH) - -# ... declare another module -- -
Returns the list of {@code Android.mk} files located in all subdirectories of -the current {@code my-dir} path. - -
You can use this function to provide deep-nested source directory hierarchies to the build -system. By default, the NDK only looks for files in the directory containing the -{@code Android.mk} file.
- -Returns the path of the current makefile (from which the build system called the function).
- -Returns the path of the parent makefile in the inclusion tree (the path of the makefile that -included the current one).
- -Returns the path of the grandparent makefile in the inclusion tree (the path of the makefile that -included the current one).
- -A function that allows you to find and include a module's {@code Android.mk} file by the name of -the module. A typical example is as follows:
- --$(call import-module,<name>) -- -
In this example, the build system looks for the module tagged {@code
This document explains the {@code Application.mk} build file, which describes the -native modules that your app requires. A module can be a static library, a shared library, -or an executable.
- -We recommend that you read the Concepts and -Android.mk pages before this one. Doing so will -help maximize your understanding of the material on this page.
- --$NDK/apps/<myapp>/Application.mk -- -
Here, {@code
This variable stores the absolute path to your app's project-root directory. The build system -uses this information to place stripped-down versions of the generated JNI shared libraries -into a specific location known to the APK-generating tools.
- -If you place your {@code Application.mk} file under {@code $NDK/apps/ Define this optional variable as either {@code release} or {@code debug}. You use it to
-alter the optimization level when building your application's modules. Release mode is the default, and generates highly optimized binaries. Debug mode generates
-unoptimized binaries that are much easier to debug. Note that you can debug either release or debug binaries. Release binaries, however, provide less
-information during debugging. For example, the build system optimizes out some variables,
-preventing you from inspecting them. Also, code re-ordering can make it more difficult to step
-through the code; stack traces may not be reliable. Declaring {@code android:debuggable} in your application manifest's {@code This variable stores a set of C compiler flags that the build system passes to the compiler
-when compiling any C or C++ source code for any of the modules. You can use this variable to change
-the build of a given module according to the application that needs it, instead of having to modify
-the {@code Android.mk} file itself. All paths in these flags should be relative to the top-level NDK directory. For example, if you
-have the following setup: To specify in {@code foo/Android.mk} that you want to add the path to the {@code bar} sources
-during compilation, you should use:
-
- Or, alternatively: {@code -I../bar} will not work since it is equivalent to
-{@code -I$NDK_ROOT/../bar}. Note: This variable only works on C, not C++, sources in
-android-ndk-1.5_r1. In all versions after that one, {@code APP_CFLAGS} matches the full Android
-build system. This variable contains a set of C++ compiler flags that the build system passes to the compiler
-when building only C++ sources. Note: In android-ndk-1.5_r1, this variable works on both C and
-C++ sources. In all subsequent versions of the NDK, {@code APP_CPPFLAGS} now matches the full
-Android build system. For flags that apply to both C and C++ sources, use {@code APP_CFLAGS}. A set of linker flags that the build system passes when linking the application. This variable
-is only relevant when the build system is building shared libraries and executables. When the
-build system builds static libraries, it ignores these flags. By default, the NDK build system looks under {@code jni/} for a file named
-{@code Android.mk}. If you want to override this behavior, you can define {@code APP_BUILD_SCRIPT} to point to an
-alternate build script. The build system always interprets a non-absolute path as relative to the
-NDK's top-level directory. By default, the NDK build system generates machine code for the
-{@code armeabi} ABI. This machine code
-corresponds to an ARMv5TE-based CPU with software floating point operations. You can use
-{@code APP_ABI} to select a different ABI. Table 1 shows the {@code APP_ABI}
-settings for different instruction sets.
- Table 1. {@code APP_ABI} settings for different instruction sets. Note: {@code all} is available starting from NDKr7. You can also specify multiple values by placing them on the same line, delimited by spaces.
-For example: For the list of all supported ABIs and details about their usage and limitations, refer to
-ABI Management. This variable contains the name of the target Android platform. For example, {@code android-3}
-specifies the Android 1.5 system images. For a complete list of platform names and corresponding
-Android system images, see Android NDK Native APIs
-. By default, the NDK build system provides C++ headers for the minimal C++ runtime library
-({@code system/lib/libstdc++.so}) provided by the Android system. In addition, it comes with
-alternative C++ implementations that you can use or link to in your own applications.
-Use {@code APP_STL} to select one of them. For information about the supported runtimes, and the
-features they offer, see NDK Runtimes and
-Features.
-
- The equivalent of {@code LOCAL_SHORT_COMMANDS} in {@code Application.mk} for your whole project.
-For more information, see the documentation for this variable on
-{@code Android.mk}. Define this variable as either {@code 4.9} or {@code 4.8} to select a version of the GCC
-compiler. Version 4.9 is the default for 64-bit ABIs, and 4.8 is the default for 32-bit ABIs.
-To select a version of Clang, define this variable as {@code clang3.4}, {@code clang3.5}, or
-{@code clang}. Specifying {@code clang} chooses the most recent version of Clang. Starting from Android 4.1 (API level 16), Android's dynamic linker supports position-independent
-executables (PIE). From Android 5.0 (API level 21), executables require PIE.
-
-To use PIE to build your executables, set the {@code -fPIE} flag. This flag makes it harder to
-exploit memory corruption bugs by randomizing code location. By default, {@code ndk-build}
-automatically sets this value to {@code true} if your project targets {@code android-16} or higher.
-You may set it manually to either {@code true} or {@code false}. This flag applies only to executables. It has no effect when building shared or static
-libraries. Note: PIE executables cannot run on Android releases prior to 4.1.
- This restriction only applies to executables. It has no effect when building shared or static
-libraries. Sets the default value of {@code LOCAL_THIN_ARCHIVE} in the {@code Android.mk} file for all
-static library modules in this project. For more information, see the documentation for
-{@code LOCAL_THIN_ARCHIVE} on {@code Android.mk}.
- When you're working with native code, hardware matters. The NDK lets you ensure you're compiling
-for the right architectures and CPUs by giving you a variety of ABIs from which
-to choose. This section begins by explaining how to target specific
-architectures and CPUs. It then
-provides information you need to know when targeting the
-ARM
-family of CPUs and architectures. Next, it provides information about the other CPUs and
-architectures that it supports: NEON, x86
-(32-bit and
-64-bit), and
-MIPS. Finally, it explains how to use the
-{@code cpufeatures}
-library, which your app can use to query a given CPU and architecture about the optional
-features they support. Google I/O 2013 - High Performance Audio
-The Khronos Group's OpenSL ES™ standard exposes audio features
-similar to those in the {@link android.media.MediaPlayer} and {@link android.media.MediaRecorder}
-APIs in the Android Java framework. OpenSL ES provides a C language interface as well as
-C++ bindings, allowing you to call it from code written in either language.
-
-This page describes the typical use cases for these high-performance audio APIs, how to add them
-into your app's source code, and how to incorporate them into the build process.
-
-The OpenSL ES APIs are available to help you develop and improve your app's audio performance.
- Some typical use cases include the following:
-You can call OpenSL ES from both C and C++ code. To add the core OpenSL ES
-feature set to your app, include the {@code OpenSLES.h} header file:
-
-
-To add the OpenSL ES
-Android extensions as well, include the {@code OpenSLES_Android.h} header file:
-
-When you include the {@code OpenSLES_Android.h} header file, the following headers are included
-automatically:
- Note:
-These headers are not required, but are shown as an aid in learning the API.
-
-You can incorporate OpenSL ES into your build by specifying it in the
-{@code Android.mk} file that serves as one of the
-NDK build system's makefiles. Add the following line to
-{@code Android.mk}:
-
-For robust debugging, we recommend that you examine the {@code SLresult} value that most of
-the OpenSL ES APIs return. You can use
-asserts
-or more advanced error-handling logic for debugging; neither offers
-an inherent advantage for working with OpenSL ES, although one or the other might be more suitable
-for a given use case.
-
-We use asserts in our
-examples, because they help catch unrealistic conditions that would indicate a coding error. We
-have used explicit error handling for other conditions more likely to occur in production.
-
-Many API errors result in a log entry, in addition to a non-zero result code. Such log entries
-can provide additional detail that proves especially useful for relatively complex APIs such as
-
-{@code Engine::CreateAudioPlayer}.
-
-You can view the log either from the command line or from Android Studio. To examine the log from
-the command line, type the following:
-
-To examine the log from Android Studio, either click the Logcat tab in the
-Debug
-window, or click the Devices | logcat tab in the
-Android DDMS
-window.
- Constantly outputting audio incurs significant power consumption. Ensure that you stop the
- output in the
- onPause() method.
- Also consider pausing the silent output after some period of user inactivity.
-
-Supported and tested example code that you can use as a model for your own code resides both locally
-and on
-
-GitHub. The local examples are located in
-{@code platforms/android-9/samples/native-audio/}, under your NDK root installation directory.
-On GitHub, they are available from the
-{@code android-ndk}
-repository, in the
-
-{@code audio-echo} and
-
-{@code native-audio} directories.
- The Android NDK implementation of OpenSL ES differs
-from the reference specification for OpenSL ES 1.0.1 in a number of respects.
-These differences are an important reason as to why sample code that
-you copy directly from the OpenSL ES reference specification may not work in your
-Android app.
-
-For more information on differences between the reference specification and the
-Android implementation, see
-
-OpenSL ES for Android.
diff --git a/docs/html/ndk/guides/audio/floating-point.jd b/docs/html/ndk/guides/audio/floating-point.jd
deleted file mode 100644
index 76efce3f60e13..0000000000000
--- a/docs/html/ndk/guides/audio/floating-point.jd
+++ /dev/null
@@ -1,101 +0,0 @@
-page.title=Floating-Point Audio
-@jd:body
-
- Will it Float? The Glory and Shame of Floating-Point Audio Using floating-point numbers to represent audio data can significantly enhance audio
- quality in high-performance audio applications. Floating point offers the following
- advantages: While floating-point can enhance audio quality, it does present certain disadvantages:
- Formerly, floating-point was notorious for being unavailable or slow. This is
- still true for low-end and embedded processors. But processors on modern
- mobile devices now have hardware floating-point with performance that is
- similar (or in some cases even faster) than integer. Modern CPUs also support
- SIMD
- (Single instruction, multiple data), which can improve performance further.
- The following best practices help you avoid problems with floating-point calculations: For floating-point audio, the audio format encoding
- The following Wikipedia pages are helpful in understanding floating-point audio: The following article provides information on those aspects of floating-point that have a
- direct impact on designers of computer systems: The NDK package includes an Android-specific implementation of the
-OpenSL ES™ API
-specification from the Khronos Group.
-This library allows you to use C or C++ to implement high-performance, low-latency audio, whether
-you are writing a synthesizer, digital audio workstation, karaoke, game,
- or other real-time app. This section begins by providing some
-basic information about the API, including
-typical use cases and how to incorporate it into your app. It then explains what you need to know
-about the Android-specific
-implementation of OpenSL ES, focusing on the differences between this implementation and the
-reference specification. Next, you'll learn how to minimze
- input latency
- when using built-in or external microphones
-and some actions that you can take to minimize
- output latency.
- It describes the reasons that you should use
- floating-point
- numbers to represent your audio data, and it provides information that will help you choose the
-optimal sample rate. This section
- concludes with some supplemental
- programming notes to ensure proper implementation of OpenSL ES.
- This page provides guidelines to help you reduce audio input latency when recording with a
-built-in microphone or an external headset microphone. Here are a few important prerequisites: The following are some methods to help ensure low audio input latency:
-
- Be sure to take these things into account to help avoid latency issues: A consequence of potentially independent audio clocks is the need for asynchronous sample rate
-conversion. A simple (though not ideal for audio quality) technique for asynchronous sample rate
-conversion is to duplicate or drop samples as needed near a zero-crossing point. More
-sophisticated conversions are possible.
-This page provides details about how the
-NDK implementation of OpenSL
-ES™ differs from the reference specification for OpenSL ES 1.0.1. When using sample code from the
-specification, you may need to modify it to work on Android.
-
-Unless otherwise noted, all features are available at Android 2.3 (API level 9) and higher.
- Some features are only available for Android 4.0 (API level 14); these are noted.
- Note:
-The Android Compatibility Definition Document (CDD) enumerates the hardware and software
-requirements of a compatible Android device. See
-Android Compatibility
-for more information on the overall compatibility program, and
-
-CDD for the actual CDD document.
-
-OpenSL ES provides a C
-language interface that is also accessible using C++. It exposes features similar to the audio
-portions of these Android Java APIs:
-
-As with all of the Android Native Development Kit (NDK), the primary purpose of OpenSL ES for
-Android is to facilitate the implementation of shared libraries to be called using the Java Native
-Interface (JNI
-). NDK is not intended for writing pure C/C++ applications. However, OpenSL ES is a
-full-featured API, and we expect that you should be able to accomplish most of your audio needs
-using only this API, without up-calls to code running in the Android runtime.
- Note:
-Though based on OpenSL ES, the Android native audio (high-performance audio) API is not a
-conforming implementation of any OpenSL ES 1.0.1 profile (game, music, or phone). This is because
-Android does not implement all of the features required by any one of the profiles. Any known cases
-where Android behaves differently than the specification are described in the
-Android extensions section below.
-
-This section provides the information needed to get started using the OpenSL ES APIs.
-
-We recommend using supported and tested example code that is usable as a model for your own
-code, which is located in the NDK folder {@code platforms/android-9/samples/native-audio/}, as well
-as in the
-audio-echo
-and
-native-audio
-folders of the
-android-ndk GitHub
-repository.
- Caution:
-The OpenSL ES 1.0.1 specification contains example code in the appendices (see
-Khronos OpenSL ES Registry
-for more details). However, the examples in Appendix B: Sample Code and
-Appendix C: Use Case Sample Code use features that are not supported by Android. Some
-examples also contain typographical errors, or use APIs that are likely to change. Proceed with
-caution when referring to these; though the code may be helpful in understanding the full OpenSL ES
-standard, it should not be used as-is with Android.
-
-Modify your {@code Android.mk} file as follows:
-
-The following are some of the many ways to package audio content for your application:
- Note:
-Finding or creating useful audio content for your application is beyond the scope of this article.
-You can use web search terms such as interactive audio, game audio, sound
-design, and audio programming to locate more information.
- Caution: It is your responsibility
-to ensure that you are legally permitted to play or record content. There may be privacy
-considerations for recording content.
-
-The Android NDK implementation of OpenSL ES inherits much of the feature set from
-the reference specification, with certain limitations.
-
-OpenSL ES for Android supports all of the global entry points in the Android specification.
-These entry points include:
-
-Table 1 shows the objects and interfaces that the Android NDK implementation of
-OpenSL ES supports. If a Yes appears in the cell, then the feature is available in this
-implementation.
-
- Table 1. Android NDK support for objects and interfaces.
-The next section explains the limitations for some of these features.
-
-Certain limitations apply to the features in Table 1. These limitations
-represent differences from the reference specification. The rest of this section provides
-information about these differences.
-OpenSL ES for Android does not support {@code RemoveInterface} or
-{@code ResumeInterface}.
-
-You cannot have both environmental reverb and preset reverb on the same output mix.
-
-The platform might ignore effect requests if it estimates that the
-CPU load would be too high.
-
-
-Environmental reverb does not support the
-You can use the MIME data format only with the URI data locator, and only for an audio
-player. You cannot use this data format for an audio recorder.
-
-The Android implementation of OpenSL ES requires you to initialize
-OpenSL ES for Android supports the following audio formats, so long as the
-Android platform supports them as well: Note:
-For a list of audio formats that Android supports, see
-Supported Media Formats.
-
-The following limitations apply to the handling of these and other formats in this
-implementation of OpenSL ES:
-
-OpenSL ES for Android does not support the following methods for manipulating objects:
-
-PCM is the only data format you can use with buffer queues. Supported PCM
-playback configurations have the following characteristics:
-
-The configurations that OpenSL ES for Android supports for recording are
-device-dependent; usually, 16,000 Hz mono/16-bit signed is available regardless of the device.
-
-The value of the
-Android 5.0 (API level 21) and above support floating-point data.
-
-An OpenSL ES playback rate indicates the speed at which an
-object presents data, expressed in thousandths of normal speed, or per mille. For example,
-a playback rate of 1,000 per mille is 1,000/1,000, or normal speed.
-A rate range is a closed interval that expresses possible rate ranges.
-
-Support for playback-rate ranges and other capabilities may vary depending
-on the platform version and implementation. Your app can determine these capabilities at runtime by
-using
-A device typically supports the same rate range for a data source in PCM format, and a unity rate
-range of 1000 per mille to 1000 per mille for other formats: that is, the unity rate range is
-effectively a single value.
-
-OpenSL ES for Android does not support the
-The
-An audio player or recorder with a data locator for a buffer queue supports PCM data format only.
-
-OpenSL ES for Android only supports use of an I/O device data locator when you have
-specified the locator as the data source for
-OpenSL ES for Android can only use the URI data locator with MIME data format,
-and only for an audio player. You cannot use this data format for an audio recorder. It supports
-{@code http:} and {@code file:} schemes. It does not support other schemes, such as {@code https:},
-{@code ftp:}, or
-{@code content:}.
-
-We have not verified support for {@code rtsp:} with audio on the Android platform.
-
-Android supports these OpenSL ES 1.0.1 data structures:
-
-OpenSL ES for Android is designed for multi-threaded applications and is thread-safe. It supports a
-single engine per application, and up to 32 objects per engine. Available device memory and CPU may
-further restrict the usable number of objects.
-
-These engine options are recognized, but ignored by {@code slCreateEngine}:
-
-OpenMAX AL and OpenSL ES may be used together in the same application. In this case, there is
-a single shared engine object internally, and the 32 object limit is shared between OpenMAX AL
-and OpenSL ES. The application should first create both engines, use both engines, and finally
-destroy both engines. The implementation maintains a reference count on the shared engine so that
-it is correctly destroyed during the second destroy operation.
-
-The Android high-performance audio APIs are based on
-Khronos Group OpenSL ES
-1.0.1. Khronos has released a revised version 1.1 of the standard. The
-revised version includes new features, clarifications, corrections of typographical errors, and
-some incompatibilities. Most of the expected incompatibilities are relatively minor or are in
-areas of OpenSL ES that are not supported by Android.
-
-An application
-developed with this version should work on future versions of the Android platform, provided
-that you follow the guidelines that are outlined in the Planning for
-binary compatibility section below.
- Note:
-Future source compatibility is not a goal. That is, if you upgrade to a newer version of the NDK,
-you may need to modify your application source code to conform to the new API. We expect that most
-such changes will be minor; see details below.
-
-We recommend that your application follow these guidelines to improve future binary compatibility:
- Note:
-See the Buffer queue behavior section below for more details.
-
-As mentioned, source code incompatibilities are expected in the next version of OpenSL ES from
-Khronos Group. The likely areas of change include:
-
-OpenSL ES for Android extends the reference OpenSL ES specification to make it compatible with
-Android, and to take advantage of the power and flexibility of the Android platform.
-
-The definition of the API for the Android extensions resides in
-These extensions limit your application's portability to
-other OpenSL ES implementations, because they are Android-specific. You can mitigate this issue by
-avoiding use of the extensions or by using {@code #ifdef} to exclude them at compile time.
-
-Table 2 shows the Android-specific interfaces and data locators that Android OpenSL ES supports
-for each object type. The Yes values in the cells indicate the interfaces and data
-locators that are available for each object type.
-
- Table 2. Interfaces and data locators, by object type.
-The Android configuration interface provides a means to set
-platform-specific parameters for objects. This interface is different from other OpenSL ES
-1.0.1 interfaces in that your app can use it before instantiating the corresponding object; thus,
-you can configure the object before instantiating it. The
-{@code OpenSLES_AndroidConfiguration.h} header file, which resides at
-{@code platforms/android-<version>/<abi>/include/SLES},
-documents the following available configuration keys and values:
-
-The following code snippet shows an example of how to set the Android audio stream type on an audio
-player:
-
-You can use similar code to configure the preset for an audio recorder:
-
-Android's effect, effect send, and effect capabilities interfaces provide
-a generic mechanism for an application to query and use device-specific
-audio effects. Device manufacturers should document any available device-specific audio effects
-that they provide.
-
-Portable applications should use the OpenSL ES 1.0.1 APIs for audio effects instead of the Android
-effect extensions.
-
-The Android file descriptor data locator permits you to specify the source for an
-audio player as an open file descriptor with read access. The data format must be MIME.
-
-This extension is especially useful in conjunction with the native asset manager, because
-the app reads assets from the APK via a file descriptor.
-
-The Android simple buffer queue data locator and interface are
-identical to those in the OpenSL ES 1.0.1 reference specification, with two exceptions: You
-can also use Android simple buffer queues with both audio players and audio recorders. Also, PCM
-is the only data format you can use with these queues.
-In the reference specification, buffer queues are for audio players only, but they are
-compatible with data formats beyond PCM.
-
-For recording, your app should enqueue empty buffers. When a registered callback sends
-notification that the system has finished writing data to the buffer, the app can
-read the buffer.
-
-Playback works in the same way. For future source code
-compatibility, however, we suggest that applications use Android simple
-buffer queues instead of OpenSL ES 1.0.1 buffer queues.
-
-For convenience, the Android implementation of OpenSL ES 1.0.1
-permits your app to specify dynamic interfaces when it instantiates an object.
-This is an alternative to using
-The Android implementation does not include the
-reference specification's requirement that the play cursor return to the beginning
-of the currently playing buffer when playback enters the {@code SL_PLAYSTATE_STOPPED}
-state. This implementation can conform to that behavior, or it can leave the location of the play
-cursor unchanged.
-
-As a result, your app cannot assume that either behavior occurs. Therefore,
-you should explicitly call the
-Similarly, there is no specification governing whether the trigger for a buffer queue callback must
-be a transition to
-There are three methods for querying whether the platform supports the Android extensions. These
-methods are:
-
-Any of these methods returns
-This section describes a deprecated Android-specific extension to OpenSL ES 1.0.1
-for decoding an encoded stream to PCM without immediate playback.
-The table below gives recommendations for use of this extension and alternatives.
- Note:
-There is currently no documentation for the NDK version of the {@code MediaCodec} API. However,
-you can refer to the
-
-native-codec sample code for an example.
-
-A standard audio player plays back to an audio device, specifying the output mix as the data sink.
-The Android extension differs in that an audio player instead
-acts as a decoder if the app has specified the data source either as a URI or as an Android
-file descriptor data locator described in MIME data format. In such a case, the data sink is
-an Android simple buffer queue data locator with PCM data format.
-
-This feature is primarily intended for games to pre-load their audio assets when changing to a
-new game level, which is similar to the functionality that the {@link android.media.SoundPool}
-class provides.
-
-The application should initially enqueue a set of empty buffers in the Android simple
-buffer queue. After that, the app fills the buffers with PCM data. The Android simple
-buffer queue callback fires after each buffer is filled. The callback handler processes
-the PCM data, re-enqueues the now-empty buffer, and then returns. The application is responsible for
-keeping track of decoded buffers; the callback parameter list does not include
-sufficient information to indicate the buffer that contains data or the buffer that should be
-enqueued next.
-
-The data source implicitly reports the end of stream (EOS) by delivering a
-
-The sink's PCM data format typically matches that of the encoded data source
-with respect to sample rate, channel count, and bit depth. However, you can decode to a different
-sample rate, channel count, or bit depth.
-For information about a provision to detect the actual PCM format, see
-Determining the format of decoded PCM data via metadata.
-
-OpenSL ES for Android's PCM decoding feature supports pause and initial seek; it does not support
-volume control, effects, looping, or playback rate.
-
-Depending on the platform implementation, decoding may require resources
-that cannot be left idle. Therefore, we recommend that you make sure to provide
-sufficient numbers of empty PCM buffers; otherwise, the decoder starves. This may happen,
-for example, if your app returns from the Android simple buffer queue callback without
-enqueueing another empty buffer. The result of decoder starvation is
-unspecified, but may include: dropping the decoded
-PCM data, pausing the decoding process, or terminating the decoder outright.
- Note:
-To decode an encoded stream to PCM but not play back immediately, for apps running on
-Android 4.x (API levels 16–20), we recommend using the {@link android.media.MediaCodec} class.
-For new applications running on Android 5.0 (API level 21) or higher, we recommend using the NDK
-equivalent, {@code <NdkMedia*.h>}. These header files reside in
-the {@code media/} directory under your installation root.
-
-An audio player acts as a streaming decoder if the data source is an
-Android buffer queue data locator with MIME data format, and the data
-sink is an Android simple buffer queue data locator with PCM data format.
-Configure the MIME data format as follows:
-
-This feature is primarily intended for streaming media applications that
-deal with AAC audio but need to perform custom audio processing
-prior to playback. Most applications that need to decode audio to PCM
-should use the method that Decode audio to PCM describes,
-as that method is simpler and handles more audio formats. The technique described
-here is a more specialized approach, to be used only if both of these
-conditions apply:
-
-The application should initially enqueue a set of filled buffers in the Android buffer queue.
-Each buffer contains one or more complete ADTS AAC frames.
-The Android buffer queue callback fires after each buffer is emptied.
-The callback handler should refill and re-enqueue the buffer, and then return.
-The application need not keep track of encoded buffers; the callback parameter
-list includes sufficient information to indicate the buffer that should be enqueued next.
-The end of stream is explicitly marked by enqueuing an EOS item.
-After EOS, no more enqueues are permitted.
-
-We recommend that you make sure to provide full
-ADTS AAC buffers, to avoid starving the decoder. This may happen, for example, if your app
-returns from the Android buffer queue callback without enqueueing another full buffer.
-The result of decoder starvation is unspecified.
-
-In all respects except for the data source, the streaming decode method is the same as
-the one that Decode audio to PCM describes.
-
-Despite the similarity in names, an Android buffer queue is not
-the same as an Android simple buffer queue. The streaming decoder
-uses both kinds of buffer queues: an Android buffer queue for the ADTS
-AAC data source, and an Android simple buffer queue for the PCM data
-sink. For more information about the Android simple buffer queue API, see Android
-simple buffer queue data locator and interface.
-For more information about the Android buffer queue API, see the {@code index.html} file in
-the {@code docs/Additional_library_docs/openmaxal/} directory under the installation root.
-
-The
-The metadata key indices are available immediately after
-the
-Metadata key names are stable, but the key indices are not documented,
-and are subject to change. An application should not assume that indices
-are persistent across different execution runs, and should not assume that
-multiple object instances share indices within the same run.
-
-An app running on Android 5.0 (API level 21) and higher can supply data to an AudioPlayer in
-single-precision, floating-point format.
-
-In following example code, the {@code Engine::CreateAudioPlayer} method creates an audio player
-that uses floating-point data:
- OpenSL ES Programming Notes
- provides supplemental information to ensure proper implementation of OpenSL ES. Note:
-For your convenience, we have included a copy of the OpenSL ES 1.0.1 specification with the NDK in
-{@code docs/opensles/OpenSL_ES_Specification_1.0.1.pdf}.
-
-This section describes known issues in the initial platform release that supports these APIs.
-
-{@code DynamicInterfaceManagement::AddInterface} does not work. Instead, specify the interface in
-the array that is passed to Create, as shown in the example code for environmental reverb.
-
-The notes in this section supplement the
-OpenSL ES 1.0.1
-specification.
-
-Two aspects of the OpenSL ES programming model that may be unfamiliar to new developers are the
-distinction between objects and interfaces, and the initialization sequence.
-
-Briefly, an OpenSL ES object is similar to the object concept in
- programming languages such as Java
-and C++, except an OpenSL ES object is only visible via its associated interfaces.
- This includes
-the initial interface for all objects, called {@code SLObjectItf}.
- There is no handle for an object
-itself, only a handle to the {@code SLObjectItf} interface of the object.
-
-An OpenSL ES object is first created, which returns an {@code SLObjectItf}, then
-realized. This is similar to the common programming pattern of first constructing an
-object (which should never fail other than for lack of memory or invalid parameters), and then
-completing initialization (which may fail due to lack of resources). The realize step gives the
-implementation a logical place to allocate additional resources if needed.
-
-As part of the API to create an object, an application specifies an array of desired interfaces
-that it plans to acquire later. Note that this array does not automatically
- acquire the interfaces;
-it merely indicates a future intention to acquire them. Interfaces are distinguished as
-implicit or explicit. An explicit interface must be listed in the array if it
-will be acquired later. An implicit interface need not be listed in the
- object create array, but
-there is no harm in listing it there. OpenSL ES has one more kind of interface called
-dynamic, which does not need to be specified in the object
- create array and can be added
-later after the object is created. The Android implementation provides
- a convenience feature to
-avoid this complexity, which is described in
- Dynamic interfaces at object creation.
-
-After the object is created and realized, the application should acquire interfaces for each
-feature it needs, using {@code GetInterface} on the initial {@code SLObjectItf}.
-
-Finally, the object is available for use via its interfaces, though note that
- some objects require
-further setup. In particular, an audio player with URI data source needs a bit
- more preparation in
-order to detect connection errors. See the
- Audio player prefetch section for details.
-
-After your application is done with the object, you should explicitly destroy it; see the
-Destroy section below.
-
-For an audio player with URI data source, {@code Object::Realize} allocates
- resources but does not
-connect to the data source (prepare) or begin pre-fetching data. These occur once the
-player state is set to either {@code SL_PLAYSTATE_PAUSED} or {@code SL_PLAYSTATE_PLAYING}.
-
-Some information may still be unknown until relatively late in this sequence. In
-particular, initially {@code Player::GetDuration} returns {@code SL_TIME_UNKNOWN} and
-{@code MuteSolo::GetChannelCount} either returns successfully with channel count zero or the
-error result {@code SL_RESULT_PRECONDITIONS_VIOLATED}. These APIs return the proper values
-once they are known.
-
-Other properties that are initially unknown include the sample rate and
- actual media content type
-based on examining the content's header (as opposed to the
- application-specified MIME type and
-container type). These are also determined later during
- prepare/prefetch, but there are no APIs to
-retrieve them.
-
-The prefetch status interface is useful for detecting when all information
- is available, or your
-application can poll periodically. Note that some information, such as the
- duration of a streaming
-MP3, may never be known.
-
-The prefetch status interface is also useful for detecting errors. Register a callback
- and enable
-at least the {@code SL_PREFETCHEVENT_FILLLEVELCHANGE} and {@code SL_PREFETCHEVENT_STATUSCHANGE}
-events. If both of these events are delivered simultaneously, and
-{@code PrefetchStatus::GetFillLevel} reports a zero level, and
-{@code PrefetchStatus::GetPrefetchStatus} reports {@code SL_PREFETCHSTATUS_UNDERFLOW},
- then this
-indicates a non-recoverable error in the data source. This includes the inability to
- connect to the
-data source because the local filename does not exist or the network URI is invalid.
-
-The next version of OpenSL ES is expected to add more explicit support for
- handling errors in the
-data source. However, for future binary compatibility, we intend to continue
- to support the current
-method for reporting a non-recoverable error.
-
-In summary, a recommended code sequence is:
- Note:
-Preparation and prefetching occur here; during this time your callback is called with
-periodic status updates.
-
-Be sure to destroy all objects when exiting from your application.
- Objects should be destroyed in
-reverse order of their creation, as it is not safe to destroy an object that has any dependent
-objects. For example, destroy in this order: audio players and recorders, output mix, and then
-finally the engine.
-
-OpenSL ES does not support automatic garbage collection or
-reference
-counting of interfaces. After you call {@code Object::Destroy}, all extant
- interfaces that are
-derived from the associated object become undefined.
-
-The Android OpenSL ES implementation does not detect the incorrect use of such interfaces.
-Continuing to use such interfaces after the object is destroyed can cause your application to
-crash or behave in unpredictable ways.
-
-We recommend that you explicitly set both the primary object interface and all associated
-interfaces to NULL as part of your object destruction sequence, which prevents the accidental
-misuse of a stale interface handle.
-
-When {@code Volume::EnableStereoPosition} is used to enable stereo panning of a mono source,
- there is a 3-dB reduction in total
-sound power
-level. This is needed to permit the total sound power level to remain constant as
- the source is
-panned from one channel to the other. Therefore, only enable stereo positioning if you need
-it. See the Wikipedia article on
-audio panning
- for more information.
-
-Callback handlers are generally called synchronously with respect to the event. That is, at the
-moment and location that the event is detected by the implementation. This point is
-asynchronous with respect to the application, so you should use a non-blocking synchronization
-mechanism to control access to any variables shared between the application and the callback
-handler. In the example code, such as for buffer queues, we have either omitted this
-synchronization or used blocking synchronization in the interest of simplicity. However, proper
-non-blocking synchronization is critical for any production code.
-
-Callback handlers are called from internal non-application threads that are not attached to the
-Android runtime, so they are ineligible to use JNI. Because these internal threads are
-critical to
-the integrity of the OpenSL ES implementation, a callback handler should also not block
- or perform
-excessive work.
-
-If your callback handler needs to use JNI or execute work that is not proportional to the
-callback, the handler should instead post an event for another thread to process. Examples of
-acceptable callback workload include rendering and enqueuing the next output buffer
-(for an AudioPlayer), processing the just-filled input buffer and enqueueing the next
- empty buffer
-(for an AudioRecorder), or simple APIs such as most of the Get family. See the
-Performance section below regarding the workload.
-
-Note that the converse is safe: an Android application thread that has entered JNI
- is allowed to
-directly call OpenSL ES APIs, including those that block. However, blocking calls are not
-recommended from the main thread, as they may result in
- Application Not Responding (ANR).
-
-The determination regarding the thread that calls a callback handler is largely left up to the
-implementation. The reason for this flexibility is to permit future optimizations,
- especially on
-multi-core devices.
-
-The thread on which the callback handler runs is not guaranteed to have the same
- identity across
-different calls. Therefore, do not rely on the {@code pthread_t returned by pthread_self()}
- or the
-{@code pid_t returned by gettid()} to be consistent across calls. For the same reason,
- do not use
-the thread local storage (TLS) APIs such as {@code pthread_setspecific()} and
-{@code pthread_getspecific()} from a callback.
-
-The implementation guarantees that concurrent callbacks of the same kind, for the
- same object, does
-not occur. However, concurrent callbacks of different kinds for the same object are possible on
-different threads.
-
-As OpenSL ES is a native C API, non-runtime application threads that call OpenSL ES have no
-runtime-related overhead such as garbage collection pauses. With one exception described below,
-there is no additional performance benefit to the use of OpenSL ES other than this.
- In particular,
-the use of OpenSL ES does not guarantee enhancements such as lower audio latency and higher
-scheduling priority over that which the platform generally provides. On the other hand, as the
-Android platform and specific device implementations continue to evolve, an OpenSL ES application
-can expect to benefit from any future system performance improvements.
-
-One such evolution is support for reduced
-audio output latency.
-The underpinnings for reduced
-output latency were first included in Android 4.1 (API level 16), and then
-continued progress occurred in Android 4.2 (API level 17). These improvements are available via
-OpenSL ES for device implementations that
- claim feature {@code android.hardware.audio.low_latency}.
-If the device doesn't claim this feature but supports Android 2.3 (API level 9)
-or later, then you can still use the OpenSL ES APIs but the output latency may be higher.
- The lower
-output latency path is used only if the application requests a buffer size and sample rate
- that are
-compatible with the device's native output configuration. These parameters are
- device-specific and
-should be obtained as described below.
-
-Beginning with Android 4.2 (API level 17), an application can query for the
-platform native or optimal output sample rate and buffer size for the device's primary output
-stream. When combined with the feature test just mentioned, an app can now configure itself
-appropriately for lower latency output on devices that claim support.
-
-For Android 4.2 (API level 17) and earlier, a buffer count of two or more is
-required for lower latency. Beginning with Android 4.3 (API level 18), a buffer
-count of one is sufficient for lower latency.
-
-All OpenSL ES interfaces for output effects preclude the lower latency path.
-
-The recommended sequence is as follows:
- Note:
-You can use the
-
- Audio Buffer Size
-test app to determine the native buffer size and sample rate for OpenSL ES audio
-applications on your audio device. You can also visit GitHub to view
-audio-buffer-size samples.
-
-
-The number of lower latency audio players is limited. If your application requires more
-than a few
-audio sources, consider mixing your audio at the application level. Be sure to destroy your audio
-players when your activity is paused, as they are a global resource shared with other apps.
-
-To avoid audible glitches, the buffer queue callback handler must execute within a small and
-predictable time window. This typically implies no unbounded blocking on mutexes, conditions,
-or I/O operations. Instead consider try locks, locks and waits with timeouts, and
-
- non-blocking algorithms.
-
-The computation required to render the next buffer (for AudioPlayer) or consume the previous
-buffer (for AudioRecord) should take approximately the same amount of time for each callback.
-Avoid algorithms that execute in a non-deterministic amount of time or are bursty in
-their computations. A callback computation is bursty if the CPU time spent in any given callback
-is significantly larger than the average. In summary, the ideal is for the CPU execution time of
-the handler to have variance near zero, and for the handler to not block for unbounded times.
-
-Lower latency audio is possible for these outputs only:
-
-On some devices, speaker latency is higher than other paths due to digital signal processing for
-speaker correction and protection.
-
-As of API level 21,
-lower latency audio input
- is supported
-on select devices. To take advantage of
-this feature, first confirm that lower latency output is available as described above. The
-capability for lower latency output is a prerequisite for the lower latency input feature. Then,
-create an AudioRecorder with the same sample rate and buffer size as would be used for output.
-OpenSL ES interfaces for input effects preclude the lower latency path. The record preset
-{@code SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION} must be used for lower latency; this preset
-disables device-specific digital signal processing that may add latency to the input path. For
-more information on record presets, see the Android
-configuration interface section above.
-
-For simultaneous input and output, separate buffer queue completion handlers are used for each
-side. There is no guarantee of the relative order of these callbacks, or the synchronization of
-the audio clocks, even when both sides use the same sample rate. Your application
- should buffer the
-data with proper buffer synchronization.
-
-One consequence of potentially independent audio clocks is the need for asynchronous sample rate
-conversion. A simple (though not ideal for audio quality) technique for asynchronous sample rate
-conversion is to duplicate or drop samples as needed near a zero-crossing point.
- More sophisticated
-conversions are possible.
-
-As far as who can do what, security in Android is done at the process level. Java programming
-language code cannot do anything more than native code, nor can native code do anything more than
-Java programming language code. The only differences between them are the available APIs.
-
-Applications using OpenSL ES must request the permissions that they would need for similar
-non-native APIs. For example, if your application records audio, then it needs the
-{@code android.permission.RECORD_AUDIO} permission. Applications that use audio effects need
-{@code android.permission.MODIFY_AUDIO_SETTINGS}. Applications that play network URI resources
-need {@code android.permission.NETWORK}. See
-Working with System
-Permissions for more information.
-
-Depending on the platform version and implementation, media content parsers and
- software codecs may
-run within the context of the Android application that calls OpenSL ES (hardware codecs are
-abstracted but are device-dependent). Malformed content designed to exploit parser and codec
-vulnerabilities is a known attack vector. We recommend that you play media only from trustworthy
-sources or that you partition your application such that code that handles media from
-untrustworthy sources runs in a relatively sandboxed environment. For example, you could
-process media from untrustworthy sources in a separate process. Though both processes would still
-run under the same UID, this separation does make an attack more difficult.
- Audio latency: buffer sizes Building great multi-media experiences on Android This page describes how to develop your audio app for low-latency output and how to avoid
-warmup latency. Low-latency audio is currently only supported when using Android's implementation of the
-OpenSL ES™ API specification, and the Android NDK:
- Latency is the time it takes for a signal to travel through a system. These are the common
-types of latency related to audio apps:
-
- It is difficult to test audio output latency in isolation since it requires knowing exactly
-when the first sample is sent into the audio path (although this can be done using a
-
-light testing circuit and an oscilloscope). If you know the round-trip audio latency, you can
-use the rough rule of thumb: audio output latency is half the round-trip audio latency
-over paths without signal processing.
- To obtain the lowest latency, you must supply audio data that matches the device's optimal
-sample rate and buffer size. For more information, see
-
-Design For Reduced Latency. In Java, you can obtain the optimal sample rate from AudioManager as shown in the following
-code example:
- Note: The sample rate refers to the rate of each stream. If your source audio
- has two channels (stereo), then you will have one stream playing a pair of samples (frame) at
-
- PROPERTY_OUTPUT_SAMPLE_RATE.
- Once you have the optimal sample output rate, you can supply it when creating your player
-using OpenSL ES:
- Note: {@code samplesPerSec} refers to the sample rate per channel in
- millihertz (1 Hz = 1000 mHz).
- Only these interfaces are supported by the fast mixer: These interfaces are not allowed because they involve signal processing and will cause
-your request for a fast-track to be rejected: When you create your player, make sure you only add fast interfaces, as shown in
-the following example: Complete these steps to verify that you have successfully obtained a low-latency track: You can measure round-trip audio latency by creating an app that generates an audio signal,
-listens for that signal, and measures the time between sending it and receiving it.
-Alternatively, you can install this
-
-latency testing app. This performs a round-trip latency test using the
-
-Larsen test. You can also
-
-view the source code for the latency testing app. Since the lowest latency is achieved over audio paths with minimal signal processing, you may
-also want to use an
-
-Audio Loopback Dongle, which allows the test to be run over the headset connector. The lowest possible round-trip audio latency varies greatly depending on device model and
-Android build. You can measure it yourself using the latency testing app and loopback
-dongle. When creating apps for Nexus devices, you can also use the
-
-published measurements. You can also get a rough idea of audio performance by testing whether the device reports
-support for the
-
-low_latency and
-
-pro hardware features. The Android Compatibility Definition Document (CDD) enumerates the hardware and software
-requirements of a compatible Android device.
-See
-Android Compatibility for more information on the overall compatibility program, and
-
-CDD for the actual CDD document. In the CDD, round-trip latency is specified as 20 ms or lower (even though musicians
-generally require 10 ms). This is because there are important use cases that are enabled by
-20 ms. There is currently no API to determine audio latency over any path on an Android device at
-runtime. You can, however, use the following hardware feature flags to find out whether the
-device makes any guarantees for latency: The criteria for reporting these flags is defined in the CDD in sections 5.6 Audio
-Latency and 5.10 Professional Audio. Here’s how to check for these features in Java: Regarding the relationship of audio features, the {@code android.hardware.audio.low_latency}
-feature is a prerequisite for {@code android.hardware.audio.pro}. A device can implement
-{@code android.hardware.audio.low_latency} and not {@code android.hardware.audio.pro}, but not
-vice-versa. You can obtain the optimal buffer size in a similar way to the optimal frame rate, using the
-AudioManager API: The
-
-PROPERTY_OUTPUT_FRAMES_PER_BUFFER property indicates the number of audio frames
-that the HAL (Hardware Abstraction Layer) buffer can hold. You should construct your audio
-buffers so that they contain an exact multiple of this number. If you use the correct number
-of audio frames, your callbacks occur at regular intervals, which reduces jitter. It is important to use the API to determine buffer size rather than using a hardcoded value,
- because HAL buffer sizes differ across devices and across Android builds. When you enqueue audio data for the first time, it takes a small, but still significant,
-amount of time for the device audio circuit to warm up. To avoid this warmup latency, you should
-enqueue buffers of audio data containing silence, as shown in the following code example: At the point when audio should be produced, you can switch to enqueuing buffers containing
-real audio data. Sample Rates: Why Can't We All Just Agree? As of Android 5.0 (Lollipop), the audio resamplers are now entirely based
-on FIR filters derived from a Kaiser windowed-sinc function. The Kaiser windowed-sinc
-offers the following properties:
-APP_OPTIM
-APP_CFLAGS
-
-sources/foo/Android.mk
-sources/bar/Android.mk
-
-
-
-APP_CFLAGS += -Isources/bar
-
-
-
-APP_CFLAGS += -I$(LOCAL_PATH)/../bar
-
-
-APP_CPPFLAGS
-APP_LDFLAGS
-APP_BUILD_SCRIPT
-APP_ABI
-
-
-
-
-
- Instruction set
- Value
-
-
- Hardware FPU instructions on ARMv7 based devices
- {@code APP_ABI := armeabi-v7a}
-
-
- ARMv8 AArch64
- {@code APP_ABI := arm64-v8a}
-
-
- IA-32
- {@code APP_ABI := x86}
-
-
- Intel64
- {@code APP_ABI := x86_64}
-
-
- MIPS32
- {@code APP_ABI := mips}
-
-
- MIPS64 (r6)
- {@code APP_ABI := mips64}
-
-
-All supported instruction sets
- {@code APP_ABI := all}
-
-APP_ABI := armeabi armeabi-v7a x86 mips
-
-
-APP_PLATFORM
-APP_STL
-APP_SHORT_COMMANDS
-NDK_TOOLCHAIN_VERSION
-APP_PIE
-APP_THIN_ARCHIVE
-On this page
-
-
- Video
- Building Great Audio Apps
-
-
-
-
-Adding OpenSL ES to your App
-
-
-#include <SLES/OpenSLES.h>
-
-
-
-#include <SLES/OpenSLES_Android.h>
-
-
-
-#include <SLES/OpenSLES_AndroidConfiguration.h>
-#include <SLES/OpenSLES_AndroidMetadata.h>
-
-
-Building and Debugging
-
-
-LOCAL_LDLIBS += -lOpenSLES
-
-
-
-$ adb logcat
-
-
-Audio Power Consumption
-Samples
-
-On this page
-
-
- Video
-
-
-
-
-
-
-Best Practices for Floating-Point Audio
-
-
-
-Floating-Point Audio in Android SDK
-
-AudioFormat.ENCODING_PCM_FLOAT is used similarly to
- ENCODING_PCM_16_BIT or ENCODING_PCM_8_BIT for specifying
- AudioTrack data
-formats. The corresponding overloaded method AudioTrack.write()
- takes in a float array to deliver data.
- public int write(float[] audioData,
- int offsetInFloats,
- int sizeInFloats,
- int writeMode)
-
-
-For More Information
-
-
-
-
-
-
diff --git a/docs/html/ndk/guides/audio/index.jd b/docs/html/ndk/guides/audio/index.jd
deleted file mode 100644
index 12d9320c7a43f..0000000000000
--- a/docs/html/ndk/guides/audio/index.jd
+++ /dev/null
@@ -1,27 +0,0 @@
-page.title=NDK High-Performance Audio
-@jd:body
-
-On this page
-
-
- Checklist
-
-
-
-
-Ways to Reduce Audio Input Latency
-
-
-
-
-What to Avoid
-
-
-
-
-On this page
-
-
- Getting Started
-
-Example code
-
-Makefile
-
-
-LOCAL_LDLIBS += -lOpenSLES
-
-
-Audio content
-
-
-
-
-Features Inherited from the Reference Specification
-
-Global entry points
-
-
-
-
-Objects and interfaces
-
-
-
-
-
-
- Feature
- Audio player
- Audio recorder
- Engine
- Output mix
-
-
- Bass boost
- Yes
- No
- No
- Yes
-
-
- Buffer queue
- Yes
- No
- No
- No
-
-
- Dynamic interface management
- Yes
- Yes
- Yes
- Yes
-
-
- Effect send
- Yes
- No
- No
- No
-
-
- Engine
- No
- No
- Yes
- No
-
-
- Environmental reverb
- No
- No
- No
- Yes
-
-
- Equalizer
- Yes
- No
- No
- Yes
-
-
- Metadata extraction
- Yes: Decode to PCM
- No
- No
- No
-
-
- Mute solo
- Yes
- No
- No
- No
-
-
- Object
- Yes
- Yes
- Yes
- Yes
-
-
- Play
- Yes
- No
- No
- No
-
-
- Playback rate
- Yes
- No
- No
- No
-
-
- Prefetch status
- Yes
- No
- No
- No
-
-
- Preset reverb
- No
- No
- No
- Yes
-
-
- Record
- No
- Yes
- No
- No
-
-
- Seek
- Yes
- No
- No
- No
-
-
- Virtualizer
- Yes
- No
- No
- Yes
-
-
- Volume
- Yes
- No
- No
- No
-
-
- Buffer queue data locator
- Yes: Source
- No
- No
- No
-
-
- I/O device data locator
- No
- Yes: Source
- No
- No
-
-
- Output mix locator
- Yes: Sink
- No
- No
- No
-
-
- URI data locator
- Yes: Source
- No
- No
- No
- Limitations
-
-Dynamic interface management
-
-Effect combinations: environment reverb and preset reverb
-
-Effect send
-
-SetSendLevel() supports a single send level per audio player.
-Environmental reverb
-
-reflectionsDelay,
-reflectionsLevel, or reverbDelay fields of
-the SLEnvironmentalReverbSettings struct.
-MIME data format
-
-mimeType
-to either NULL or a valid UTF-8 string. You must also initialize
-containerType to a valid value.
-In the absence of other considerations, such as portability to other
-implementations or content format that an app cannot identify by header,
-we recommend that you
-set mimeType to NULL and containerType
-to SL_CONTAINERTYPE_UNSPECIFIED.
-
-
-
-
-
-
-Object-related methods
-
-
-
-
-PCM data format
-
-
-
-
-
-
samplesPerSec field is in units of milliHz, despite the misleading
-name. To avoid accidentally using the wrong value, we recommend that you initialize this field using
-one of the symbolic constants defined for this purpose, such as {@code SL_SAMPLINGRATE_44_1}.
-Playback rate
-
-PlaybackRate::GetRateRange() or
-PlaybackRate::GetCapabilitiesOfRate() to query the device.
-Record
-
-SL_RECORDEVENT_HEADATLIMIT
-or SL_RECORDEVENT_HEADMOVING events.
-Seek
-
-SetLoop() method enables whole-file looping. To enable looping,
-set the startPos parameter to 0, and the value of the endPos parameter
-to SL_TIME_UNKNOWN.
-Buffer queue data locator
-
-I/O device data locator
-
-Engine::CreateAudioRecorder().
-Initialize the device data locator using the values contained in the following code snippet.
-
-SLDataLocator_IODevice loc_dev =
- {SL_DATALOCATOR_IODEVICE, SL_IODEVICE_AUDIOINPUT,
- SL_DEFAULTDEVICEID_AUDIOINPUT, NULL};
-
-
-URI data locator
-
-Data structures
-
-
-
-
-Platform configuration
-
-
-
-
-Planning for Future Versions of OpenSL ES
-
-Planning for binary compatibility
-
-
-
-
-Planning for source compatibility
-
-
-
-
-Android Extensions
-
-OpenSLES_Android.h
-and the header files that it includes. Consult {@code OpenSLES_Android.h}
-for details about these extensions. This file is located under your installation root, in the
-{@code platforms/android-<version>/<abi>/include/SLES} directory. Unless otherwise
-noted, all interfaces are explicit.
-
-
-
-
-
- Feature
- Audio player
- Audio recorder
- Engine
- Output mix
-
-
- Android buffer queue
- Yes: Source (decode)
- No
- No
- No
-
-
- Android configuration
- Yes
- Yes
- No
- No
-
-
- Android effect
- Yes
- No
- No
- Yes
-
-
- Android effect capabilities
- No
- No
- Yes
- No
-
-
- Android effect send
- Yes
- No
- No
- No
-
-
- Android simple buffer queue
- Yes: Source (playback) or sink (decode)
- Yes
- No
- No
-
-
- Android buffer queue data locator
- Yes: Source (decode)
- No
- No
- No
-
-
- Android file descriptor data locator
- Yes: Source
- No
- No
- No
-
-
-Android simple buffer queue data locator
- Yes: Source (playback) or sink (decode)
- Yes: Sink
- No
- No
- Android configuration interface
-
-
-
-
-SL_ANDROID_STREAM_MEDIA).SL_ANDROID_RECORDING_PRESET_GENERIC).
-
-// CreateAudioPlayer and specify SL_IID_ANDROIDCONFIGURATION
-// in the required interface ID array. Do not realize player yet.
-// ...
-SLAndroidConfigurationItf playerConfig;
-result = (*playerObject)->GetInterface(playerObject,
- SL_IID_ANDROIDCONFIGURATION, &playerConfig);
-assert(SL_RESULT_SUCCESS == result);
-SLint32 streamType = SL_ANDROID_STREAM_ALARM;
-result = (*playerConfig)->SetConfiguration(playerConfig,
- SL_ANDROID_KEY_STREAM_TYPE, &streamType, sizeof(SLint32));
-assert(SL_RESULT_SUCCESS == result);
-// ...
-// Now realize the player here.
-
-
-
-// ... obtain the configuration interface as the first four lines above, then:
-SLuint32 presetValue = SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION;
-result = (*playerConfig)->SetConfiguration(playerConfig,
- RECORDING_PRESET, &presetValue, sizeof(SLuint32));
-
-
-Android effects interfaces
-
-Android file descriptor data locator
-
-Android simple buffer queue data locator and interface
-
-Dynamic interfaces at object creation
-
-DynamicInterfaceManagement::AddInterface()
-to add these interfaces after instantiation.
-Buffer queue behavior
-
-BufferQueue::Clear() method after a transition to
-SL_PLAYSTATE_STOPPED. Doing so sets the buffer queue to a known state.
-SL_PLAYSTATE_STOPPED or execution of
-BufferQueue::Clear(). Therefore, we recommend that you do not create a dependency on
-one or the other; instead, your app should be able to handle both.
-Reporting of extensions
-
-
-
-Engine::QueryNumSupportedExtensions()Engine::QuerySupportedExtension()Engine::IsExtensionSupported()ANDROID_SDK_LEVEL_<API-level>,
-where {@code API-level} is the platform API level; for example, {@code ANDROID_SDK_LEVEL_23}.
-A platform API level of 9 or higher means that the platform supports the extensions.
-Decode audio to PCM
-
-
-
-
-
-
-API level
- Alternatives
-
-
-13 and below
- An open-source codec with a suitable license
-
-
-14 to 15
- An open-source codec with a suitable license
-
-
-16 to 20
-
- The {@link android.media.MediaCodec} class or an open-source codec with a suitable license
-
-
-
-21 and above
-
- NDK MediaCodec in the {@code <media/NdkMedia*.h>} header files, the
- {@link android.media.MediaCodec} class, or an open-source codec with a suitable license
-
-SL_PLAYEVENT_HEADATEND event at the end of the stream. After the app has decoded
-all of the data it received, it makes no further calls to the Android simple buffer queue callback.
-Decode streaming ADTS AAC to PCM
-
-
-
-
-
-
-
-Determining the format of decoded PCM data via metadata
-
-SLMetadataExtractionItf interface is part of the reference specification.
-However, the metadata keys that indicate the actual format of decoded PCM data are specific to
-Android. The OpenSLES_AndroidMetadata.h header file defines these metadata keys.
-This header file resides under your installation root, in the
-{@code platforms/android-<version>/<abi>/include/SLES} directory.
-Object::Realize() method finishes executing. However, the associated values are not
-available until after the app decodes the first encoded data. A good
-practice is to query for the key indices in the main thread after calling the {@code
-Object::Realize} method, and to read the PCM format metadata values in the Android simple
-buffer queue callback handler when calling it for the first time. Consult the
-example code in the
-NDK package for examples of working with this interface.
-Floating-point data
-
-
-#include <SLES/OpenSLES_Android.h>
-...
-SLAndroidDataFormat_PCM_EX pcm;
-pcm.formatType = SL_ANDROID_DATAFORMAT_PCM_EX;
-pcm.numChannels = 2;
-pcm.sampleRate = SL_SAMPLINGRATE_44_1;
-pcm.bitsPerSample = 32;
-pcm.containerSize = 32;
-pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
-pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
-pcm.representation = SL_ANDROID_PCM_REPRESENTATION_FLOAT;
-...
-SLDataSource audiosrc;
-audiosrc.pLocator = ...
-audiosrc.pFormat = &pcm;
-
-
-Programming Notes
-Platform Issues
-
-Dynamic interface management
-
-On this page
-
-
- Objects and Interface Initialization
-
-Audio Player Prefetch
-
-
-
-
-Destroy
-
-Stereo Panning
-
-Callbacks and Threads
-
-Performance
-
-
-
-
-import android.content.pm.PackageManager;
-...
-PackageManager pm = getContext().getPackageManager();
-boolean claimsFeature = pm.hasSystemFeature(PackageManager.FEATURE_AUDIO_LOW_LATENCY);
-
import android.media.AudioManager;
-...
-AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
-String sampleRate = am.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE));
-String framesPerBuffer = am.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER));
-
- Note that {@code sampleRate} and {@code framesPerBuffer} are strings. First check for
- null and then convert to int using {@code Integer.parseInt()}.
-
-
-Security and Permissions
-
-On this page
-
-
-
- Also read
-
-
- Video
- Video
- Prerequisites
-
-
-
-
-Obtain a Low-Latency Track
-
-
-
-
-Obtain the optimal sample rate
-
-
-AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
-String frameRate = am.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
-int frameRateInt = Integer.parseInt(frameRate);
-if (frameRateInt == 0) frameRateInt = 44100; // Use a default value if property not found
-
-
-Use the optimal sample rate when creating your audio player
-
-
-// create buffer queue audio player
-void Java_com_example_audio_generatetone_MainActivity_createBufferQueueAudioPlayer
- (JNIEnv* env, jclass clazz, jint sampleRate, jint framesPerBuffer)
-{
- ...
- // specify the audio source format
- SLDataFormat_PCM format_pcm;
- format_pcm.numChannels = 2;
- format_pcm.samplesPerSec = (SLuint32) sampleRate * 1000;
- ...
-}
-
-
-Avoid adding output interfaces that involve signal processing
-
-
-
-
-
-
-
-
-const SLInterfaceID interface_ids[2] = { SL_IID_ANDROIDSIMPLEBUFFERQUEUE, SL_IID_VOLUME };
-
-
-Verify you're using a low-latency track
-
-
-
-
-
-adb shell ps | grep your_app_name
-
-
-
-adb shell dumpsys media.audio_flinger
-
-
- Measure round-trip latency
-
-Review the CDD and audio latency
-
-
-
-
-
-boolean hasLowLatencyFeature =
- getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUDIO_LOW_LATENCY);
-
-boolean hasProFeature =
- getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUDIO_PRO);
-
-
-Use the Optimal Buffer Size When Enqueuing Audio Data
-
-
-AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
-String framesPerBuffer = am.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);
-int framesPerBufferInt = Integer.parseInt(framesPerBuffer);
-if (framesPerBufferInt == 0) framesPerBufferInt = 256; // Use default
-
-
-Avoid Warmup Latency
-
-
-#define CHANNELS 1
-static short* silenceBuffer;
-int numSamples = frames * CHANNELS;
-silenceBuffer = malloc(sizeof(*silenceBuffer) * numSamples);
- for (i = 0; i < numSamples; i++) {
- silenceBuffer[i] = 0;
- }
-
-
-On this page
-
-
- Video
-
-
-See P.P. Vaidyanathan,
-Multirate Systems and Filter Banks, p. 50 for discussions of the
-Kaiser Window and its optimality and relationship to Prolate Spheroidal
-Windows.
The design parameters are automatically computed based on internal -quality determination and the sampling ratios desired. Based on the -design parameters, the windowed-sinc filter is generated. For music use, -the resampler for 44.1 to 48 kHz and vice versa is generated at a higher -quality than for arbitrary frequency conversion.
- -The audio resamplers provide increased quality, as well as speed -to achieve that quality. But resamplers can introduce small amounts -of passband ripple and aliasing harmonic noise, and they can cause some high -frequency loss in the transition band, so avoid using them unnecessarily.
- -This section describes some best practices to help you avoid problems with sampling rates.
-In general, it is best to choose the sampling rate to fit the device, -typically 44.1 kHz or 48 kHz. Use of a sample rate greater than -48 kHz will typically result in decreased quality because a resampler must be -used to play back the file.
- -The resampler operates in one of the following modes:
-The resampler is fastest in fixed polyphase mode, when the ratio of input -rate over output rate L/M (taking out the greatest common divisor) -has M less than 256. For example, for 44,100 to 48,000 conversion, L = 147, -M = 160.
- -In fixed polyphase mode, the sampling rate is locked for as -many samples converted and does not change. In interpolated polyphase -mode, the sampling rate is approximate. The drift is generally on the -order of one sample over a few hours of playback on a 48-kHz device. -This is not usually a concern because approximation error is much less than -frequency error of internal quartz oscillators, thermal drift, or jitter - (typically tens of ppm).
- -Choose simple-ratio sampling rates such as 24 kHz (1:2) and 32 kHz (2:3) when playing back - on a 48-kHz device, even though other sampling -rates and ratios may be permitted through AudioTrack.
- -Sampling rates can be changed on the fly. The granularity of -such change is based on the internal buffering (typically a few hundred -samples), not on a sample-by-sample basis. This can be used for effects.
- -Do not dynamically change sampling rates when -downsampling. When changing sample rates after an audio track is -created, differences of around 5 to 10 percent from the original rate may -trigger a filter recomputation when downsampling (to properly suppress -aliasing). This can consume computing resources and may cause an audible click -if the filter is replaced in real time.
- -Downsampling is typically triggered by hardware device requirements. When the - Sample Rate converter is used for downsampling, -try to limit the downsampling ratio to no more than 6:1 for good aliasing -suppression (for example, no greater downsample than 48,000 to 8,000). The filter -lengths adjust to match the downsampling ratio, but you sacrifice more -transition bandwidth at higher downsampling ratios to avoid excessively -increasing the filter length. There are no similar aliasing concerns for -upsampling. Note that some parts of the audio pipeline -may prevent downsampling greater than 2:1.
- -Resampling prevents the track from being placed in the FastMixer -path, which means that significantly higher latency occurs due to the additional, - larger buffer in the ordinary Mixer path. Furthermore, - there is an implicit delay from the filter length of the resampler, - though this is typically on the order of one millisecond or less, - which is not as large as the additional buffering for the ordinary Mixer path - (typically 20 milliseconds).
- -This section lists some additional resources about sampling and resampling.
- -- -Sampling (signal processing) at Wikipedia.
- --Sample rate conversion at Wikipedia.
- --Sample Rate Conversion at source.android.com.
- --24/192 Music Downloads ... and why they make no sense -by Christopher "Monty" Montgomery of Xiph.Org.
- --D/A and A/D | Digital Show and Tell -video by Christopher "Monty" Montgomery of Xiph.Org.
- --The Science of Sample Rates (When Higher Is Better - And When It Isn't).
- - - --192kHz/24bit vs. 96kHz/24bit "debate"- Interesting revelation
diff --git a/docs/html/ndk/guides/build.jd b/docs/html/ndk/guides/build.jd deleted file mode 100644 index 62863283c3863..0000000000000 --- a/docs/html/ndk/guides/build.jd +++ /dev/null @@ -1,18 +0,0 @@ -page.title=Building Your Project -@jd:body - -One of the NDK's core purposes is allowing you to build C and C++ source code into shared -libraries that you can use in your app.
- -This section explains how to build native binaries for use in your Android app. It begins by -explaining the -{@code Android.mk} file, which -defines properties specific to individual modules, or libraries. Then, it explains the -{@code Application.mk} file, which defines -properties for all the modules that you use in your -app. Next, it tells you how to use the -{@code ndk-build} script, which is what the NDK uses to build your sources. Last, it ventures -into advanced territory, discussing how to incorporate the NDK into your own -toolchain, if you prefer to -build that way instead of using -{@code ndk-build}.
\ No newline at end of file diff --git a/docs/html/ndk/guides/concepts.jd b/docs/html/ndk/guides/concepts.jd deleted file mode 100755 index 7879219f347b8..0000000000000 --- a/docs/html/ndk/guides/concepts.jd +++ /dev/null @@ -1,303 +0,0 @@ -page.title=Concepts -@jd:body - -This guide assumes that you are already familiar with concepts inherent in native programming and -in Android development.
- - -This section provides a high-level explanation of how the NDK works. The Android NDK is a set of -tools allowing you to embed C or C++ (“native code”) into your Android apps. The ability to use -native code in Android apps can be particularly useful to developers who wish to do one or more of -the following:
-This section introduces the main components used in building a native application for Android, -and goes on to describe the process of building and packaging.
-You should have an understanding of the following components as you build your app:
-For more information, see -ndk-build.
-When developing Java components, use the {@code native} keyword to indicate methods implemented -as native code. For example, the following function declaration tells the compiler that the -implementation is in a native library:
- - - --public native int add(int x, int y); --
Note: If two libraries implement respective methods with the same -signature, a link error occurs. In C, "signature" means method name only. In C++, "signature" means -not only method name, but also its argument names and types.
-The following two items are only required for building using the -{@code ndk-build} script, -and for debugging using the -{@code ndk-gdb} script. - -
The general flow for developing a native app for Android is as follows:
-Note: While it is possible to completely avoid Java, you are likely -to find the Android Java framework useful for tasks including controlling the display and UI.
-The Android SDK provides a helper class, {@link android.app.NativeActivity}, that allows you to -write a completely native activity. {@link android.app.NativeActivity} handles the communication -between the Android framework and your native code, so you do not have to subclass it or call its -methods. All you need to do is declare your application to be native in your -{@code AndroidManifest.xml} file, and begin creating your native application.
- -An Android application using {@link android.app.NativeActivity} still runs in its own virtual -machine, sandboxed from other applications. You can therefore still access Android framework APIs -through the JNI. In certain cases, however–such as for sensors, input events, and -assets–the NDK provides native interfaces that you can use instead of having to call -across the JNI. For more information about such support, see -Android NDK Native APIs.
- -Regardless of whether or not you are developing a native activity, we recommend that you create -your projects with the traditional Android build tools. Doing so helps ensure building and packaging -of Android applications with the correct structure.
- -The Android NDK provides you with two choices to implement your native activity:
- -The {@code
For more information on how to use this static library, examine the native-activity sample
-application and its documentation. Further reading is also available in the comments in the {@code
To implement a native activity with the -{@code native_activity.h} -interface:
- -Because your application has no Java code, set {@code android:hasCode} to {@code false}.
- --<application android:label="@string/app_name" android:hasCode="false"> -- -
You must set the {@code android:name} attribute of the activity tag to -{@link android.app.NativeActivity}.
- --<activity android:name="android.app.NativeActivity" - android:label="@string/app_name"> --
Note: You can subclass {@link android.app.NativeActivity}. If you -do, use the name of the subclass instead of {@link android.app.NativeActivity}.
-The {@code android:value} attribute of the {@code meta-data} tag specifies the name of the shared -library containing the entry point to the application (such as C/C++ {@code main}), omitting the -{@code lib} prefix and {@code .so} suffix from the library name.
- -- <meta-data android:name="android.app.lib_name" - android:value="native-activity" /> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - </manifest> -- -
-$ cd <path>/<to>/<project> -$ <ndk>/ndk-build -- -
The Android platform provides a very minimal C++ runtime support library ({@code libstdc++}). -This minimal support does not include, for example:
- -The NDK provides headers for use with this default library. In addition, the NDK provides a -number of helper runtimes that provide additional features. This page provides information about -these helper runtimes, their characteristics, and how to use them. -
- -Table 1 provides names, brief explanations, and features of runtimes available inthe NDK.
- -- Table 1. NDK Runtimes and Features.
- -| Name | -Explanation> - | Features - |
|---|---|---|
| {@code libstdc++} (default) | -The default minimal system C++ runtime library. | -N/A | -
| {@code gabi++_static} | -The GAbi++ runtime (static). | -C++ Exceptions and RTTI | -
| {@code gabi++_shared} | -The GAbi++ runtime (shared). | -C++ Exceptions and RTTI | -
| {@code stlport_static} | -The STLport runtime (static). | -C++ Exceptions and RTTI; Standard Library | -
| {@code stlport_shared} | -The STLport runtime (shared). | -C++ Exceptions and RTTI; Standard Library | -
| {@code gnustl_static} | -The GNU STL (static). | -C++ Exceptions and RTTI; Standard Library | -
| {@code gnustl_shared} | -The GNU STL (shared). | -C++ Exceptions and RTTI; Standard Library | -
| {@code c++_static} | -The LLVM libc++ runtime (static). | -C++ Exceptions and RTTI; Standard Library | -
| {@code c++_shared} | -The LLVM libc++ runtime (shared). | -C++ Exceptions and RTTI; Standard Library | -
Use the {@code APP_STL} variable in your -{@code Application.mk} file to specify the runtime you wish to use. Use the values in -the "Name" column in Table 1 as your setting. For example:
- --APP_STL := gnustl_static -- -
You may only select one runtime for your app, and can only do in -{@code Application.mk}.
- -Even if you do not use the NDK build system, you can still use STLport, libc++ or GNU STL. -For more information on how to use these runtimes with your own toolchain, see Standalone Toolchain.
- -This runtime only provides the following headers, with no support beyond them:
-This runtime provides the same headers as the default runtime, but adds support for RTTI -(RunTime Type Information) and exception handling.
- - -This runtime is an Android port of STLport -(http://www.stlport.org). It provides a complete set of C++ -standard library headers. It also, by embedding its own instance of GAbi++, provides support for -RTTI and exception handling.
- -While shared and static versions of this runtime are avilable, we recommend using the shared -version. For more information, see Static runtimes.
- -The shared library file is named {@code libstlport_shared.so} instead of {@code libstdc++.so} -as is common on other platforms.
- -In addition to the static- and shared-library options, you can also force the NDK to -build the library from sources by adding the following line to your {@code Application.mk} -file, or setting it in your environment prior to building:
- --STLPORT_FORCE_REBUILD := true -- - -
This runtime is the GNU Standard C++ Library, ({@code libstdc++-v3}). Its shared library file is -named {@code libgnustl_shared.so}.
- - -This runtime is an Android port of LLVM libc++. Its -shared library file is named {@code libc++_shared.so}.
- -By default, this runtime compiles with {@code -std=c++11}. As with GNU {@code libstdc++}, you -need to explicitly turn on exceptions or RTTI support. For information on how to do this, see -C++ Exceptions and RTTI.
- -The NDK provides prebuilt static and shared libraries for {@code libc++}, but you can force the -NDK to rebuild {@code libc++} from sources by adding the following line to your -{@code Application.mk} file, or setting it in your environment prior to building:
- --LIBCXX_FORCE_REBUILD := true -- -
If you include {@code
-LOCAL_LDLIBS += -latomic -- -
If you are using your own toolchain, use:
- ---latomic -- - -
The NDK's libc++ is not stable. Not all the tests pass, and the test suite is not comprehensive. -Some known issues are:
- -You should also make sure to check the "Known Issues" section of the changelog for the NDK -release you are using.
- -Warning: Attempting to change to an unsupported locale will -not fail. The operation will succeed, but the locale will not change and the -following message will appear in {@code logcat}.
- --newlocale() WARNING: Trying to set locale to en_US.UTF-8 other than "", "C" or "POSIX" -- - -
In all versions of the NDK later than NDKr5, the NDK toolchain allows you to use C++ runtimes -that support exception handling. However, to ensure compatibility with earlier releases, it -compiles all C++ sources with {@code -fno-exceptions} support by default. You can enable C++ -exceptions either for your entire app, or for individual modules. - -
To enable exception-handling support for your entire app, add the following line to -your {@code Application.mk} file. -To enable exception-handling support for individual modules', add the following line to -their respective {@code Android.mk} files.
- --APP_CPPFLAGS += -fexceptions -- -
In all versions of the NDK later than NDKr5, the NDK toolchain allows you to use C++ runtimes -that support RTTI. However, to ensure compatibility with earlier releases, it compiles all C++ -sources with {@code -fno-rtti} by default. - -
To enable RTTI support for your entire app for your entire application, add the following line to -your {@code Application.mk} file: - -
-APP_CPPFLAGS += -frtti -- -To enable RTTI support for individual modules, add the following line to -their respective {@code Android.mk} files: - -
-LOCAL_CPP_FEATURES += rtti -- -Alternatively, you can use: - -
-LOCAL_CPPFLAGS += -frtti -- -
Linking the static library variant of a C++ runtime to more than one binary may result in -unexpected behavior. For example, you may experience:
- -In addition, if you link two shared libraries–or a shared library and an executable– -against the same static runtime, the final binary image of each shared library includes a copy of -the runtime's code. Having multiple instances of runtime code is problematic because of duplication -of certain global variables that the runtime uses or provides internally.
- -This problem does not apply to a project comprising a single shared library. For example, -you can link against {@code stlport_static}, and expect your app to behave correctly. If your -project requires several shared library modules, we recommend that you use the shared library -variant of your C++ runtime.
- -If your app targets a version of Android earlier than Android 4.3 (Android API level 18), -and you use the shared library variant of a given C++ runtime, you must load the shared library -before any other library that depends on it.
- -For example, an app may have the following modules:
- -You must load the libraries in reverse dependency order:
-
- static {
- System.loadLibrary("stlport_shared");
- System.loadLibrary("bar");
- System.loadLibrary("foo");
- }
-
-
-Note: Do not use the {@code lib} prefix when calling -{@code System.loadLibrary()}.
- -STLport is licensed under a BSD-style open-source license. See -{@code $NDK/sources/cxx-stl/stlport/README} for more details about STLport.
- -GNU libstdc++ is covered by the GPLv3 license, and not the LGPLv2 or LGPLv3. For -more information, see -License on the GCC website.
- -LLVM {@code libc++} -is dual-licensed under both the University of Illinois "BSD-Like" license and the MIT license.
diff --git a/docs/html/ndk/guides/cpu-arm-neon.jd b/docs/html/ndk/guides/cpu-arm-neon.jd deleted file mode 100644 index 1d12937c5fb49..0000000000000 --- a/docs/html/ndk/guides/cpu-arm-neon.jd +++ /dev/null @@ -1,109 +0,0 @@ -page.title=NEON Support -@jd:body - -The NDK supports the ARM Advanced SIMD, an optional instruction-set extension of the ARMv7 spec. -NEON provides a set of scalar/vector instructions and registers (shared with the FPU) comparable to -MMX/SSE/3DNow! in the x86 world. To function, it requires VFPv3-D32 (32 hardware FPU 64-bit -registers, instead of the minimum of 16).
- -The NDK supports the compilation of modules or even specific source files with support for NEON. -As a result, a specific compiler flag enables the use of GCC ARM NEON intrinsics and VFPv3-D32 -at the same time.
- -Not all ARMv7-based Android devices support NEON, but devices that do may benefit significantly -from its support for scalar/vector instructions. For x86 devices, the NDK can also translate NEON -instructions into SSE, although with several restrictions. For more information, see -x86 Support for ARM NEON Intrinsics.
- -To have the NDK build all its source files with NEON support, include the following line in -your module definition:
- --LOCAL_ARM_NEON := true -- -
It can be especially useful to build all source files with NEON support if you want to build a -static or shared library that specifically contains NEON code paths.
- -When listing source files for your {@code LOCAL_SRC_FILES} variable, you have the option of -using the {@code .neon} suffix to indicate that you want to build binaries with NEON support. -For example, the following example builds one file with {@code .neon} support, and another -without it:
- --LOCAL_SRC_FILES := foo.c.neon bar.c -- -
You can combine the {@code .neon} suffix with the {@code .arm} suffix, which specifies the 32-bit -ARM instruction set for non-NEON instructions. In such a definition, {@code arm} must come before -{@code neon}. For example: {@code foo.c.arm.neon} works, but {@code foo.c.neon.arm} does not.
- -NEON support only works with the {@code armeabi-v7a} and {@code x86} ABIs. If the NDK build -scripts encounter other ABIs while attempting to build with NEON support, the NDK build scripts -exit. x86 provides partial NEON support via translation header. It is -important to use checks like the following in your -{@code Android.mk} file:
- --# define a static library containing our NEON code -ifeq ($(TARGET_ARCH_ABI),$(filter $(TARGET_ARCH_ABI), armeabi-v7a x86)) -include $(CLEAR_VARS) -LOCAL_MODULE := mylib-neon -LOCAL_SRC_FILES := mylib-neon.c -LOCAL_ARM_NEON := true -include $(BUILD_STATIC_LIBRARY) -endif # TARGET_ARCH_ABI == armeabi-v7a || x86 -- -
Your app must perform runtime detection to confirm that NEON-capable machine code can be run on -the target device. This is because not all ARMv7-based Android devices support NEON. The app can -perform this check using the -{@code cpufeatures} library that comes with -this NDK.
- -You should explicitly check that {@code android_getCpuFamily()} returns {@code -ANDROID_CPU_FAMILY_ARM}, and that {@code android_getCpuFeatures()} returns a value including the -{@code ANDROID_CPU_ARM_FEATURE_NEON flag} set. For example:
- -
-#include <cpu-features.h>
-...
-...
-if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM &&
- (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0)
-{
- // use NEON-optimized routines
- ...
-}
-else
-{
- // use non-NEON fallback routines instead
- ...
-}
-
-...
-
-
-The source code for the NDK's hello-neon sample provides an example of how to use the -{@code cpufeatures} library and NEON intrinsics at the same time. This sample implements a tiny -benchmark for a FIR filter loop using a C version, and a NEON-optimized one for devices that -support it.
\ No newline at end of file diff --git a/docs/html/ndk/guides/cpu-features.jd b/docs/html/ndk/guides/cpu-features.jd deleted file mode 100644 index 3323efdb719db..0000000000000 --- a/docs/html/ndk/guides/cpu-features.jd +++ /dev/null @@ -1,210 +0,0 @@ -page.title=The cpufeatures Library -@jd:body - -The NDK provides a small library named {@code cpufeatures} that your app can use at runtime to -detect the target device's CPU family and the optional features it supports. It is designed to work -as-is on all official Android platform versions.
- -The {@code cpufeatures} library is available as an import module. To use it, follow the procedure -below:
- --LOCAL_STATIC_LIBRARIES := cpufeatures --
-$(call import-module,android/cpufeatures) -- -
Here is a simple example of an {@code Android.mk} file that imports the {@code cpufeatures} -library:
- --<project-path>/jni/Android.mk: -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := <your-module-name> -LOCAL_SRC_FILES := <your-source-files> -LOCAL_STATIC_LIBRARIES := cpufeatures -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,android/cpufeatures) --
The {@code cpufeatures} library provides two functions. The first function returns the family to -which the device's CPU belongs. Declare it as follows:
- --AndroidCpuFamily android_getCpuFamily(); -- -
The function returns one of the following enums, representing the CPU family/architecture that -the device supports.
-For a 32-bit executable on a 64-bit system, this function returns only the 32-bit value.
- -The second function returns the set of optional features that the device's CPU supports. Declare -it as follows: - -
-uint64_t android_getCpuFeatures(); -- -
The return value takes the form of a set of bit flags, each flag representing one -CPU-family-specific feature. The rest of this section provides information on features for -the respective families.
- -The following flags are available for the 32-bit ARM CPU family:
-This value is equivalent to the {@code VFPv3-D16} instruction set, which provides provides only -16 hardware double-precision FP registers.
The following flags are available for the 64-bit ARM CPU family:
-The following flags are available for the 32-bit x86 CPU family.
-
{@code android_getCpuFeatures()} returns {@code 0} for CPU families for which there are no -listed extensions.
- -The following function returns the maximum number of CPU cores on the target device:
- --int android_getCpuCount(void); -- -
For the complete change history of this library, see the comments in -{@code $NDK/sources/android/cpufeatures/cpu-features.c}, where {@code $NDK} is the root of your -NDK installation.
\ No newline at end of file diff --git a/docs/html/ndk/guides/debug.jd b/docs/html/ndk/guides/debug.jd deleted file mode 100644 index 3c4da3be0af34..0000000000000 --- a/docs/html/ndk/guides/debug.jd +++ /dev/null @@ -1,11 +0,0 @@ -page.title=Debugging Your Project -@jd:body - -After you've built your app, you'll probably need to debug it. This section introduces you to the -NDK's debugging tools.
- -It begins by telling you how to use the -{@code ndk-gdb} tool to debug your code. It closes with an explanation of the -{@code ndk-stack} tool, which helps you use the -ADB logcat tool -as you debug.
\ No newline at end of file diff --git a/docs/html/ndk/guides/graphics/design-notes.jd b/docs/html/ndk/guides/graphics/design-notes.jd deleted file mode 100644 index 272bd2d14c54b..0000000000000 --- a/docs/html/ndk/guides/graphics/design-notes.jd +++ /dev/null @@ -1,121 +0,0 @@ -page.title=Vulkan Design Guidelines -@jd:body - --Vulkan is unlike earlier graphics APIs in that drivers do not perform certain -optimizations, such as pipeline reuse, for apps. Instead, apps using Vulkan must -implement such optimizations themselves. If they do not, they may exhibit worse -performance than apps running OpenGL ES. -
- --When apps implement these optimizations themselves, they have the potential -to do so more successfully than the driver can, because they have access to -more specific information for a given use case. As a result, skillfully -optimizing an app that uses Vulkan can yield better performance than if the -app were using OpenGL ES. -
- --This page introduces several optimizations that your Android app can implement -to gain performance boosts from Vulkan. -
- --When the upward-facing direction of an app doesn’t match the orientation of the device’s -display, the compositor rotates the application’s swapchain images so that it -does match. It performs this rotation as it displays the images, which results -in more power consumption—sometimes significantly more—than if it were not -rotating them. -
- --By contrast, rotating swapchain images while generating them results in -little, if any, additional power consumption. The -{@code VkSurfaceCapabilitiesKHR::currentTransform} field indicates the rotation -that the compositor applies to the window. After an app applies that rotation -during rendering, the app uses the {@code VkSwapchainCreateInfoKHR::preTransform} -field to report that the rotation is complete. -
- --On most mobile GPU architectures, beginning and ending a render pass is an -expensive operation. Your app can improve performance by organizing rendering operations into -as few render passes as possible. -
- --Different attachment-load and attachment-store ops offer different levels of -performance. For example, if you do not need to preserve the contents of an attachment, you -can use the much faster {@code VK_ATTACHMENT_LOAD_OP_CLEAR} or -{@code VK_ATTACHMENT_LOAD_OP_DONT_CARE} instead of {@code VK_ATTACHMENT_LOAD_OP_LOAD}. Similarly, if -you don't need to write the attachment's final values to memory for later use, you can use -{@code VK_ATTACHMENT_STORE_OP_DONT_CARE} to attain much better performance than -{@code VK_ATTACHMENT_STORE_OP_STORE}. -
- --Also, in most render passes, your app doesn’t need to load or store the -depth/stencil attachment. In such cases, you can avoid having to allocate physical memory for -the attachment by using the {@code VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT} -flag when creating the attachment image. This bit provides the same benefits as does -{@code glFramebufferDiscard} in OpenGL ES. -
- --When allocating device memory, apps must choose a memory type. Memory type -determines how an app can use the memory, and also describes caching and -coherence properties of the memory. Different devices have different memory -types available; different memory types exhibit different performance -characteristics. -
- --An app can use a simple algorithm to pick the best memory type for a given -use. This algorithm picks the first memory type in the -{@code VkPhysicalDeviceMemoryProperties::memoryTypes} array that meets two criteria: -The memory type must be allowed for the buffer -or image, and must have the minimum properties that the app requires. -
- --Mobile systems generally don’t have separate physical memory heaps for the -CPU and GPU. On such systems, {@code VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT} is not as -significant as it is on systems that have discrete GPUs with their own, dedicated -memory. An app should not assume this property is required. -
- --If you have resource bindings that change at different frequencies, use -multiple descriptor sets per pipeline rather than rebinding all resources for -each draw. For example, you can have one set of descriptors for per-scene -bindings, another set for per-material bindings, and a third set for -per-mesh-instance bindings. -
- --Use immediate constants for the highest-frequency changes, such as changes -executed with each draw call. -
- diff --git a/docs/html/ndk/guides/graphics/getting-started.jd b/docs/html/ndk/guides/graphics/getting-started.jd deleted file mode 100644 index 0c2d939f1182e..0000000000000 --- a/docs/html/ndk/guides/graphics/getting-started.jd +++ /dev/null @@ -1,201 +0,0 @@ -page.title=Vulkan Setup -@jd:body - - --This document explains how to get started with the Vulkan graphics library by downloading, -compiling, and running several sample apps. -
- --Before beginning, make sure you have the right hardware and platform version prepared. You should -be using one of the following devices, running at least Android N, Developer Preview 2: -
- --You can confirm your Android version by going to the Settings menu, and -selecting About <device> > Android Version. -Once you’ve confirmed that you have the right hardware and platform version set up, you can -download the necessary software. -
- --Before getting started, you must download several tools and other software. -
- --../../../ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk \ - APP_STL:=c++_shared APP_ABI=all libshaderc_combined -- -You can specify {@code APP_STL} as {@code gnustl_static}, -{@code gnustl_shared}, {@code c++_static}, -or {@code c++_shared}.
-$ git clone https://github.com/googlesamples/vulkan-basic-samples.git --
-$ ./update_external_sources.sh -s -g --
-To confirm that Vulkan is set up properly, you can test it with -the set of Vulkan API samples provided partly for that purpose. Follow these steps to -build and execute these samples: -
- --$ cd API-samples -$ cmake -DANDROID=ON -DANDROID_ABI=[armeabi-v7a|arm64-v8a| x86|x86_64|all(default)] --
You may see an error about missing components or missing SDK version. -Ignore this error message, and follow the installation prompts.
- -After several minutes, the Project pane should -resemble the window shown in Figure 1.
- -
-
--Figure 1. Project pane displaying samples after they've been imported. - -
To compile your project, follow these steps:
- -
-
--Figure 2. Selecting an individual project to compile. - -
Note: -Additional -tutorial samples illustrate the use of shaders compiled with off-line -compilation integrated into Android Studio. For simplicity, each tutorial -is self-contained, and builds according to standard Android Studio -build procedures. -
- -To run your project, choose an APK to run by choosing Run > Run <project-name>.
- -To debug an APK, choose Run > -Debug <project-name>. For each project, -there’s a Java version and a native (C or C++) version. Run the -native version of the app. For example, for drawcube, -run drawcube-native.
- -Most of the samples have simple functionality, and most stop -automatically after running. The drawcube example is one of -the more visually interesting examples. When you run it, it -should display the image in Figure 3
. - -
-
--Figure 3. The successfully compiled program runs and produces a display. -
- --The samples use a dynamic loader helper function defined in {@code vulkan_wrapper.h/cpp} to -retrieve Vulkan API pointers using {@code dlopen()} and {@code dlsym()}. It does this rather -than statically linking them with {@code vulkan.so}. -
- --Using this loader allows the code to link against API level 23 and earlier versions of the platform, which don’t include the {@code vulkan.so} shared library, but can run on devices that support Vulkan API. -
- --The following snippet shows how to use the dynamic loader. -
- --#include "vulkan_wrapper.h" // Include Vulkan_wrapper and dynamically load symbols. -... -// Before any Vulkan API usage, -InitVulkan(); -diff --git a/docs/html/ndk/guides/graphics/index.jd b/docs/html/ndk/guides/graphics/index.jd deleted file mode 100644 index cbd4b9ca802cd..0000000000000 --- a/docs/html/ndk/guides/graphics/index.jd +++ /dev/null @@ -1,36 +0,0 @@ -page.title=Vulkan Graphics API -@jd:body - - -
The Android platform includes an Android-specific implementation of the -Vulkan API -specification from the Khronos Group. Vulkan is a -low-overhead, cross-platform API for high-performance, 3D graphics. It provides tools -for creating high-quality, real-time graphics in -applications. Vulkan also provides advantages such as reducing -CPU overhead and providing support for the -SPIR-V Binary -Intermediate language. -
- --This section begins with information on how to -get started using Vulkan in your -Android app. Next, it provides useful information that you should know about -Vulkan design guidelines -on the Android platform. From there, it explains how -to use Vulkan's shader compilers. -Last, it teaches you how to use -validation layers -to help assure stability in apps using Vulkan. -
- --For more general information about this cross-platform API specification, see -Khronos's - -Vulkan Overview. -You can also keep up with the latest Vulkan-related developments at the -Vulkan -news page. -
diff --git a/docs/html/ndk/guides/graphics/shader-compilers.jd b/docs/html/ndk/guides/graphics/shader-compilers.jd deleted file mode 100644 index c51c21c5b7d99..0000000000000 --- a/docs/html/ndk/guides/graphics/shader-compilers.jd +++ /dev/null @@ -1,194 +0,0 @@ -page.title=Vulkan Shader Compilers on Android -@jd:body - --A Vulkan app must manage shaders differently from the way an OpenGL ES app does so: -In OpenGL ES, you provide a shader as a set of strings forming the source text of a -GLSL shader program. By contrast, the Vulkan API requires you to provide a shader in -the form of an entry point in a SPIR-V module. -
- --The NDK includes a runtime library for compiling GLSL into SPIR-V. -The runtime library is the same as the one in the -Shaderc open source project, and use the same -Glslang GLSL reference compiler as a -back end. By default, the Shaderc version of the -compiler assumes you are compiling for Vulkan. After checking whether your code is valid for -Vulkan, the compiler automatically enables the {@code KHR_vulkan_glsl} extension. The Shaderc -version of the compiler also generates Vulkan-compliant SPIR-V code. -
- --You can choose to compile SPIR-V modules into your Vulkan app during development, a -practice called ahead-of-time, or AOT, compiling. Alternatively, -you can have your app compile them from shipped or procedurally generated shader -source when needed during runtime. This practice is called runtime compiling. -
- --The rest of this page provides more detail about each practice, and then explains -how to integrate shader compilation into your Vulkan app. -
- --For AOT compilation, we recommend the glslc command-line compiler from GLSL to SPIR-V. -This compiler is available from the Shaderc -project.Many of its command-line options are similar to those of GCC and Clang, allowing -you to integrate glslc into build systems easily. -
- --The glslc tool compiles a single-source file to a SPIR-V module with a single shader -entry point. By default, the output file has the same name as that of the source file, -but with the {@code .spv} extension appended. -
- --You use filename extensions to tell the glslc tool which graphics shader stage to compile, -or whether a compute shader is being compiled. For information on how to use these filename -extensions, and options you can use with the tool, see - -Shader stage specification in the - -glslc manual. -
- --For JIT compilation of shaders during runtime, the NDK provides the libshaderc library, -which has both C and C++ APIs. -
- --C++ applications should use the C++ API. We recommend that apps in other languages -use the C API, because the C ABI is lower level, and likely to provide better stability. -
- --The following example shows how to use the C++ API: -
- -
-#include <iostream>
-#include <string>
-#include <vector>
-#include <shaderc/shaderc.hpp>
-
-std::vector<uint32_t> compile_file(const std::string& name,
- shaderc_shader_kind kind,
- const std::string& data) {
- shaderc::Compiler compiler;
- shaderc::CompileOptions options;
-
- // Like -DMY_DEFINE=1
- options.AddMacroDefinition("MY_DEFINE", "1");
-
- shaderc::SpvCompilationResult module = compiler.CompileGlslToSpv(
- data.c_str(), data.size(), kind, name.c_str(), options);
-
- if (module.GetCompilationStatus() !=
- shaderc_compilation_status_success) {
- std::cerr << module.GetErrorMessage();
- }
-
- std::vector<uint32_t> result(module.cbegin(), module.cend());
- return result;
-}
-
-
-
-
--You can integrate the Vulkan shader compiler into your app using either the project's -{@code Android.mk} file or Gradle. -
- --Perform the following steps to use your project's {@code Android.mk} -file to integrate the shader compiler. -
- --include $(CLEAR_VARS) - ... -LOCAL_STATIC_LIBRARIES := shaderc - ... -include $(BUILD_SHARED_LIBRARY) - -$(call import-module, third_party/shaderc) --
-$ ../../../ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk \ -APP_STL:=<stl_version> APP_ABI=all libshaderc_combined -- -
-This command places two folders in <ndk_root>/sources/third_party/shaderc/. The directory -structure is as follows: -
- -
-include/
- shaderc/
- shaderc.h
- shaderc.hpp
-libs/
- <stl_version>/
- {all of the abis}
- libshaderc.a
-
--The STL that you use to build your program must match the {@code stl} specified in -{@code stl_version}. -Only {@code c++_static}, {@code c++_shared}, {@code gnustl_static}, and -{@code gnustl_shared} are supported. -
diff --git a/docs/html/ndk/guides/graphics/validation-layer.jd b/docs/html/ndk/guides/graphics/validation-layer.jd deleted file mode 100644 index 1a7d83246d01c..0000000000000 --- a/docs/html/ndk/guides/graphics/validation-layer.jd +++ /dev/null @@ -1,433 +0,0 @@ -page.title=Vulkan Validation Layers on Android -@jd:body - --Most explicit graphics APIs do not perform error-checking, because doing so can result in a -performance penalty. Vulkan provides error-checking in a manner that lets you use this feature at -development time, but exclude it from the release build of your app, thus avoiding the penalty when -it matters most. You do this by enabling validation layers. Validation layers intercept -or hook Vulkan entry points for various debug and validation purposes. -
- --Each validation layer can contain definitions for one or more of these entry points, and -intercepts the entry points for which it contains definitions. When a validation -layer does not define an entry point, the system passes the entry point on to the next -layer. Ultimately, an entry point not defined in any layer reaches the driver, the -base level, unvalidated. -
- --The Android SDK, NDK, and Vulkan samples include Vulkan validation layers for -use during development. You can hook these validation layers into the graphics stack, allowing -them to report validation issues. This instrumentation allows you to catch and fix misuses -during development. -
- --This page explains how to: -
- NDK release 12 and higher includes pre-built validation layer binaries. At - instance and device creation time, when requested by your application, the - Vulkan loader finds them in the APK installed location and loads them. -
- -- To use the pre-built validation layer binaries, either modify the gradle build - configuration of your project or manually add the binaries into the JNI - libraries directory of your project. -
- - -- You can add the validation layer your project using either Andorid Studio's - support for CMake and Ndk-build, or using Studio's experimental plugin for - Gradle. In general, you should use the CMake and Ndk-build configuration. -
- - -- To add the libraries using Android Studio's support for CMake/Ndk-build, - add the following to your project's gradle configuration: -
- -
-sourceSets {
- main {
- jniLibs {
- srcDir "${your-ndk-dir}/sources/third_party/vulkan/src/build-android/jniLibs"
- }
- }
-}
-
-- To add the libraries using Android Studio's experimental plugin for Gradle, - add the following to your project's gradle configuration: -
- -
-sources {
- main {
- jniLibs {
- source.srcDir "${your-ndk-dir}/sources/third_party/vulkan/src/build-android/jniLibs"
- }
- }
-}
-
-
-- If configuring your project's gradle build file is not working, you can - manually add the validation layer binaries to your project's JNI libraries - directory by using the following command line options: -
- -
-$ cd ${your-app-project-root}
-$ mkdir -p app/src/main
-$ cp -fr ${your-ndk-dir}/sources/third_party/vulkan/src/build-android/jniLibs app/src/main/
-
-
-
--If your app needs the latest validation layer, you can pull the latest source from the Khronos Group - -GitHub repository and follow the build instructions there. -
- --Regardless of whether you build with NDK's prebuilt layers or you build from the latest source code, -the build process produces final file structure like the following: -
- --src/main/jniLibs/ - arm64-v8a/ - libVkLayer_core_validation.so - libVkLayer_device_limits.so - libVkLayer_image.so - libVkLayer_object_tracker.so - libVkLayer_parameter_validation.so - libVkLayer_swapchain.so - libVkLayer_threading.so - libVkLayer_unique_objects.so - armeabi-v7a/ - libVkLayer_core_validation.so - ... -- -
-The following example shows how to verify that your APK contains the validation layers -as expected: -
- --$ jar -xvf project.apk - ... - inflated: lib/arm64-v8a/libVkLayer_threading.so - inflated: lib/arm64-v8a/libVkLayer_object_tracker.so - inflated: lib/arm64-v8a/libVkLayer_swapchain.so - inflated: lib/arm64-v8a/libVkLayer_unique_objects.so - inflated: lib/arm64-v8a/libVkLayer_parameter_validation.so - inflated: lib/arm64-v8a/libVkLayer_image.so - inflated: lib/arm64-v8a/libVkLayer_core_validation.so - inflated: lib/arm64-v8a/libVkLayer_device_limits.so - ... -- - -
The Vulkan API allows an app to enable both instance layers and device layers.
- --A layer that can intercept Vulkan instance-level entry points is called an instance layer. -Instance-level entry points are those with {@code VkInstance} or {@code VkPhysicalDevice} -as the first parameter. -
- --You can call {@code vkEnumerateInstanceLayerProperties()} to list the available instance layers -and their properties. The system enables instance layers when {@code vkCreateInstace()} executes. -
- --The following code snippet shows how an app can use the Vulkan API to programmatically enable and -query an instance layer: -
- -
-// Get instance layer count using null pointer as last parameter
-uint32_t instance_layer_present_count = 0;
-vkEnumerateInstanceLayerProperties(&instance_layer_present_count, nullptr);
-
-// Enumerate instance layers with valid pointer in last parameter
-VkLayerProperties* layer_props =
- (VkLayerProperties*)malloc(instance_layer_present_count * sizeof(VkLayerProperties));
-vkEnumerateInstanceLayerProperties(&instance_layer_present_count, layer_props));
-
-// Make sure the desired instance validation layers are available
-// NOTE: These are not listed in an arbitrary order. Threading must be
-// first, and unique_objects must be last. This is the order they
-// will be inserted by the loader.
-const char *instance_layers[] = {
- "VK_LAYER_GOOGLE_threading",
- "VK_LAYER_LUNARG_parameter_validation",
- "VK_LAYER_LUNARG_object_tracker",
- "VK_LAYER_LUNARG_core_validation",
- "VK_LAYER_LUNARG_device_limits",
- "VK_LAYER_LUNARG_image",
- "VK_LAYER_LUNARG_swapchain",
- "VK_LAYER_GOOGLE_unique_objects"
-};
-
-uint32_t instance_layer_request_count =
- sizeof(instance_layers) / sizeof(instance_layers[0]);
-for (uint32_t i = 0; i < instance_layer_request_count; i++) {
- bool found = false;
- for (uint32_t j = 0; j < instance_layer_present_count; j++) {
- if (strcmp(instance_layers[i], layer_props[j].layerName) == 0) {
- found = true;
- }
- }
- if (!found) {
- error();
- }
-}
-
-// Pass desired instance layers into vkCreateInstance
-VkInstanceCreateInfo instance_info = {};
-instance_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
-instance_info.enabledLayerCount = instance_layer_request_count;
-instance_info.ppEnabledLayerNames = instance_layers;
-...
-
-
--A layer that can intercept device-level entry points is called a device layer. Device-level entry -points are those whose first parameter is {@code VkDevice}, {@code VkCommandBuffer}, -or {@code VkQueue}. The list of -device layers to enable is included in the {@code ppEnabledLayerNames} field of the -{@code VkDeviceCreateInfo} -struct that the app passes into {@code vkCreateDevice()}. -
- --You can call {@code vkEnumerateDeviceLayerProperties} to list the available layers -and their properties. The system enables device layers when it calls {@code vkCreateDevice()}. -
- --The following code snippet shows how an app can use the Vulkan API to programmatically enable a -device layer. -
- -
-
-// Get device layer count using null as last parameter
-uint32_t device_layer_present_count = 0;
-vkEnumerateDeviceLayerProperties(&device_layer_present_count, nullptr);
-
-// Enumerate device layers with valid pointer in last parameter
-VkLayerProperties* layer_props =
- (VkLayerProperties *)malloc(device_layer_present_count * sizeof(VkLayerProperties));
-vkEnumerateDeviceLayerProperties(physical_device, device_layer_present_count, layer_props));
-
-// Make sure the desired device validation layers are available
-// Ensure threading is first and unique_objects is last!
-const char *device_layers[] = {
- "VK_LAYER_GOOGLE_threading",
- "VK_LAYER_LUNARG_parameter_validation",
- "VK_LAYER_LUNARG_object_tracker",
- "VK_LAYER_LUNARG_core_validation",
- "VK_LAYER_LUNARG_device_limits",
- "VK_LAYER_LUNARG_image",
- "VK_LAYER_LUNARG_swapchain",
- "VK_LAYER_GOOGLE_unique_objects"
-};
-
-uint32_t device_layer_request_count =
- sizeof(device_layers) / sizeof(device_layers[0]);
-for (uint32_t i = 0; i < device_layer_request_count; i++) {
- bool found = false;
- for (uint32_t j = 0; j < device_layer_present_count; j++) {
- if (strcmp(device_layers[i],
- layer_props[j].layerName) == 0) {
- found = true;
- }
- }
- if (!found) {
- error();
- }
-}
-
-// Pass desired device layers into vkCreateDevice
-VkDeviceCreateInfo device_info = {};
-device_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
-device_info.enabledLayerCount = device_layer_request_count;
-device_info.ppEnabledLayerNames = device_layers;
-...
-
-
--The Debug Report extension {@code VK_EXT_debug_report} allows your application to control -layer behavior when an event occurs.
- --Before using this extension, you must first make sure that the platform supports it. -The following example shows how to check for debug extension support and -register a callback if the extension is supported. -
- -
-// Get the instance extension count
-uint32_t inst_ext_count = 0;
-vkEnumerateInstanceExtensionProperties(nullptr, &inst_ext_count, nullptr);
-
-// Enumerate the instance extensions
-VkExtensionProperties* inst_exts =
- (VkExtensionProperties *)malloc(inst_ext_count * sizeof(VkExtensionProperties));
-vkEnumerateInstanceExtensionProperties(nullptr, &inst_ext_count, inst_exts);
-
-const char * enabled_inst_exts[16] = {};
-uint32_t enabled_inst_ext_count = 0;
-
-// Make sure the debug report extension is available
-for (uint32_t i = 0; i < inst_ext_count; i++) {
- if (strcmp(inst_exts[i].extensionName,
- VK_EXT_DEBUG_REPORT_EXTENSION_NAME) == 0) {
- enabled_inst_exts[enabled_inst_ext_count++] =
- VK_EXT_DEBUG_REPORT_EXTENSION_NAME;
- }
-}
-
-if (enabled_inst_ext_count == 0)
- return;
-
-// Pass the instance extensions into vkCreateInstance
-VkInstanceCreateInfo instance_info = {};
-instance_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
-instance_info.enabledExtensionCount = enabled_inst_ext_count;
-instance_info.ppEnabledExtensionNames = enabled_inst_exts;
-
-PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT;
-PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallbackEXT;
-
-vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)
- vkGetInstanceProcAddr(instance, "vkCreateDebugReportCallbackEXT");
-vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)
- vkGetInstanceProcAddr(instance, "vkDestroyDebugReportCallbackEXT");
-
-assert(vkCreateDebugReportCallbackEXT);
-assert(vkDestroyDebugReportCallbackEXT);
-
-// Create the debug callback with desired settings
-VkDebugReportCallbackEXT debugReportCallback;
-if (vkCreateDebugReportCallbackEXT) {
- VkDebugReportCallbackCreateInfoEXT debugReportCallbackCreateInfo;
- debugReportCallbackCreateInfo.sType =
- VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
- debugReportCallbackCreateInfo.pNext = NULL;
- debugReportCallbackCreateInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT |
- VK_DEBUG_REPORT_WARNING_BIT_EXT |
- VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
- debugReportCallbackCreateInfo.pfnCallback = DebugReportCallback;
- debugReportCallbackCreateInfo.pUserData = NULL;
-
- vkCreateDebugReportCallbackEXT(instance, &debugReportCallbackCreateInfo,
- nullptr, &debugReportCallback);
-}
-
-// Later, when shutting down Vulkan, call the following
-if (vkDestroyDebugReportCallbackEXT) {
- vkDestroyDebugReportCallbackEXT(instance, debugReportCallback, nullptr);
-}
-
-
-
--Once your app has registered and enabled the debug callback, the system routes debugging -messages to a callback that you register. An example of such a callback appears below: -
- - -
-#include <android/log.h>
-
-static VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback(
- VkDebugReportFlagsEXT msgFlags,
- VkDebugReportObjectTypeEXT objType,
- uint64_t srcObject, size_t location,
- int32_t msgCode, const char * pLayerPrefix,
- const char * pMsg, void * pUserData )
-{
- if (msgFlags & VK_DEBUG_REPORT_ERROR_BIT_EXT) {
- __android_log_print(ANDROID_LOG_ERROR,
- "AppName",
- "ERROR: [%s] Code %i : %s",
- pLayerPrefix, msgCode, pMsg);
- } else if (msgFlags & VK_DEBUG_REPORT_WARNING_BIT_EXT) {
- __android_log_print(ANDROID_LOG_WARN,
- "AppName",
- "WARNING: [%s] Code %i : %s",
- pLayerPrefix, msgCode, pMsg);
- } else if (msgFlags & VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT) {
- __android_log_print(ANDROID_LOG_WARN,
- "AppName",
- "PERFORMANCE WARNING: [%s] Code %i : %s",
- pLayerPrefix, msgCode, pMsg);
- } else if (msgFlags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT) {
- __android_log_print(ANDROID_LOG_INFO,
- "AppName", "INFO: [%s] Code %i : %s",
- pLayerPrefix, msgCode, pMsg);
- } else if (msgFlags & VK_DEBUG_REPORT_DEBUG_BIT_EXT) {
- __android_log_print(ANDROID_LOG_VERBOSE,
- "AppName", "DEBUG: [%s] Code %i : %s",
- pLayerPrefix, msgCode, pMsg);
- }
-
- // Returning false tells the layer not to stop when the event occurs, so
- // they see the same behavior with and without validation layers enabled.
- return VK_FALSE;
-}
-
-
-
-
diff --git a/docs/html/ndk/guides/guides_toc.cs b/docs/html/ndk/guides/guides_toc.cs
deleted file mode 100644
index 09b2a120fcaa9..0000000000000
--- a/docs/html/ndk/guides/guides_toc.cs
+++ /dev/null
@@ -1,113 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/docs/html/ndk/guides/images/NDK_build_string.png b/docs/html/ndk/guides/images/NDK_build_string.png
deleted file mode 100644
index 338378bca6f0e..0000000000000
Binary files a/docs/html/ndk/guides/images/NDK_build_string.png and /dev/null differ
diff --git a/docs/html/ndk/guides/images/NDK_build_string@2x.png b/docs/html/ndk/guides/images/NDK_build_string@2x.png
deleted file mode 100644
index 5ba3ce3baf66f..0000000000000
Binary files a/docs/html/ndk/guides/images/NDK_build_string@2x.png and /dev/null differ
diff --git a/docs/html/ndk/guides/images/config-pulldown.png b/docs/html/ndk/guides/images/config-pulldown.png
deleted file mode 100644
index 5af0870a56bab..0000000000000
Binary files a/docs/html/ndk/guides/images/config-pulldown.png and /dev/null differ
diff --git a/docs/html/ndk/guides/images/drawcube-output.png b/docs/html/ndk/guides/images/drawcube-output.png
deleted file mode 100644
index 3b7f775fc10c3..0000000000000
Binary files a/docs/html/ndk/guides/images/drawcube-output.png and /dev/null differ
diff --git a/docs/html/ndk/guides/images/project-pane.png b/docs/html/ndk/guides/images/project-pane.png
deleted file mode 100644
index f6d624bacd4c4..0000000000000
Binary files a/docs/html/ndk/guides/images/project-pane.png and /dev/null differ
diff --git a/docs/html/ndk/guides/images/verification_screen.png b/docs/html/ndk/guides/images/verification_screen.png
deleted file mode 100644
index 91858baa850cd..0000000000000
Binary files a/docs/html/ndk/guides/images/verification_screen.png and /dev/null differ
diff --git a/docs/html/ndk/guides/images/verification_screen@2x.png b/docs/html/ndk/guides/images/verification_screen@2x.png
deleted file mode 100644
index 0d666c9d02b3f..0000000000000
Binary files a/docs/html/ndk/guides/images/verification_screen@2x.png and /dev/null differ
diff --git a/docs/html/ndk/guides/index.jd b/docs/html/ndk/guides/index.jd
deleted file mode 100644
index 465ce139b6e5b..0000000000000
--- a/docs/html/ndk/guides/index.jd
+++ /dev/null
@@ -1,25 +0,0 @@
-page.title=Getting Started with the NDK
-@jd:body
-
-The Native Development Kit (NDK) is a set of tools that allow you to leverage C and -C++ code in your Android apps. You can use it either to build from your own source code, or to take -advantage of existing prebuilt libraries.
- -The NDK is not appropriate for most novice Android programmers, and has little value for many -types of Android apps. It is often not worth the additional complexity it inevitably brings to the -development process. However, it can be useful in cases in which you need to:
- -This guide gives you the information you need to get up and running with the NDK. It starts by -explaining the concepts underpinning the NDK, and -how to set it up. Next, it continues with information -about targeting different hardware platforms in your -builds. Then, it explains how to use -the NDK to build and -debug your app. Finally, it discusses how to use your -own and other prebuilt libraries.
diff --git a/docs/html/ndk/guides/libs.jd b/docs/html/ndk/guides/libs.jd deleted file mode 100644 index ea607de8e8647..0000000000000 --- a/docs/html/ndk/guides/libs.jd +++ /dev/null @@ -1,13 +0,0 @@ -page.title=Using Existing Libraries -@jd:body - -This section discusses the use of existing libraries–both your own, and those that the NDK -provides.
- -It begins by telling you how to use your own -prebuilt libraries. Then, it explains the -C++ helper runtimes available with the NDK, and how to use them. Finally, it provides -information on the other libraries that the NDK provides, such -as OpenGL ES and -OpenSL ES, and the minimum Android API levels -required to support those libraries.
\ No newline at end of file diff --git a/docs/html/ndk/guides/mips.jd b/docs/html/ndk/guides/mips.jd deleted file mode 100755 index d104ffec7ee68..0000000000000 --- a/docs/html/ndk/guides/mips.jd +++ /dev/null @@ -1,43 +0,0 @@ -page.title=MIPS Support -@jd:body - -The NDK supports the {@code mips} ABI, which allows native code to run on Android-based devices -that have CPUs supporting the MIPS32 instruction set.
- -To generate MIPS machine code, include {@code mips} in your -{@code Application.mk} file's -{@code APP_ABI} definition. For example:
- --APP_ABI := mips -- -
For more information about defining the {@code APP_ABI} variable, see -{@code Application.mk}.
- -The build system places generated libraries into {@code $PROJECT/libs/mips/}, where -{@code $PROJECT} represents your project's root directory, and embeds them in your APK under -the {@code /lib/mips/} directory.
- -The Android package manager extracts these libraries when installing your APK on a compatible -MIPS-based device, placing them under your app's private data directory.
- -In the Google Play store, the server filters applications so that a consumer sees only the native -libraries that run on the CPU powering his or her device.
- -MIPS support requires, at minimum, Android 2.3 (Android API level 9). If your project files -target an older API level, but include MIPS as a targeted platform, the NDK build script -automatically selects the right set of native platform headers/libraries for you.
diff --git a/docs/html/ndk/guides/ndk-build.jd b/docs/html/ndk/guides/ndk-build.jd deleted file mode 100755 index e653bf50420e1..0000000000000 --- a/docs/html/ndk/guides/ndk-build.jd +++ /dev/null @@ -1,168 +0,0 @@ -page.title=ndk-build -@jd:body - -The {@code ndk-build} file is a shell script introduced in Android NDK r4. Its purpose -is to invoke the right NDK build script. - -
Running the {@code ndk-build} script is equivalent to running the following command:
- --$GNUMAKE -f <ndk>/build/core/build-local.mk -<parameters> -- -
$GNUMAKE points to GNU Make 3.81 or later, and
-<ndk> points to your NDK installation directory. You can use
-this information to invoke ndk-build from other shell scripts, or even your own
-make files.
The {@code ndk-build} file lives in the top level the NDK installation directory. To run it -from the command line, invoke it while in or under your application project directory. -For example:
- --cd <project> -$ <ndk>/ndk-build -- -
In this example, <project> points to your
-project’s root directory, and <ndk> is the directory where
-you installed the NDK.
All parameters to ndk-build are passed directly to the underlying GNU {@code make}
-command that runs the NDK build scripts. Combine ndk-build and
-options in the form ndk-build <option>. For example:
-$ ndk-build clean -- -
The following options are available:
-Application.mk file pointed to by the
- {@code NDK_APPLICATION_MK} variable.Use the NDK_DEBUG option and, in certain cases,
-{@code AndroidManifest.xml} to specify debug or release build,
-optimization-related behavior, and inclusion of symbols. Table 1 shows the
-results of each possible combination of settings.
Table 1. Results of NDK_DEBUG (command line) and
-android:debuggable (manifest) combinations.
| NDK_DEBUG=0 | NDK_DEBUG=1 | NDK_DEBUG not specified - | |
|---|---|---|---|
| android:debuggble="true" | Debug; Symbols; Optimized*1 - | Debug; Symbols; Not optimized*2 | (same as NDK_DEBUG=1) - |
| android:debuggable="false" | Release; Symbols; Optimized - | Release; Symbols; Not optimized | Release; No symbols; -Optimized*3 |
Note: {@code NDK_DEBUG=0} is the equivalent of -{@code APP_OPTIM=release}, and complies with the GCC {@code -O2} option. {@code NDK_DEBUG=1} is the -equivalent of {@code APP_OPTIM=debug} in {@code Application.mk}, and complies with the GCC -{@code -O0} option. For more information about {@code APP_OPTIM}, see -Application.mk.
-The syntax on the command line is, for example:
- --$ ndk-build NDK_DEBUG=1 -- -
If you are using build tools from prior to SDK r8, you must also modify your -{@code AndroidManifest.xml} file to specify debug mode. The syntax for doing so resembles the -following:
- -<application android:label="@string/app_name" -android:debuggable="true"> -- -From SDK r8 onward, you do not need to touch {@code AndroidManifest.xml}. Building a debug package -(e.g. with ant debug or the corresponding option of the ADT plugin) causes the tool automatically to -pick the native debug files generated with {@code NDK_DEBUG=1}. - - -
Some toolchains come with both 64-bit and 32-bit versions. For example,
-directories {@code
Note that 64-bit tools utilize host resources better (for instance, they are faster, and handle -larger programs), and they can still generate 32-bit binaries for Android.
- -You need GNU Make 3.81 or later to use ndk-build or the NDK in general. -The build scripts will detect a non-compliant Make tool, and generate an error -message.
-If you have GNU Make 3.81 installed, but the default make
-command doesn’t launch it, define {@code GNUMAKE} in your environment to point to it
-before launching ndk-build. For example:
-$ export GNUMAKE=/usr/local/bin/gmake -$ ndk-build -- -
You can override other host prebuilt tools in {@code $NDK/prebuilt/
-$ export NDK_HOST_AWK=<path-to-awk> -$ export NDK_HOST_ECHO=<path-to-echo> -$ export NDK_HOST_CMP=<path-to-cmp> -diff --git a/docs/html/ndk/guides/ndk-gdb.jd b/docs/html/ndk/guides/ndk-gdb.jd deleted file mode 100755 index 1a990f0b6c8ae..0000000000000 --- a/docs/html/ndk/guides/ndk-gdb.jd +++ /dev/null @@ -1,231 +0,0 @@ -page.title=ndk-gdb -@jd:body - -
The NDK includes a helper shell script named {@code ndk-gdb} to easily launch a native debugging - session for your NDK-generated machine code.
- -For native debugging to work, you must follow these requirements:
- --cd $PROJECT -$NDK/ndk-gdb -- -
Here, {@code $PROJECT} points to your project's root directory, and {@code $NDK} points to your -NDK installation path.
- -When you invoke {@code ndk-gdb}, it configures the session to look for your source files -and symbol/debug versions of your generated native libraries. On successfully attaching to your -application process, {@code ndk-gdb} outputs a long series of error messages, noting that it cannot -find various system libraries. This is normal, because your host machine does not contain -symbol/debug versions of these libraries on your target device. You can safely ignore these -messages.
- -Next, {@code ndk-gdb} displays a normal GDB prompt.
- -You interact with {@code ndk-gdb} in the same way as you would with GNU GDB. For example, you can
-use {@code b
Note that when you quit the GDB prompt, the application process that you're debugging stops. This -behavior is a gdb limitation.
- -{@code ndk-gdb} handles many error conditions, and displays an informative error message if it -finds a problem. these checks include making sure that the following conditions are satisfied:
- -By default, {@code ndk-gdb} searches for an already-running application process, and displays an
-error if it doesn't find one. You can, however, use the {@code --start} or
-{@code --launch=
To see a complete list of options, type {@code ndk-gdb --help} on the command line. Table 1 -shows a number of the more commonly used ones, along with brief descriptions.
- -- Table 1. Common ndk-gdb options and their descriptions.
- -| Option | -Description> | -
|---|---|
| {@code --verbose} | -This option tells the build system to print verbose information about the native-debugging -session setup. It is necessary only for debugging problems when the debugger can't connect to the -app, and the error messages that {@code ndk-gdb} displays are not enough. |
-
| {@code --force} | -By default, {@code ndk-gdb} aborts if it finds that another native debugging session is already - running on the same device. This option kills the other session, and replaces it with a new one. - Note that this option does not kill the actual app being debugged, which you must kill - separately. | -
| {@code --start} | -When you start {@code ndk-gdb}, it tries by default to attach to an existing running instance of -your app on the target device. You can override this default behavior by using {@code --start} to -explicitly launch the application on the target device before the debugging session. |
-
-
| {@code --launch= |
-This option is similar to {@code --start}, except that it allows you to start a specific - activity from your application. This feature is only useful if your manifest defines multiple - launchable activities. |
-
| {@code --launch-list} | -This convenience option prints the list of all launchable activity names found in your - app manifest. {@code --start} uses the first activity name. |
-
| {@code --project= |
-This option specifies the app project directory. It is useful if you want to launch the - script without first having to change to the project directory. | -
| {@code --port= |
- By default, {@code ndk-gdb} uses local TCP port 5039 to communicate with the app it - is debugging on the target device. Using a different port allows you to natively debug programs - running on different devices or emulators connected to the same host machine. |
-
| {@code --adb= |
-This option specifies the adb -tool executable. It is only necessary if you have not set your path to include that executable. - |
-
|
- |
-These flags are similar to the adb commands with the same names. Set these flags if you have -several devices or emulators connected to your host machine. Their meanings are as follows: -
Alternatively, you can define the {@code ADB_SERIAL} environment variable to list a specific -device, without the need for a specific option. |
-
|
- |
-This option tells {@code ndk-gdb} to run the GDB initialization commands found in
-{@code |
-
| {@code --nowait} | -Disable pausing the Java code until GDB connects. Passing this option may cause the debugger - to miss early breakpoints. - |
| {@code --tui} -{@code -t} | -Enable Text User Interface if it is available. |
-
| {@code --gnumake-flag= |
-This option is an extra flag (or flags) to pass to the -{@code ndk-build} system when -querying it for project information. You can use multiple instances of this option in the -same command. |
-
| {@code --stdcxx-py-pr={auto|none|gnustdcxx[-GCCVER]|stlport}} | -Use specified Python pretty-printers for displaying types in the Standard C++ Library. - {@code auto} mode works by looking at the {@code .so} files for a {@code libstdc++} library, - and as such only works for a shared library. When linking statically to a {@code libstdc++} library, - you must specify the required printers. The default is {@code none}. |
-
Note: The final three options in this table are only for the -Python version of {@code ndk-gdb}.
- -If your app runs on a platform older than Android 2.3 (API level 9), {@code ndk-gdb} -cannot debug native threads properly. The debugger can only debug the main thread, abd completely -ignores the execution of other threads.
- -If you place a breakpoint on a function executed on a non-main thread, the program exits, and -GDB displays the following message:
- --Program terminated with signal SIGTRAP, Trace/breakpoint trap. - The program no longer exists. -diff --git a/docs/html/ndk/guides/ndk-stack.jd b/docs/html/ndk/guides/ndk-stack.jd deleted file mode 100644 index 45d433cbaeb96..0000000000000 --- a/docs/html/ndk/guides/ndk-stack.jd +++ /dev/null @@ -1,86 +0,0 @@ -page.title=ndk-stack -@jd:body - -
The {@code ndk-stack} tool allows you to filter stack traces as they appear in the
-output of {@code adb logcat}. It also replaces any
-address inside a shared library with the corresponding
-{@code
For example, it translates something like:
- --I/DEBUG ( 31): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** -I/DEBUG ( 31): Build fingerprint: 'generic/google_sdk/generic/:2.2/FRF91/43546:eng/test-keys' -I/DEBUG ( 31): pid: 351, tid: 351 %gt;%gt;%gt; /data/local/ndk-tests/crasher <<< -I/DEBUG ( 31): signal 11 (SIGSEGV), fault addr 0d9f00d8 -I/DEBUG ( 31): r0 0000af88 r1 0000a008 r2 baadf00d r3 0d9f00d8 -I/DEBUG ( 31): r4 00000004 r5 0000a008 r6 0000af88 r7 00013c44 -I/DEBUG ( 31): r8 00000000 r9 00000000 10 00000000 fp 00000000 -I/DEBUG ( 31): ip 0000959c sp be956cc8 lr 00008403 pc 0000841e cpsr 60000030 -I/DEBUG ( 31): #00 pc 0000841e /data/local/ndk-tests/crasher -I/DEBUG ( 31): #01 pc 000083fe /data/local/ndk-tests/crasher -I/DEBUG ( 31): #02 pc 000083f6 /data/local/ndk-tests/crasher -I/DEBUG ( 31): #03 pc 000191ac /system/lib/libc.so -I/DEBUG ( 31): #04 pc 000083ea /data/local/ndk-tests/crasher -I/DEBUG ( 31): #05 pc 00008458 /data/local/ndk-tests/crasher -I/DEBUG ( 31): #06 pc 0000d362 /system/lib/libc.so -I/DEBUG ( 31): -- -
into the more readable output:
- --********** Crash dump: ********** -Build fingerprint: 'generic/google_sdk/generic/:2.2/FRF91/43546:eng/test-keys' -pid: 351, tid: 351 >>> /data/local/ndk-tests/crasher <<< -signal 11 (SIGSEGV), fault addr 0d9f00d8 -Stack frame #00 pc 0000841e /data/local/ndk-tests/crasher : Routine zoo in /tmp/foo/crasher/jni/zoo.c:13 -Stack frame #01 pc 000083fe /data/local/ndk-tests/crasher : Routine bar in /tmp/foo/crasher/jni/bar.c:5 -Stack frame #02 pc 000083f6 /data/local/ndk-tests/crasher : Routine my_comparison in /tmp/foo/crasher/jni/foo.c:9 -Stack frame #03 pc 000191ac /system/lib/libc.so -Stack frame #04 pc 000083ea /data/local/ndk-tests/crasher : Routine foo in /tmp/foo/crasher/jni/foo.c:14 -Stack frame #05 pc 00008458 /data/local/ndk-tests/crasher : Routine main in /tmp/foo/crasher/jni/main.c:19 -Stack frame #06 pc 0000d362 /system/lib/libc.so -- -
To use {@code ndk-stack}, you first need a directory containing symbolic versions of your app's
-shared libraries. If you use the NDK build system ({@code ndk-build}), these shared-library
-files reside under {@code $PROJECT_PATH/obj/local/
There are two ways to use the tool. You can feed the logcat text as direct input to the program. -For example:
- --adb logcat | $NDK/ndk-stack -sym $PROJECT_PATH/obj/local/armeabi -- -
You can also use the {@code -dump} option to specify the logcat as an input file. For example: -
- --adb logcat > /tmp/foo.txt -$NDK/ndk-stack -sym $PROJECT_PATH/obj/local/armeabi -dump foo.txt -- -
When it begins parsing the logcat output, the tool looks for an initial line of asterisks. -For example:
- --*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** -- -
Note: When copy/pasting traces, don't forget this line, or -{@code ndk-stack} won't work correctly.
\ No newline at end of file diff --git a/docs/html/ndk/guides/prebuilts.jd b/docs/html/ndk/guides/prebuilts.jd deleted file mode 100644 index 4cb18198aed82..0000000000000 --- a/docs/html/ndk/guides/prebuilts.jd +++ /dev/null @@ -1,145 +0,0 @@ -page.title=Using Prebuilt Libraries -@jd:body - -The NDK supports the use of prebuilt libraries, both static and shared. There are two principal -use cases for this functionality:
- -This page explains how to use prebuilt libraries.
- -You must declare each prebuilt library you use as a single independent module. To do - so, perform the following steps: - -
Note: You must make sure to select the version of your prebuilt - library appropriate to your target ABI. For more information on ensuring library support for - ABIs, see Selecting ABIs for Prebuilt Libraries.
Here is a trivial example that assumes the prebuilt library {@code libfoo.so} resides in - the same directory as the {@code Android.mk} - file that describes it.
- --LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := foo-prebuilt -LOCAL_SRC_FILES := libfoo.so -include $(PREBUILT_SHARED_LIBRARY) -- -
In this example, the name of the module is the same as that of the prebuilt library.
- -The build system places a copy of your prebuilt shared library into {@code $PROJECT/obj/local},
-and another copy, stripped of debug information, into {@code $PROJECT/libs/
To reference a prebuilt library from other modules, specify its name as the value -of the {@code LOCAL_STATIC_LIBRARIES} or {@code LOCAL_SHARED_LIBRARIES} variable in the -{@code Android.mk} files associated with those -other modules.
- -For example, the description of a module using {@code libfoo.so} might be as follows:
- --include $(CLEAR_VARS) -LOCAL_MODULE := foo-user -LOCAL_SRC_FILES := foo-user.c -LOCAL_SHARED_LIBRARIES := foo-prebuilt -include $(BUILD_SHARED_LIBRARY) -- -
Here, {@code LOCAL_MODULE} is the name of the module referring to the prebuilt; {@code - LOCAL_SHARED_LIBRARIES} is the name of the prebuilt, itself.
- -The code in {@code foo-user.c} depends on specific declarations that normally -reside in a header file, such as {@code foo.h}, distributed with the prebuilt library. -For example, {@code foo-user.c} might have a line like the following:
- --#include <foo.h> -- -
In such a case, you need to provide the header and its include path to the compiler when you -build the {@code foo-user} module. A simple way to accomplish this task is to use exports in the -prebuilt module definition. For example, as long as header {@code foo.h} is located under the -{@code include} directory associated with the prebuilt module, you can declare it as follows:
- --include $(CLEAR_VARS) -LOCAL_MODULE := foo-prebuilt -LOCAL_SRC_FILES := libfoo.so -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include -include $(PREBUILT_SHARED_LIBRARY) -- -
The {@code LOCAL_EXPORT_C_INCLUDES} definition here ensures that the build system -exports the path to the prebuilt library's {@code include} directory, prepending that path onto the -value of the {@code LOCAL_C_INCLUDES} for the module dependent on it.
- -This operation allows the build system to find the necessary headers.
- -We recommend that you provide prebuilt shared libraries containing debug symbols. The NDK build
-system always strips the symbols from the version of the library that it installs into
-{@code $PROJECT/libs/
You must make sure to select the right version of your prebuilt shared library for your targeted -ABI. The -{@code TARGET_ARCH_ABI} variable in the -{@code Android.mk} file can point the build system at the appropriate version of the library. -
- -For example, assume that your project contains two versions of library {@code libfoo.so}:
- --armeabi/libfoo.so -x86/libfoo.so -- -
The following snippet shows how to use {@code TARGET_ARCH_ABI} so that the build system selects - the appropriate version of the library:
- --include $(CLEAR_VARS) -LOCAL_MODULE := foo-prebuilt -LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libfoo.so -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include -include $(PREBUILT_SHARED_LIBRARY) -- -
If you have specified {@code armeabi} as the value of {@code TARGET_ARCH_ABI}, the build system -uses the version of {@code libfoo.so} located in the {@code armeabi} directory. If you have -specified {@code x86} as the value {@code TARGET_ARCH_ABI}, the build system uses the version in the -{@code x86} directory.
diff --git a/docs/html/ndk/guides/sample.jd b/docs/html/ndk/guides/sample.jd deleted file mode 100644 index 18ca0b82a0b05..0000000000000 --- a/docs/html/ndk/guides/sample.jd +++ /dev/null @@ -1,11 +0,0 @@ -page.title=Sample Walkthroughs -@jd:body - -This section explains several of the sample apps provided with the NDK. It assumes that you already have a working knowledge of programming in Java and native code, and focuses on issues particular to working with the NDK.
-It discusses the following samples:
-ndk_helper class. This document explains how to:
-This document assumes that you are already familiar with Java-based Android development. For more -information on that topic, see the -Android developer site.
- -To install and configure the NDK, follow these steps:
-Eclipse must know where the NDK is in order to use it when building your app. Follow these steps -to set the location of the NDK.
-To confirm that you have installed the NDK, set it up correctly, and properly configured Eclipse, -follow these steps:
-Follow these steps to build from the command line:
-If you have successfully installed and configured the NDK, the screen on your target device looks -as shown in Figure 1.
- -
-
--Figure 1. Target-device screen after successful launch. -
diff --git a/docs/html/ndk/guides/stable_apis.jd b/docs/html/ndk/guides/stable_apis.jd deleted file mode 100644 index c38e68436a21e..0000000000000 --- a/docs/html/ndk/guides/stable_apis.jd +++ /dev/null @@ -1,501 +0,0 @@ -page.title=Android NDK Native APIs -@jd:body - -The Android NDK provides a set of native headers and shared library files that has gradually -increased with successive releases of new Android API levels. This page explains these headers and -files, and maps them to specific - Android API levels. -
- -There are two basic steps to enable your app to use the libraries that the NDK provides: -
- --LOCAL_LDLIBS := -lfoo -- -
To list multiple libraries, use a space as a delimiter. For more information about using the -{@code LOCAL_LDLIBS} variable, see Android.mk. -
- -For all API levels, the build system automatically links the standard C libraries, the -standard C++ libraries, real-time extensions, and {@code pthread}; you do not need -to include them when defining your {@code LOCAL_LDLIBS} variable. For more information about -the C and C++ libraries, see Android API level 3.
- -The NDK often provides new headers and libraries for new Android releases. These files reside
-under {@code $NDK/platforms/android-
Table 1 shows the correspondence between NDK-supported API levels and Android releases.
- -- Table 1. NDK-supported API levels and corresponding Android releases.
-| NDK-supported API level | -Android release | -
|---|---|
| 3 | -1.5 | -
| 4 | -1.6 | -
| 5 | -2.0 | -
| 8 | -2.2 | -
| 9 | -2.3 through 3.0.x | -
| 12 | -3.1.x | -
| 13 | -3.2 | -
| 14 | -4.0 through 4.0.2 | -
| 15 | -4.0.3 and 4.0.4 | -
| 16 | -4.1 and 4.1.1 | -
| 17 | -4.2 and 4.2.2 | -
| 18 | -4.3 | -
| 19 | -4.4 | -
| 21 | -4.4W and 5.0 | -
Each new release of NDK headers and libraries for a given Android API level is cumulative; you -are nearly always safe if you use the most recently released headers when building your app. For -example, you can use the NDK headers for Android API level 21 for an app targeting API level 16. By doing so, however, you increase your APK's footprint.
- --For more information about Android API levels, see -What is API Level?. -
- -The NDK provides the following APIs for developing native code that runs on Android 1.5 system -images and above.
- -The C library headers for Android 1.5 are available through their standard names, such as -{@code stdlib.h} and {@code stdio.h}. If a header is missing at build time, it's because the -header is not available on the 1.5 system image.
- -An extremely minimal C++ support API is available. For more -information on C++ library support, see -C++ Library Support.
- -{@code
You can write your own wrapper macros to access this functionality. If you wish to perform -logging, your native module should link to {@code /system/lib/liblog.so}. Implement this -linking by including the following line in your -{@code Android.mk} file:
- --LOCAL_LDLIBS := -llog -- -
You can use the Zlib compression library -by including {@code zlib.h} and {@code zconf.h}. You must also link your native -module against {@code /system/lib/libz.so} by including the following line in your -{@code Android.mk} file:
- --LOCAL_LDLIBS := -lz -- -
You can access the Android dynamic linker's {@code dlopen()}, {@code dlsym()}, and -{@code dlclose()} functions by including {@code dlfcn.h}. You must also link against -{@code /system/lib/libdl.so} by including the following line in your -{@code Android.mk} file:
- --LOCAL_LDLIBS := -ldl -- -
The NDK provides the following APIs for developing native code that runs on Android 1.6 system -images and above.
- -The standard OpenGL ES headers {@code gl.h} and {@code glext.h} contain -the declarations necessary for performing OpenGL ES 1.x rendering calls from native code.
- -To use these headers, link your native module to {@code /system/lib/libGLESv1_CM.so} by -including the following line in your -{@code Android.mk} file:
- - --LOCAL_LDLIBS := -lGLESv1_CM --
All Android-based devices support OpenGL ES 1.0, because Android provides an Open GL 1.0-capable -software renderer that can be used on devices without GPUs.
-Only Android devices that have the necessary GPU fully support OpenGL ES 1.1. An app can -query the OpenGL ES version string and extension string to determine whether the current device -supports the features it needs. For information on how to perform this query, see the description of -{@code glGetString()} -in the OpenGL specification.
- -Additionally, you must put a
-{@code
-
The EGL APIs are only available starting from API level 9. You can, however, -use the VM to perform some of the operations that you would get from those APIS. These operations -include surface creation and flipping. For an example of how to use {@code GLSurfaceView}, see - -Introducing GLSurfaceView.
- -The san-angeles sample application provides an example of how to perform these operations, -rendering each frame in native code. This sample is a small Android port of the excellent -San Angeles Observation demo -program.
- -The NDK provides the following APIs for developing native code that runs on Android 2.0 system -images and above.
- -The standard OpenGL ES 2.0 headers {@code
To use OpenGL ES 2.0, link your native module to {@code /system/lib/libGLESv2.so} by -including the following line in your -{@code Android.mk} file:
- --LOCAL_LDLIBS := -lGLESv2 -- -
Not all devices support OpenGL ES 2.0. An app can query the OpenGL -ES version string and extension string to determine whether the current device -supports the features it needs. For information on how to perform this query, see the description of - -{@code glGetString()} in the OpenGL specification.
- -Additionally, you must put a
-{@code
-
The hello-gl2 sample application provies a basic example of how to use OpenGL ES 2.0 with the -NDK.
- -The EGL APIs are only available starting from API level 9. You can, however, -use the VM to perform some of the operations that you would get from those APIs. These operations -include surface creation and flipping. For an example of how to use {@code GLSurfaceView}, see - -Introducing GLSurfaceView.
- -Note: The Android emulator does not support OpenGL ES 2.0 hardware -emulation. Running and testing code that uses this API requires a real device with hardware that can -support OpenGL ES 2.0.
- -The NDK provides the following APIs for developing native code that runs on Android 2.2 system -images and above.
- -The {@code jnigraphics} library exposes a C-based interface that allows native code to reliably access -the pixel buffers of Java bitmap objects. The workflow for using {@code jnigraphics} is as follows: -
- -To use {@code jnigraphics}, include the {@code
-LOCAL_LDLIBS += -ljnigraphics -- -
Additional details about this feature are in the comments of the {@code bitmap.h} file. - -
The NDK provides the following APIs for developing native code that runs on Android 2.3 system -images and above.
- -EGL provides a native platform interface for allocating and managing OpenGLES surfaces. -For more information about its features, see -EGL Native Platform Interface.
- -EGL allows you to perform the following operations from native code:
- -The following headers provide EGL functionality:
-To link against the system's EGL library, add the following line to your -{@code Android.mk} file:
- --LOCAL_LDLIBS += -lEGL -- -
Android native audio handling is based on the Khronos Group OpenSL ES 1.0.1 API.
- -The standard OpenSL ES headers {@code OpenSLES.h} and {@code OpenSLES_Platform.h} contain -the declarations necessary for performing audio input and output from the native side of Android. -The NDK distribution of the OpenSL ES also provides Android-specific extensions. For information -about these extensions, see the comments in {@code OpenSLES_Android.h} and -{@code OpenSLES_AndroidConfiguration.h}.
- - -The system library {@code libOpenSLES.so} implements the public native audio functions. Link -against it by adding the following line to your -{@code Android.mk} file:
- --LOCAL_LDLIBS += -lOpenSLES -- -
For more information about the OpenSL ES API, refer to -{@code $NDK/docs/Additional_library_docs/opensles/index.html}, where {@code $NDK} is your NDK -installation root directory.
- -Starting from API level 9, you can write an entire Android app with native code, without using -any Java.
- -Note: Writing your app in native code is not, in itself, enough -for your app to run in the VM. Moreover, your app must still access most features of the Android -platform via JNI.
- -This release provides the following native headers:
-For more information about these headers, see the -NDK API Reference documentation, as well as -the comments in the headers, themselves. Also, for more information about the larger topic of -writing native apps, see -Native Activities and Applications. - -
When you include one or more of these headers, you must also link against the -{@code libandroid.so} library. To link against {@code libandroid.so}, include the following line in -your {@code Android.mk} file:
- --LOCAL_LDLIBS += -landroid -- -
The NDK provides the following APIs for developing native code that runs on Android 4.0 system -images and above.
- -Android native multimedia handling is based on Khronos Group OpenMAX AL 1.0.1 API.
-The standard OpenMAX AL headers {@code
The NDK distribution of OpenMAX AL also provides Android-specific extensions. For information -about these extensions, see the comments in {@code OpenMAXAL_Android.h}.
- -The system library {@code libOpenMAXAL.so} implements the public native multimedia functions. -To link against this library, include the following line in your - {@code Android.mk} file:
- -LOCAL_LDLIBS += -lOpenMAXAL -
For more information about this topic, see {@code $NDK/docs/openmaxal/index.html}, -where {@code $NDK} is the root directory of your NDK installation.
- -OpenSL ES support for this Android API level adds PCM support. For more information about -OpenSL ES support in the NDK, see OpenSL ES.
- -The NDK provides the following APIs for developing native code that runs on Android 4.3 system -images and above.
- -The standard OpenGL ES 3.0 headers {@code gl3.h} and {@code gl3ext.h} contain the declarations -needed for performing OpenGL ES 3.0 rendering calls from native code. These rendering calls provide -the ability to use the GLSL language to define and use vertex and fragment shaders. - -
To use OpenGL ES 3.0, link your native module against {@code /system/lib/libGLESv3.so} by -including the following line in your -{@code Android.mk} file:
- --LOCAL_LDLIBS := -lGLESv3 -- -
Not all devices support OpenGL ES 3.0. An app can query the OpenGL -ES version string and extension string to determine whether the current device -supports the features it needs. For information on how to perform this query, see the description of - -{@code glGetString()} in the OpenGL specification.
- -Additionally, you must put a
-{@code
-
The gles3jni sample application provides a basic example of how to use OpenGL ES 3.0 with the -NDK.
- -Note: The Android emulator does not support OpenGL ES 3.0 hardware -emulation. Running and testing code that uses this API requires a real device with hardware that can -support OpenGL ES 3.0.
- - -The NDK provides the following APIs for developing native code that runs on Android 4.3 system -images and above.
- -The standard OpenGL ES 3.1 headers {@code gl31.h} and {@code gl3ext.h} contain the declarations -needed for performing OpenGL ES 3.1 rendering calls from native code. These rendering calls provide -the ability to use the GLSL language to define and use vertex and fragment shaders. - -
To use OpenGL ES 3.1, link your native module against {@code /system/lib/libGLESv3.so} by -including the following line in your -{@code Android.mk} file:
- --LOCAL_LDLIBS := -lGLESv3 -- -
Not all devices support OpenGL ES 3.1. An app can query the OpenGL -ES version string and extension string to determine whether the current device -supports the features it needs. For information on how to perform this query, see the description of - -{@code glGetString()} in the OpenGL specification.
- -Additionally, you must put a
-{@code
-
The gles3jni sample application provides a basic example of how to use OpenGL ES 3.1 with the -NDK.
- -Note: The Android emulator does not support OpenGL ES 3.1 hardware -emulation. Running and testing code that uses this API requires a real device with hardware that can -support OpenGL ES 3.1.
- diff --git a/docs/html/ndk/guides/standalone_toolchain.jd b/docs/html/ndk/guides/standalone_toolchain.jd deleted file mode 100755 index 7a6f906cd54d8..0000000000000 --- a/docs/html/ndk/guides/standalone_toolchain.jd +++ /dev/null @@ -1,605 +0,0 @@ -page.title=Standalone Toolchain -@jd:body - -You can use the toolchains provided with the Android NDK independently, or as plug-ins -with an existing IDE. This flexibility -can be useful if you already have your own build system, and only need the ability to invoke the -cross-compiler in order to add support to Android for it.
- -A typical use case is invoking the configure script of an open-source library that expects a -cross-compiler in the {@code CC} environment variable.
- -Note: This page assumes significant understanding of -compiling, linking, and low-level architecture. In addition, the techniques it describes are -unnecessary for most use cases. In most cases, we recommend that you forego using a standalone -toolchain, and instead stick to the NDK build system.
- -Before anything else, you need to decide which processing architecture your standalone toolchain -is going to target. Each architecture corresponds to a different toolchain name, as Table 1 -shows.
- -- Table 1. {@code APP_ABI} settings for different instruction sets.
-| Architecture | -Toolchain name | -
|---|---|
| ARM-based | -{@code arm-linux-androideabi- |
-
| x86-based | -{@code x86- |
-
| MIPS-based | -{@code mipsel-linux-android- |
-
| ARM64-based | -{@code aarch64-linux-android- |
-
| X86-64-based | -{@code x86_64- |
-
| MIPS64-based | -{@code mips64el-linux-android-- |
-
The next thing you need to do is define your sysroot (A sysroot is a directory containing -the system headers and libraries for your target). To define the sysroot, you must must know the -Android API level you want to target for native support; available native APIs vary by Android API -level.
- -Native APIs for the respective -Android API levels reside under {@code $NDK/platforms/}; each API-level -directory, in turn, contains subdirectories for the various CPUs and architectures. The -following example shows how to define a sysroot for a build targeting Android 5.0 -(API level 21), for ARM architecture:
- --SYSROOT=$NDK/platforms/android-21/arch-arm -- -For more detail about the Android API levels and the respective native APIs they support, see -Android NDK Native APIs. - -
There are two ways to invoke the compiler. One method is simple, and leaves most of the lifting -to the build system. The other is more advanced, but provides more flexibility.
- -The simplest way to build is by invoking the appropriate compiler directly from the command -line, using the {@code --sysroot} option to indicate the location of the system files for the -platform you're targeting. For example:
- --export CC="$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/ \ -linux-x86/bin/arm-linux-androideabi-gcc-4.8 --sysroot=$SYSROOT" -$CC -o foo.o -c foo.c -- -
While this method is simple, it lacks in flexibility: It does not allow you to use any C++ STL -(STLport, libc++, or the GNU libstdc++) with it. It also does not support exceptions or RTTI.
- -For Clang, you need to perform an additional two steps:
-- Table 2. Architectures and corresponding values for {@code -target}.
-| Architecture | -Value | -
|---|---|
| armeabi | -{@code -target armv5te-none-linux-androideabi} | -
| armeabi-v7a | -{@code -target armv7-none-linux-androideabi} | -
| arm64-v8a | -{@code -target aarch64-none-linux-android} | -
| x86 | -{@code -target i686-none-linux-android} | -
| x86_64 | -{@code -target x86_64-none-linux-android} | -
| mips | -{@code -target mipsel-none-linux-android} | -
--gcc-toolchain $NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64 --
-export CC="$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/ \ -linux-x86/bin/arm-linux-androideabi-gcc-4.8 --sysroot=$SYSROOT" -target \ -armv7-none-linux-androideabi \ --gcc-toolchain $NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64" -$CC -o foo.o -c foo.c -- - -
The NDK provides the {@code make-standalone-toolchain.sh} shell script to allow you to perform a -customized toolchain installation from the command line. This approach affords you more flexibility -than the procedure described in Simple method.
- -The script is located in the {@code $NDK/build/tools/} directory, where {@code $NDK} is the -installation root for the NDK. An example of the use of this script appears below:
- --$NDK/build/tools/make-standalone-toolchain.sh \ ---arch=arm --platform=android-21 --install-dir=/tmp/my-android-toolchain -- -
This command creates a directory named {@code /tmp/my-android-toolchain/}, containing a copy of -the {@code android-21/arch-arm} sysroot, and of the toolchain binaries for a 32-bit ARM -architecture.
- -Note that the toolchain binaries do not depend on or contain host-specific paths, in other words, -you can install them in any location, or even move them if you need to.
- -By default, the build system uses the 32-bit, ARM-based GCC 4.8 toolchain. You can specify a
-different value, however, by specifying {@code --arch=
- Table 3. Toolchains and corresponding values, using {@code --arch}. Alternatively, you can use the {@code --toolchain=
- Table 4. Toolchains and corresponding values, using {@code --toolchain}. Note: Table 4 is not an exhaustive list. Other combinations may
-also be valid, but are unverified. You can also copy Clang/LLVM 3.6, using one of two methods: You can append {@code -clang3.6} to
-the {@code --toolchain} option, so that the {@code --toolchain} option looks like the following
-example:
-
- You can also add {@code -llvm-version=3.6} as a separate option on the command
-line. Note: Instead of specifying a specific version, you can also
-use {@code By default, the build system builds for a 32-bit host toolchain. You can specify a 64-bit
-host toolchain instead. Table 5 shows the value to use with {@code -system} for different
-platforms.
- Table 5. Host toolchains and corresponding values, using {@code -system}. You may specify {@code --stl=stlport} to copy {@code libstlport} instead of the default
-{@code libgnustl}. If you do so, and you wish to link against the shared library, you must
-explicitly use {@code -lstlport_shared}. This requirement is similar to having to use
-{@code -lgnustl_shared} for GNU {@code libstdc++}. Similarly, you can specify {@code --stl=libc++} to copy the LLVM libc++ headers and libraries.
-To link against the shared library, you must explicitly use -lc++_shared. You can make these settings directly, as in the following example: Note that if you omit the {@code -install-dir} option, the {@code make-standalone-toolchain.sh}
-shell script creates a tarball in {@code tmp/ndk/ This standalone toolchain provides an additional benefit, as well, in that it contains a working
-copy of a C++ STL library, with working exceptions and RTTI support. For more options and details, use {@code --help}. You can install Clang binaries in the standalone installation by using the
-{@code --llvm-version= Note that Clang binaries are copied along with the GCC ones, because they rely on the same
-assembler, linker, headers, libraries, and C++ STL implementation. This operation also installs two scripts, named {@code clang} and {@code clang++}, under
-{@code In an ARM standalone installation built with {@code llvm-version=3.6}, invoking
-Clang on a Unix system takes the form of a single line. For
-instance: When building for ARM, Clang changes the target based on the presence of the
-{@code -march=armv7-a} and/or {@code -mthumb} options:
- Table 5. Specifiable {@code -march} values and their resulting targets. You may also override with your own {@code -target} if you wish. The {@code -gcc-toolchain} option is unnecessary because, in a standalone package,
-Clang locates {@code as} and {@code ld} in a predefined relative location.
-
- {@code clang} and {@code clang++} should be easy drop-in replacements for {@code gcc} and
-{@code g++} in a makefile. When in doubt, add the following options to verify that they are
-working properly: For more information about Clang, see
-http://clang.llvm.org/, especially the GCC compatibility
-section. The machine code that the ARM toolchain generates should be compatible with the official Android
-{@code armeabi} ABI by default. We recommend use of the {@code -mthumb} compiler flag to force the generation of 16-bit Thumb-1
-instructions (the default being 32-bit ARM instructions). If you want to target the armeabi-v7a ABI, you must set the following flags: The first flag enables Thumb-2 instructions. The second flag enables hardware-FPU instructions
-while ensuring that the system passes floating-point parameters in core registers, which is critical
-for ABI compatibility. Note: In versions of the NDK prior to r9b, do not use these flags
-separately. You must set all or none of them. Otherwise, unpredictable behavior and crashes may
-result. To use NEON instructions, you must change the {@code -mfpu} compiler flag: Note that this setting forces the use of {@code VFPv3-D32}, per the ARM specification. Also, make sure to provide the following two flags to the linker: The first flag instructs the linker to pick {@code libgcc.a}, {@code libgcov.a}, and
-{@code crt*.o}, which are tailored for armv7-a. The 2nd flag is required as a workaround for a CPU
-bug in some Cortex-A8 implementations. Since NDK version r9b, all Android native APIs taking or returning double or float values have
-{@code attribute((pcs("aapcs")))} for ARM. This makes it possible to compile user code in
-{@code -mhard-float} (which implies {@code -mfloat-abi=hard}), and still link with the Android
-native APIs that comply with the softfp ABI. For more information on this, see the comments in
-{@code $NDK/tests/device/hard-float/jni/Android.mk}. If you want to use NEON intrinsics on x86, the build system can translate them to the native x86
-SSE intrinsics using a special C/C++ language header with the same name, {@code arm_neon.h}, as the
-standard ARM NEON intrinsics header. By default, the x86 ABI supports SIMD up to SSSE3, and the header covers ~93% of (1869 of 2009)
-NEON functions. You don't have to use any specific compiler flag when targeting the MIPS ABI. To learn more about ABI support, see x86 Support. The Windows binaries do not depend on Cygwin. This lack of dependency makes them faster. The
-cost, however, is that they do not understand Cygwin path specifications like
-{@code cygdrive/c/foo/bar}, as opposed to {@code C:/foo/bar}. The NDK build system ensures that all paths passed to the compiler from Cygwin are automatically
-translated, and manages other complexities, as well. If you have a custom build system,
-you may need to resolve these complexities yourself. For information on contributing to support for Cygwin/MSys, visit the android-ndk
-forum. The Android platform did not really support {@code wchar_t} until Android 2.3 (API level 9). This
-fact has several ramifications: We recommend that you get rid of any dependencies on the {@code wchar_t} type, and switch to
-better representations. The support provided in Android is only there to help you migrate existing
-code. The toolchain binaries support C++ exceptions and RTTI by default. To disable C++ exceptions
-and RTTI when building sources (to generate lighter-weight machine code, for example), use
-{@code -fno-exceptions} and {@code -fno-rtti}. To use these features in conjunction with GNU libstdc++, you must explicitly link with libsupc++.
-To do so, use {@code -lsupc++} when linking binaries. For example: You do not need to do this when using the STLport or libc++ library. The standalone toolchain includes a copy of a C++ Standard Template Library implementation. This
-implementation is either for GNU libstdc++, STLport, or libc++, depending on what you specify for the
-{@code --stl= This is the method that we recommend. Note: GNU libstdc++ is licensed under the GPLv3 license, with a
-linking exception. If you cannot comply with its requirements, you cannot redistribute the
-shared library in your project.
- Table 6. Specifiable {@code -march} values and their resulting targets. Note: If your project contains multiple shared libraries or
-executables, you must link against a shared-library STL implementation. Otherwise, the build
-system does not define certain global uniquely, which can result in unpredictable runtime behavior.
-This behavior may include crashes and failure to properly catch exceptions. The reason the shared version of the libraries is not simply called {@code libstdc++.so} is that
-this name would conflict at runtime with the system's own minimal C++ runtime. For this reason,
-the build system enforces a new name for the GNU ELF library. The static library does not have
-this problem. The Android NDK supports the {@code x86_64} ABI. This ABI allows native code to run on
-Android-based devices using CPUs that support the 64-bit x86 instruction set. To generate 64-bit machine code for x86, add {@code x86_64} to the {@code APP_ABI} definition in
-your {@code Application.mk} file. For example:
-
-
-
-
-
-
- Toolchain
- Value
-
-
- mips64 compiler
- {@code --arch=mips64}
-
-
- mips GCC 4.8 compiler
- {@code --arch=mips}
-
-
- x86 GCC 4.8 compiler
- {@code --arch=x86}
-
-
- x86_64 GCC 4.8 compiler
- {@code --arch=x86_64}
-
-
-mips GCC 4.8 compiler
- {@code --arch=mips}
-
-
-
-
-
-
- Toolchain
- Value
-
-
- arm
-
-
-
-
- x86
-
-
-
-
-
- mips
-
-
-
-
- arm64
-
-
-
-
- x86_64
-
-
-
-
-mips64
-
-
-
---toolchain=arm-linux-androideabi-clang3.6
-
-
-
-
-
-For more information on specifying a 64- or 32-bit instruction host toolchain, see
-64-Bit and 32-Bit Toolchains.
-
-
-
- Host toolchain
- Value
-
-
- 64-bit Linux
- {@code -system=linux-x86_64}
-
-
- 64-bit MacOSX
- {@code -system=darwin-x86_64}
-
-
-64-bit Windows
- {@code -system=windows-x86_64}
-
-export PATH=/tmp/my-android-toolchain/bin:$PATH
-export CC=arm-linux-androideabi-gcc # or export CC=clang
-export CXX=arm-linux-androideabi-g++ # or export CXX=clang++
-
-
-Working with Clang
-
-build/tools/make-standalone-toolchain.sh \
---install-dir=/tmp/mydir \
---toolchain=arm-linux-androideabi-4.8 \
---llvm-version=3.6
-
-
-Invoking Clang
-
-`dirname $0`/clang36 -target armv5te-none-linux-androideabi "$@"
-
-
-clang++ invokes clang++31 in the same way.Clang targets with ARM
-
-
-
-
-
-
- {@code -march} value
- Resulting target
-
-
- {@code -march=armv7-a}
- {@code armv7-none-linux-androideabi}
-
-
- {@code -mthumb}
- {@code thumb-none-linux-androideabi}
-
-
-Both {@code -march=armv7-a} and {@code -mthumb}
- {@code thumbv7-none-linux-androideabi}
-
-
-
-ABI Compatibility
-
-CFLAGS= -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
-
-
-
-CFLAGS= -march=armv7-a -mfloat-abi=softfp -mfpu=neon
-
-
-
-LDFLAGS= -march=armv7-a -Wl,--fix-cortex-a8
-
-
-Warnings and Limitations
-Windows support
-wchar_t support
-
-
-
-
-Exceptions, RTTI, and STL
-
-arm-linux-androideabi-g++ .... -lsupc++
-
-
-C++ STL support
-
-
-
-
-
-
- Toolchain
- Location
-
-
- arm
- {@code $TOOLCHAIN/arm-linux-androideabi/lib/}
-
-
- arm64
- {@code $TOOLCHAIN/aarch64-linux-android/lib/}
-
-
- x86
- {@code $TOOLCHAIN/i686-linux-android/lib/}
-
-
- x86_64
- {@code $TOOLCHAIN/x86_64-linux-android/lib/}
-
-
- mips
- {@code $TOOLCHAIN/mipsel-linux-android/lib/}
-
-
-mips64
- {@code $TOOLCHAIN/mips64el-linux-android/lib/}
- On this page
-
-
-
-
-
- Overview
-
-APP_ABI := x86_64
-
-
-For more information on how to specify values for {@code APP_ABI}, see
-Application.mk.
The build system places libraries generated for the {@code x86_64} ABI into -{@code $PROJECT/libs/x86_64/} on your host machine, where {@code $PROJECT} is the root directory -of your project. It also embeds them in your APK, under {@code /lib/x86_64/}.
- -The Android package manager extracts these libraries when installing your APK on a compatible -64-bit, x86-powered device, placing them under your app's private data directory.
- -In the Google Play store, the server filters applications so that a consumer sees only the native -libraries that run on the CPU powering his or her device.
- -You can use the 64-bit x86 toolchain in standalone mode with the NDK. For more -information about doing so, see -Standalone Toolchain, under the "Advanced method" section. - -
The NDK provides native versions of Android APIs for 64-bit x86 machine code starting from -Android 5.0 (Android API level 21). If your project files target an older API level, but include -{@code x86_64} as a targeted platform, the NDK build script automatically selects the right set of -native platform headers and libraries for you.
diff --git a/docs/html/ndk/guides/x86.jd b/docs/html/ndk/guides/x86.jd deleted file mode 100644 index 3a01b05d718f8..0000000000000 --- a/docs/html/ndk/guides/x86.jd +++ /dev/null @@ -1,215 +0,0 @@ -page.title=x86 Support -@jd:body - -The NDK includes support for the {@code x86} ABI, which allows native code to run on -Android-based devices running on CPUs supporting the IA-32 instruction set.
- -To generate x86 machine code, add {@code x86} to the {@code APP_ABI} definition in your -{@code Application.mk} file. For example:
- --APP_ABI := armeabi armeabi-v7a x86 -For more information about defining the {@code APP_ABI} variable, see -{@code Application.mk}. - -
The build system places generated libraries into {@code $PROJECT/libs/x86/}, where -{@code $PROJECT} represents your project's root directory, and embeds them in your APK under -{@code /lib/mips/}.
- -The Android package extracts these libraries when installing your APK on a compatible x86-based -device, placing them under your app's private data directory.
- -In the Google Play store, the server filters applications so that a consumer sees only the native -libraries that run on the CPU powering his or her device.
- -Support for ARM NEON intrinsics is provided in the form of C/C++ language headers with the same -name as the standard ARM NEON intrinsics header, {@code arm_neon.h}. These headers are available for -all NDK x86 toolchains. They translate NEON intrinsics to native x86 SSE ones.
- -Characteristics of this solution include the following:
-In most cases, you should be able to attain performance similar to what you would get from ARM -NEON code. Recommendations for best results include:
- -For more information on this topic, see - -From ARM NEON to Intel SSE– the automatic porting solution, tips and tricks.
- -In the great majority of cases, x86 implementations produce the same results as ARM -implementations for NEON. x86 implementations pass -NEON tests nearly 100% of the -time. Still, there are several corner cases in which an x86 implementation produces results -different from its ARM counterpart. Known incompatibilities are as follows:
- -In your project make sure to include the {@code arm_neon.h} header, and define include -{@code x86} in your definition of {@code APP_ABI}. The build system then ports your code to x86.
- -For an example of how porting ARM NEON to x86 SSE works, see the hello-neon sample.
- -You can incorporate the {@code x86} ABI into your own toolchain. For more information, see -Standalone Toolchain.
- -x86 support requires, at minimum, Android 2.3 (Android API level 9). If your project files -target an older API level, but include x86 as a targeted platform, the NDK build script -automatically selects the right set of native platform headers/libraries for you.
\ No newline at end of file diff --git a/docs/html/ndk/index.jd b/docs/html/ndk/index.jd deleted file mode 100644 index fc1c595e748b8..0000000000000 --- a/docs/html/ndk/index.jd +++ /dev/null @@ -1,51 +0,0 @@ -page.title=Android NDK -page.tags="ndk, native, c, c++", -meta.tags="ndk, native, c++" -fullpage=true -section.landing=true -header.hide=1 -footer.hide=1 -@jd:body - - - --Typedefs | |
| typedef struct AAssetManager | AAssetManager |
| typedef struct AAssetDir | AAssetDir |
| typedef struct AAsset | AAsset |
-Enumerations | |
| enum | { AASSET_MODE_UNKNOWN = 0, -AASSET_MODE_RANDOM = 1, -AASSET_MODE_STREAMING = 2, -AASSET_MODE_BUFFER = 3 - } |
-Functions | |
| AAssetDir * | AAssetManager_openDir (AAssetManager *mgr, const char *dirName) |
| AAsset * | AAssetManager_open (AAssetManager *mgr, const char *filename, int mode) |
| const char * | AAssetDir_getNextFileName (AAssetDir *assetDir) |
| void | AAssetDir_rewind (AAssetDir *assetDir) |
| void | AAssetDir_close (AAssetDir *assetDir) |
| int | AAsset_read (AAsset *asset, void *buf, size_t count) |
| off_t | AAsset_seek (AAsset *asset, off_t offset, int whence) |
| off64_t | AAsset_seek64 (AAsset *asset, off64_t offset, int whence) |
| void | AAsset_close (AAsset *asset) |
| const void * | AAsset_getBuffer (AAsset *asset) |
| off_t | AAsset_getLength (AAsset *asset) |
| off64_t | AAsset_getLength64 (AAsset *asset) |
| off_t | AAsset_getRemainingLength (AAsset *asset) |
| off64_t | AAsset_getRemainingLength64 (AAsset *asset) |
| int | AAsset_openFileDescriptor (AAsset *asset, off_t *outStart, off_t *outLength) |
| int | AAsset_openFileDescriptor64 (AAsset *asset, off64_t *outStart, off64_t *outLength) |
| int | AAsset_isAllocated (AAsset *asset) |
-Functions | |
| AAssetManager * | AAssetManager_fromJava (JNIEnv *env, jobject assetManager) |
#include <stdint.h>#include <jni.h>-Data Structures | |
| struct | AndroidBitmapInfo |
-Macros | |
| #define | ANDROID_BITMAP_RESUT_SUCCESS ANDROID_BITMAP_RESULT_SUCCESS |
-Enumerations | |
| enum | { ANDROID_BITMAP_RESULT_SUCCESS = 0, -ANDROID_BITMAP_RESULT_BAD_PARAMETER = -1, -ANDROID_BITMAP_RESULT_JNI_EXCEPTION = -2, -ANDROID_BITMAP_RESULT_ALLOCATION_FAILED = -3 - } |
| enum | AndroidBitmapFormat { - ANDROID_BITMAP_FORMAT_NONE = 0, -ANDROID_BITMAP_FORMAT_RGBA_8888 = 1, -ANDROID_BITMAP_FORMAT_RGB_565 = 4, -ANDROID_BITMAP_FORMAT_RGBA_4444 = 7, - - ANDROID_BITMAP_FORMAT_A_8 = 8 - - } |
-Functions | |
| int | AndroidBitmap_getInfo (JNIEnv *env, jobject jbitmap, AndroidBitmapInfo *info) |
| int | AndroidBitmap_lockPixels (JNIEnv *env, jobject jbitmap, void **addrPtr) |
| int | AndroidBitmap_unlockPixels (JNIEnv *env, jobject jbitmap) |
| AMetaDataEvent | ANativeWindow_Buffer | ASensorEvent | ||
| ANativeActivity | AndroidBitmapInfo | ASensorVector | |||
| AHeartRateEvent | ANativeActivityCallbacks | ARect | AUncalibratedEvent | ||
#include <android/asset_manager.h>-Typedefs | |
| typedef struct AConfiguration | AConfiguration |
-Files | |
| file | asset_manager.h |
| file | asset_manager_jni.h |
| file | bitmap.h |
| file | configuration.h |
| file | input.h |
| file | keycodes.h |
| file | looper.h |
| file | native_activity.h |
| file | native_window.h |
| file | native_window_jni.h |
| file | obb.h |
| file | rect.h |
| file | sensor.h |
| file | storage_manager.h |
| file | window.h |
-Directories | |
| directory | android |
-Files | |
| file | asset_manager.h |
| file | asset_manager_jni.h |
-Typedefs | |
| typedef struct AAssetManager | AAssetManager |
| typedef struct AAssetDir | AAssetDir |
| typedef struct AAsset | AAsset |
-Enumerations | |
| enum | { AASSET_MODE_UNKNOWN = 0, -AASSET_MODE_RANDOM = 1, -AASSET_MODE_STREAMING = 2, -AASSET_MODE_BUFFER = 3 - } |
-Functions | |
| AAssetDir * | AAssetManager_openDir (AAssetManager *mgr, const char *dirName) |
| AAsset * | AAssetManager_open (AAssetManager *mgr, const char *filename, int mode) |
| const char * | AAssetDir_getNextFileName (AAssetDir *assetDir) |
| void | AAssetDir_rewind (AAssetDir *assetDir) |
| void | AAssetDir_close (AAssetDir *assetDir) |
| int | AAsset_read (AAsset *asset, void *buf, size_t count) |
| off_t | AAsset_seek (AAsset *asset, off_t offset, int whence) |
| off64_t | AAsset_seek64 (AAsset *asset, off64_t offset, int whence) |
| void | AAsset_close (AAsset *asset) |
| const void * | AAsset_getBuffer (AAsset *asset) |
| off_t | AAsset_getLength (AAsset *asset) |
| off64_t | AAsset_getLength64 (AAsset *asset) |
| off_t | AAsset_getRemainingLength (AAsset *asset) |
| off64_t | AAsset_getRemainingLength64 (AAsset *asset) |
| int | AAsset_openFileDescriptor (AAsset *asset, off_t *outStart, off_t *outLength) |
| int | AAsset_openFileDescriptor64 (AAsset *asset, off64_t *outStart, off64_t *outLength) |
| int | AAsset_isAllocated (AAsset *asset) |
| AAssetManager * | AAssetManager_fromJava (JNIEnv *env, jobject assetManager) |
AAssetDir provides access to a chunk of the asset hierarchy as if it were a single directory. The contents are populated by the AAssetManager.
-The list of files will be sorted in ascending order by ASCII value.
- -| typedef struct AAssetManager AAssetManager | -
AAssetManager provides access to an application's raw assets by creating AAsset objects.
-AAssetManager is a wrapper to the low-level native implementation of the java AAssetManager, a pointer can be obtained using AAssetManager_fromJava().
-The asset hierarchy may be examined like a filesystem, using AAssetDir objects to peruse a single directory.
-A native AAssetManager pointer may be shared across multiple threads.
- -| anonymous enum | -
Available access modes for opening assets with AAssetManager_open
-| void AAsset_close | -( | -AAsset * | -asset | ) | -- |
Close the asset, freeing all associated resources.
- -| const void* AAsset_getBuffer | -( | -AAsset * | -asset | ) | -- |
Get a pointer to a buffer holding the entire contents of the assset.
-Returns NULL on failure.
- -| off_t AAsset_getLength | -( | -AAsset * | -asset | ) | -- |
Report the total size of the asset data.
- -| off64_t AAsset_getLength64 | -( | -AAsset * | -asset | ) | -- |
Report the total size of the asset data. Reports the size using a 64-bit number insted of 32-bit as AAsset_getLength.
- -| off_t AAsset_getRemainingLength | -( | -AAsset * | -asset | ) | -- |
Report the total amount of asset data that can be read from the current position.
- -| off64_t AAsset_getRemainingLength64 | -( | -AAsset * | -asset | ) | -- |
Report the total amount of asset data that can be read from the current position.
-Uses a 64-bit number instead of a 32-bit number as AAsset_getRemainingLength does.
- -| int AAsset_isAllocated | -( | -AAsset * | -asset | ) | -- |
Returns whether this asset's internal buffer is allocated in ordinary RAM (i.e. not mmapped).
- -| int AAsset_openFileDescriptor | -( | -AAsset * | -asset, | -
| - | - | off_t * | -outStart, | -
| - | - | off_t * | -outLength | -
| - | ) | -- |
Open a new file descriptor that can be used to read the asset data. If the start or length cannot be represented by a 32-bit number, it will be truncated. If the file is large, use AAsset_openFileDescriptor64 instead.
-Returns < 0 if direct fd access is not possible (for example, if the asset is compressed).
- -| int AAsset_openFileDescriptor64 | -( | -AAsset * | -asset, | -
| - | - | off64_t * | -outStart, | -
| - | - | off64_t * | -outLength | -
| - | ) | -- |
Open a new file descriptor that can be used to read the asset data.
-Uses a 64-bit number for the offset and length instead of 32-bit instead of as AAsset_openFileDescriptor does.
-Returns < 0 if direct fd access is not possible (for example, if the asset is compressed).
- -| int AAsset_read | -( | -AAsset * | -asset, | -
| - | - | void * | -buf, | -
| - | - | size_t | -count | -
| - | ) | -- |
Attempt to read 'count' bytes of data from the current offset.
-Returns the number of bytes read, zero on EOF, or < 0 on error.
- -| off_t AAsset_seek | -( | -AAsset * | -asset, | -
| - | - | off_t | -offset, | -
| - | - | int | -whence | -
| - | ) | -- |
Seek to the specified offset within the asset data. 'whence' uses the same constants as lseek()/fseek().
-Returns the new position on success, or (off_t) -1 on error.
- -| off64_t AAsset_seek64 | -( | -AAsset * | -asset, | -
| - | - | off64_t | -offset, | -
| - | - | int | -whence | -
| - | ) | -- |
Seek to the specified offset within the asset data. 'whence' uses the same constants as lseek()/fseek().
-Uses 64-bit data type for large files as opposed to the 32-bit type used by AAsset_seek.
-Returns the new position on success, or (off64_t) -1 on error.
- -| void AAssetDir_close | -( | -AAssetDir * | -assetDir | ) | -- |
Close an opened AAssetDir, freeing any related resources.
- -| const char* AAssetDir_getNextFileName | -( | -AAssetDir * | -assetDir | ) | -- |
Iterate over the files in an asset directory. A NULL string is returned when all the file names have been returned.
-The returned file name is suitable for passing to AAssetManager_open().
-The string returned here is owned by the AssetDir implementation and is not guaranteed to remain valid if any other calls are made on this AAssetDir instance.
- -| void AAssetDir_rewind | -( | -AAssetDir * | -assetDir | ) | -- |
Reset the iteration state of AAssetDir_getNextFileName() to the beginning.
- -| AAssetManager* AAssetManager_fromJava | -( | -JNIEnv * | -env, | -
| - | - | jobject | -assetManager | -
| - | ) | -- |
Given a Dalvik AssetManager object, obtain the corresponding native AAssetManager object. Note that the caller is responsible for obtaining and holding a VM reference to the jobject to prevent its being garbage collected while the native object is in use.
- -| AAsset* AAssetManager_open | -( | -AAssetManager * | -mgr, | -
| - | - | const char * | -filename, | -
| - | - | int | -mode | -
| - | ) | -- |
Open an asset.
-The object returned here should be freed by calling AAsset_close().
- -| AAssetDir* AAssetManager_openDir | -( | -AAssetManager * | -mgr, | -
| - | - | const char * | -dirName | -
| - | ) | -- |
Open the named directory within the asset hierarchy. The directory can then be inspected with the AAssetDir functions. To open the top-level directory, pass in "" as the dirName.
-The object returned here should be freed by calling AAssetDir_close().
- --Files | |
| file | bitmap.h |
-Data Structures | |
| struct | AndroidBitmapInfo |
-Macros | |
| #define | ANDROID_BITMAP_RESUT_SUCCESS ANDROID_BITMAP_RESULT_SUCCESS |
-Enumerations | |
| enum | { ANDROID_BITMAP_RESULT_SUCCESS = 0, -ANDROID_BITMAP_RESULT_BAD_PARAMETER = -1, -ANDROID_BITMAP_RESULT_JNI_EXCEPTION = -2, -ANDROID_BITMAP_RESULT_ALLOCATION_FAILED = -3 - } |
| enum | AndroidBitmapFormat { - ANDROID_BITMAP_FORMAT_NONE = 0, -ANDROID_BITMAP_FORMAT_RGBA_8888 = 1, -ANDROID_BITMAP_FORMAT_RGB_565 = 4, -ANDROID_BITMAP_FORMAT_RGBA_4444 = 7, - - ANDROID_BITMAP_FORMAT_A_8 = 8 - - } |
-Functions | |
| int | AndroidBitmap_getInfo (JNIEnv *env, jobject jbitmap, AndroidBitmapInfo *info) |
| int | AndroidBitmap_lockPixels (JNIEnv *env, jobject jbitmap, void **addrPtr) |
| int | AndroidBitmap_unlockPixels (JNIEnv *env, jobject jbitmap) |
| #define ANDROID_BITMAP_RESUT_SUCCESS ANDROID_BITMAP_RESULT_SUCCESS | -
Backward compatibility: this macro used to be misspelled.
- -| anonymous enum | -
| enum AndroidBitmapFormat | -
Bitmap pixel format.
-| int AndroidBitmap_getInfo | -( | -JNIEnv * | -env, | -
| - | - | jobject | -jbitmap, | -
| - | - | AndroidBitmapInfo * | -info | -
| - | ) | -- |
Given a java bitmap object, fill out the AndroidBitmapInfo struct for it. If the call fails, the info parameter will be ignored.
- -| int AndroidBitmap_lockPixels | -( | -JNIEnv * | -env, | -
| - | - | jobject | -jbitmap, | -
| - | - | void ** | -addrPtr | -
| - | ) | -- |
Given a java bitmap object, attempt to lock the pixel address. Locking will ensure that the memory for the pixels will not move until the unlockPixels call, and ensure that, if the pixels had been previously purged, they will have been restored.
-If this call succeeds, it must be balanced by a call to AndroidBitmap_unlockPixels, after which time the address of the pixels should no longer be used.
-If this succeeds, *addrPtr will be set to the pixel address. If the call fails, addrPtr will be ignored.
- -| int AndroidBitmap_unlockPixels | -( | -JNIEnv * | -env, | -
| - | - | jobject | -jbitmap | -
| - | ) | -- |
Call this to balance a successful call to AndroidBitmap_lockPixels.
- --Files | |
| file | configuration.h |
-Typedefs | |
| typedef struct AConfiguration | AConfiguration |
| typedef struct AConfiguration AConfiguration | -
AConfiguration is an opaque type used to get and set various subsystem configurations.
-A AConfiguration pointer can be obtained using:
- - -| anonymous enum | -
Define flags and constants for various subsystem configurations.
-| Enumerator | |
|---|---|
| ACONFIGURATION_ORIENTATION_ANY |
- Orientation: not specified. - |
| ACONFIGURATION_ORIENTATION_PORT |
- Orientation: value corresponding to the port resource qualifier. - |
| ACONFIGURATION_ORIENTATION_LAND |
- Orientation: value corresponding to the land resource qualifier. - |
| ACONFIGURATION_ORIENTATION_SQUARE |
-
|
| ACONFIGURATION_TOUCHSCREEN_ANY |
- Touchscreen: not specified. - |
| ACONFIGURATION_TOUCHSCREEN_NOTOUCH |
- Touchscreen: value corresponding to the notouch resource qualifier. - |
| ACONFIGURATION_TOUCHSCREEN_STYLUS |
-
|
| ACONFIGURATION_TOUCHSCREEN_FINGER |
- Touchscreen: value corresponding to the finger resource qualifier. - |
| ACONFIGURATION_DENSITY_DEFAULT |
- Density: default density. - |
| ACONFIGURATION_DENSITY_LOW |
- Density: value corresponding to the ldpi resource qualifier. - |
| ACONFIGURATION_DENSITY_MEDIUM |
- Density: value corresponding to the mdpi resource qualifier. - |
| ACONFIGURATION_DENSITY_TV |
- Density: value corresponding to the tvdpi resource qualifier. - |
| ACONFIGURATION_DENSITY_HIGH |
- Density: value corresponding to the hdpi resource qualifier. - |
| ACONFIGURATION_DENSITY_XHIGH |
- Density: value corresponding to the xhdpi resource qualifier. - |
| ACONFIGURATION_DENSITY_XXHIGH |
- Density: value corresponding to the xxhdpi resource qualifier. - |
| ACONFIGURATION_DENSITY_XXXHIGH |
- Density: value corresponding to the xxxhdpi resource qualifier. - |
| ACONFIGURATION_DENSITY_ANY |
- Density: any density. - |
| ACONFIGURATION_DENSITY_NONE |
- Density: no density specified. - |
| ACONFIGURATION_KEYBOARD_ANY |
- Keyboard: not specified. - |
| ACONFIGURATION_KEYBOARD_NOKEYS |
- Keyboard: value corresponding to the nokeys resource qualifier. - |
| ACONFIGURATION_KEYBOARD_QWERTY |
- Keyboard: value corresponding to the qwerty resource qualifier. - |
| ACONFIGURATION_KEYBOARD_12KEY |
- Keyboard: value corresponding to the 12key resource qualifier. - |
| ACONFIGURATION_NAVIGATION_ANY |
- Navigation: not specified. - |
| ACONFIGURATION_NAVIGATION_NONAV |
- Navigation: value corresponding to the nonav resource qualifier. - |
| ACONFIGURATION_NAVIGATION_DPAD |
- Navigation: value corresponding to the dpad resource qualifier. - |
| ACONFIGURATION_NAVIGATION_TRACKBALL |
- Navigation: value corresponding to the trackball resource qualifier. - |
| ACONFIGURATION_NAVIGATION_WHEEL |
- Navigation: value corresponding to the wheel resource qualifier. - |
| ACONFIGURATION_KEYSHIDDEN_ANY |
- Keyboard availability: not specified. - |
| ACONFIGURATION_KEYSHIDDEN_NO |
- Keyboard availability: value corresponding to the keysexposed resource qualifier. - |
| ACONFIGURATION_KEYSHIDDEN_YES |
- Keyboard availability: value corresponding to the keyshidden resource qualifier. - |
| ACONFIGURATION_KEYSHIDDEN_SOFT |
- Keyboard availability: value corresponding to the keyssoft resource qualifier. - |
| ACONFIGURATION_NAVHIDDEN_ANY |
- Navigation availability: not specified. - |
| ACONFIGURATION_NAVHIDDEN_NO |
- Navigation availability: value corresponding to the navexposed resource qualifier. - |
| ACONFIGURATION_NAVHIDDEN_YES |
- Navigation availability: value corresponding to the navhidden resource qualifier. - |
| ACONFIGURATION_SCREENSIZE_ANY |
- Screen size: not specified. - |
| ACONFIGURATION_SCREENSIZE_SMALL |
- Screen size: value indicating the screen is at least approximately 320x426 dp units, corresponding to the small resource qualifier. - |
| ACONFIGURATION_SCREENSIZE_NORMAL |
- Screen size: value indicating the screen is at least approximately 320x470 dp units, corresponding to the normal resource qualifier. - |
| ACONFIGURATION_SCREENSIZE_LARGE |
- Screen size: value indicating the screen is at least approximately 480x640 dp units, corresponding to the large resource qualifier. - |
| ACONFIGURATION_SCREENSIZE_XLARGE |
- Screen size: value indicating the screen is at least approximately 720x960 dp units, corresponding to the xlarge resource qualifier. - |
| ACONFIGURATION_SCREENLONG_ANY |
- Screen layout: not specified. - |
| ACONFIGURATION_SCREENLONG_NO |
- Screen layout: value that corresponds to the notlong resource qualifier. - |
| ACONFIGURATION_SCREENLONG_YES |
- Screen layout: value that corresponds to the long resource qualifier. - |
| ACONFIGURATION_UI_MODE_TYPE_ANY |
- UI mode: not specified. - |
| ACONFIGURATION_UI_MODE_TYPE_NORMAL |
- UI mode: value that corresponds to no UI mode type resource qualifier specified. - |
| ACONFIGURATION_UI_MODE_TYPE_DESK |
- UI mode: value that corresponds to desk resource qualifier specified. - |
| ACONFIGURATION_UI_MODE_TYPE_CAR |
- UI mode: value that corresponds to car resource qualifier specified. - |
| ACONFIGURATION_UI_MODE_TYPE_TELEVISION |
- UI mode: value that corresponds to television resource qualifier specified. - |
| ACONFIGURATION_UI_MODE_TYPE_APPLIANCE |
- UI mode: value that corresponds to appliance resource qualifier specified. - |
| ACONFIGURATION_UI_MODE_TYPE_WATCH |
- UI mode: value that corresponds to watch resource qualifier specified. - |
| ACONFIGURATION_UI_MODE_NIGHT_ANY |
- UI night mode: not specified. - |
| ACONFIGURATION_UI_MODE_NIGHT_NO |
- UI night mode: value that corresponds to notnight resource qualifier specified. - |
| ACONFIGURATION_UI_MODE_NIGHT_YES |
- UI night mode: value that corresponds to night resource qualifier specified. - |
| ACONFIGURATION_SCREEN_WIDTH_DP_ANY |
- Screen width DPI: not specified. - |
| ACONFIGURATION_SCREEN_HEIGHT_DP_ANY |
- Screen height DPI: not specified. - |
| ACONFIGURATION_SMALLEST_SCREEN_WIDTH_DP_ANY |
- Smallest screen width DPI: not specified. - |
| ACONFIGURATION_LAYOUTDIR_ANY |
- Layout direction: not specified. - |
| ACONFIGURATION_LAYOUTDIR_LTR |
- Layout direction: value that corresponds to ldltr resource qualifier specified. - |
| ACONFIGURATION_LAYOUTDIR_RTL |
- Layout direction: value that corresponds to ldrtl resource qualifier specified. - |
| ACONFIGURATION_MCC |
- Bit mask for mcc configuration. - |
| ACONFIGURATION_MNC |
- Bit mask for mnc configuration. - |
| ACONFIGURATION_LOCALE |
- Bit mask for locale configuration. - |
| ACONFIGURATION_TOUCHSCREEN |
- Bit mask for touchscreen configuration. - |
| ACONFIGURATION_KEYBOARD |
- Bit mask for keyboard configuration. - |
| ACONFIGURATION_KEYBOARD_HIDDEN |
- Bit mask for keyboardHidden configuration. - |
| ACONFIGURATION_NAVIGATION |
- Bit mask for navigation configuration. - |
| ACONFIGURATION_ORIENTATION |
- Bit mask for orientation configuration. - |
| ACONFIGURATION_DENSITY |
- Bit mask for density configuration. - |
| ACONFIGURATION_SCREEN_SIZE |
- Bit mask for screen size configuration. - |
| ACONFIGURATION_VERSION |
- Bit mask for platform version configuration. - |
| ACONFIGURATION_SCREEN_LAYOUT |
- Bit mask for screen layout configuration. - |
| ACONFIGURATION_UI_MODE |
- Bit mask for ui mode configuration. - |
| ACONFIGURATION_SMALLEST_SCREEN_SIZE |
- Bit mask for smallest screen width configuration. - |
| ACONFIGURATION_LAYOUTDIR |
- Bit mask for layout direction configuration. - |
| ACONFIGURATION_MNC_ZERO |
- Constant used to to represent MNC (Mobile Network Code) zero. 0 cannot be used, since it is used to represent an undefined MNC. - |
| void AConfiguration_copy | -( | -AConfiguration * | -dest, | -
| - | - | AConfiguration * | -src | -
| - | ) | -- |
Copy the contents of 'src' to 'dest'.
- -| void AConfiguration_delete | -( | -AConfiguration * | -config | ) | -- |
Free an AConfiguration that was previously created with AConfiguration_new().
- -| int32_t AConfiguration_diff | -( | -AConfiguration * | -config1, | -
| - | - | AConfiguration * | -config2 | -
| - | ) | -- |
Perform a diff between two configurations. Returns a bit mask of ACONFIGURATION_* constants, each bit set meaning that configuration element is different between them.
- -| void AConfiguration_fromAssetManager | -( | -AConfiguration * | -out, | -
| - | - | AAssetManager * | -am | -
| - | ) | -- |
Create and return a new AConfiguration based on the current configuration in use in the given AAssetManager.
- -| void AConfiguration_getCountry | -( | -AConfiguration * | -config, | -
| - | - | char * | -outCountry | -
| - | ) | -- |
Return the current country code set in the configuration. The output will be filled with an array of two characters. They are not 0-terminated. If a country is not set, they will be 0.
- -| int32_t AConfiguration_getDensity | -( | -AConfiguration * | -config | ) | -- |
Return the current ACONFIGURATION_DENSITY_* set in the configuration.
- -| int32_t AConfiguration_getKeyboard | -( | -AConfiguration * | -config | ) | -- |
Return the current ACONFIGURATION_KEYBOARD_* set in the configuration.
- -| int32_t AConfiguration_getKeysHidden | -( | -AConfiguration * | -config | ) | -- |
Return the current ACONFIGURATION_KEYSHIDDEN_* set in the configuration.
- -| void AConfiguration_getLanguage | -( | -AConfiguration * | -config, | -
| - | - | char * | -outLanguage | -
| - | ) | -- |
Return the current language code set in the configuration. The output will be filled with an array of two characters. They are not 0-terminated. If a language is not set, they will be 0.
- -| int32_t AConfiguration_getLayoutDirection | -( | -AConfiguration * | -config | ) | -- |
Return the configuration's layout direction, or ACONFIGURATION_LAYOUTDIR_ANY if not set.
- -| int32_t AConfiguration_getMcc | -( | -AConfiguration * | -config | ) | -- |
Return the current MCC set in the configuration. 0 if not set.
- -| int32_t AConfiguration_getMnc | -( | -AConfiguration * | -config | ) | -- |
Return the current MNC set in the configuration. 0 if not set.
- -| int32_t AConfiguration_getNavHidden | -( | -AConfiguration * | -config | ) | -- |
Return the current ACONFIGURATION_NAVHIDDEN_* set in the configuration.
- -| int32_t AConfiguration_getNavigation | -( | -AConfiguration * | -config | ) | -- |
Return the current ACONFIGURATION_NAVIGATION_* set in the configuration.
- -| int32_t AConfiguration_getOrientation | -( | -AConfiguration * | -config | ) | -- |
Return the current ACONFIGURATION_ORIENTATION_* set in the configuration.
- -| int32_t AConfiguration_getScreenHeightDp | -( | -AConfiguration * | -config | ) | -- |
Return the current configuration screen height in dp units, or ACONFIGURATION_SCREEN_HEIGHT_DP_ANY if not set.
- -| int32_t AConfiguration_getScreenLong | -( | -AConfiguration * | -config | ) | -- |
Return the current ACONFIGURATION_SCREENLONG_* set in the configuration.
- -| int32_t AConfiguration_getScreenSize | -( | -AConfiguration * | -config | ) | -- |
Return the current ACONFIGURATION_SCREENSIZE_* set in the configuration.
- -| int32_t AConfiguration_getScreenWidthDp | -( | -AConfiguration * | -config | ) | -- |
Return the current configuration screen width in dp units, or ACONFIGURATION_SCREEN_WIDTH_DP_ANY if not set.
- -| int32_t AConfiguration_getSdkVersion | -( | -AConfiguration * | -config | ) | -- |
Return the current SDK (API) version set in the configuration.
- -| int32_t AConfiguration_getSmallestScreenWidthDp | -( | -AConfiguration * | -config | ) | -- |
Return the configuration's smallest screen width in dp units, or ACONFIGURATION_SMALLEST_SCREEN_WIDTH_DP_ANY if not set.
- -| int32_t AConfiguration_getTouchscreen | -( | -AConfiguration * | -config | ) | -- |
Return the current ACONFIGURATION_TOUCHSCREEN_* set in the configuration.
- -| int32_t AConfiguration_getUiModeNight | -( | -AConfiguration * | -config | ) | -- |
Return the current ACONFIGURATION_UI_MODE_NIGHT_* set in the configuration.
- -| int32_t AConfiguration_getUiModeType | -( | -AConfiguration * | -config | ) | -- |
Return the current ACONFIGURATION_UI_MODE_TYPE_* set in the configuration.
- -| int32_t AConfiguration_isBetterThan | -( | -AConfiguration * | -base, | -
| - | - | AConfiguration * | -test, | -
| - | - | AConfiguration * | -requested | -
| - | ) | -- |
Determine whether the configuration in 'test' is better than the existing configuration in 'base'. If 'requested' is non-NULL, this decision is based on the overall configuration given there. If it is NULL, this decision is simply based on which configuration is more specific. Returns non-0 if 'test' is better than 'base'.
-This assumes you have already filtered the configurations with AConfiguration_match().
- -| int32_t AConfiguration_match | -( | -AConfiguration * | -base, | -
| - | - | AConfiguration * | -requested | -
| - | ) | -- |
Determine whether 'base' is a valid configuration for use within the environment 'requested'. Returns 0 if there are any values in 'base' that conflict with 'requested'. Returns 1 if it does not conflict.
- -| AConfiguration* AConfiguration_new | -( | -) | -- |
Create a new AConfiguration, initialized with no values set.
- -| void AConfiguration_setCountry | -( | -AConfiguration * | -config, | -
| - | - | const char * | -country | -
| - | ) | -- |
Set the current country code in the configuration, from the first two characters in the string.
- -| void AConfiguration_setDensity | -( | -AConfiguration * | -config, | -
| - | - | int32_t | -density | -
| - | ) | -- |
Set the current density in the configuration.
- -| void AConfiguration_setKeyboard | -( | -AConfiguration * | -config, | -
| - | - | int32_t | -keyboard | -
| - | ) | -- |
Set the current keyboard in the configuration.
- -| void AConfiguration_setKeysHidden | -( | -AConfiguration * | -config, | -
| - | - | int32_t | -keysHidden | -
| - | ) | -- |
Set the current keys hidden in the configuration.
- -| void AConfiguration_setLanguage | -( | -AConfiguration * | -config, | -
| - | - | const char * | -language | -
| - | ) | -- |
Set the current language code in the configuration, from the first two characters in the string.
- -| void AConfiguration_setLayoutDirection | -( | -AConfiguration * | -config, | -
| - | - | int32_t | -value | -
| - | ) | -- |
Set the configuration's layout direction.
- -| void AConfiguration_setMcc | -( | -AConfiguration * | -config, | -
| - | - | int32_t | -mcc | -
| - | ) | -- |
Set the current MCC in the configuration. 0 to clear.
- -| void AConfiguration_setMnc | -( | -AConfiguration * | -config, | -
| - | - | int32_t | -mnc | -
| - | ) | -- |
Set the current MNC in the configuration. 0 to clear.
- -| void AConfiguration_setNavHidden | -( | -AConfiguration * | -config, | -
| - | - | int32_t | -navHidden | -
| - | ) | -- |
Set the current nav hidden in the configuration.
- -| void AConfiguration_setNavigation | -( | -AConfiguration * | -config, | -
| - | - | int32_t | -navigation | -
| - | ) | -- |
Set the current navigation in the configuration.
- -| void AConfiguration_setOrientation | -( | -AConfiguration * | -config, | -
| - | - | int32_t | -orientation | -
| - | ) | -- |
Set the current orientation in the configuration.
- -| void AConfiguration_setScreenHeightDp | -( | -AConfiguration * | -config, | -
| - | - | int32_t | -value | -
| - | ) | -- |
Set the configuration's current screen width in dp units.
- -| void AConfiguration_setScreenLong | -( | -AConfiguration * | -config, | -
| - | - | int32_t | -screenLong | -
| - | ) | -- |
Set the current screen long in the configuration.
- -| void AConfiguration_setScreenSize | -( | -AConfiguration * | -config, | -
| - | - | int32_t | -screenSize | -
| - | ) | -- |
Set the current screen size in the configuration.
- -| void AConfiguration_setScreenWidthDp | -( | -AConfiguration * | -config, | -
| - | - | int32_t | -value | -
| - | ) | -- |
Set the configuration's current screen width in dp units.
- -| void AConfiguration_setSdkVersion | -( | -AConfiguration * | -config, | -
| - | - | int32_t | -sdkVersion | -
| - | ) | -- |
Set the current SDK version in the configuration.
- -| void AConfiguration_setSmallestScreenWidthDp | -( | -AConfiguration * | -config, | -
| - | - | int32_t | -value | -
| - | ) | -- |
Set the configuration's smallest screen width in dp units.
- -| void AConfiguration_setTouchscreen | -( | -AConfiguration * | -config, | -
| - | - | int32_t | -touchscreen | -
| - | ) | -- |
Set the current touchscreen in the configuration.
- -| void AConfiguration_setUiModeNight | -( | -AConfiguration * | -config, | -
| - | - | int32_t | -uiModeNight | -
| - | ) | -- |
Set the current UI mode night in the configuration.
- -| void AConfiguration_setUiModeType | -( | -AConfiguration * | -config, | -
| - | - | int32_t | -uiModeType | -
| - | ) | -- |
Set the current UI mode type in the configuration.
- --Files | |
| file | input.h |
| file | keycodes.h |
-Macros | |
| #define | AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8 |
-Typedefs | |
| typedef struct AInputEvent | AInputEvent |
| typedef struct AInputQueue | AInputQueue |
-Functions | |
| int32_t | AInputEvent_getType (const AInputEvent *event) |
| int32_t | AInputEvent_getDeviceId (const AInputEvent *event) |
| int32_t | AInputEvent_getSource (const AInputEvent *event) |
| int32_t | AKeyEvent_getAction (const AInputEvent *key_event) |
| int32_t | AKeyEvent_getFlags (const AInputEvent *key_event) |
| int32_t | AKeyEvent_getKeyCode (const AInputEvent *key_event) |
| int32_t | AKeyEvent_getScanCode (const AInputEvent *key_event) |
| int32_t | AKeyEvent_getMetaState (const AInputEvent *key_event) |
| int32_t | AKeyEvent_getRepeatCount (const AInputEvent *key_event) |
| int64_t | AKeyEvent_getDownTime (const AInputEvent *key_event) |
| int64_t | AKeyEvent_getEventTime (const AInputEvent *key_event) |
| int32_t | AMotionEvent_getAction (const AInputEvent *motion_event) |
| int32_t | AMotionEvent_getFlags (const AInputEvent *motion_event) |
| int32_t | AMotionEvent_getMetaState (const AInputEvent *motion_event) |
| int32_t | AMotionEvent_getButtonState (const AInputEvent *motion_event) |
| int32_t | AMotionEvent_getEdgeFlags (const AInputEvent *motion_event) |
| int64_t | AMotionEvent_getDownTime (const AInputEvent *motion_event) |
| int64_t | AMotionEvent_getEventTime (const AInputEvent *motion_event) |
| float | AMotionEvent_getXOffset (const AInputEvent *motion_event) |
| float | AMotionEvent_getYOffset (const AInputEvent *motion_event) |
| float | AMotionEvent_getXPrecision (const AInputEvent *motion_event) |
| float | AMotionEvent_getYPrecision (const AInputEvent *motion_event) |
| size_t | AMotionEvent_getPointerCount (const AInputEvent *motion_event) |
| int32_t | AMotionEvent_getPointerId (const AInputEvent *motion_event, size_t pointer_index) |
| int32_t | AMotionEvent_getToolType (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getRawX (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getRawY (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getX (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getY (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getPressure (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getSize (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getTouchMajor (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getTouchMinor (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getToolMajor (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getToolMinor (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getOrientation (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getAxisValue (const AInputEvent *motion_event, int32_t axis, size_t pointer_index) |
| size_t | AMotionEvent_getHistorySize (const AInputEvent *motion_event) |
| int64_t | AMotionEvent_getHistoricalEventTime (const AInputEvent *motion_event, size_t history_index) |
| float | AMotionEvent_getHistoricalRawX (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalRawY (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalX (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalY (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalPressure (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalSize (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalTouchMajor (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalTouchMinor (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalToolMajor (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalToolMinor (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalOrientation (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalAxisValue (const AInputEvent *motion_event, int32_t axis, size_t pointer_index, size_t history_index) |
| void | AInputQueue_attachLooper (AInputQueue *queue, ALooper *looper, int ident, ALooper_callbackFunc callback, void *data) |
| void | AInputQueue_detachLooper (AInputQueue *queue) |
| int32_t | AInputQueue_hasEvents (AInputQueue *queue) |
| int32_t | AInputQueue_getEvent (AInputQueue *queue, AInputEvent **outEvent) |
| int32_t | AInputQueue_preDispatchEvent (AInputQueue *queue, AInputEvent *event) |
| void | AInputQueue_finishEvent (AInputQueue *queue, AInputEvent *event, int handled) |
| #define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8 | -
Bit shift for the action bits holding the pointer index as defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK.
- -| typedef struct AInputEvent AInputEvent | -
Input events.
-Input events are opaque structures. Use the provided accessors functions to read their properties.
- -| typedef struct AInputQueue AInputQueue | -
Input queue
-An input queue is the facility through which you retrieve input events.
- -| anonymous enum | -
Motion event edge touch flags.
-| anonymous enum | -
Constants that identify each individual axis of a motion event.
-| Enumerator | |
|---|---|
| AMOTION_EVENT_AXIS_X |
- Axis constant: X axis of a motion event. -
|
| AMOTION_EVENT_AXIS_Y |
- Axis constant: Y axis of a motion event. -
|
| AMOTION_EVENT_AXIS_PRESSURE |
- Axis constant: Pressure axis of a motion event. -
|
| AMOTION_EVENT_AXIS_SIZE |
- Axis constant: Size axis of a motion event. -
|
| AMOTION_EVENT_AXIS_TOUCH_MAJOR |
- Axis constant: TouchMajor axis of a motion event. -
|
| AMOTION_EVENT_AXIS_TOUCH_MINOR |
- Axis constant: TouchMinor axis of a motion event. -
When the touch is circular, the major and minor axis lengths will be equal to one another. - |
| AMOTION_EVENT_AXIS_TOOL_MAJOR |
- Axis constant: ToolMajor axis of a motion event. -
When the touch is circular, the major and minor axis lengths will be equal to one another. -The tool size may be larger than the touch size since the tool may not be fully in contact with the touch sensor. - |
| AMOTION_EVENT_AXIS_TOOL_MINOR |
- Axis constant: ToolMinor axis of a motion event. -
When the touch is circular, the major and minor axis lengths will be equal to one another. -The tool size may be larger than the touch size since the tool may not be fully in contact with the touch sensor. - |
| AMOTION_EVENT_AXIS_ORIENTATION |
- Axis constant: Orientation axis of a motion event. -
|
| AMOTION_EVENT_AXIS_VSCROLL |
- Axis constant: Vertical Scroll axis of a motion event. -
This axis should be used to scroll views vertically. - |
| AMOTION_EVENT_AXIS_HSCROLL |
- Axis constant: Horizontal Scroll axis of a motion event. -
This axis should be used to scroll views horizontally. - |
| AMOTION_EVENT_AXIS_Z |
- Axis constant: Z axis of a motion event. -
|
| AMOTION_EVENT_AXIS_RX |
- Axis constant: X Rotation axis of a motion event. -
|
| AMOTION_EVENT_AXIS_RY |
- Axis constant: Y Rotation axis of a motion event. -
|
| AMOTION_EVENT_AXIS_RZ |
- Axis constant: Z Rotation axis of a motion event. -
|
| AMOTION_EVENT_AXIS_HAT_X |
- Axis constant: Hat X axis of a motion event. -
|
| AMOTION_EVENT_AXIS_HAT_Y |
- Axis constant: Hat Y axis of a motion event. -
|
| AMOTION_EVENT_AXIS_LTRIGGER |
- Axis constant: Left Trigger axis of a motion event. -
|
| AMOTION_EVENT_AXIS_RTRIGGER |
- Axis constant: Right Trigger axis of a motion event. -
|
| AMOTION_EVENT_AXIS_THROTTLE |
- Axis constant: Throttle axis of a motion event. -
|
| AMOTION_EVENT_AXIS_RUDDER |
- Axis constant: Rudder axis of a motion event. -
|
| AMOTION_EVENT_AXIS_WHEEL |
- Axis constant: Wheel axis of a motion event. -
|
| AMOTION_EVENT_AXIS_GAS |
- Axis constant: Gas axis of a motion event. -
|
| AMOTION_EVENT_AXIS_BRAKE |
- Axis constant: Brake axis of a motion event. -
|
| AMOTION_EVENT_AXIS_DISTANCE |
- Axis constant: Distance axis of a motion event. -
|
| AMOTION_EVENT_AXIS_TILT |
- Axis constant: Tilt axis of a motion event. -
|
| AMOTION_EVENT_AXIS_GENERIC_1 |
- Axis constant: Generic 1 axis of a motion event. The interpretation of a generic axis is device-specific. - |
| AMOTION_EVENT_AXIS_GENERIC_2 |
- Axis constant: Generic 2 axis of a motion event. The interpretation of a generic axis is device-specific. - |
| AMOTION_EVENT_AXIS_GENERIC_3 |
- Axis constant: Generic 3 axis of a motion event. The interpretation of a generic axis is device-specific. - |
| AMOTION_EVENT_AXIS_GENERIC_4 |
- Axis constant: Generic 4 axis of a motion event. The interpretation of a generic axis is device-specific. - |
| AMOTION_EVENT_AXIS_GENERIC_5 |
- Axis constant: Generic 5 axis of a motion event. The interpretation of a generic axis is device-specific. - |
| AMOTION_EVENT_AXIS_GENERIC_6 |
- Axis constant: Generic 6 axis of a motion event. The interpretation of a generic axis is device-specific. - |
| AMOTION_EVENT_AXIS_GENERIC_7 |
- Axis constant: Generic 7 axis of a motion event. The interpretation of a generic axis is device-specific. - |
| AMOTION_EVENT_AXIS_GENERIC_8 |
- Axis constant: Generic 8 axis of a motion event. The interpretation of a generic axis is device-specific. - |
| AMOTION_EVENT_AXIS_GENERIC_9 |
- Axis constant: Generic 9 axis of a motion event. The interpretation of a generic axis is device-specific. - |
| AMOTION_EVENT_AXIS_GENERIC_10 |
- Axis constant: Generic 10 axis of a motion event. The interpretation of a generic axis is device-specific. - |
| AMOTION_EVENT_AXIS_GENERIC_11 |
- Axis constant: Generic 11 axis of a motion event. The interpretation of a generic axis is device-specific. - |
| AMOTION_EVENT_AXIS_GENERIC_12 |
- Axis constant: Generic 12 axis of a motion event. The interpretation of a generic axis is device-specific. - |
| AMOTION_EVENT_AXIS_GENERIC_13 |
- Axis constant: Generic 13 axis of a motion event. The interpretation of a generic axis is device-specific. - |
| AMOTION_EVENT_AXIS_GENERIC_14 |
- Axis constant: Generic 14 axis of a motion event. The interpretation of a generic axis is device-specific. - |
| AMOTION_EVENT_AXIS_GENERIC_15 |
- Axis constant: Generic 15 axis of a motion event. The interpretation of a generic axis is device-specific. - |
| AMOTION_EVENT_AXIS_GENERIC_16 |
- Axis constant: Generic 16 axis of a motion event. The interpretation of a generic axis is device-specific. - |
| anonymous enum | -
Constants that identify buttons that are associated with motion events. Refer to the documentation on the MotionEvent class for descriptions of each button.
-| anonymous enum | -
Constants that identify tool types. Refer to the documentation on the MotionEvent class for descriptions of each tool type.
-| anonymous enum | -
Input source masks.
-Refer to the documentation on android.view.InputDevice for more details about input sources and their correct interpretation.
-| anonymous enum | -
Input sources.
-| anonymous enum | -
| anonymous enum | -
Constants used to retrieve information about the range of motion for a particular coordinate of a motion event.
-Refer to the documentation on android.view.InputDevice for more details about input sources and their correct interpretation.
-| anonymous enum | -
Key codes.
-| Enumerator | |
|---|---|
| AKEYCODE_UNKNOWN |
- Unknown key code. - |
| AKEYCODE_SOFT_LEFT |
- Soft Left key. Usually situated below the display on phones and used as a multi-function feature key for selecting a software defined function shown on the bottom left of the display. - |
| AKEYCODE_SOFT_RIGHT |
- Soft Right key. Usually situated below the display on phones and used as a multi-function feature key for selecting a software defined function shown on the bottom right of the display. - |
| AKEYCODE_HOME |
- Home key. This key is handled by the framework and is never delivered to applications. - |
| AKEYCODE_BACK |
- Back key. - |
| AKEYCODE_CALL |
- Call key. - |
| AKEYCODE_ENDCALL |
- End Call key. - |
| AKEYCODE_0 |
- '0' key. - |
| AKEYCODE_1 |
- '1' key. - |
| AKEYCODE_2 |
- '2' key. - |
| AKEYCODE_3 |
- '3' key. - |
| AKEYCODE_4 |
- '4' key. - |
| AKEYCODE_5 |
- '5' key. - |
| AKEYCODE_6 |
- '6' key. - |
| AKEYCODE_7 |
- '7' key. - |
| AKEYCODE_8 |
- '8' key. - |
| AKEYCODE_9 |
- '9' key. - |
| AKEYCODE_STAR |
- '*' key. - |
| AKEYCODE_POUND |
- '#' key. - |
| AKEYCODE_DPAD_UP |
- Directional Pad Up key. May also be synthesized from trackball motions. - |
| AKEYCODE_DPAD_DOWN |
- Directional Pad Down key. May also be synthesized from trackball motions. - |
| AKEYCODE_DPAD_LEFT |
- Directional Pad Left key. May also be synthesized from trackball motions. - |
| AKEYCODE_DPAD_RIGHT |
- Directional Pad Right key. May also be synthesized from trackball motions. - |
| AKEYCODE_DPAD_CENTER |
- Directional Pad Center key. May also be synthesized from trackball motions. - |
| AKEYCODE_VOLUME_UP |
- Volume Up key. Adjusts the speaker volume up. - |
| AKEYCODE_VOLUME_DOWN |
- Volume Down key. Adjusts the speaker volume down. - |
| AKEYCODE_POWER |
- Power key. - |
| AKEYCODE_CAMERA |
- Camera key. Used to launch a camera application or take pictures. - |
| AKEYCODE_CLEAR |
- Clear key. - |
| AKEYCODE_A |
- 'A' key. - |
| AKEYCODE_B |
- 'B' key. - |
| AKEYCODE_C |
- 'C' key. - |
| AKEYCODE_D |
- 'D' key. - |
| AKEYCODE_E |
- 'E' key. - |
| AKEYCODE_F |
- 'F' key. - |
| AKEYCODE_G |
- 'G' key. - |
| AKEYCODE_H |
- 'H' key. - |
| AKEYCODE_I |
- 'I' key. - |
| AKEYCODE_J |
- 'J' key. - |
| AKEYCODE_K |
- 'K' key. - |
| AKEYCODE_L |
- 'L' key. - |
| AKEYCODE_M |
- 'M' key. - |
| AKEYCODE_N |
- 'N' key. - |
| AKEYCODE_O |
- 'O' key. - |
| AKEYCODE_P |
- 'P' key. - |
| AKEYCODE_Q |
- 'Q' key. - |
| AKEYCODE_R |
- 'R' key. - |
| AKEYCODE_S |
- 'S' key. - |
| AKEYCODE_T |
- 'T' key. - |
| AKEYCODE_U |
- 'U' key. - |
| AKEYCODE_V |
- 'V' key. - |
| AKEYCODE_W |
- 'W' key. - |
| AKEYCODE_X |
- 'X' key. - |
| AKEYCODE_Y |
- 'Y' key. - |
| AKEYCODE_Z |
- 'Z' key. - |
| AKEYCODE_COMMA |
- ',' key. - |
| AKEYCODE_PERIOD |
- '.' key. - |
| AKEYCODE_ALT_LEFT |
- Left Alt modifier key. - |
| AKEYCODE_ALT_RIGHT |
- Right Alt modifier key. - |
| AKEYCODE_SHIFT_LEFT |
- Left Shift modifier key. - |
| AKEYCODE_SHIFT_RIGHT |
- Right Shift modifier key. - |
| AKEYCODE_TAB |
- Tab key. - |
| AKEYCODE_SPACE |
- Space key. - |
| AKEYCODE_SYM |
- Symbol modifier key. Used to enter alternate symbols. - |
| AKEYCODE_EXPLORER |
- Explorer special function key. Used to launch a browser application. - |
| AKEYCODE_ENVELOPE |
- Envelope special function key. Used to launch a mail application. - |
| AKEYCODE_ENTER |
- Enter key. - |
| AKEYCODE_DEL |
- Backspace key. Deletes characters before the insertion point, unlike AKEYCODE_FORWARD_DEL. - |
| AKEYCODE_GRAVE |
- '`' (backtick) key. - |
| AKEYCODE_MINUS |
- '-'. - |
| AKEYCODE_EQUALS |
- '=' key. - |
| AKEYCODE_LEFT_BRACKET |
- '[' key. - |
| AKEYCODE_RIGHT_BRACKET |
- ']' key. - |
| AKEYCODE_BACKSLASH |
- '\' key. - |
| AKEYCODE_SEMICOLON |
- ';' key. - |
| AKEYCODE_APOSTROPHE |
- ''' (apostrophe) key. - |
| AKEYCODE_SLASH |
- '/' key. - |
| AKEYCODE_AT |
- '@' key. - |
| AKEYCODE_NUM |
- Number modifier key. Used to enter numeric symbols. This key is not AKEYCODE_NUM_LOCK; it is more like AKEYCODE_ALT_LEFT. - |
| AKEYCODE_HEADSETHOOK |
- Headset Hook key. Used to hang up calls and stop media. - |
| AKEYCODE_FOCUS |
- Camera Focus key. Used to focus the camera. - |
| AKEYCODE_PLUS |
- '+' key. - |
| AKEYCODE_MENU |
- Menu key. - |
| AKEYCODE_NOTIFICATION |
- Notification key. - |
| AKEYCODE_SEARCH |
- Search key. - |
| AKEYCODE_MEDIA_PLAY_PAUSE |
- Play/Pause media key. - |
| AKEYCODE_MEDIA_STOP |
- Stop media key. - |
| AKEYCODE_MEDIA_NEXT |
- Play Next media key. - |
| AKEYCODE_MEDIA_PREVIOUS |
- Play Previous media key. - |
| AKEYCODE_MEDIA_REWIND |
- Rewind media key. - |
| AKEYCODE_MEDIA_FAST_FORWARD |
- Fast Forward media key. - |
| AKEYCODE_MUTE |
- Mute key. Mutes the microphone, unlike AKEYCODE_VOLUME_MUTE. - |
| AKEYCODE_PAGE_UP |
- Page Up key. - |
| AKEYCODE_PAGE_DOWN |
- Page Down key. - |
| AKEYCODE_PICTSYMBOLS |
- Picture Symbols modifier key. Used to switch symbol sets (Emoji, Kao-moji). - |
| AKEYCODE_SWITCH_CHARSET |
- Switch Charset modifier key. Used to switch character sets (Kanji, Katakana). - |
| AKEYCODE_BUTTON_A |
- A Button key. On a game controller, the A button should be either the button labeled A or the first button on the bottom row of controller buttons. - |
| AKEYCODE_BUTTON_B |
- B Button key. On a game controller, the B button should be either the button labeled B or the second button on the bottom row of controller buttons. - |
| AKEYCODE_BUTTON_C |
- C Button key. On a game controller, the C button should be either the button labeled C or the third button on the bottom row of controller buttons. - |
| AKEYCODE_BUTTON_X |
- X Button key. On a game controller, the X button should be either the button labeled X or the first button on the upper row of controller buttons. - |
| AKEYCODE_BUTTON_Y |
- Y Button key. On a game controller, the Y button should be either the button labeled Y or the second button on the upper row of controller buttons. - |
| AKEYCODE_BUTTON_Z |
- Z Button key. On a game controller, the Z button should be either the button labeled Z or the third button on the upper row of controller buttons. - |
| AKEYCODE_BUTTON_L1 |
- L1 Button key. On a game controller, the L1 button should be either the button labeled L1 (or L) or the top left trigger button. - |
| AKEYCODE_BUTTON_R1 |
- R1 Button key. On a game controller, the R1 button should be either the button labeled R1 (or R) or the top right trigger button. - |
| AKEYCODE_BUTTON_L2 |
- L2 Button key. On a game controller, the L2 button should be either the button labeled L2 or the bottom left trigger button. - |
| AKEYCODE_BUTTON_R2 |
- R2 Button key. On a game controller, the R2 button should be either the button labeled R2 or the bottom right trigger button. - |
| AKEYCODE_BUTTON_THUMBL |
- Left Thumb Button key. On a game controller, the left thumb button indicates that the left (or only) joystick is pressed. - |
| AKEYCODE_BUTTON_THUMBR |
- Right Thumb Button key. On a game controller, the right thumb button indicates that the right joystick is pressed. - |
| AKEYCODE_BUTTON_START |
- Start Button key. On a game controller, the button labeled Start. - |
| AKEYCODE_BUTTON_SELECT |
- Select Button key. On a game controller, the button labeled Select. - |
| AKEYCODE_BUTTON_MODE |
- Mode Button key. On a game controller, the button labeled Mode. - |
| AKEYCODE_ESCAPE |
- Escape key. - |
| AKEYCODE_FORWARD_DEL |
- Forward Delete key. Deletes characters ahead of the insertion point, unlike AKEYCODE_DEL. - |
| AKEYCODE_CTRL_LEFT |
- Left Control modifier key. - |
| AKEYCODE_CTRL_RIGHT |
- Right Control modifier key. - |
| AKEYCODE_CAPS_LOCK |
- Caps Lock key. - |
| AKEYCODE_SCROLL_LOCK |
- Scroll Lock key. - |
| AKEYCODE_META_LEFT |
- Left Meta modifier key. - |
| AKEYCODE_META_RIGHT |
- Right Meta modifier key. - |
| AKEYCODE_FUNCTION |
- Function modifier key. - |
| AKEYCODE_SYSRQ |
- System Request / Print Screen key. - |
| AKEYCODE_BREAK |
- Break / Pause key. - |
| AKEYCODE_MOVE_HOME |
- Home Movement key. Used for scrolling or moving the cursor around to the start of a line or to the top of a list. - |
| AKEYCODE_MOVE_END |
- End Movement key. Used for scrolling or moving the cursor around to the end of a line or to the bottom of a list. - |
| AKEYCODE_INSERT |
- Insert key. Toggles insert / overwrite edit mode. - |
| AKEYCODE_FORWARD |
- Forward key. Navigates forward in the history stack. Complement of AKEYCODE_BACK. - |
| AKEYCODE_MEDIA_PLAY |
- Play media key. - |
| AKEYCODE_MEDIA_PAUSE |
- Pause media key. - |
| AKEYCODE_MEDIA_CLOSE |
- Close media key. May be used to close a CD tray, for example. - |
| AKEYCODE_MEDIA_EJECT |
- Eject media key. May be used to eject a CD tray, for example. - |
| AKEYCODE_MEDIA_RECORD |
- Record media key. - |
| AKEYCODE_F1 |
- F1 key. - |
| AKEYCODE_F2 |
- F2 key. - |
| AKEYCODE_F3 |
- F3 key. - |
| AKEYCODE_F4 |
- F4 key. - |
| AKEYCODE_F5 |
- F5 key. - |
| AKEYCODE_F6 |
- F6 key. - |
| AKEYCODE_F7 |
- F7 key. - |
| AKEYCODE_F8 |
- F8 key. - |
| AKEYCODE_F9 |
- F9 key. - |
| AKEYCODE_F10 |
- F10 key. - |
| AKEYCODE_F11 |
- F11 key. - |
| AKEYCODE_F12 |
- F12 key. - |
| AKEYCODE_NUM_LOCK |
- Num Lock key. This is the Num Lock key; it is different from AKEYCODE_NUM. This key alters the behavior of other keys on the numeric keypad. - |
| AKEYCODE_NUMPAD_0 |
- Numeric keypad '0' key. - |
| AKEYCODE_NUMPAD_1 |
- Numeric keypad '1' key. - |
| AKEYCODE_NUMPAD_2 |
- Numeric keypad '2' key. - |
| AKEYCODE_NUMPAD_3 |
- Numeric keypad '3' key. - |
| AKEYCODE_NUMPAD_4 |
- Numeric keypad '4' key. - |
| AKEYCODE_NUMPAD_5 |
- Numeric keypad '5' key. - |
| AKEYCODE_NUMPAD_6 |
- Numeric keypad '6' key. - |
| AKEYCODE_NUMPAD_7 |
- Numeric keypad '7' key. - |
| AKEYCODE_NUMPAD_8 |
- Numeric keypad '8' key. - |
| AKEYCODE_NUMPAD_9 |
- Numeric keypad '9' key. - |
| AKEYCODE_NUMPAD_DIVIDE |
- Numeric keypad '/' key (for division). - |
| AKEYCODE_NUMPAD_MULTIPLY |
- Numeric keypad '*' key (for multiplication). - |
| AKEYCODE_NUMPAD_SUBTRACT |
- Numeric keypad '-' key (for subtraction). - |
| AKEYCODE_NUMPAD_ADD |
- Numeric keypad '+' key (for addition). - |
| AKEYCODE_NUMPAD_DOT |
- Numeric keypad '.' key (for decimals or digit grouping). - |
| AKEYCODE_NUMPAD_COMMA |
- Numeric keypad ',' key (for decimals or digit grouping). - |
| AKEYCODE_NUMPAD_ENTER |
- Numeric keypad Enter key. - |
| AKEYCODE_NUMPAD_EQUALS |
- Numeric keypad '=' key. - |
| AKEYCODE_NUMPAD_LEFT_PAREN |
- Numeric keypad '(' key. - |
| AKEYCODE_NUMPAD_RIGHT_PAREN |
- Numeric keypad ')' key. - |
| AKEYCODE_VOLUME_MUTE |
- Volume Mute key. Mutes the speaker, unlike AKEYCODE_MUTE. This key should normally be implemented as a toggle such that the first press mutes the speaker and the second press restores the original volume. - |
| AKEYCODE_INFO |
- Info key. Common on TV remotes to show additional information related to what is currently being viewed. - |
| AKEYCODE_CHANNEL_UP |
- Channel up key. On TV remotes, increments the television channel. - |
| AKEYCODE_CHANNEL_DOWN |
- Channel down key. On TV remotes, decrements the television channel. - |
| AKEYCODE_ZOOM_IN |
- Zoom in key. - |
| AKEYCODE_ZOOM_OUT |
- Zoom out key. - |
| AKEYCODE_TV |
- TV key. On TV remotes, switches to viewing live TV. - |
| AKEYCODE_WINDOW |
- Window key. On TV remotes, toggles picture-in-picture mode or other windowing functions. - |
| AKEYCODE_GUIDE |
- Guide key. On TV remotes, shows a programming guide. - |
| AKEYCODE_DVR |
- DVR key. On some TV remotes, switches to a DVR mode for recorded shows. - |
| AKEYCODE_BOOKMARK |
- Bookmark key. On some TV remotes, bookmarks content or web pages. - |
| AKEYCODE_CAPTIONS |
- Toggle captions key. Switches the mode for closed-captioning text, for example during television shows. - |
| AKEYCODE_SETTINGS |
- Settings key. Starts the system settings activity. - |
| AKEYCODE_TV_POWER |
- TV power key. On TV remotes, toggles the power on a television screen. - |
| AKEYCODE_TV_INPUT |
- TV input key. On TV remotes, switches the input on a television screen. - |
| AKEYCODE_STB_POWER |
- Set-top-box power key. On TV remotes, toggles the power on an external Set-top-box. - |
| AKEYCODE_STB_INPUT |
- Set-top-box input key. On TV remotes, switches the input mode on an external Set-top-box. - |
| AKEYCODE_AVR_POWER |
- A/V Receiver power key. On TV remotes, toggles the power on an external A/V Receiver. - |
| AKEYCODE_AVR_INPUT |
- A/V Receiver input key. On TV remotes, switches the input mode on an external A/V Receiver. - |
| AKEYCODE_PROG_RED |
- Red "programmable" key. On TV remotes, acts as a contextual/programmable key. - |
| AKEYCODE_PROG_GREEN |
- Green "programmable" key. On TV remotes, actsas a contextual/programmable key. - |
| AKEYCODE_PROG_YELLOW |
- Yellow "programmable" key. On TV remotes, acts as a contextual/programmable key. - |
| AKEYCODE_PROG_BLUE |
- Blue "programmable" key. On TV remotes, acts as a contextual/programmable key. - |
| AKEYCODE_APP_SWITCH |
- App switch key. Should bring up the application switcher dialog. - |
| AKEYCODE_BUTTON_1 |
- Generic Game Pad Button #1. - |
| AKEYCODE_BUTTON_2 |
- Generic Game Pad Button #2. - |
| AKEYCODE_BUTTON_3 |
- Generic Game Pad Button #3. - |
| AKEYCODE_BUTTON_4 |
- Generic Game Pad Button #4. - |
| AKEYCODE_BUTTON_5 |
- Generic Game Pad Button #5. - |
| AKEYCODE_BUTTON_6 |
- Generic Game Pad Button #6. - |
| AKEYCODE_BUTTON_7 |
- Generic Game Pad Button #7. - |
| AKEYCODE_BUTTON_8 |
- Generic Game Pad Button #8. - |
| AKEYCODE_BUTTON_9 |
- Generic Game Pad Button #9. - |
| AKEYCODE_BUTTON_10 |
- Generic Game Pad Button #10. - |
| AKEYCODE_BUTTON_11 |
- Generic Game Pad Button #11. - |
| AKEYCODE_BUTTON_12 |
- Generic Game Pad Button #12. - |
| AKEYCODE_BUTTON_13 |
- Generic Game Pad Button #13. - |
| AKEYCODE_BUTTON_14 |
- Generic Game Pad Button #14. - |
| AKEYCODE_BUTTON_15 |
- Generic Game Pad Button #15. - |
| AKEYCODE_BUTTON_16 |
- Generic Game Pad Button #16. - |
| AKEYCODE_LANGUAGE_SWITCH |
- Language Switch key. Toggles the current input language such as switching between English and Japanese on a QWERTY keyboard. On some devices, the same function may be performed by pressing Shift+Spacebar. - |
| AKEYCODE_MANNER_MODE |
- Manner Mode key. Toggles silent or vibrate mode on and off to make the device behave more politely in certain settings such as on a crowded train. On some devices, the key may only operate when long-pressed. - |
| AKEYCODE_3D_MODE |
- 3D Mode key. Toggles the display between 2D and 3D mode. - |
| AKEYCODE_CONTACTS |
- Contacts special function key. Used to launch an address book application. - |
| AKEYCODE_CALENDAR |
- Calendar special function key. Used to launch a calendar application. - |
| AKEYCODE_MUSIC |
- Music special function key. Used to launch a music player application. - |
| AKEYCODE_CALCULATOR |
- Calculator special function key. Used to launch a calculator application. - |
| AKEYCODE_ZENKAKU_HANKAKU |
- Japanese full-width / half-width key. - |
| AKEYCODE_EISU |
- Japanese alphanumeric key. - |
| AKEYCODE_MUHENKAN |
- Japanese non-conversion key. - |
| AKEYCODE_HENKAN |
- Japanese conversion key. - |
| AKEYCODE_KATAKANA_HIRAGANA |
- Japanese katakana / hiragana key. - |
| AKEYCODE_YEN |
- Japanese Yen key. - |
| AKEYCODE_RO |
- Japanese Ro key. - |
| AKEYCODE_KANA |
- Japanese kana key. - |
| AKEYCODE_ASSIST |
- Assist key. Launches the global assist activity. Not delivered to applications. - |
| AKEYCODE_BRIGHTNESS_DOWN |
- Brightness Down key. Adjusts the screen brightness down. - |
| AKEYCODE_BRIGHTNESS_UP |
- Brightness Up key. Adjusts the screen brightness up. - |
| AKEYCODE_MEDIA_AUDIO_TRACK |
- Audio Track key. Switches the audio tracks. - |
| AKEYCODE_SLEEP |
- Sleep key. Puts the device to sleep. Behaves somewhat like AKEYCODE_POWER but it has no effect if the device is already asleep. - |
| AKEYCODE_WAKEUP |
- Wakeup key. Wakes up the device. Behaves somewhat like AKEYCODE_POWER but it has no effect if the device is already awake. - |
| AKEYCODE_PAIRING |
- Pairing key. Initiates peripheral pairing mode. Useful for pairing remote control devices or game controllers, especially if no other input mode is available. - |
| AKEYCODE_MEDIA_TOP_MENU |
- Media Top Menu key. Goes to the top of media menu. - |
| AKEYCODE_11 |
- '11' key. - |
| AKEYCODE_12 |
- '12' key. - |
| AKEYCODE_LAST_CHANNEL |
- Last Channel key. Goes to the last viewed channel. - |
| AKEYCODE_TV_DATA_SERVICE |
- TV data service key. Displays data services like weather, sports. - |
| AKEYCODE_VOICE_ASSIST |
- Voice Assist key. Launches the global voice assist activity. Not delivered to applications. - |
| AKEYCODE_TV_RADIO_SERVICE |
- Radio key. Toggles TV service / Radio service. - |
| AKEYCODE_TV_TELETEXT |
- Teletext key. Displays Teletext service. - |
| AKEYCODE_TV_NUMBER_ENTRY |
- Number entry key. Initiates to enter multi-digit channel nubmber when each digit key is assigned for selecting separate channel. Corresponds to Number Entry Mode (0x1D) of CEC User Control Code. - |
| AKEYCODE_TV_TERRESTRIAL_ANALOG |
- Analog Terrestrial key. Switches to analog terrestrial broadcast service. - |
| AKEYCODE_TV_TERRESTRIAL_DIGITAL |
- Digital Terrestrial key. Switches to digital terrestrial broadcast service. - |
| AKEYCODE_TV_SATELLITE |
- Satellite key. Switches to digital satellite broadcast service. - |
| AKEYCODE_TV_SATELLITE_BS |
- BS key. Switches to BS digital satellite broadcasting service available in Japan. - |
| AKEYCODE_TV_SATELLITE_CS |
- CS key. Switches to CS digital satellite broadcasting service available in Japan. - |
| AKEYCODE_TV_SATELLITE_SERVICE |
- BS/CS key. Toggles between BS and CS digital satellite services. - |
| AKEYCODE_TV_NETWORK |
- Toggle Network key. Toggles selecting broacast services. - |
| AKEYCODE_TV_ANTENNA_CABLE |
- Antenna/Cable key. Toggles broadcast input source between antenna and cable. - |
| AKEYCODE_TV_INPUT_HDMI_1 |
- HDMI #1 key. Switches to HDMI input #1. - |
| AKEYCODE_TV_INPUT_HDMI_2 |
- HDMI #2 key. Switches to HDMI input #2. - |
| AKEYCODE_TV_INPUT_HDMI_3 |
- HDMI #3 key. Switches to HDMI input #3. - |
| AKEYCODE_TV_INPUT_HDMI_4 |
- HDMI #4 key. Switches to HDMI input #4. - |
| AKEYCODE_TV_INPUT_COMPOSITE_1 |
- Composite #1 key. Switches to composite video input #1. - |
| AKEYCODE_TV_INPUT_COMPOSITE_2 |
- Composite #2 key. Switches to composite video input #2. - |
| AKEYCODE_TV_INPUT_COMPONENT_1 |
- Component #1 key. Switches to component video input #1. - |
| AKEYCODE_TV_INPUT_COMPONENT_2 |
- Component #2 key. Switches to component video input #2. - |
| AKEYCODE_TV_INPUT_VGA_1 |
- VGA #1 key. Switches to VGA (analog RGB) input #1. - |
| AKEYCODE_TV_AUDIO_DESCRIPTION |
- Audio description key. Toggles audio description off / on. - |
| AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP |
- Audio description mixing volume up key. Louden audio description volume as compared with normal audio volume. - |
| AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN |
- Audio description mixing volume down key. Lessen audio description volume as compared with normal audio volume. - |
| AKEYCODE_TV_ZOOM_MODE |
- Zoom mode key. Changes Zoom mode (Normal, Full, Zoom, Wide-zoom, etc.) - |
| AKEYCODE_TV_CONTENTS_MENU |
- Contents menu key. Goes to the title list. Corresponds to Contents Menu (0x0B) of CEC User Control Code - |
| AKEYCODE_TV_MEDIA_CONTEXT_MENU |
- Media context menu key. Goes to the context menu of media contents. Corresponds to Media Context-sensitive Menu (0x11) of CEC User Control Code. - |
| AKEYCODE_TV_TIMER_PROGRAMMING |
- Timer programming key. Goes to the timer recording menu. Corresponds to Timer Programming (0x54) of CEC User Control Code. - |
| AKEYCODE_HELP |
- Help key. - |
| anonymous enum | -
Key states (may be returned by queries about the current state of a particular key code, scan code or switch).
-| anonymous enum | -
Meta key / modifer state.
-| anonymous enum | -
| anonymous enum | -
Key event actions.
-| anonymous enum | -
Key event flags.
-| anonymous enum | -
Motion event actions
-| anonymous enum | -
Motion event flags.
-| int32_t AInputEvent_getDeviceId | -( | -const AInputEvent * | -event | ) | -- |
Get the id for the device that an input event came from.
-Input events can be generated by multiple different input devices. Use the input device id to obtain information about the input device that was responsible for generating a particular event.
-An input device id of 0 indicates that the event didn't come from a physical device; other numbers are arbitrary and you shouldn't depend on the values. Use the provided input device query API to obtain information about input devices.
- -| int32_t AInputEvent_getSource | -( | -const AInputEvent * | -event | ) | -- |
Get the input event source.
- -| int32_t AInputEvent_getType | -( | -const AInputEvent * | -event | ) | -- |
Input event accessors.
-Note that most functions can only be used on input events that are of a given type. Calling these functions on input events of other types will yield undefined behavior.Get the input event type.
- -| void AInputQueue_attachLooper | -( | -AInputQueue * | -queue, | -
| - | - | ALooper * | -looper, | -
| - | - | int | -ident, | -
| - | - | ALooper_callbackFunc | -callback, | -
| - | - | void * | -data | -
| - | ) | -- |
Add this input queue to a looper for processing. See ALooper_addFd() for information on the ident, callback, and data params.
- -| void AInputQueue_detachLooper | -( | -AInputQueue * | -queue | ) | -- |
Remove the input queue from the looper it is currently attached to.
- -| void AInputQueue_finishEvent | -( | -AInputQueue * | -queue, | -
| - | - | AInputEvent * | -event, | -
| - | - | int | -handled | -
| - | ) | -- |
Report that dispatching has finished with the given event. This must be called after receiving an event with AInputQueue_get_event().
- -| int32_t AInputQueue_getEvent | -( | -AInputQueue * | -queue, | -
| - | - | AInputEvent ** | -outEvent | -
| - | ) | -- |
Returns the next available event from the queue. Returns a negative value if no events are available or an error has occurred.
- -| int32_t AInputQueue_hasEvents | -( | -AInputQueue * | -queue | ) | -- |
Returns true if there are one or more events available in the input queue. Returns 1 if the queue has events; 0 if it does not have events; and a negative value if there is an error.
- -| int32_t AInputQueue_preDispatchEvent | -( | -AInputQueue * | -queue, | -
| - | - | AInputEvent * | -event | -
| - | ) | -- |
Sends the key for standard pre-dispatching – that is, possibly deliver it to the current IME to be consumed before the app. Returns 0 if it was not pre-dispatched, meaning you can process it right now. If non-zero is returned, you must abandon the current event processing and allow the event to appear again in the event queue (if it does not get consumed during pre-dispatching).
- -| int32_t AKeyEvent_getAction | -( | -const AInputEvent * | -key_event | ) | -- |
Get the key event action.
- -| int64_t AKeyEvent_getDownTime | -( | -const AInputEvent * | -key_event | ) | -- |
Get the time of the most recent key down event, in the java.lang.System.nanoTime() time base. If this is a down event, this will be the same as eventTime. Note that when chording keys, this value is the down time of the most recently pressed key, which may not be the same physical key of this event.
- -| int64_t AKeyEvent_getEventTime | -( | -const AInputEvent * | -key_event | ) | -- |
Get the time this event occurred, in the java.lang.System.nanoTime() time base.
- -| int32_t AKeyEvent_getFlags | -( | -const AInputEvent * | -key_event | ) | -- |
Get the key event flags.
- -| int32_t AKeyEvent_getKeyCode | -( | -const AInputEvent * | -key_event | ) | -- |
Get the key code of the key event. This is the physical key that was pressed, not the Unicode character.
- -| int32_t AKeyEvent_getMetaState | -( | -const AInputEvent * | -key_event | ) | -- |
Get the meta key state.
- -| int32_t AKeyEvent_getRepeatCount | -( | -const AInputEvent * | -key_event | ) | -- |
Get the repeat count of the event. For both key up an key down events, this is the number of times the key has repeated with the first down starting at 0 and counting up from there. For multiple key events, this is the number of down/up pairs that have occurred.
- -| int32_t AKeyEvent_getScanCode | -( | -const AInputEvent * | -key_event | ) | -- |
Get the hardware key id of this key event. These values are not reliable and vary from device to device.
- -| int32_t AMotionEvent_getAction | -( | -const AInputEvent * | -motion_event | ) | -- |
Get the combined motion event action code and pointer index.
- -| float AMotionEvent_getAxisValue | -( | -const AInputEvent * | -motion_event, | -
| - | - | int32_t | -axis, | -
| - | - | size_t | -pointer_index | -
| - | ) | -- |
Get the value of the request axis for the given pointer index.
- -| int32_t AMotionEvent_getButtonState | -( | -const AInputEvent * | -motion_event | ) | -- |
Get the button state of all buttons that are pressed.
- -| int64_t AMotionEvent_getDownTime | -( | -const AInputEvent * | -motion_event | ) | -- |
Get the time when the user originally pressed down to start a stream of position events, in the java.lang.System.nanoTime() time base.
- -| int32_t AMotionEvent_getEdgeFlags | -( | -const AInputEvent * | -motion_event | ) | -- |
Get a bitfield indicating which edges, if any, were touched by this motion event. For touch events, clients can use this to determine if the user's finger was touching the edge of the display.
- -| int64_t AMotionEvent_getEventTime | -( | -const AInputEvent * | -motion_event | ) | -- |
Get the time when this specific event was generated, in the java.lang.System.nanoTime() time base.
- -| int32_t AMotionEvent_getFlags | -( | -const AInputEvent * | -motion_event | ) | -- |
Get the motion event flags.
- -| float AMotionEvent_getHistoricalAxisValue | -( | -const AInputEvent * | -motion_event, | -
| - | - | int32_t | -axis, | -
| - | - | size_t | -pointer_index, | -
| - | - | size_t | -history_index | -
| - | ) | -- |
Get the historical value of the request axis for the given pointer index that occurred between this event and the previous motion event.
- -| int64_t AMotionEvent_getHistoricalEventTime | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -history_index | -
| - | ) | -- |
Get the time that a historical movement occurred between this event and the previous event, in the java.lang.System.nanoTime() time base.
- -| float AMotionEvent_getHistoricalOrientation | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index, | -
| - | - | size_t | -history_index | -
| - | ) | -- |
Get the historical orientation of the touch area and tool area in radians clockwise from vertical for the given pointer index that occurred between this event and the previous motion event. An angle of 0 degrees indicates that the major axis of contact is oriented upwards, is perfectly circular or is of unknown orientation. A positive angle indicates that the major axis of contact is oriented to the right. A negative angle indicates that the major axis of contact is oriented to the left. The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians (finger pointing fully right).
- -| float AMotionEvent_getHistoricalPressure | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index, | -
| - | - | size_t | -history_index | -
| - | ) | -- |
Get the historical pressure of this event for the given pointer index that occurred between this event and the previous motion event. The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), although values higher than 1 may be generated depending on the calibration of the input device.
- -| float AMotionEvent_getHistoricalRawX | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index, | -
| - | - | size_t | -history_index | -
| - | ) | -- |
Get the historical raw X coordinate of this event for the given pointer index that occurred between this event and the previous motion event. For touch events on the screen, this is the original location of the event on the screen, before it had been adjusted for the containing window and views. Whole numbers are pixels; the value may have a fraction for input devices that are sub-pixel precise.
- -| float AMotionEvent_getHistoricalRawY | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index, | -
| - | - | size_t | -history_index | -
| - | ) | -- |
Get the historical raw Y coordinate of this event for the given pointer index that occurred between this event and the previous motion event. For touch events on the screen, this is the original location of the event on the screen, before it had been adjusted for the containing window and views. Whole numbers are pixels; the value may have a fraction for input devices that are sub-pixel precise.
- -| float AMotionEvent_getHistoricalSize | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index, | -
| - | - | size_t | -history_index | -
| - | ) | -- |
Get the current scaled value of the approximate size for the given pointer index that occurred between this event and the previous motion event. This represents some approximation of the area of the screen being pressed; the actual value in pixels corresponding to the touch is normalized with the device specific range of values and scaled to a value between 0 and 1. The value of size can be used to determine fat touch events.
- -| float AMotionEvent_getHistoricalToolMajor | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index, | -
| - | - | size_t | -history_index | -
| - | ) | -- |
Get the historical length of the major axis of an ellipse that describes the size of the approaching tool for the given pointer index that occurred between this event and the previous motion event. The tool area represents the estimated size of the finger or pen that is touching the device independent of its actual touch area at the point of contact.
- -| float AMotionEvent_getHistoricalToolMinor | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index, | -
| - | - | size_t | -history_index | -
| - | ) | -- |
Get the historical length of the minor axis of an ellipse that describes the size of the approaching tool for the given pointer index that occurred between this event and the previous motion event. The tool area represents the estimated size of the finger or pen that is touching the device independent of its actual touch area at the point of contact.
- -| float AMotionEvent_getHistoricalTouchMajor | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index, | -
| - | - | size_t | -history_index | -
| - | ) | -- |
Get the historical length of the major axis of an ellipse that describes the touch area at the point of contact for the given pointer index that occurred between this event and the previous motion event.
- -| float AMotionEvent_getHistoricalTouchMinor | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index, | -
| - | - | size_t | -history_index | -
| - | ) | -- |
Get the historical length of the minor axis of an ellipse that describes the touch area at the point of contact for the given pointer index that occurred between this event and the previous motion event.
- -| float AMotionEvent_getHistoricalX | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index, | -
| - | - | size_t | -history_index | -
| - | ) | -- |
Get the historical X coordinate of this event for the given pointer index that occurred between this event and the previous motion event. Whole numbers are pixels; the value may have a fraction for input devices that are sub-pixel precise.
- -| float AMotionEvent_getHistoricalY | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index, | -
| - | - | size_t | -history_index | -
| - | ) | -- |
Get the historical Y coordinate of this event for the given pointer index that occurred between this event and the previous motion event. Whole numbers are pixels; the value may have a fraction for input devices that are sub-pixel precise.
- -| size_t AMotionEvent_getHistorySize | -( | -const AInputEvent * | -motion_event | ) | -- |
Get the number of historical points in this event. These are movements that have occurred between this event and the previous event. This only applies to AMOTION_EVENT_ACTION_MOVE events – all other actions will have a size of 0. Historical samples are indexed from oldest to newest.
- -| int32_t AMotionEvent_getMetaState | -( | -const AInputEvent * | -motion_event | ) | -- |
Get the state of any meta / modifier keys that were in effect when the event was generated.
- -| float AMotionEvent_getOrientation | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index | -
| - | ) | -- |
Get the current orientation of the touch area and tool area in radians clockwise from vertical for the given pointer index. An angle of 0 degrees indicates that the major axis of contact is oriented upwards, is perfectly circular or is of unknown orientation. A positive angle indicates that the major axis of contact is oriented to the right. A negative angle indicates that the major axis of contact is oriented to the left. The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians (finger pointing fully right).
- -| size_t AMotionEvent_getPointerCount | -( | -const AInputEvent * | -motion_event | ) | -- |
Get the number of pointers of data contained in this event. Always >= 1.
- -| int32_t AMotionEvent_getPointerId | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index | -
| - | ) | -- |
Get the pointer identifier associated with a particular pointer data index in this event. The identifier tells you the actual pointer number associated with the data, accounting for individual pointers going up and down since the start of the current gesture.
- -| float AMotionEvent_getPressure | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index | -
| - | ) | -- |
Get the current pressure of this event for the given pointer index. The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), although values higher than 1 may be generated depending on the calibration of the input device.
- -| float AMotionEvent_getRawX | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index | -
| - | ) | -- |
Get the original raw X coordinate of this event. For touch events on the screen, this is the original location of the event on the screen, before it had been adjusted for the containing window and views.
- -| float AMotionEvent_getRawY | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index | -
| - | ) | -- |
Get the original raw X coordinate of this event. For touch events on the screen, this is the original location of the event on the screen, before it had been adjusted for the containing window and views.
- -| float AMotionEvent_getSize | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index | -
| - | ) | -- |
Get the current scaled value of the approximate size for the given pointer index. This represents some approximation of the area of the screen being pressed; the actual value in pixels corresponding to the touch is normalized with the device specific range of values and scaled to a value between 0 and 1. The value of size can be used to determine fat touch events.
- -| float AMotionEvent_getToolMajor | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index | -
| - | ) | -- |
Get the current length of the major axis of an ellipse that describes the size of the approaching tool for the given pointer index. The tool area represents the estimated size of the finger or pen that is touching the device independent of its actual touch area at the point of contact.
- -| float AMotionEvent_getToolMinor | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index | -
| - | ) | -- |
Get the current length of the minor axis of an ellipse that describes the size of the approaching tool for the given pointer index. The tool area represents the estimated size of the finger or pen that is touching the device independent of its actual touch area at the point of contact.
- -| int32_t AMotionEvent_getToolType | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index | -
| - | ) | -- |
Get the tool type of a pointer for the given pointer index. The tool type indicates the type of tool used to make contact such as a finger or stylus, if known.
- -| float AMotionEvent_getTouchMajor | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index | -
| - | ) | -- |
Get the current length of the major axis of an ellipse that describes the touch area at the point of contact for the given pointer index.
- -| float AMotionEvent_getTouchMinor | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index | -
| - | ) | -- |
Get the current length of the minor axis of an ellipse that describes the touch area at the point of contact for the given pointer index.
- -| float AMotionEvent_getX | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index | -
| - | ) | -- |
Get the current X coordinate of this event for the given pointer index. Whole numbers are pixels; the value may have a fraction for input devices that are sub-pixel precise.
- -| float AMotionEvent_getXOffset | -( | -const AInputEvent * | -motion_event | ) | -- |
Get the X coordinate offset. For touch events on the screen, this is the delta that was added to the raw screen coordinates to adjust for the absolute position of the containing windows and views.
- -| float AMotionEvent_getXPrecision | -( | -const AInputEvent * | -motion_event | ) | -- |
Get the precision of the X coordinates being reported. You can multiply this number with an X coordinate sample to find the actual hardware value of the X coordinate.
- -| float AMotionEvent_getY | -( | -const AInputEvent * | -motion_event, | -
| - | - | size_t | -pointer_index | -
| - | ) | -- |
Get the current Y coordinate of this event for the given pointer index. Whole numbers are pixels; the value may have a fraction for input devices that are sub-pixel precise.
- -| float AMotionEvent_getYOffset | -( | -const AInputEvent * | -motion_event | ) | -- |
Get the Y coordinate offset. For touch events on the screen, this is the delta that was added to the raw screen coordinates to adjust for the absolute position of the containing windows and views.
- -| float AMotionEvent_getYPrecision | -( | -const AInputEvent * | -motion_event | ) | -- |
Get the precision of the Y coordinates being reported. You can multiply this number with a Y coordinate sample to find the actual hardware value of the Y coordinate.
- --Files | |
| file | looper.h |
-Typedefs | |
| typedef struct ALooper | ALooper |
| typedef int(* | ALooper_callbackFunc )(int fd, int events, void *data) |
-Enumerations | |
| enum | { ALOOPER_PREPARE_ALLOW_NON_CALLBACKS = 1<<0 - } |
| enum | { ALOOPER_POLL_WAKE = -1, -ALOOPER_POLL_CALLBACK = -2, -ALOOPER_POLL_TIMEOUT = -3, -ALOOPER_POLL_ERROR = -4 - } |
| enum | { - ALOOPER_EVENT_INPUT = 1 << 0, -ALOOPER_EVENT_OUTPUT = 1 << 1, -ALOOPER_EVENT_ERROR = 1 << 2, -ALOOPER_EVENT_HANGUP = 1 << 3, - - ALOOPER_EVENT_INVALID = 1 << 4 - - } |
-Functions | |
| ALooper * | ALooper_forThread () |
| ALooper * | ALooper_prepare (int opts) |
| void | ALooper_acquire (ALooper *looper) |
| void | ALooper_release (ALooper *looper) |
| int | ALooper_pollOnce (int timeoutMillis, int *outFd, int *outEvents, void **outData) |
| int | ALooper_pollAll (int timeoutMillis, int *outFd, int *outEvents, void **outData) |
| void | ALooper_wake (ALooper *looper) |
| int | ALooper_addFd (ALooper *looper, int fd, int ident, int events, ALooper_callbackFunc callback, void *data) |
| int | ALooper_removeFd (ALooper *looper, int fd) |
ALooper
-A looper is the state tracking an event loop for a thread. Loopers do not define event structures or other such things; rather they are a lower-level facility to attach one or more discrete objects listening for an event. An "event" here is simply data available on a file descriptor: each attached object has an associated file descriptor, and waiting for "events" means (internally) polling on all of these file descriptors until one or more of them have data available.
-A thread can have only one ALooper associated with it.
- -| typedef int(* ALooper_callbackFunc)(int fd, int events, void *data) | -
For callback-based event loops, this is the prototype of the function that is called when a file descriptor event occurs. It is given the file descriptor it is associated with, a bitmask of the poll events that were triggered (typically ALOOPER_EVENT_INPUT), and the data pointer that was originally supplied.
-Implementations should return 1 to continue receiving callbacks, or 0 to have this file descriptor and callback unregistered from the looper.
- -| anonymous enum | -
Option for for ALooper_prepare().
-| Enumerator | |
|---|---|
| ALOOPER_PREPARE_ALLOW_NON_CALLBACKS |
- This looper will accept calls to ALooper_addFd() that do not have a callback (that is provide NULL for the callback). In this case the caller of ALooper_pollOnce() or ALooper_pollAll() MUST check the return from these functions to discover when data is available on such fds and process it. - |
| anonymous enum | -
Result from ALooper_pollOnce() and ALooper_pollAll().
-| Enumerator | |
|---|---|
| ALOOPER_POLL_WAKE |
- The poll was awoken using wake() before the timeout expired and no callbacks were executed and no other file descriptors were ready. - |
| ALOOPER_POLL_CALLBACK |
- Result from ALooper_pollOnce() and ALooper_pollAll(): One or more callbacks were executed. - |
| ALOOPER_POLL_TIMEOUT |
- Result from ALooper_pollOnce() and ALooper_pollAll(): The timeout expired. - |
| ALOOPER_POLL_ERROR |
- Result from ALooper_pollOnce() and ALooper_pollAll(): An error occurred. - |
| anonymous enum | -
Flags for file descriptor events that a looper can monitor.
-These flag bits can be combined to monitor multiple events at once.
-| void ALooper_acquire | -( | -ALooper * | -looper | ) | -- |
Acquire a reference on the given ALooper object. This prevents the object from being deleted until the reference is removed. This is only needed to safely hand an ALooper from one thread to another.
- -| int ALooper_addFd | -( | -ALooper * | -looper, | -
| - | - | int | -fd, | -
| - | - | int | -ident, | -
| - | - | int | -events, | -
| - | - | ALooper_callbackFunc | -callback, | -
| - | - | void * | -data | -
| - | ) | -- |
Adds a new file descriptor to be polled by the looper. If the same file descriptor was previously added, it is replaced.
-"fd" is the file descriptor to be added. "ident" is an identifier for this event, which is returned from ALooper_pollOnce(). The identifier must be >= 0, or ALOOPER_POLL_CALLBACK if providing a non-NULL callback. "events" are the poll events to wake up on. Typically this is ALOOPER_EVENT_INPUT. "callback" is the function to call when there is an event on the file descriptor. "data" is a private data pointer to supply to the callback.
-There are two main uses of this function:
-(1) If "callback" is non-NULL, then this function will be called when there is data on the file descriptor. It should execute any events it has pending, appropriately reading from the file descriptor. The 'ident' is ignored in this case.
-(2) If "callback" is NULL, the 'ident' will be returned by ALooper_pollOnce when its file descriptor has data available, requiring the caller to take care of processing it.
-Returns 1 if the file descriptor was added or -1 if an error occurred.
-This method can be called on any thread. This method may block briefly if it needs to wake the poll.
- -| ALooper* ALooper_forThread | -( | -) | -- |
Returns the looper associated with the calling thread, or NULL if there is not one.
- -| int ALooper_pollAll | -( | -int | -timeoutMillis, | -
| - | - | int * | -outFd, | -
| - | - | int * | -outEvents, | -
| - | - | void ** | -outData | -
| - | ) | -- |
Like ALooper_pollOnce(), but performs all pending callbacks until all data has been consumed or a file descriptor is available with no callback. This function will never return ALOOPER_POLL_CALLBACK.
- -| int ALooper_pollOnce | -( | -int | -timeoutMillis, | -
| - | - | int * | -outFd, | -
| - | - | int * | -outEvents, | -
| - | - | void ** | -outData | -
| - | ) | -- |
Waits for events to be available, with optional timeout in milliseconds. Invokes callbacks for all file descriptors on which an event occurred.
-If the timeout is zero, returns immediately without blocking. If the timeout is negative, waits indefinitely until an event appears.
-Returns ALOOPER_POLL_WAKE if the poll was awoken using wake() before the timeout expired and no callbacks were invoked and no other file descriptors were ready.
-Returns ALOOPER_POLL_CALLBACK if one or more callbacks were invoked.
-Returns ALOOPER_POLL_TIMEOUT if there was no data before the given timeout expired.
-Returns ALOOPER_POLL_ERROR if an error occurred.
-Returns a value >= 0 containing an identifier (the same identifier ident passed to ALooper_addFd()) if its file descriptor has data and it has no callback function (requiring the caller here to handle it). In this (and only this) case outFd, outEvents and outData will contain the poll events and data associated with the fd, otherwise they will be set to NULL.
This method does not return until it has finished invoking the appropriate callbacks for all file descriptors that were signalled.
- -| ALooper* ALooper_prepare | -( | -int | -opts | ) | -- |
Prepares a looper associated with the calling thread, and returns it. If the thread already has a looper, it is returned. Otherwise, a new one is created, associated with the thread, and returned.
-The opts may be ALOOPER_PREPARE_ALLOW_NON_CALLBACKS or 0.
- -| void ALooper_release | -( | -ALooper * | -looper | ) | -- |
Remove a reference that was previously acquired with ALooper_acquire().
- -| int ALooper_removeFd | -( | -ALooper * | -looper, | -
| - | - | int | -fd | -
| - | ) | -- |
Removes a previously added file descriptor from the looper.
-When this method returns, it is safe to close the file descriptor since the looper will no longer have a reference to it. However, it is possible for the callback to already be running or for it to run one last time if the file descriptor was already signalled. Calling code is responsible for ensuring that this case is safely handled. For example, if the callback takes care of removing itself during its own execution either by returning 0 or by calling this method, then it can be guaranteed to not be invoked again at any later time unless registered anew.
-Returns 1 if the file descriptor was removed, 0 if none was previously registered or -1 if an error occurred.
-This method can be called on any thread. This method may block briefly if it needs to wake the poll.
- -| void ALooper_wake | -( | -ALooper * | -looper | ) | -- |
Wakes the poll asynchronously.
-This method can be called on any thread. This method returns immediately.
- --Files | |
| file | native_activity.h |
| file | native_window.h |
| file | native_window_jni.h |
| file | rect.h |
| file | window.h |
-Data Structures | |
| struct | ANativeActivity |
| struct | ANativeActivityCallbacks |
| struct | ANativeWindow_Buffer |
| struct | ARect |
-Typedefs | |
| typedef struct ANativeActivity | ANativeActivity |
| typedef struct -ANativeActivityCallbacks | ANativeActivityCallbacks |
| typedef void | ANativeActivity_createFunc (ANativeActivity *activity, void *savedState, size_t savedStateSize) |
| typedef struct ANativeWindow | ANativeWindow |
| typedef struct ANativeWindow_Buffer | ANativeWindow_Buffer |
| typedef struct ARect | ARect |
-Variables | |
| ANativeActivity_createFunc | ANativeActivity_onCreate |
| typedef struct ANativeActivity ANativeActivity | -
This structure defines the native side of an android.app.NativeActivity. It is created by the framework, and handed to the application's native code as it is being launched.
- -| typedef void ANativeActivity_createFunc(ANativeActivity *activity, void *savedState, size_t savedStateSize) | -
This is the function that must be in the native code to instantiate the application's native activity. It is called with the activity instance (see above); if the code is being instantiated from a previously saved instance, the savedState will be non-NULL and point to the saved data. You must make any copy of this data you need – it will be released after you return from this function.
- -| typedef struct ANativeActivityCallbacks ANativeActivityCallbacks | -
These are the callbacks the framework makes into a native application. All of these callbacks happen on the main thread of the application. By default, all callbacks are NULL; set to a pointer to your own function to have it called.
- -| typedef struct ANativeWindow ANativeWindow | -
ANativeWindow is opaque type that provides access to a native window.
-A pointer can be obtained using ANativeWindow_fromSurface().
- -| typedef struct ANativeWindow_Buffer ANativeWindow_Buffer | -
ANativeWindow is a struct that represents a windows buffer.
-A pointer can be obtained using ANativeWindow_lock().
- -ARect is a struct that represents a rectangular window area.
-It is used with ANativeActivityCallbacks::onContentRectChanged event callback and ANativeWindow_lock() function.
- -| anonymous enum | -
Flags for ANativeActivity_showSoftInput; see the Java InputMethodManager API for documentation.
-| anonymous enum | -
Flags for ANativeActivity_hideSoftInput; see the Java InputMethodManager API for documentation.
-| Enumerator | |
|---|---|
| ANATIVEACTIVITY_HIDE_SOFT_INPUT_IMPLICIT_ONLY |
- The soft input window should only be hidden if it was not explicitly shown by the user. - |
| ANATIVEACTIVITY_HIDE_SOFT_INPUT_NOT_ALWAYS |
- The soft input window should normally be hidden, unless it was originally shown with ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED. - |
| anonymous enum | -
| anonymous enum | -
Window flags, as per the Java API at android.view.WindowManager.LayoutParams.
-| Enumerator | |
|---|---|
| AWINDOW_FLAG_ALLOW_LOCK_WHILE_SCREEN_ON |
- As long as this window is visible to the user, allow the lock screen to activate while the screen is on. This can be used independently, or in combination with AWINDOW_FLAG_KEEP_SCREEN_ON and/or AWINDOW_FLAG_SHOW_WHEN_LOCKED - |
| AWINDOW_FLAG_DIM_BEHIND |
- Everything behind this window will be dimmed. - |
| AWINDOW_FLAG_BLUR_BEHIND |
- Blur everything behind this window. -
|
| AWINDOW_FLAG_NOT_FOCUSABLE |
- This window won't ever get key input focus, so the user can not send key or other button events to it. Those will instead go to whatever focusable window is behind it. This flag will also enable AWINDOW_FLAG_NOT_TOUCH_MODAL whether or not that is explicitly set. -Setting this flag also implies that the window will not need to interact with a soft input method, so it will be Z-ordered and positioned independently of any active input method (typically this means it gets Z-ordered on top of the input method, so it can use the full screen for its content and cover the input method if needed. You can use AWINDOW_FLAG_ALT_FOCUSABLE_IM to modify this behavior. - |
| AWINDOW_FLAG_NOT_TOUCHABLE |
- this window can never receive touch events. - |
| AWINDOW_FLAG_NOT_TOUCH_MODAL |
- Even when this window is focusable (its AWINDOW_FLAG_NOT_FOCUSABLE is not set), allow any pointer events outside of the window to be sent to the windows behind it. Otherwise it will consume all pointer events itself, regardless of whether they are inside of the window. - |
| AWINDOW_FLAG_TOUCHABLE_WHEN_WAKING |
- When set, if the device is asleep when the touch screen is pressed, you will receive this first touch event. Usually the first touch event is consumed by the system since the user can not see what they are pressing on. -
|
| AWINDOW_FLAG_KEEP_SCREEN_ON |
- As long as this window is visible to the user, keep the device's screen turned on and bright. - |
| AWINDOW_FLAG_LAYOUT_IN_SCREEN |
- Place the window within the entire screen, ignoring decorations around the border (such as the status bar). The window must correctly position its contents to take the screen decoration into account. - |
| AWINDOW_FLAG_LAYOUT_NO_LIMITS |
- allow window to extend outside of the screen. - |
| AWINDOW_FLAG_FULLSCREEN |
- Hide all screen decorations (such as the status bar) while this window is displayed. This allows the window to use the entire display space for itself – the status bar will be hidden when an app window with this flag set is on the top layer. A fullscreen window will ignore a value of AWINDOW_SOFT_INPUT_ADJUST_RESIZE; the window will stay fullscreen and will not resize. - |
| AWINDOW_FLAG_FORCE_NOT_FULLSCREEN |
- Override AWINDOW_FLAG_FULLSCREEN and force the screen decorations (such as the status bar) to be shown. - |
| AWINDOW_FLAG_DITHER |
- Turn on dithering when compositing this window to the screen. -
|
| AWINDOW_FLAG_SECURE |
- Treat the content of the window as secure, preventing it from appearing in screenshots or from being viewed on non-secure displays. - |
| AWINDOW_FLAG_SCALED |
- A special mode where the layout parameters are used to perform scaling of the surface when it is composited to the screen. - |
| AWINDOW_FLAG_IGNORE_CHEEK_PRESSES |
- Intended for windows that will often be used when the user is holding the screen against their face, it will aggressively filter the event stream to prevent unintended presses in this situation that may not be desired for a particular window, when such an event stream is detected, the application will receive a AMOTION_EVENT_ACTION_CANCEL to indicate this so applications can handle this accordingly by taking no action on the event until the finger is released. - |
| AWINDOW_FLAG_LAYOUT_INSET_DECOR |
- A special option only for use in combination with AWINDOW_FLAG_LAYOUT_IN_SCREEN. When requesting layout in the screen your window may appear on top of or behind screen decorations such as the status bar. By also including this flag, the window manager will report the inset rectangle needed to ensure your content is not covered by screen decorations. - |
| AWINDOW_FLAG_ALT_FOCUSABLE_IM |
- Invert the state of AWINDOW_FLAG_NOT_FOCUSABLE with respect to how this window interacts with the current method. That is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the window will behave as if it needs to interact with the input method and thus be placed behind/away from it; if AWINDOW_FLAG_NOT_FOCUSABLE is not set and this flag is set, then the window will behave as if it doesn't need to interact with the input method and can be placed to use more space and cover the input method. - |
| AWINDOW_FLAG_WATCH_OUTSIDE_TOUCH |
- If you have set AWINDOW_FLAG_NOT_TOUCH_MODAL, you can set this flag to receive a single special MotionEvent with the action AMOTION_EVENT_ACTION_OUTSIDE for touches that occur outside of your window. Note that you will not receive the full down/move/up gesture, only the location of the first down as an AMOTION_EVENT_ACTION_OUTSIDE. - |
| AWINDOW_FLAG_SHOW_WHEN_LOCKED |
- Special flag to let windows be shown when the screen is locked. This will let application windows take precedence over key guard or any other lock screens. Can be used with AWINDOW_FLAG_KEEP_SCREEN_ON to turn screen on and display windows directly before showing the key guard window. Can be used with AWINDOW_FLAG_DISMISS_KEYGUARD to automatically fully dismisss non-secure keyguards. This flag only applies to the top-most full-screen window. - |
| AWINDOW_FLAG_SHOW_WALLPAPER |
- Ask that the system wallpaper be shown behind your window. The window surface must be translucent to be able to actually see the wallpaper behind it; this flag just ensures that the wallpaper surface will be there if this window actually has translucent regions. - |
| AWINDOW_FLAG_TURN_SCREEN_ON |
- When set as a window is being added or made visible, once the window has been shown then the system will poke the power manager's user activity (as if the user had woken up the device) to turn the screen on. - |
| AWINDOW_FLAG_DISMISS_KEYGUARD |
- When set the window will cause the keyguard to be dismissed, only if it is not a secure lock keyguard. Because such a keyguard is not needed for security, it will never re-appear if the user navigates to another window (in contrast to AWINDOW_FLAG_SHOW_WHEN_LOCKED, which will only temporarily hide both secure and non-secure keyguards but ensure they reappear when the user moves to another UI that doesn't hide them). If the keyguard is currently active and is secure (requires an unlock pattern) than the user will still need to confirm it before seeing this window, unless AWINDOW_FLAG_SHOW_WHEN_LOCKED has also been set. - |
| void ANativeActivity_finish | -( | -ANativeActivity * | -activity | ) | -- |
Finish the given activity. Its finish() method will be called, causing it to be stopped and destroyed. Note that this method can be called from any thread; it will send a message to the main thread of the process where the Java finish call will take place.
- -| void ANativeActivity_hideSoftInput | -( | -ANativeActivity * | -activity, | -
| - | - | uint32_t | -flags | -
| - | ) | -- |
Hide the IME while in the given activity. Calls InputMethodManager.hideSoftInput() for the given activity. Note that this method can be called from any thread; it will send a message to the main thread of the process where the Java finish call will take place.
- -| void ANativeActivity_setWindowFlags | -( | -ANativeActivity * | -activity, | -
| - | - | uint32_t | -addFlags, | -
| - | - | uint32_t | -removeFlags | -
| - | ) | -- |
Change the window flags of the given activity. Calls getWindow().setFlags() of the given activity. Note that this method can be called from any thread; it will send a message to the main thread of the process where the Java finish call will take place. See window.h for flag constants.
- -| void ANativeActivity_setWindowFormat | -( | -ANativeActivity * | -activity, | -
| - | - | int32_t | -format | -
| - | ) | -- |
Change the window format of the given activity. Calls getWindow().setFormat() of the given activity. Note that this method can be called from any thread; it will send a message to the main thread of the process where the Java finish call will take place.
- -| void ANativeActivity_showSoftInput | -( | -ANativeActivity * | -activity, | -
| - | - | uint32_t | -flags | -
| - | ) | -- |
Show the IME while in the given activity. Calls InputMethodManager.showSoftInput() for the given activity. Note that this method can be called from any thread; it will send a message to the main thread of the process where the Java finish call will take place.
- -| void ANativeWindow_acquire | -( | -ANativeWindow * | -window | ) | -- |
Acquire a reference on the given ANativeWindow object. This prevents the object from being deleted until the reference is removed.
- -| ANativeWindow* ANativeWindow_fromSurface | -( | -JNIEnv * | -env, | -
| - | - | jobject | -surface | -
| - | ) | -- |
Return the ANativeWindow associated with a Java Surface object, for interacting with it through native code. This acquires a reference on the ANativeWindow that is returned; be sure to use ANativeWindow_release() when done with it so that it doesn't leak.
- -| int32_t ANativeWindow_getFormat | -( | -ANativeWindow * | -window | ) | -- |
Return the current pixel format of the window surface. Returns a negative value on error.
- -| int32_t ANativeWindow_getHeight | -( | -ANativeWindow * | -window | ) | -- |
Return the current height in pixels of the window surface. Returns a negative value on error.
- -| int32_t ANativeWindow_getWidth | -( | -ANativeWindow * | -window | ) | -- |
Return the current width in pixels of the window surface. Returns a negative value on error.
- -| int32_t ANativeWindow_lock | -( | -ANativeWindow * | -window, | -
| - | - | ANativeWindow_Buffer * | -outBuffer, | -
| - | - | ARect * | -inOutDirtyBounds | -
| - | ) | -- |
Lock the window's next drawing surface for writing. inOutDirtyBounds is used as an in/out parameter, upon entering the function, it contains the dirty region, that is, the region the caller intends to redraw. When the function returns, inOutDirtyBounds is updated with the actual area the caller needs to redraw – this region is often extended by ANativeWindow_lock.
- -| void ANativeWindow_release | -( | -ANativeWindow * | -window | ) | -- |
Remove a reference that was previously acquired with ANativeWindow_acquire().
- -| int32_t ANativeWindow_setBuffersGeometry | -( | -ANativeWindow * | -window, | -
| - | - | int32_t | -width, | -
| - | - | int32_t | -height, | -
| - | - | int32_t | -format | -
| - | ) | -- |
Change the format and size of the window buffers.
-The width and height control the number of pixels in the buffers, not the dimensions of the window on screen. If these are different than the window's physical size, then it buffer will be scaled to match that size when compositing it to the screen.
-For all of these parameters, if 0 is supplied then the window's base value will come back in force.
-width and height must be either both zero or both non-zero.
- -| int32_t ANativeWindow_unlockAndPost | -( | -ANativeWindow * | -window | ) | -- |
Unlock the window's drawing surface after previously locking it, posting the new buffer to the display.
- -| ANativeActivity_createFunc ANativeActivity_onCreate | -
The name of the function that NativeInstance looks for when launching its native code. This is the default function that is used, you can specify "android.app.func_name" string meta-data in your manifest to use a different function.
- --Files | |
| file | sensor.h |
-Data Structures | |
| struct | ASensorVector |
| struct | AMetaDataEvent |
| struct | AUncalibratedEvent |
| struct | AHeartRateEvent |
| struct | ASensorEvent |
-Macros | |
| #define | ASENSOR_STANDARD_GRAVITY (9.80665f) |
| #define | ASENSOR_MAGNETIC_FIELD_EARTH_MAX (60.0f) |
| #define | ASENSOR_MAGNETIC_FIELD_EARTH_MIN (30.0f) |
-Typedefs | |
| typedef struct ASensorVector | ASensorVector |
| typedef struct AMetaDataEvent | AMetaDataEvent |
| typedef struct AUncalibratedEvent | AUncalibratedEvent |
| typedef struct AHeartRateEvent | AHeartRateEvent |
| typedef struct ASensorEvent | ASensorEvent |
| typedef struct ASensorManager | ASensorManager |
| typedef struct ASensorEventQueue | ASensorEventQueue |
| typedef struct ASensor | ASensor |
| typedef ASensor const * | ASensorRef |
| typedef ASensorRef const * | ASensorList |
-Enumerations | |
| enum | { - ASENSOR_TYPE_ACCELEROMETER = 1, -ASENSOR_TYPE_MAGNETIC_FIELD = 2, -ASENSOR_TYPE_GYROSCOPE = 4, -ASENSOR_TYPE_LIGHT = 5, - - ASENSOR_TYPE_PROXIMITY = 8 - - } |
| enum | { - ASENSOR_STATUS_NO_CONTACT = -1, -ASENSOR_STATUS_UNRELIABLE = 0, -ASENSOR_STATUS_ACCURACY_LOW = 1, -ASENSOR_STATUS_ACCURACY_MEDIUM = 2, - - ASENSOR_STATUS_ACCURACY_HIGH = 3 - - } |
| enum | { AREPORTING_MODE_CONTINUOUS = 0, -AREPORTING_MODE_ON_CHANGE = 1, -AREPORTING_MODE_ONE_SHOT = 2, -AREPORTING_MODE_SPECIAL_TRIGGER = 3 - } |
| #define ASENSOR_MAGNETIC_FIELD_EARTH_MAX (60.0f) | -
Maximum magnetic field on Earth's surface in uT
- -| #define ASENSOR_MAGNETIC_FIELD_EARTH_MIN (30.0f) | -
Minimum magnetic field on Earth's surface in uT
- -| #define ASENSOR_STANDARD_GRAVITY (9.80665f) | -
Earth's gravity in m/s^2
- -| typedef struct AHeartRateEvent AHeartRateEvent | -
| typedef struct AMetaDataEvent AMetaDataEvent | -
ASensor is an opaque type that provides information about an hardware sensors.
-A ASensor pointer can be obtained using ASensorManager_getDefaultSensor(), ASensorManager_getDefaultSensorEx() or from a ASensorList.
-This file provides a set of functions to access properties of a ASensor:
- - -| typedef struct ASensorEvent ASensorEvent | -
| typedef struct ASensorEventQueue ASensorEventQueue | -
ASensorEventQueue is an opaque type that provides access to ASensorEvent from hardware sensors.
-A new ASensorEventQueue can be obtained using ASensorManager_createEventQueue().
-This file provides a set of functions to enable and disable sensors, check and get events, and set event rates on a ASensorEventQueue.
- - -| typedef ASensorRef const* ASensorList | -
ASensorList is an array of reference to ASensor.
-A ASensorList can be initialized using ASensorManager_getSensorList().
- -| typedef struct ASensorManager ASensorManager | -
ASensorManager is an opaque type to manage sensors and events queues.
-ASensorManager is a singleton that can be obtained using ASensorManager_getInstance().
-This file provides a set of functions that uses ASensorManager to access and list hardware sensors, and create and destroy event queues:
- - -| typedef ASensor const* ASensorRef | -
ASensorRef is a type for constant pointers to ASensor.
-This is used to define entry in ASensorList arrays.
- -| typedef struct ASensorVector ASensorVector | -
A sensor event.
- -| typedef struct AUncalibratedEvent AUncalibratedEvent | -
| anonymous enum | -
Structures and functions to receive and process sensor events in native code. Sensor types. (keep in sync with hardware/sensor.h)
-| Enumerator | |
|---|---|
| ASENSOR_TYPE_ACCELEROMETER |
- ASENSOR_TYPE_ACCELEROMETER reporting-mode: continuous -All values are in SI units (m/s^2) and measure the acceleration of the device minus the force of gravity. - |
| ASENSOR_TYPE_MAGNETIC_FIELD |
- ASENSOR_TYPE_MAGNETIC_FIELD reporting-mode: continuous -All values are in micro-Tesla (uT) and measure the geomagnetic field in the X, Y and Z axis. - |
| ASENSOR_TYPE_GYROSCOPE |
- ASENSOR_TYPE_GYROSCOPE reporting-mode: continuous -All values are in radians/second and measure the rate of rotation around the X, Y and Z axis. - |
| ASENSOR_TYPE_LIGHT |
- ASENSOR_TYPE_LIGHT reporting-mode: on-change -The light sensor value is returned in SI lux units. - |
| ASENSOR_TYPE_PROXIMITY |
- ASENSOR_TYPE_PROXIMITY reporting-mode: on-change -The proximity sensor which turns the screen off and back on during calls is the wake-up proximity sensor. Implement wake-up proximity sensor before implementing a non wake-up proximity sensor. For the wake-up proximity sensor set the flag SENSOR_FLAG_WAKE_UP. The value corresponds to the distance to the nearest object in centimeters. - |
| anonymous enum | -
| anonymous enum | -
| int ASensor_getFifoMaxEventCount | -( | -ASensor const * | -sensor | ) | -- |
Returns the maximum size of batches for this sensor. Batches will often be smaller, as the hardware fifo might be used for other sensors.
- -| int ASensor_getFifoReservedEventCount | -( | -ASensor const * | -sensor | ) | -- |
Returns the hardware batch fifo size reserved to this sensor.
- -| int ASensor_getMinDelay | -( | -ASensor const * | -sensor | ) | -- |
Returns the minimum delay allowed between events in microseconds. A value of zero means that this sensor doesn't report events at a constant rate, but rather only when a new data is available.
- -| const char* ASensor_getName | -( | -ASensor const * | -sensor | ) | -- |
Returns this sensor's name (non localized)
- -| int ASensor_getReportingMode | -( | -ASensor const * | -sensor | ) | -- |
Returns the reporting mode for this sensor. One of AREPORTING_MODE_* constants.
- -| float ASensor_getResolution | -( | -ASensor const * | -sensor | ) | -- |
Returns this sensors's resolution
- -| const char* ASensor_getStringType | -( | -ASensor const * | -sensor | ) | -- |
Returns this sensor's string type.
- -| int ASensor_getType | -( | -ASensor const * | -sensor | ) | -- |
Return this sensor's type
- -| const char* ASensor_getVendor | -( | -ASensor const * | -sensor | ) | -- |
Returns this sensor's vendor's name (non localized)
- -| bool ASensor_isWakeUpSensor | -( | -ASensor const * | -sensor | ) | -- |
Returns true if this is a wake up sensor, false otherwise.
- -| int ASensorEventQueue_disableSensor | -( | -ASensorEventQueue * | -queue, | -
| - | - | ASensor const * | -sensor | -
| - | ) | -- |
Disable the selected sensor. Returns a negative error code on failure.
- -| int ASensorEventQueue_enableSensor | -( | -ASensorEventQueue * | -queue, | -
| - | - | ASensor const * | -sensor | -
| - | ) | -- |
Enable the selected sensor. Returns a negative error code on failure.
- -| ssize_t ASensorEventQueue_getEvents | -( | -ASensorEventQueue * | -queue, | -
| - | - | ASensorEvent * | -events, | -
| - | - | size_t | -count | -
| - | ) | -- |
Returns the next available events from the queue. Returns a negative value if no events are available or an error has occurred, otherwise the number of events returned.
-Examples: ASensorEvent event; ssize_t numEvent = ASensorEventQueue_getEvents(queue, &event, 1);
-ASensorEvent eventBuffer[8]; ssize_t numEvent = ASensorEventQueue_getEvents(queue, eventBuffer, 8);
- -| int ASensorEventQueue_hasEvents | -( | -ASensorEventQueue * | -queue | ) | -- |
Returns true if there are one or more events available in the sensor queue. Returns 1 if the queue has events; 0 if it does not have events; and a negative value if there is an error.
- -| int ASensorEventQueue_setEventRate | -( | -ASensorEventQueue * | -queue, | -
| - | - | ASensor const * | -sensor, | -
| - | - | int32_t | -usec | -
| - | ) | -- |
Sets the delivery rate of events in microseconds for the given sensor. Note that this is a hint only, generally event will arrive at a higher rate. It is an error to set a rate inferior to the value returned by ASensor_getMinDelay(). Returns a negative error code on failure.
- -| ASensorEventQueue* ASensorManager_createEventQueue | -( | -ASensorManager * | -manager, | -
| - | - | ALooper * | -looper, | -
| - | - | int | -ident, | -
| - | - | ALooper_callbackFunc | -callback, | -
| - | - | void * | -data | -
| - | ) | -- |
Creates a new sensor event queue and associate it with a looper.
-"ident" is a identifier for the events that will be returned when calling ALooper_pollOnce(). The identifier must be >= 0, or ALOOPER_POLL_CALLBACK if providing a non-NULL callback.
- -| int ASensorManager_destroyEventQueue | -( | -ASensorManager * | -manager, | -
| - | - | ASensorEventQueue * | -queue | -
| - | ) | -- |
Destroys the event queue and free all resources associated to it.
- -| ASensor const* ASensorManager_getDefaultSensor | -( | -ASensorManager * | -manager, | -
| - | - | int | -type | -
| - | ) | -- |
Returns the default sensor for the given type, or NULL if no sensor of that type exists.
- -| ASensor const* ASensorManager_getDefaultSensorEx | -( | -ASensorManager * | -manager, | -
| - | - | int | -type, | -
| - | - | bool | -wakeUp | -
| - | ) | -- |
Returns the default sensor with the given type and wakeUp properties or NULL if no sensor of this type and wakeUp properties exists.
- -| ASensorManager* ASensorManager_getInstance | -( | -) | -- |
Get a reference to the sensor manager. ASensorManager is a singleton.
-Example:
-ASensorManager* sensorManager = ASensorManager_getInstance();-
| int ASensorManager_getSensorList | -( | -ASensorManager * | -manager, | -
| - | - | ASensorList * | -list | -
| - | ) | -- |
Returns the list of available sensors.
- --Files | |
| file | obb.h |
| file | storage_manager.h |
-Typedefs | |
| typedef struct AObbInfo | AObbInfo |
| typedef struct AStorageManager | AStorageManager |
| typedef void(* | AStorageManager_obbCallbackFunc )(const char *filename, const int32_t state, void *data) |
-Enumerations | |
| enum | { AOBBINFO_OVERLAY = 0x0001 - } |
| enum | { - AOBB_STATE_MOUNTED = 1, -AOBB_STATE_UNMOUNTED = 2, -AOBB_STATE_ERROR_INTERNAL = 20, -AOBB_STATE_ERROR_COULD_NOT_MOUNT = 21, - - AOBB_STATE_ERROR_COULD_NOT_UNMOUNT = 22, -AOBB_STATE_ERROR_NOT_MOUNTED = 23, -AOBB_STATE_ERROR_ALREADY_MOUNTED = 24, -AOBB_STATE_ERROR_PERMISSION_DENIED = 25 - - } |
-Functions | |
| AObbInfo * | AObbScanner_getObbInfo (const char *filename) |
| void | AObbInfo_delete (AObbInfo *obbInfo) |
| const char * | AObbInfo_getPackageName (AObbInfo *obbInfo) |
| int32_t | AObbInfo_getVersion (AObbInfo *obbInfo) |
| int32_t | AObbInfo_getFlags (AObbInfo *obbInfo) |
| AStorageManager * | AStorageManager_new () |
| void | AStorageManager_delete (AStorageManager *mgr) |
| void | AStorageManager_mountObb (AStorageManager *mgr, const char *filename, const char *key, AStorageManager_obbCallbackFunc cb, void *data) |
| void | AStorageManager_unmountObb (AStorageManager *mgr, const char *filename, const int force, AStorageManager_obbCallbackFunc cb, void *data) |
| int | AStorageManager_isObbMounted (AStorageManager *mgr, const char *filename) |
| const char * | AStorageManager_getMountedObbPath (AStorageManager *mgr, const char *filename) |
AObbInfo is an opaque type representing information for obb storage.
- -| typedef struct AStorageManager AStorageManager | -
AStorageManager manages application OBB storage, a pointer can be obtained with AStorageManager_new().
- -| typedef void(* AStorageManager_obbCallbackFunc)(const char *filename, const int32_t state, void *data) | -
Callback function for asynchronous calls made on OBB files.
-"state" is one of the following constants:
- - -| anonymous enum | -
Flag for an obb file, returned by AObbInfo_getFlags().
-| Enumerator | |
|---|---|
| AOBBINFO_OVERLAY |
- overlay - |
| anonymous enum | -
The different states of a OBB storage passed to AStorageManager_obbCallbackFunc().
-| void AObbInfo_delete | -( | -AObbInfo * | -obbInfo | ) | -- |
Destroy the AObbInfo object. You must call this when finished with the object.
- -| int32_t AObbInfo_getFlags | -( | -AObbInfo * | -obbInfo | ) | -- |
Get the flags of an OBB file.
- -| const char* AObbInfo_getPackageName | -( | -AObbInfo * | -obbInfo | ) | -- |
Get the package name for the OBB.
- -| int32_t AObbInfo_getVersion | -( | -AObbInfo * | -obbInfo | ) | -- |
Get the version of an OBB file.
- -| AObbInfo* AObbScanner_getObbInfo | -( | -const char * | -filename | ) | -- |
Scan an OBB and get information about it.
- -| void AStorageManager_delete | -( | -AStorageManager * | -mgr | ) | -- |
Release AStorageManager instance.
- -| const char* AStorageManager_getMountedObbPath | -( | -AStorageManager * | -mgr, | -
| - | - | const char * | -filename | -
| - | ) | -- |
Get the mounted path for an OBB.
- -| int AStorageManager_isObbMounted | -( | -AStorageManager * | -mgr, | -
| - | - | const char * | -filename | -
| - | ) | -- |
Check whether an OBB is mounted.
- -| void AStorageManager_mountObb | -( | -AStorageManager * | -mgr, | -
| - | - | const char * | -filename, | -
| - | - | const char * | -key, | -
| - | - | AStorageManager_obbCallbackFunc | -cb, | -
| - | - | void * | -data | -
| - | ) | -- |
Attempts to mount an OBB file. This is an asynchronous operation.
- -| AStorageManager* AStorageManager_new | -( | -) | -- |
Obtains a new instance of AStorageManager.
- -| void AStorageManager_unmountObb | -( | -AStorageManager * | -mgr, | -
| - | - | const char * | -filename, | -
| - | - | const int | -force, | -
| - | - | AStorageManager_obbCallbackFunc | -cb, | -
| - | - | void * | -data | -
| - | ) | -- |
Attempts to unmount an OBB file. This is an asynchronous operation.
- -The API reference for the NDK includes documentation for the base set of -native headers that the NDK provides for Android. These headers, and their associated libraries, -expose a variety of features otherwise only accessible via the Android framework. -A few of these features are as follows:
- -The API reference provides detailed information on these and other functionalities provided -in the NDK.
diff --git a/docs/html/ndk/reference/input_8h.jd b/docs/html/ndk/reference/input_8h.jd deleted file mode 100644 index 855a346a70280..0000000000000 --- a/docs/html/ndk/reference/input_8h.jd +++ /dev/null @@ -1,374 +0,0 @@ -page.title=input.h File Reference -page.customHeadTag= -@jd:body - - - -#include <stdint.h>#include <sys/types.h>#include <android/keycodes.h>#include <android/looper.h>-Macros | |
| #define | AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8 |
-Typedefs | |
| typedef struct AInputEvent | AInputEvent |
| typedef struct AInputQueue | AInputQueue |
-Functions | |
| int32_t | AInputEvent_getType (const AInputEvent *event) |
| int32_t | AInputEvent_getDeviceId (const AInputEvent *event) |
| int32_t | AInputEvent_getSource (const AInputEvent *event) |
| int32_t | AKeyEvent_getAction (const AInputEvent *key_event) |
| int32_t | AKeyEvent_getFlags (const AInputEvent *key_event) |
| int32_t | AKeyEvent_getKeyCode (const AInputEvent *key_event) |
| int32_t | AKeyEvent_getScanCode (const AInputEvent *key_event) |
| int32_t | AKeyEvent_getMetaState (const AInputEvent *key_event) |
| int32_t | AKeyEvent_getRepeatCount (const AInputEvent *key_event) |
| int64_t | AKeyEvent_getDownTime (const AInputEvent *key_event) |
| int64_t | AKeyEvent_getEventTime (const AInputEvent *key_event) |
| int32_t | AMotionEvent_getAction (const AInputEvent *motion_event) |
| int32_t | AMotionEvent_getFlags (const AInputEvent *motion_event) |
| int32_t | AMotionEvent_getMetaState (const AInputEvent *motion_event) |
| int32_t | AMotionEvent_getButtonState (const AInputEvent *motion_event) |
| int32_t | AMotionEvent_getEdgeFlags (const AInputEvent *motion_event) |
| int64_t | AMotionEvent_getDownTime (const AInputEvent *motion_event) |
| int64_t | AMotionEvent_getEventTime (const AInputEvent *motion_event) |
| float | AMotionEvent_getXOffset (const AInputEvent *motion_event) |
| float | AMotionEvent_getYOffset (const AInputEvent *motion_event) |
| float | AMotionEvent_getXPrecision (const AInputEvent *motion_event) |
| float | AMotionEvent_getYPrecision (const AInputEvent *motion_event) |
| size_t | AMotionEvent_getPointerCount (const AInputEvent *motion_event) |
| int32_t | AMotionEvent_getPointerId (const AInputEvent *motion_event, size_t pointer_index) |
| int32_t | AMotionEvent_getToolType (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getRawX (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getRawY (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getX (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getY (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getPressure (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getSize (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getTouchMajor (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getTouchMinor (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getToolMajor (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getToolMinor (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getOrientation (const AInputEvent *motion_event, size_t pointer_index) |
| float | AMotionEvent_getAxisValue (const AInputEvent *motion_event, int32_t axis, size_t pointer_index) |
| size_t | AMotionEvent_getHistorySize (const AInputEvent *motion_event) |
| int64_t | AMotionEvent_getHistoricalEventTime (const AInputEvent *motion_event, size_t history_index) |
| float | AMotionEvent_getHistoricalRawX (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalRawY (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalX (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalY (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalPressure (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalSize (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalTouchMajor (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalTouchMinor (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalToolMajor (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalToolMinor (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalOrientation (const AInputEvent *motion_event, size_t pointer_index, size_t history_index) |
| float | AMotionEvent_getHistoricalAxisValue (const AInputEvent *motion_event, int32_t axis, size_t pointer_index, size_t history_index) |
| void | AInputQueue_attachLooper (AInputQueue *queue, ALooper *looper, int ident, ALooper_callbackFunc callback, void *data) |
| void | AInputQueue_detachLooper (AInputQueue *queue) |
| int32_t | AInputQueue_hasEvents (AInputQueue *queue) |
| int32_t | AInputQueue_getEvent (AInputQueue *queue, AInputEvent **outEvent) |
| int32_t | AInputQueue_preDispatchEvent (AInputQueue *queue, AInputEvent *event) |
| void | AInputQueue_finishEvent (AInputQueue *queue, AInputEvent *event, int handled) |
#include <sys/types.h>-Typedefs | |
| typedef struct ALooper | ALooper |
| typedef int(* | ALooper_callbackFunc )(int fd, int events, void *data) |
-Enumerations | |
| enum | { ALOOPER_PREPARE_ALLOW_NON_CALLBACKS = 1<<0 - } |
| enum | { ALOOPER_POLL_WAKE = -1, -ALOOPER_POLL_CALLBACK = -2, -ALOOPER_POLL_TIMEOUT = -3, -ALOOPER_POLL_ERROR = -4 - } |
| enum | { - ALOOPER_EVENT_INPUT = 1 << 0, -ALOOPER_EVENT_OUTPUT = 1 << 1, -ALOOPER_EVENT_ERROR = 1 << 2, -ALOOPER_EVENT_HANGUP = 1 << 3, - - ALOOPER_EVENT_INVALID = 1 << 4 - - } |
-Functions | |
| ALooper * | ALooper_forThread () |
| ALooper * | ALooper_prepare (int opts) |
| void | ALooper_acquire (ALooper *looper) |
| void | ALooper_release (ALooper *looper) |
| int | ALooper_pollOnce (int timeoutMillis, int *outFd, int *outEvents, void **outData) |
| int | ALooper_pollAll (int timeoutMillis, int *outFd, int *outEvents, void **outData) |
| void | ALooper_wake (ALooper *looper) |
| int | ALooper_addFd (ALooper *looper, int fd, int ident, int events, ALooper_callbackFunc callback, void *data) |
| int | ALooper_removeFd (ALooper *looper, int fd) |
#include <stdint.h>#include <sys/types.h>#include <jni.h>#include <android/asset_manager.h>#include <android/input.h>#include <android/native_window.h>-Data Structures | |
| struct | ANativeActivity |
| struct | ANativeActivityCallbacks |
-Typedefs | |
| typedef struct ANativeActivity | ANativeActivity |
| typedef struct -ANativeActivityCallbacks | ANativeActivityCallbacks |
| typedef void | ANativeActivity_createFunc (ANativeActivity *activity, void *savedState, size_t savedStateSize) |
-Enumerations | |
| enum | { ANATIVEACTIVITY_SHOW_SOFT_INPUT_IMPLICIT = 0x0001, -ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED = 0x0002 - } |
| enum | { ANATIVEACTIVITY_HIDE_SOFT_INPUT_IMPLICIT_ONLY = 0x0001, -ANATIVEACTIVITY_HIDE_SOFT_INPUT_NOT_ALWAYS = 0x0002 - } |
-Functions | |
| void | ANativeActivity_finish (ANativeActivity *activity) |
| void | ANativeActivity_setWindowFormat (ANativeActivity *activity, int32_t format) |
| void | ANativeActivity_setWindowFlags (ANativeActivity *activity, uint32_t addFlags, uint32_t removeFlags) |
| void | ANativeActivity_showSoftInput (ANativeActivity *activity, uint32_t flags) |
| void | ANativeActivity_hideSoftInput (ANativeActivity *activity, uint32_t flags) |
-Variables | |
| ANativeActivity_createFunc | ANativeActivity_onCreate |
#include <android/rect.h>-Data Structures | |
| struct | ANativeWindow_Buffer |
-Typedefs | |
| typedef struct ANativeWindow | ANativeWindow |
| typedef struct ANativeWindow_Buffer | ANativeWindow_Buffer |
-Enumerations | |
| enum | { WINDOW_FORMAT_RGBA_8888 = 1, -WINDOW_FORMAT_RGBX_8888 = 2, -WINDOW_FORMAT_RGB_565 = 4 - } |
-Functions | |
| void | ANativeWindow_acquire (ANativeWindow *window) |
| void | ANativeWindow_release (ANativeWindow *window) |
| int32_t | ANativeWindow_getWidth (ANativeWindow *window) |
| int32_t | ANativeWindow_getHeight (ANativeWindow *window) |
| int32_t | ANativeWindow_getFormat (ANativeWindow *window) |
| int32_t | ANativeWindow_setBuffersGeometry (ANativeWindow *window, int32_t width, int32_t height, int32_t format) |
| int32_t | ANativeWindow_lock (ANativeWindow *window, ANativeWindow_Buffer *outBuffer, ARect *inOutDirtyBounds) |
| int32_t | ANativeWindow_unlockAndPost (ANativeWindow *window) |
-Functions | |
| ANativeWindow * | ANativeWindow_fromSurface (JNIEnv *env, jobject surface) |
#include <sys/types.h>-Typedefs | |
| typedef struct AObbInfo | AObbInfo |
-Enumerations | |
| enum | { AOBBINFO_OVERLAY = 0x0001 - } |
-Functions | |
| AObbInfo * | AObbScanner_getObbInfo (const char *filename) |
| void | AObbInfo_delete (AObbInfo *obbInfo) |
| const char * | AObbInfo_getPackageName (AObbInfo *obbInfo) |
| int32_t | AObbInfo_getVersion (AObbInfo *obbInfo) |
| int32_t | AObbInfo_getFlags (AObbInfo *obbInfo) |
#include <stdint.h>-Data Structures | |
| struct | ARect |
-Typedefs | |
| typedef struct ARect | ARect |
-Data Structures | |
| struct | ASensorVector |
| struct | AMetaDataEvent |
| struct | AUncalibratedEvent |
| struct | AHeartRateEvent |
| struct | ASensorEvent |
-Macros | |
| #define | ASENSOR_STANDARD_GRAVITY (9.80665f) |
| #define | ASENSOR_MAGNETIC_FIELD_EARTH_MAX (60.0f) |
| #define | ASENSOR_MAGNETIC_FIELD_EARTH_MIN (30.0f) |
-Typedefs | |
| typedef struct ASensorVector | ASensorVector |
| typedef struct AMetaDataEvent | AMetaDataEvent |
| typedef struct AUncalibratedEvent | AUncalibratedEvent |
| typedef struct AHeartRateEvent | AHeartRateEvent |
| typedef struct ASensorEvent | ASensorEvent |
| typedef struct ASensorManager | ASensorManager |
| typedef struct ASensorEventQueue | ASensorEventQueue |
| typedef struct ASensor | ASensor |
| typedef ASensor const * | ASensorRef |
| typedef ASensorRef const * | ASensorList |
-Enumerations | |
| enum | { - ASENSOR_TYPE_ACCELEROMETER = 1, -ASENSOR_TYPE_MAGNETIC_FIELD = 2, -ASENSOR_TYPE_GYROSCOPE = 4, -ASENSOR_TYPE_LIGHT = 5, - - ASENSOR_TYPE_PROXIMITY = 8 - - } |
| enum | { - ASENSOR_STATUS_NO_CONTACT = -1, -ASENSOR_STATUS_UNRELIABLE = 0, -ASENSOR_STATUS_ACCURACY_LOW = 1, -ASENSOR_STATUS_ACCURACY_MEDIUM = 2, - - ASENSOR_STATUS_ACCURACY_HIGH = 3 - - } |
| enum | { AREPORTING_MODE_CONTINUOUS = 0, -AREPORTING_MODE_ON_CHANGE = 1, -AREPORTING_MODE_ONE_SHOT = 2, -AREPORTING_MODE_SPECIAL_TRIGGER = 3 - } |
#include <stdint.h>-Typedefs | |
| typedef struct AStorageManager | AStorageManager |
| typedef void(* | AStorageManager_obbCallbackFunc )(const char *filename, const int32_t state, void *data) |
-Enumerations | |
| enum | { - AOBB_STATE_MOUNTED = 1, -AOBB_STATE_UNMOUNTED = 2, -AOBB_STATE_ERROR_INTERNAL = 20, -AOBB_STATE_ERROR_COULD_NOT_MOUNT = 21, - - AOBB_STATE_ERROR_COULD_NOT_UNMOUNT = 22, -AOBB_STATE_ERROR_NOT_MOUNTED = 23, -AOBB_STATE_ERROR_ALREADY_MOUNTED = 24, -AOBB_STATE_ERROR_PERMISSION_DENIED = 25 - - } |
-Functions | |
| AStorageManager * | AStorageManager_new () |
| void | AStorageManager_delete (AStorageManager *mgr) |
| void | AStorageManager_mountObb (AStorageManager *mgr, const char *filename, const char *key, AStorageManager_obbCallbackFunc cb, void *data) |
| void | AStorageManager_unmountObb (AStorageManager *mgr, const char *filename, const int force, AStorageManager_obbCallbackFunc cb, void *data) |
| int | AStorageManager_isObbMounted (AStorageManager *mgr, const char *filename) |
| const char * | AStorageManager_getMountedObbPath (AStorageManager *mgr, const char *filename) |
#include <sensor.h>
-Data Fields | |
| float | bpm |
| int8_t | status |
| float bpm | -
| int8_t status | -
#include <sensor.h>
-Data Fields | |
| int32_t | what |
| int32_t | sensor |
| int32_t sensor | -
| int32_t what | -
#include <native_activity.h>
-Data Fields | |
| struct ANativeActivityCallbacks * | callbacks |
| JavaVM * | vm |
| JNIEnv * | env |
| jobject | clazz |
| const char * | internalDataPath |
| const char * | externalDataPath |
| int32_t | sdkVersion |
| void * | instance |
| AAssetManager * | assetManager |
| const char * | obbPath |
This structure defines the native side of an android.app.NativeActivity. It is created by the framework, and handed to the application's native code as it is being launched.
-| AAssetManager* assetManager | -
Pointer to the Asset Manager instance for the application. The application uses this to access binary assets bundled inside its own .apk file.
- -| struct ANativeActivityCallbacks* callbacks | -
Pointer to the callback function table of the native application. You can set the functions here to your own callbacks. The callbacks pointer itself here should not be changed; it is allocated and managed for you by the framework.
- -| jobject clazz | -
The NativeActivity object handle.
-IMPORTANT NOTE: This member is mis-named. It should really be named 'activity' instead of 'clazz', since it's a reference to the NativeActivity instance created by the system for you.
-We unfortunately cannot change this without breaking NDK source-compatibility.
- -| JNIEnv* env | -
JNI context for the main thread of the app. Note that this field can ONLY be used from the main thread of the process; that is, the thread that calls into the ANativeActivityCallbacks.
- -| const char* externalDataPath | -
Path to this application's external (removable/mountable) data directory.
- -| void* instance | -
This is the native instance of the application. It is not used by the framework, but can be set by the application to its own instance state.
- -| const char* internalDataPath | -
Path to this application's internal data directory.
- -| const char* obbPath | -
Available starting with Honeycomb: path to the directory containing the application's OBB files (if any). If the app doesn't have any OBB files, this directory may not exist.
- -| int32_t sdkVersion | -
The platform's SDK version code.
- -| JavaVM* vm | -
The global handle on the process's Java VM.
- -#include <native_activity.h>
These are the callbacks the framework makes into a native application. All of these callbacks happen on the main thread of the application. By default, all callbacks are NULL; set to a pointer to your own function to have it called.
-| void(* onConfigurationChanged)(ANativeActivity *activity) | -
The current device AConfiguration has changed. The new configuration can be retrieved from assetManager.
- -| void(* onContentRectChanged)(ANativeActivity *activity, const ARect *rect) | -
The rectangle in the window in which content should be placed has changed.
- -| void(* onDestroy)(ANativeActivity *activity) | -
NativeActivity is being destroyed. See Java documentation for Activity.onDestroy() for more information.
- -| void(* onInputQueueCreated)(ANativeActivity *activity, AInputQueue *queue) | -
The input queue for this native activity's window has been created. You can use the given input queue to start retrieving input events.
- -| void(* onInputQueueDestroyed)(ANativeActivity *activity, AInputQueue *queue) | -
The input queue for this native activity's window is being destroyed. You should no longer try to reference this object upon returning from this function.
- -| void(* onLowMemory)(ANativeActivity *activity) | -
The system is running low on memory. Use this callback to release resources you do not need, to help the system avoid killing more important processes.
- -| void(* onNativeWindowCreated)(ANativeActivity *activity, ANativeWindow *window) | -
The drawing window for this native activity has been created. You can use the given native window object to start drawing.
- -| void(* onNativeWindowDestroyed)(ANativeActivity *activity, ANativeWindow *window) | -
The drawing window for this native activity is going to be destroyed. You MUST ensure that you do not touch the window object after returning from this function: in the common case of drawing to the window from another thread, that means the implementation of this callback must properly synchronize with the other thread to stop its drawing before returning from here.
- -| void(* onNativeWindowRedrawNeeded)(ANativeActivity *activity, ANativeWindow *window) | -
The drawing window for this native activity needs to be redrawn. To avoid transient artifacts during screen changes (such resizing after rotation), applications should not return from this function until they have finished drawing their window in its current state.
- -| void(* onNativeWindowResized)(ANativeActivity *activity, ANativeWindow *window) | -
The drawing window for this native activity has been resized. You should retrieve the new size from the window and ensure that your rendering in it now matches.
- -| void(* onPause)(ANativeActivity *activity) | -
NativeActivity has paused. See Java documentation for Activity.onPause() for more information.
- -| void(* onResume)(ANativeActivity *activity) | -
NativeActivity has resumed. See Java documentation for Activity.onResume() for more information.
- -| void*(* onSaveInstanceState)(ANativeActivity *activity, size_t *outSize) | -
Framework is asking NativeActivity to save its current instance state. See Java documentation for Activity.onSaveInstanceState() for more information. The returned pointer needs to be created with malloc(); the framework will call free() on it for you. You also must fill in outSize with the number of bytes in the allocation. Note that the saved state will be persisted, so it can not contain any active entities (pointers to memory, file descriptors, etc).
- -| void(* onStart)(ANativeActivity *activity) | -
NativeActivity has started. See Java documentation for Activity.onStart() for more information.
- -| void(* onStop)(ANativeActivity *activity) | -
NativeActivity has stopped. See Java documentation for Activity.onStop() for more information.
- -| void(* onWindowFocusChanged)(ANativeActivity *activity, int hasFocus) | -
Focus has changed in this NativeActivity's window. This is often used, for example, to pause a game when it loses input focus.
- -#include <native_window.h>
-Data Fields | |
| int32_t | width |
| int32_t | height |
| int32_t | stride |
| int32_t | format |
| void * | bits |
| uint32_t | reserved [6] |
ANativeWindow is a struct that represents a windows buffer.
-A pointer can be obtained using ANativeWindow_lock().
-| void* bits | -
| int32_t format | -
| int32_t height | -
| uint32_t reserved[6] | -
| int32_t stride | -
| int32_t width | -
#include <rect.h>
-Data Fields | |
| int32_t | left |
| int32_t | top |
| int32_t | right |
| int32_t | bottom |
ARect is a struct that represents a rectangular window area.
-It is used with ANativeActivityCallbacks::onContentRectChanged event callback and ANativeWindow_lock() function.
-| int32_t bottom | -
bottom position
- -| int32_t left | -
left position
- -| int32_t right | -
left position
- -| int32_t top | -
top position
- -#include <sensor.h>
-Data Fields | |
| int32_t | version |
| int32_t | sensor |
| int32_t | type |
| int32_t | reserved0 |
| int64_t | timestamp |
| union { | |
| union { | |
| float data [16] | |
| ASensorVector vector | |
| ASensorVector acceleration | |
| ASensorVector magnetic | |
| float temperature | |
| float distance | |
| float light | |
| float pressure | |
| float relative_humidity | |
| AUncalibratedEvent uncalibrated_gyro | |
| AUncalibratedEvent uncalibrated_magnetic | |
| AMetaDataEvent meta_data | |
| AHeartRateEvent heart_rate | |
| } | |
| union { | |
| uint64_t data [8] | |
| uint64_t step_counter | |
| } u64 | |
| }; | |
| uint32_t | flags |
| int32_t | reserved1 [3] |
| union { ... } | -
| ASensorVector acceleration | -
| float data[16] | -
| uint64_t data[8] | -
| float distance | -
| uint32_t flags | -
| AHeartRateEvent heart_rate | -
| float light | -
| ASensorVector magnetic | -
| AMetaDataEvent meta_data | -
| float pressure | -
| float relative_humidity | -
| int32_t reserved0 | -
| int32_t reserved1[3] | -
| int32_t sensor | -
| uint64_t step_counter | -
| float temperature | -
| int64_t timestamp | -
| int32_t type | -
| union { ... } u64 | -
| AUncalibratedEvent uncalibrated_gyro | -
| AUncalibratedEvent uncalibrated_magnetic | -
| ASensorVector vector | -
| int32_t version | -
#include <sensor.h>
-Data Fields | |
| union { | |
| float v [3] | |
| struct { | |
| float x | |
| float y | |
| float z | |
| } | |
| struct { | |
| float azimuth | |
| float pitch | |
| float roll | |
| } | |
| }; | |
| int8_t | status |
| uint8_t | reserved [3] |
A sensor event.
-| union { ... } | -
| float azimuth | -
| float pitch | -
| uint8_t reserved[3] | -
| float roll | -
| int8_t status | -
| float v[3] | -
| float x | -
| float y | -
| float z | -
#include <sensor.h>
-Data Fields | |
| union { | |
| float uncalib [3] | |
| struct { | |
| float x_uncalib | |
| float y_uncalib | |
| float z_uncalib | |
| } | |
| }; | |
| union { | |
| float bias [3] | |
| struct { | |
| float x_bias | |
| float y_bias | |
| float z_bias | |
| } | |
| }; | |
| union { ... } | -
| union { ... } | -
| float bias[3] | -
| float uncalib[3] | -
| float x_bias | -
| float x_uncalib | -
| float y_bias | -
| float y_uncalib | -
| float z_bias | -
| float z_uncalib | -
#include <bitmap.h>
-Data Fields | |
| uint32_t | width |
| uint32_t | height |
| uint32_t | stride |
| int32_t | format |
| uint32_t | flags |
Bitmap info, see AndroidBitmap_getInfo().
-| uint32_t flags | -
Unused.
- -| int32_t format | -
The bitmap pixel format. See AndroidBitmapFormat
- -| uint32_t height | -
The bitmap height in pixels.
- -| uint32_t stride | -
The number of byte per row.
- -| uint32_t width | -
The bitmap width in pixels.
- -Welcome to the NDK samples area. Here, you can download a variety of sample -apps to help deepen your understanding the NDK. - - -
From this page, you can download samples that provide a look at the NDK in action. A few of the -topics covered are:
- -Note: These samples are also contained in the NDK installation -package; if you have already downloaded the NDK, you have them. They reside in -{@code $NDK/samples/}, where {@code $NDK} is the NDK installation root.
- - - -Vulkan samples are located separately from those for the rest of the NDK. To explore them, -access the link below.
- - \ No newline at end of file diff --git a/docs/html/ndk/samples/sample_hellojni.jd b/docs/html/ndk/samples/sample_hellojni.jd deleted file mode 100644 index fa61b28152fe8..0000000000000 --- a/docs/html/ndk/samples/sample_hellojni.jd +++ /dev/null @@ -1,123 +0,0 @@ -page.title=Sample: hello-jni -@jd:body - -This sample guides you through HelloJNI, a minimal -application built with the NDK. This sample is in the {@code samples/hello-jni/} directory -under the root directory of your NDK installation.
- -The following two lines provide the name of the native source file, along -with the name of the shared library to build. The full name of the built -library is {@code libhello-jni.so}, once the build system adds the -{@code lib} prefix and the {@code .so} extension.
- --LOCAL_SRC_FILES := hello-jni.c -LOCAL_MODULE := hello-jni -- -
For more information about what the {@code Android.mk} file does, and how to use it, see -Android.mk.
- -This line tells the build system the CPU and architecture against which to build. In this -example, the build system builds for all supported architectures.
- --APP_ABI := all -- -
For more information about the {@code Application.mk} file, and how to use it, see -Application.mk.
- -The {@code helloJNI.java} file is located in {@code hellojni/src/com/example/hellojni/}. It calls -a function to retrieve a string from the native side, then displays it on the screen.
- -The source code contains three lines of particular interest to the NDK user. -They are presented here in the order in which they are used, rather than by -line order.
- -This function call loads the {@code .so} file upon application startup.
- -
-System.loadLibrary("hello-jni");
-
-
-The {@code native} keyword in this method declaration tells the -virtual machine that the function is in the shared library (that is, implemented on the native -side).
- --public native String stringFromJNI(); -- -
The Android framework calls the function loaded and declared in the -previous steps, displaying the string on the screen.
- --tv.setText( stringFromJNI() ); -- -
The {@code hello-jni.c} file is located in {@code hello-jni/jni/}. It contains a function that -returns a string that the Java side requested). The function declaration is as -follows:
- --jstring -Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env, - jobject thiz ) -- -
This declaration corresponds to the native function declared in the -Java source code. The return type, {@code jstring}, is a data type defined -in the -Java Native -Interface Specification. It is not actually a string, but a -pointer to a Java string.
- -After {@code jstring} comes the function name, which is based on the -Java function name and and the path to the file containing it. Construct it -according to the following rules:
- -Following these rules, this example uses the function name -{@code Java_com_example_hellojni_HelloJni_stringFromJNI}. This name refers to a Java -function called {@code stringFromJNI()}, which resides in -{@code hellojni/src/com/example/hellojni/HelloJni.java}.
- -{@code JNIEnv*} is the pointer to the VM, and -{@code jobject} is a pointer to the implicit {@code this} object passed from -the Java side.
- -The following line calls the VM API {@code (*env)}, and passes it a return value: -that is, the string that the function on the Java side had requested.
- --return (*env)->NewStringUTF(env, "Hello from JNI ! -Compiled with ABI " ABI "."); -diff --git a/docs/html/ndk/samples/sample_na.jd b/docs/html/ndk/samples/sample_na.jd deleted file mode 100644 index 0966dd893d487..0000000000000 --- a/docs/html/ndk/samples/sample_na.jd +++ /dev/null @@ -1,259 +0,0 @@ -page.title=Sample: native-activity -@jd:body - -
The native-activity sample resides under the NDK installation root, in -{@code samples/native-activity}. It is a very simple example of a purely native -application, with no Java source code. In the absence of any Java source, the -Java compiler still creates an executable stub for the virtual machine to run. -The stub serves as a wrapper for the actual, native program, which is located in the {@code .so} -file.
- -The app itself simply renders a color onto the entire screen, and -then changes the color partly in response to movement that it detects.
- -An app with only native code must not specify an Android API level lower than 9, which introduced -the {@code NativeActivity} framework class.
- --<uses-sdk android:minSdkVersion="9" /> -- -
The following line declares {@code android:hasCode} as {@code false}, as this app has only -native code–no Java. -
- --<application android:label="@string/app_name" -android:hasCode="false"> -- -
The next line declares the {@code NativeActivity} class.
- --<activity android:name="android.app.NativeActivity" -- -
Finally, the manifest specifies {@code android:value} as the name of the shared library to be -built, minus the initial {@code lib} and the {@code .so} extension. This value must be the same as -the name of {@code LOCAL_MODULE} in {@code Android.mk}.
- --<meta-data android:name="android.app.lib_name" - android:value="native-activity" /> -- -
This file begins by providing the name of the shared library to generate.
- --LOCAL_MODULE := native-activity -- -
Next, it declares the name of the native source-code file.
- --LOCAL_SRC_FILES := main.c -- -
Next, it lists the external libraries for the build system to use in building the binary. The -{@code -l} (link-against) option precedes each library name.
- -For each library:
- --LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM -- -
The next line provides the name of the static library, {@code android_native_app_glue}, which the -application uses to manage {@code NativeActivity} lifecycle events and touch input.
- --LOCAL_STATIC_LIBRARIES := android_native_app_glue -- -
The final line tells the build system to build this static library. -The {@code ndk-build} script places the built library -({@code libandroid_native_app_glue.a}) into the {@code obj} directory -generated during the build process. For more information about the {@code android_native_app_glue} -library, see its {@code android_native_app_glue.h} header and corresponding {@code .c}source file. -
- - --$(call import-module,android/native_app_glue) -- -
For more information about the {@code Android.mk} file, see -Android.mk.
- - -This line defines the minimum level of Android API Level support.
- --APP_PLATFORM := android-10 -- -
Because there is no ABI definition, the build system defaults to building only for -{@code armeabi}.
- -This file essentially contains the entire progam.
- -The following includes correspond to the libraries, both shared and static, -enumerated in {@code Android.mk}.
- --#include <EGL/egl.h> -#include <GLES/gl.h> - - -#include <android/sensor.h> -#include <android/log.h> -#include <android_native_app_glue> -- -
The {@code android_native_app_glue} library calls the following function, -passing it a predefined state structure. It also serves as a wrapper that -simplifies handling of {@code NativeActivity} callbacks.
- -
-void android_main(struct android_app* state) {
-
-
-Next, the program handles events queued by the glue library. The event -handler follows the state structure.
- --struct engine engine; - - - -// Suppress link-time optimization that removes unreferenced code -// to make sure glue isn't stripped. -app_dummy(); - - -memset(&engine, 0, sizeof(engine)); -state->userData = &engine; -state->onAppCmd = engine_handle_cmd; -state->onInputEvent = engine_handle_input; -engine.app = state; -- -
The application prepares to start monitoring the sensors, using the -APIs in {@code sensor.h}.
- -- engine.sensorManager = ASensorManager_getInstance(); - engine.accelerometerSensor = - ASensorManager_getDefaultSensor(engine.sensorManager, - ASENSOR_TYPE_ACCELEROMETER); - engine.sensorEventQueue = - ASensorManager_createEventQueue(engine.sensorManager, - state->looper, LOOPER_ID_USER, NULL, NULL); -- -
Next, a loop begins, in which the application polls the system for -messages (sensor events). It sends messages to -{@code android_native_app_glue}, which checks to see whether they match -any {@code onAppCmd} events defined in {@code android_main}. When a -match occurs, the message is sent to the handler for execution.
- -
-while (1) {
- // Read all pending events.
- int ident;
- int events;
- struct android_poll_source* source;
-
-
- // If not animating, we will block forever waiting for events.
- // If animating, we loop until all events are read, then continue
- // to draw the next frame of animation.
- while ((ident=ALooper_pollAll(engine.animating ? 0 : -1, NULL,
- &events,
- (void**)&source)) >= 0) {
-
-
- // Process this event.
- if (source != NULL) {
- source->process(state, source);
- }
-
-
- // If a sensor has data, process it now.
- if (ident == LOOPER_ID_USER) {
- if (engine.accelerometerSensor != NULL) {
- ASensorEvent event;
- while (ASensorEventQueue_getEvents(engine.sensorEventQueue,
- &event, 1) > 0) {
- LOGI("accelerometer: x=%f y=%f z=%f",
- event.acceleration.x, event.acceleration.y,
- event.acceleration.z);
- }
- }
- }
-
-
- // Check if we are exiting.
- if (state->destroyRequested != 0) {
- engine_term_display(&engine);
- return;
- }
- }
-
-
-Once the queue is empty, and the program exits the polling loop, the -program calls OpenGL to draw the screen.
-
- if (engine.animating) {
- // Done with events; draw next animation frame.
- engine.state.angle += .01f;
- if (engine.state.angle > 1) {
- engine.state.angle = 0;
- }
-
-
- // Drawing is throttled to the screen update rate, so there
- // is no need to do timing here.
- engine_draw_frame(&engine);
- }
-}
-
diff --git a/docs/html/ndk/samples/sample_teapot.jd b/docs/html/ndk/samples/sample_teapot.jd
deleted file mode 100644
index 97708a7cb0bcc..0000000000000
--- a/docs/html/ndk/samples/sample_teapot.jd
+++ /dev/null
@@ -1,360 +0,0 @@
-page.title=Sample: Teapot
-@jd:body
-
-The Teapot sample is located under in the {@code samples/Teapot/} directory, under the NDK -installation's root directory. This sample uses the OpenGL library to render the iconic -Utah -teapot. In particular, it showcases the {@code ndk_helper} helper class, -a collection of native helper functions required for implementing games and -similar applications as native applications. This class provides:
- -The activity declaration here is not {@link android.app.NativeActivity} itself, but -a subclass of it: {@code TeapotNativeActivity}.
- -- <activity android:name="com.sample.teapot.TeapotNativeActivity" - android:label="@string/app_name" - android:configChanges="orientation|keyboardHidden"> -- -
Ultimately, the name of the shared-object file that the build system builds is -{@code libTeapotNativeActivity.so}. The build system adds the {@code lib} prefix and the {@code .so} -extension; neither is part of the value that the manifest originally assigns to -{@code android:value}.
- -- <meta-data android:name="android.app.lib_name" - android:value="TeapotNativeActivity" /> -- -
An app that uses the {@link android.app.NativeActivity} framework class must not specify an -Android API level lower than 9, which introduced that class. For more information about the -{@link android.app.NativeActivity} class, see -Native Activities and Applications. -
- --APP_PLATFORM := android-9 -- -
The next line tells the build system to build for all supported architectures.
--APP_ABI := all -- -
Next, the file tells the build system which -C++ runtime support library to use.
- --APP_STL := stlport_static -- -
The {@code TeapotNativeActivity.java} file is located in -{@code samples/Teapot/src/com/sample/teapot}, under the NDK installation root directory. It handles -activity lifecycle events, and also enables the app to display text on the screen. The following -block of code is most important from the perspective of the native-side implementation: The native -code calls it to display a popup window for displaying text.
- -
-
-void setImmersiveSticky() {
- View decorView = getWindow().getDecorView();
- decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN
- | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
-}
-
-
-This section explores the part of the Teapot app implemented in C++.
- -These function calls perform the actual rendering of the teapot. It uses -{@code ndk_helper} for matrix calculation and to reposition the camera -based on where the user taps.
- --ndk_helper::Mat4 mat_projection_; -ndk_helper::Mat4 mat_view_; -ndk_helper::Mat4 mat_model_; - - -ndk_helper::TapCamera* camera_; -- -
The following lines include {@code ndk_helper} in the native source file, and define the -helper-class name.
- -- -#include "NDKHelper.h" - -//------------------------------------------------------------------------- -//Preprocessor -//------------------------------------------------------------------------- -#define HELPER_CLASS_NAME "com/sample/helper/NDKHelper" //Class name of helper -function -- -
The first use of the {@code ndk_helper} class is to handle the -EGL-related lifecycle, associating EGL context states (created/lost) with -Android lifecycle events. The {@code ndk_helper} class enables the application to preserve context -information so that the system can restore a destroyed activity. This ability is useful, for -example, when the target machine is rotated (causing an activity to be -destroyed, then immediately restored in the new orientation), or when the lock -screen appears.
- --ndk_helper::GLContext* gl_context_; // handles EGL-related lifecycle. -- -
Next, {@code ndk_helper} provides touch control.
- --ndk_helper::DoubletapDetector doubletap_detector_; -ndk_helper::PinchDetector pinch_detector_; -ndk_helper::DragDetector drag_detector_; -ndk_helper::PerfMonitor monitor_; -- -
It also provides camera control (openGL view frustum).
- --ndk_helper::TapCamera tap_camera_; -- -
The app then prepares to use the device's sensors, using the native APIs provided in the NDK.
- --ASensorManager* sensor_manager_; -const ASensor* accelerometer_sensor_; -ASensorEventQueue* sensor_event_queue_; -- -
The app calls the following functions in response to various Android -lifecycle events and EGL context state changes, using various functionalities -provided by {@code ndk_helper} via the {@code Engine} class.
- -- -void LoadResources(); -void UnloadResources(); -void DrawFrame(); -void TermDisplay(); -void TrimMemory(); -bool IsReady(); -- -
Then, the following function calls back to the Java side to update the UI display.
- -
-void Engine::ShowUI()
-{
- JNIEnv *jni;
- app_->activity->vm->AttachCurrentThread( &jni, NULL );
-
-
- //Default class retrieval
- jclass clazz = jni->GetObjectClass( app_->activity->clazz );
- jmethodID methodID = jni->GetMethodID( clazz, "showUI", "()V" );
- jni->CallVoidMethod( app_->activity->clazz, methodID );
-
-
- app_->activity->vm->DetachCurrentThread();
- return;
-}
-
-
-Next, this function calls back to the Java side to draw a text box -superimposed on the screen rendered on the native side, and showing frame -count.
- -
-void Engine::UpdateFPS( float fFPS )
-{
- JNIEnv *jni;
- app_->activity->vm->AttachCurrentThread( &jni, NULL );
-
-
- //Default class retrieval
- jclass clazz = jni->GetObjectClass( app_->activity->clazz );
- jmethodID methodID = jni->GetMethodID( clazz, "updateFPS", "(F)V" );
- jni->CallVoidMethod( app_->activity->clazz, methodID, fFPS );
-
-
- app_->activity->vm->DetachCurrentThread();
- return;
-}
-
-
-The application gets the system clock and supplies it to the renderer -for time-based animation based on real-time clock. This information is used, for example, in -calculating momentum, where speed declines as a function of time.
- --renderer_.Update( monitor_.GetCurrentTime() ); -- -
The application now checks whether the context information that {@code GLcontext} holds is still -valid. If not, {@code ndk-helper} swaps the buffer, reinstantiating the GL context.
- --if( EGL_SUCCESS != gl_context_->Swap() ) // swaps -buffer. -- -
The program passes touch-motion events to the gesture detector defined -in the {@code ndk_helper} class. The gesture detector tracks multitouch -gestures, such as pinch-and-drag, and sends a notification when triggered by -any of these events.
- -
- if( AInputEvent_getType( event ) == AINPUT_EVENT_TYPE_MOTION )
- {
- ndk_helper::GESTURE_STATE doubleTapState =
- eng->doubletap_detector_.Detect( event );
- ndk_helper::GESTURE_STATE dragState = eng->drag_detector_.Detect( event );
- ndk_helper::GESTURE_STATE pinchState = eng->pinch_detector_.Detect( event );
-
- //Double tap detector has a priority over other detectors
- if( doubleTapState == ndk_helper::GESTURE_STATE_ACTION )
- {
- //Detect double tap
- eng->tap_camera_.Reset( true );
- }
- else
- {
- //Handle drag state
- if( dragState & ndk_helper::GESTURE_STATE_START )
- {
- //Otherwise, start dragging
- ndk_helper::Vec2 v;
- eng->drag_detector_.GetPointer( v );
- eng->TransformPosition( v );
- eng->tap_camera_.BeginDrag( v );
- }
- // ...else other possible drag states...
-
- //Handle pinch state
- if( pinchState & ndk_helper::GESTURE_STATE_START )
- {
- //Start new pinch
- ndk_helper::Vec2 v1;
- ndk_helper::Vec2 v2;
- eng->pinch_detector_.GetPointers( v1, v2 );
- eng->TransformPosition( v1 );
- eng->TransformPosition( v2 );
- eng->tap_camera_.BeginPinch( v1, v2 );
- }
- // ...else other possible pinch states...
- }
- return 1;
- }
-
-
-The {@code ndk_helper} class also provides access to a vector-math library -({@code vecmath.h}), using it here to transform touch coordinates.
- -
-void Engine::TransformPosition( ndk_helper::Vec2& vec )
-{
- vec = ndk_helper::Vec2( 2.0f, 2.0f ) * vec
- / ndk_helper::Vec2( gl_context_->GetScreenWidth(),
- gl_context_->GetScreenHeight() ) - ndk_helper::Vec2( 1.f, 1.f );
-}
-
-
-
-The {@code HandleCmd()} method handles commands posted from the -android_native_app_glue library. For more information about what the messages -mean, refer to the comments in the {@code android_native_app_glue.h} and -{@code .c} source files.
- -
-void Engine::HandleCmd( struct android_app* app,
- int32_t cmd )
-{
- Engine* eng = (Engine*) app->userData;
- switch( cmd )
- {
- case APP_CMD_SAVE_STATE:
- break;
- case APP_CMD_INIT_WINDOW:
- // The window is being shown, get it ready.
- if( app->window != NULL )
- {
- eng->InitDisplay();
- eng->DrawFrame();
- }
- break;
- case APP_CMD_TERM_WINDOW:
- // The window is being hidden or closed, clean it up.
- eng->TermDisplay();
- eng->has_focus_ = false;
- break;
- case APP_CMD_STOP:
- break;
- case APP_CMD_GAINED_FOCUS:
- eng->ResumeSensors();
- //Start animation
- eng->has_focus_ = true;
- break;
- case APP_CMD_LOST_FOCUS:
- eng->SuspendSensors();
- // Also stop animating.
- eng->has_focus_ = false;
- eng->DrawFrame();
- break;
- case APP_CMD_LOW_MEMORY:
- //Free up GL resources
- eng->TrimMemory();
- break;
- }
-}
-
-
-The {@code ndk_helper} class posts {@code APP_CMD_INIT_WINDOW} when {@code android_app_glue} -receives an {@code onNativeWindowCreated()} callback from the system. -Applications can normally perform window initializations, such as EGL -initialization. They do this outside of the activity lifecycle, since the -activity is not yet ready.
- -- //Init helper functions - ndk_helper::JNIHelper::Init( state->activity, HELPER_CLASS_NAME ); - - state->userData = &g_engine; - state->onAppCmd = Engine::HandleCmd; - state->onInputEvent = Engine::HandleInput; -diff --git a/docs/html/ndk/samples/samples_toc.cs b/docs/html/ndk/samples/samples_toc.cs deleted file mode 100644 index 92266b13b408b..0000000000000 --- a/docs/html/ndk/samples/samples_toc.cs +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - diff --git a/docs/html/ndk/samples/walkthroughs.jd b/docs/html/ndk/samples/walkthroughs.jd deleted file mode 100644 index 88ceb56c4b24c..0000000000000 --- a/docs/html/ndk/samples/walkthroughs.jd +++ /dev/null @@ -1,13 +0,0 @@ -page.title=Samples: Walkthroughs -@jd:body - -
This section provides detailed walkthroughs of several key samples. The samples are as -follows:
- -ndk_helper class.