Restore __ANDROID_API__ guards for core <android/*> APIs
This commit restores the __ANDROID_API__ guards removed in
"Add __INTRODUCED_IN to core <android/*.h> APIs.",
commit 9db409b053460e065cefb1d1caefe048f90cfff0.
Add a guard to surface_texture.h.
In choreographer.h, declare the types even for older APIs.
Bug: http://b/111668906
Bug: http://b/113052379
Test: builds
Change-Id: Ia013f48a109310f9f8ca6a3211f28fcb69dd602d
(cherry picked from commit 92b1ebea095f9cac70b81ae7382ae69583c9914d)
diff --git a/include/android/choreographer.h b/include/android/choreographer.h
index 11f8f6b..d75de1e 100644
--- a/include/android/choreographer.h
+++ b/include/android/choreographer.h
@@ -43,6 +43,8 @@
*/
typedef void (*AChoreographer_frameCallback)(long frameTimeNanos, void* data);
+#if __ANDROID_API__ >= 24
+
/**
* Get the AChoreographer instance for the current thread. This must be called
* on an ALooper thread.
@@ -65,6 +67,8 @@
AChoreographer_frameCallback callback, void* data,
long delayMillis) __INTRODUCED_IN(24);
+#endif /* __ANDROID_API__ >= 24 */
+
__END_DECLS
#endif // ANDROID_CHOREOGRAPHER_H
diff --git a/include/android/configuration.h b/include/android/configuration.h
index 81aedca..ef6c5a2 100644
--- a/include/android/configuration.h
+++ b/include/android/configuration.h
@@ -675,6 +675,7 @@
*/
void AConfiguration_setUiModeNight(AConfiguration* config, int32_t uiModeNight);
+#if __ANDROID_API__ >= 13
/**
* Return the current configuration screen width in dp units, or
* ACONFIGURATION_SCREEN_WIDTH_DP_ANY if not set.
@@ -707,7 +708,9 @@
* Set the configuration's smallest screen width in dp units.
*/
void AConfiguration_setSmallestScreenWidthDp(AConfiguration* config, int32_t value) __INTRODUCED_IN(13);
+#endif /* __ANDROID_API__ >= 13 */
+#if __ANDROID_API__ >= 17
/**
* Return the configuration's layout direction, or
* ACONFIGURATION_LAYOUTDIR_ANY if not set.
@@ -718,6 +721,7 @@
* Set the configuration's layout direction.
*/
void AConfiguration_setLayoutDirection(AConfiguration* config, int32_t value) __INTRODUCED_IN(17);
+#endif /* __ANDROID_API__ >= 17 */
/**
* Perform a diff between two configurations. Returns a bit mask of
diff --git a/include/android/input.h b/include/android/input.h
index 1e49b7a..6810901 100644
--- a/include/android/input.h
+++ b/include/android/input.h
@@ -986,8 +986,10 @@
*/
int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event);
+#if __ANDROID_API__ >= 14
/** Get the button state of all buttons that are pressed. */
int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event) __INTRODUCED_IN(14);
+#endif
/**
* Get a bitfield indicating which edges, if any, were touched by this motion event.
@@ -1052,12 +1054,14 @@
*/
int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index);
+#if __ANDROID_API__ >= 14
/**
* 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.
*/
int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index) __INTRODUCED_IN(14);
+#endif
/**
* Get the original raw X coordinate of this event.
@@ -1147,9 +1151,11 @@
*/
float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index);
+#if __ANDROID_API__ >= 13
/** Get the value of the request axis for the given pointer index. */
float AMotionEvent_getAxisValue(const AInputEvent* motion_event,
int32_t axis, size_t pointer_index) __INTRODUCED_IN(13);
+#endif
/**
* Get the number of historical points in this event. These are movements that
@@ -1280,12 +1286,14 @@
float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index,
size_t history_index);
+#if __ANDROID_API__ >= 13
/**
* Get the historical value of the request axis for the given pointer index
* that occurred between this event and the previous motion event.
*/
float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event,
int32_t axis, size_t pointer_index, size_t history_index) __INTRODUCED_IN(13);
+#endif
struct AInputQueue;
diff --git a/include/android/multinetwork.h b/include/android/multinetwork.h
index 55df9f8..4d24680 100644
--- a/include/android/multinetwork.h
+++ b/include/android/multinetwork.h
@@ -60,6 +60,8 @@
* on failure with an appropriate errno value set.
*/
+#if __ANDROID_API__ >= 23
+
/**
* Set the network to be used by the given socket file descriptor.
*
@@ -106,6 +108,8 @@
const char *node, const char *service,
const struct addrinfo *hints, struct addrinfo **res) __INTRODUCED_IN(23);
+#endif /* __ANDROID_API__ >= 23 */
+
__END_DECLS
#endif // ANDROID_MULTINETWORK_H
diff --git a/include/android/native_window_jni.h b/include/android/native_window_jni.h
index 74e43c7..0c196b9 100644
--- a/include/android/native_window_jni.h
+++ b/include/android/native_window_jni.h
@@ -44,6 +44,7 @@
*/
ANativeWindow* ANativeWindow_fromSurface(JNIEnv* env, jobject surface);
+#if __ANDROID_API__ >= 26
/**
* Return a Java Surface object derived from the ANativeWindow, for interacting
* with it through Java code. The returned Java object acquires a reference on
@@ -52,6 +53,7 @@
* collected.
*/
jobject ANativeWindow_toSurface(JNIEnv* env, ANativeWindow* window) __INTRODUCED_IN(26);
+#endif
#ifdef __cplusplus
};
diff --git a/include/android/sensor.h b/include/android/sensor.h
index 59229c1..005564d 100644
--- a/include/android/sensor.h
+++ b/include/android/sensor.h
@@ -472,12 +472,13 @@
* ASensorManager* sensorManager = ASensorManager_getInstance();
*
*/
-#if __ANDROID_API__ >= __ANDROID_API_O__
+#if __ANDROID_API__ >= 26
__attribute__ ((deprecated)) ASensorManager* ASensorManager_getInstance();
#else
ASensorManager* ASensorManager_getInstance();
#endif
+#if __ANDROID_API__ >= 26
/**
* Get a reference to the sensor manager. ASensorManager is a singleton
* per package as different packages may have access to different sensors.
@@ -488,6 +489,7 @@
*
*/
ASensorManager* ASensorManager_getInstanceForPackage(const char* packageName) __INTRODUCED_IN(26);
+#endif
/**
* Returns the list of available sensors.
@@ -500,11 +502,13 @@
*/
ASensor const* ASensorManager_getDefaultSensor(ASensorManager* manager, int type);
+#if __ANDROID_API__ >= 21
/**
* Returns the default sensor with the given type and wakeUp properties or NULL if no sensor
* of this type and wakeUp properties exists.
*/
ASensor const* ASensorManager_getDefaultSensorEx(ASensorManager* manager, int type, bool wakeUp) __INTRODUCED_IN(21);
+#endif
/**
* Creates a new sensor event queue and associate it with a looper.
@@ -521,6 +525,7 @@
*/
int ASensorManager_destroyEventQueue(ASensorManager* manager, ASensorEventQueue* queue);
+#if __ANDROID_API__ >= 26
/**
* Create direct channel based on shared memory
*
@@ -609,6 +614,7 @@
*/
int ASensorManager_configureDirectReport(ASensorManager* manager,
ASensor const* sensor, int channelId, int rate) __INTRODUCED_IN(26);
+#endif /* __ANDROID_API__ >= 26 */
/*****************************************************************************/
@@ -727,6 +733,7 @@
*/
int ASensor_getMinDelay(ASensor const* sensor);
+#if __ANDROID_API__ >= 21
/**
* Returns the maximum size of batches for this sensor. Batches will often be
* smaller, as the hardware fifo might be used for other sensors.
@@ -752,7 +759,9 @@
* Returns true if this is a wake up sensor, false otherwise.
*/
bool ASensor_isWakeUpSensor(ASensor const* sensor) __INTRODUCED_IN(21);
+#endif /* __ANDROID_API__ >= 21 */
+#if __ANDROID_API__ >= 26
/**
* Test if sensor supports a certain type of direct channel.
*
@@ -774,6 +783,7 @@
* does not support direct report.
*/
int ASensor_getHighestDirectReportRateLevel(ASensor const* sensor) __INTRODUCED_IN(26);
+#endif /* __ANDROID_API__ >= 26 */
#ifdef __cplusplus
};
diff --git a/include/android/sharedmem.h b/include/android/sharedmem.h
index 5a4f695..8c3ff74 100644
--- a/include/android/sharedmem.h
+++ b/include/android/sharedmem.h
@@ -28,6 +28,7 @@
#define ANDROID_SHARED_MEMORY_H
#include <stddef.h>
+#include <sys/cdefs.h>
/******************************************************************
*
@@ -49,6 +50,8 @@
extern "C" {
#endif
+#if __ANDROID_API__ >= 26
+
/**
* Create a shared memory region.
*
@@ -109,6 +112,8 @@
*/
int ASharedMemory_setProt(int fd, int prot) __INTRODUCED_IN(26);
+#endif // __ANDROID_API__ >= 26
+
#ifdef __cplusplus
};
#endif
diff --git a/include/android/sharedmem_jni.h b/include/android/sharedmem_jni.h
index 5abc245..13e56e6 100644
--- a/include/android/sharedmem_jni.h
+++ b/include/android/sharedmem_jni.h
@@ -30,6 +30,7 @@
#include <jni.h>
#include <android/sharedmem.h>
#include <stddef.h>
+#include <sys/cdefs.h>
/******************************************************************
*
@@ -51,6 +52,8 @@
extern "C" {
#endif
+#if __ANDROID_API__ >= 27
+
/**
* Returns a dup'd FD from the given Java android.os.SharedMemory object. The returned file
* descriptor has all the same properties & capabilities as the FD returned from
@@ -69,6 +72,8 @@
*/
int ASharedMemory_dupFromJava(JNIEnv* env, jobject sharedMemory) __INTRODUCED_IN(27);
+#endif // __ANDROID_API__ >= 27
+
#ifdef __cplusplus
};
#endif
diff --git a/include/android/surface_texture.h b/include/android/surface_texture.h
index db10a16..a36e982 100644
--- a/include/android/surface_texture.h
+++ b/include/android/surface_texture.h
@@ -43,6 +43,7 @@
*/
#include <stdint.h>
+#include <sys/cdefs.h>
#include <android/native_window.h>
@@ -58,6 +59,8 @@
*/
typedef struct ASurfaceTexture ASurfaceTexture;
+#if __ANDROID_API__ >= 28
+
/**
* Release the reference to the native ASurfaceTexture acquired with
* ASurfaceTexture_fromSurfaceTexture().
@@ -157,6 +160,8 @@
*/
int64_t ASurfaceTexture_getTimestamp(ASurfaceTexture* st) __INTRODUCED_IN(28);
+#endif /* __ANDROID_API__ >= 28 */
+
__END_DECLS
#endif /* ANDROID_NATIVE_SURFACE_TEXTURE_H */
diff --git a/include/android/trace.h b/include/android/trace.h
index 0c44732..aa24995 100644
--- a/include/android/trace.h
+++ b/include/android/trace.h
@@ -39,6 +39,8 @@
extern "C" {
#endif
+#if __ANDROID_API__ >= 23
+
/**
* Returns true if tracing is enabled. Use this to avoid expensive computation only necessary
* when tracing is enabled.
@@ -69,6 +71,8 @@
*/
void ATrace_endSection() __INTRODUCED_IN(23);
+#endif /* __ANDROID_API__ >= 23 */
+
#ifdef __cplusplus
};
#endif