Skip to content

Commit

Permalink
Add __INTRODUCED_IN to core <android/*.h> APIs.
Browse files Browse the repository at this point in the history
Bug: android/ndk#706
Test: builds
Change-Id: I23db5a2180517045bafabe6fbf783456cbddf21a
(cherry picked from commit 9db409b)
  • Loading branch information
enh-google authored and rprichard committed Aug 23, 2018
1 parent a3ae0db commit 93e101b
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 91 deletions.
12 changes: 5 additions & 7 deletions include/android/choreographer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

__BEGIN_DECLS

#if __ANDROID_API__ >= 24

struct AChoreographer;
typedef struct AChoreographer AChoreographer;

Expand All @@ -49,23 +47,23 @@ typedef void (*AChoreographer_frameCallback)(long frameTimeNanos, void* data);
* Get the AChoreographer instance for the current thread. This must be called
* on an ALooper thread.
*/
AChoreographer* AChoreographer_getInstance();
AChoreographer* AChoreographer_getInstance() __INTRODUCED_IN(24);

/**
* Post a callback to be run on the next frame. The data pointer provided will
* be passed to the callback function when it's called.
*/
void AChoreographer_postFrameCallback(AChoreographer* choreographer,
AChoreographer_frameCallback callback, void* data);
AChoreographer_frameCallback callback, void* data) __INTRODUCED_IN(24);

/**
* Post a callback to be run on the frame following the specified delay. The
* data pointer provided will be passed to the callback function when it's
* called.
*/
void AChoreographer_postFrameCallbackDelayed(AChoreographer* choreographer,
AChoreographer_frameCallback callback, void* data, long delayMillis);

#endif /* __ANDROID_API__ >= 24 */
AChoreographer_frameCallback callback, void* data,
long delayMillis) __INTRODUCED_IN(24);

__END_DECLS

Expand Down
24 changes: 12 additions & 12 deletions include/android/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@

#include <android/asset_manager.h>

#if !defined(__INTRODUCED_IN)
#define __INTRODUCED_IN(__api_level) /* nothing */
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -671,53 +675,49 @@ int32_t AConfiguration_getUiModeNight(AConfiguration* config);
*/
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.
*/
int32_t AConfiguration_getScreenWidthDp(AConfiguration* config);
int32_t AConfiguration_getScreenWidthDp(AConfiguration* config) __INTRODUCED_IN(13);

/**
* Set the configuration's current screen width in dp units.
*/
void AConfiguration_setScreenWidthDp(AConfiguration* config, int32_t value);
void AConfiguration_setScreenWidthDp(AConfiguration* config, int32_t value) __INTRODUCED_IN(13);

/**
* Return the current configuration screen height in dp units, or
* ACONFIGURATION_SCREEN_HEIGHT_DP_ANY if not set.
*/
int32_t AConfiguration_getScreenHeightDp(AConfiguration* config);
int32_t AConfiguration_getScreenHeightDp(AConfiguration* config) __INTRODUCED_IN(13);

/**
* Set the configuration's current screen width in dp units.
*/
void AConfiguration_setScreenHeightDp(AConfiguration* config, int32_t value);
void AConfiguration_setScreenHeightDp(AConfiguration* config, int32_t value) __INTRODUCED_IN(13);

/**
* Return the configuration's smallest screen width in dp units, or
* ACONFIGURATION_SMALLEST_SCREEN_WIDTH_DP_ANY if not set.
*/
int32_t AConfiguration_getSmallestScreenWidthDp(AConfiguration* config);
int32_t AConfiguration_getSmallestScreenWidthDp(AConfiguration* config) __INTRODUCED_IN(13);

/**
* Set the configuration's smallest screen width in dp units.
*/
void AConfiguration_setSmallestScreenWidthDp(AConfiguration* config, int32_t value);
#endif /* __ANDROID_API__ >= 13 */
void AConfiguration_setSmallestScreenWidthDp(AConfiguration* config, int32_t value) __INTRODUCED_IN(13);

#if __ANDROID_API__ >= 17
/**
* Return the configuration's layout direction, or
* ACONFIGURATION_LAYOUTDIR_ANY if not set.
*/
int32_t AConfiguration_getLayoutDirection(AConfiguration* config);
int32_t AConfiguration_getLayoutDirection(AConfiguration* config) __INTRODUCED_IN(17);

/**
* Set the configuration's layout direction.
*/
void AConfiguration_setLayoutDirection(AConfiguration* config, int32_t value);
#endif /* __ANDROID_API__ >= 17 */
void AConfiguration_setLayoutDirection(AConfiguration* config, int32_t value) __INTRODUCED_IN(17);

/**
* Perform a diff between two configurations. Returns a bit mask of
Expand Down
20 changes: 8 additions & 12 deletions include/android/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
#include <android/keycodes.h>
#include <android/looper.h>

#if !defined(__INTRODUCED_IN)
#define __INTRODUCED_IN(__api_level) /* nothing */
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -982,10 +986,8 @@ int32_t AMotionEvent_getFlags(const AInputEvent* motion_event);
*/
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);
#endif
int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event) __INTRODUCED_IN(14);

/**
* Get a bitfield indicating which edges, if any, were touched by this motion event.
Expand Down Expand Up @@ -1050,14 +1052,12 @@ size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event);
*/
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);
#endif
int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index) __INTRODUCED_IN(14);

/**
* Get the original raw X coordinate of this event.
Expand Down Expand Up @@ -1147,11 +1147,9 @@ float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_
*/
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);
#endif
int32_t axis, size_t pointer_index) __INTRODUCED_IN(13);

/**
* Get the number of historical points in this event. These are movements that
Expand Down Expand Up @@ -1282,14 +1280,12 @@ float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_
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);
#endif
int32_t axis, size_t pointer_index, size_t history_index) __INTRODUCED_IN(13);


struct AInputQueue;
Expand Down
10 changes: 3 additions & 7 deletions include/android/multinetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ typedef uint64_t net_handle_t;
* on failure with an appropriate errno value set.
*/

#if __ANDROID_API__ >= 24

/**
* Set the network to be used by the given socket file descriptor.
*
Expand All @@ -70,7 +68,7 @@ typedef uint64_t net_handle_t;
* This is the equivalent of: [android.net.Network#bindSocket()](https://developer.android.com/reference/android/net/Network.html#bindSocket(java.net.Socket))
*
*/
int android_setsocknetwork(net_handle_t network, int fd);
int android_setsocknetwork(net_handle_t network, int fd) __INTRODUCED_IN(23);


/**
Expand All @@ -87,7 +85,7 @@ int android_setsocknetwork(net_handle_t network, int fd);
* This is the equivalent of: [android.net.ConnectivityManager#setProcessDefaultNetwork()](https://developer.android.com/reference/android/net/ConnectivityManager.html#setProcessDefaultNetwork(android.net.Network))
*
*/
int android_setprocnetwork(net_handle_t network);
int android_setprocnetwork(net_handle_t network) __INTRODUCED_IN(23);


/**
Expand All @@ -106,9 +104,7 @@ int android_setprocnetwork(net_handle_t network);
*/
int android_getaddrinfofornetwork(net_handle_t network,
const char *node, const char *service,
const struct addrinfo *hints, struct addrinfo **res);

#endif /* __ANDROID_API__ >= 24 */
const struct addrinfo *hints, struct addrinfo **res) __INTRODUCED_IN(23);

__END_DECLS

Expand Down
4 changes: 1 addition & 3 deletions include/android/native_window_jni.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,14 @@ extern "C" {
*/
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
* the ANativeWindow; maintains it through general Java object's life cycle;
* and will automatically release the reference when the Java object gets garbage
* collected.
*/
jobject ANativeWindow_toSurface(JNIEnv* env, ANativeWindow* window);
#endif
jobject ANativeWindow_toSurface(JNIEnv* env, ANativeWindow* window) __INTRODUCED_IN(26);

#ifdef __cplusplus
};
Expand Down
39 changes: 15 additions & 24 deletions include/android/sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ __attribute__ ((deprecated)) ASensorManager* ASensorManager_getInstance();
ASensorManager* ASensorManager_getInstance();
#endif

#if __ANDROID_API__ >= __ANDROID_API_O__
/**
* Get a reference to the sensor manager. ASensorManager is a singleton
* per package as different packages may have access to different sensors.
Expand All @@ -488,8 +487,7 @@ ASensorManager* ASensorManager_getInstance();
* ASensorManager* sensorManager = ASensorManager_getInstanceForPackage("foo.bar.baz");
*
*/
ASensorManager* ASensorManager_getInstanceForPackage(const char* packageName);
#endif
ASensorManager* ASensorManager_getInstanceForPackage(const char* packageName) __INTRODUCED_IN(26);

/**
* Returns the list of available sensors.
Expand All @@ -502,13 +500,11 @@ int ASensorManager_getSensorList(ASensorManager* manager, ASensorList* list);
*/
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);
#endif
ASensor const* ASensorManager_getDefaultSensorEx(ASensorManager* manager, int type, bool wakeUp) __INTRODUCED_IN(21);

/**
* Creates a new sensor event queue and associate it with a looper.
Expand All @@ -525,7 +521,6 @@ ASensorEventQueue* ASensorManager_createEventQueue(ASensorManager* manager,
*/
int ASensorManager_destroyEventQueue(ASensorManager* manager, ASensorEventQueue* queue);

#if __ANDROID_API__ >= __ANDROID_API_O__
/**
* Create direct channel based on shared memory
*
Expand All @@ -542,7 +537,7 @@ int ASensorManager_destroyEventQueue(ASensorManager* manager, ASensorEventQueue*
* {@link ASensorManager_destroyDirectChannel} and
* {@link ASensorManager_configureDirectReport}, or value less or equal to 0 for failures.
*/
int ASensorManager_createSharedMemoryDirectChannel(ASensorManager* manager, int fd, size_t size);
int ASensorManager_createSharedMemoryDirectChannel(ASensorManager* manager, int fd, size_t size) __INTRODUCED_IN(26);

/**
* Create direct channel based on AHardwareBuffer
Expand All @@ -560,7 +555,7 @@ int ASensorManager_createSharedMemoryDirectChannel(ASensorManager* manager, int
* {@link ASensorManager_configureDirectReport}, or value less or equal to 0 for failures.
*/
int ASensorManager_createHardwareBufferDirectChannel(
ASensorManager* manager, AHardwareBuffer const * buffer, size_t size);
ASensorManager* manager, AHardwareBuffer const * buffer, size_t size) __INTRODUCED_IN(26);

/**
* Destroy a direct channel
Expand All @@ -575,7 +570,7 @@ int ASensorManager_createHardwareBufferDirectChannel(
* {@link ASensorManager_createSharedMemoryDirectChannel} or
* {@link ASensorManager_createHardwareBufferDirectChannel}.
*/
void ASensorManager_destroyDirectChannel(ASensorManager* manager, int channelId);
void ASensorManager_destroyDirectChannel(ASensorManager* manager, int channelId) __INTRODUCED_IN(26);

/**
* Configure direct report on channel
Expand Down Expand Up @@ -612,9 +607,8 @@ void ASensorManager_destroyDirectChannel(ASensorManager* manager, int channelId)
*
* \return positive token for success or negative error code.
*/
int ASensorManager_configureDirectReport(
ASensorManager* manager, ASensor const* sensor, int channelId, int rate);
#endif
int ASensorManager_configureDirectReport(ASensorManager* manager,
ASensor const* sensor, int channelId, int rate) __INTRODUCED_IN(26);

/*****************************************************************************/

Expand Down Expand Up @@ -733,35 +727,32 @@ float ASensor_getResolution(ASensor const* sensor);
*/
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.
*/
int ASensor_getFifoMaxEventCount(ASensor const* sensor);
int ASensor_getFifoMaxEventCount(ASensor const* sensor) __INTRODUCED_IN(21);

/**
* Returns the hardware batch fifo size reserved to this sensor.
*/
int ASensor_getFifoReservedEventCount(ASensor const* sensor);
int ASensor_getFifoReservedEventCount(ASensor const* sensor) __INTRODUCED_IN(21);

/**
* Returns this sensor's string type.
*/
const char* ASensor_getStringType(ASensor const* sensor);
const char* ASensor_getStringType(ASensor const* sensor) __INTRODUCED_IN(21);

/**
* Returns the reporting mode for this sensor. One of AREPORTING_MODE_* constants.
*/
int ASensor_getReportingMode(ASensor const* sensor);
int ASensor_getReportingMode(ASensor const* sensor) __INTRODUCED_IN(21);

/**
* Returns true if this is a wake up sensor, false otherwise.
*/
bool ASensor_isWakeUpSensor(ASensor const* sensor);
#endif /* __ANDROID_API__ >= 21 */
bool ASensor_isWakeUpSensor(ASensor const* sensor) __INTRODUCED_IN(21);

#if __ANDROID_API__ >= __ANDROID_API_O__
/**
* Test if sensor supports a certain type of direct channel.
*
Expand All @@ -771,7 +762,8 @@ bool ASensor_isWakeUpSensor(ASensor const* sensor);
* or {@link ASENSOR_DIRECT_CHANNEL_TYPE_HARDWARE_BUFFER}.
* \returns true if sensor supports the specified direct channel type.
*/
bool ASensor_isDirectChannelTypeSupported(ASensor const* sensor, int channelType);
bool ASensor_isDirectChannelTypeSupported(ASensor const* sensor, int channelType) __INTRODUCED_IN(26);

/**
* Get the highest direct rate level that a sensor support.
*
Expand All @@ -781,8 +773,7 @@ bool ASensor_isDirectChannelTypeSupported(ASensor const* sensor, int channelType
* If return value is {@link ASENSOR_DIRECT_RATE_STOP}, it means the sensor
* does not support direct report.
*/
int ASensor_getHighestDirectReportRateLevel(ASensor const* sensor);
#endif
int ASensor_getHighestDirectReportRateLevel(ASensor const* sensor) __INTRODUCED_IN(26);

#ifdef __cplusplus
};
Expand Down
Loading

0 comments on commit 93e101b

Please sign in to comment.