Merge "binder_parcel_fuzzer: add cc's"
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 5469d0c..61e22a4 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -154,6 +154,7 @@
#define XFRM_STAT_PROC_FILE "/proc/net/xfrm_stat"
#define WLUTIL "/vendor/xbin/wlutil"
#define WMTRACE_DATA_DIR "/data/misc/wmtrace"
+#define OTA_METADATA_DIR "/metadata/ota"
// TODO(narayan): Since this information has to be kept in sync
// with tombstoned, we should just put it in a common header.
@@ -1546,6 +1547,7 @@
add_mountinfo();
DumpIpTablesAsRoot();
DumpDynamicPartitionInfo();
+ ds.AddDir(OTA_METADATA_DIR, true);
// Capture any IPSec policies in play. No keys are exposed here.
RunCommand("IP XFRM POLICY", {"ip", "xfrm", "policy"}, CommandOptions::WithTimeout(10).Build());
diff --git a/include/android/choreographer.h b/include/android/choreographer.h
index 1b589bc..0d97e8c 100644
--- a/include/android/choreographer.h
+++ b/include/android/choreographer.h
@@ -59,6 +59,8 @@
/**
* Get the AChoreographer instance for the current thread. This must be called
* on an ALooper thread.
+ *
+ * Available since API level 24.
*/
AChoreographer* AChoreographer_getInstance() __INTRODUCED_IN(24);
@@ -82,6 +84,8 @@
/**
* Power a callback to be run on the next frame. The data pointer provided will
* be passed to the callback function when it's called.
+ *
+ * Available since API level 29.
*/
void AChoreographer_postFrameCallback64(AChoreographer* choreographer,
AChoreographer_frameCallback64 callback, void* data) __INTRODUCED_IN(29);
@@ -90,6 +94,8 @@
* 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.
+ *
+ * Available since API level 29.
*/
void AChoreographer_postFrameCallbackDelayed64(AChoreographer* choreographer,
AChoreographer_frameCallback64 callback, void* data, uint32_t delayMillis) __INTRODUCED_IN(29);
diff --git a/include/android/configuration.h b/include/android/configuration.h
index ef6c5a2..3310722 100644
--- a/include/android/configuration.h
+++ b/include/android/configuration.h
@@ -675,50 +675,52 @@
*/
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) __INTRODUCED_IN(13);
+int32_t AConfiguration_getScreenWidthDp(AConfiguration* config);
/**
* Set the configuration's current screen width in dp units.
*/
-void AConfiguration_setScreenWidthDp(AConfiguration* config, int32_t value) __INTRODUCED_IN(13);
+void AConfiguration_setScreenWidthDp(AConfiguration* config, int32_t value);
/**
* Return the current configuration screen height in dp units, or
* ACONFIGURATION_SCREEN_HEIGHT_DP_ANY if not set.
*/
-int32_t AConfiguration_getScreenHeightDp(AConfiguration* config) __INTRODUCED_IN(13);
+int32_t AConfiguration_getScreenHeightDp(AConfiguration* config);
/**
* Set the configuration's current screen width in dp units.
*/
-void AConfiguration_setScreenHeightDp(AConfiguration* config, int32_t value) __INTRODUCED_IN(13);
+void AConfiguration_setScreenHeightDp(AConfiguration* config, int32_t value);
/**
* 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) __INTRODUCED_IN(13);
+int32_t AConfiguration_getSmallestScreenWidthDp(AConfiguration* config);
/**
* 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 */
+void AConfiguration_setSmallestScreenWidthDp(AConfiguration* config, int32_t value);
#if __ANDROID_API__ >= 17
/**
* Return the configuration's layout direction, or
* ACONFIGURATION_LAYOUTDIR_ANY if not set.
+ *
+ * Available since API level 17.
*/
int32_t AConfiguration_getLayoutDirection(AConfiguration* config) __INTRODUCED_IN(17);
/**
* Set the configuration's layout direction.
+ *
+ * Available since API level 17.
*/
void AConfiguration_setLayoutDirection(AConfiguration* config, int32_t value) __INTRODUCED_IN(17);
#endif /* __ANDROID_API__ >= 17 */
diff --git a/include/android/font.h b/include/android/font.h
index 8001ee1..1618096 100644
--- a/include/android/font.h
+++ b/include/android/font.h
@@ -96,6 +96,8 @@
/**
* Close an AFont.
*
+ * Available since API level 29.
+ *
* \param font a font returned by ASystemFontIterator_next or AFontMatchert_match.
* Do nothing if NULL is passed.
*/
@@ -116,6 +118,8 @@
* The font file returned is guaranteed to be opend with O_RDONLY.
* Note that the returned pointer is valid until AFont_close() is called for the given font.
*
+ * Available since API level 29.
+ *
* \param font a font object. Passing NULL is not allowed.
* \return a string of the font file path.
*/
@@ -184,6 +188,8 @@
*
* For more information about font weight, read [OpenType usWeightClass](https://docs.microsoft.com/en-us/typography/opentype/spec/os2#usweightclass)
*
+ * Available since API level 29.
+ *
* \param font a font object. Passing NULL is not allowed.
* \return a positive integer less than or equal to {@link ASYSTEM_FONT_MAX_WEIGHT} is returned.
*/
@@ -192,6 +198,8 @@
/**
* Return true if the current font is italic, otherwise returns false.
*
+ * Available since API level 29.
+ *
* \param font a font object. Passing NULL is not allowed.
* \return true if italic, otherwise false.
*/
@@ -204,6 +212,8 @@
*
* Note that the returned pointer is valid until AFont_close() is called.
*
+ * Available since API level 29.
+ *
* \param font a font object. Passing NULL is not allowed.
* \return a IETF BCP47 compliant language tag or nullptr if not available.
*/
@@ -216,6 +226,8 @@
* returns a non-negative value as an font offset in the collection. This
* always returns 0 if the target font file is a regular font.
*
+ * Available since API level 29.
+ *
* \param font a font object. Passing NULL is not allowed.
* \return a font collection index.
*/
@@ -247,6 +259,8 @@
*
* For more information about font variation settings, read [Font Variations Table](https://docs.microsoft.com/en-us/typography/opentype/spec/fvar)
*
+ * Available since API level 29.
+ *
* \param font a font object. Passing NULL is not allowed.
* \return a number of font variation settings.
*/
@@ -258,6 +272,8 @@
*
* See AFont_getAxisCount for more details.
*
+ * Available since API level 29.
+ *
* \param font a font object. Passing NULL is not allowed.
* \param axisIndex an index to the font variation settings. Passing value larger than or
* equal to {@link AFont_getAxisCount} is not allowed.
@@ -271,6 +287,8 @@
*
* See AFont_getAxisCount for more details.
*
+ * Available since API level 29.
+ *
* \param font a font object. Passing NULL is not allowed.
* \param axisIndex an index to the font variation settings. Passing value larger than or
* equal to {@link ASYstemFont_getAxisCount} is not allwed.
diff --git a/include/android/font_matcher.h b/include/android/font_matcher.h
index 0b8f892..d4bd892 100644
--- a/include/android/font_matcher.h
+++ b/include/android/font_matcher.h
@@ -130,13 +130,17 @@
*/
/**
- * Creates a new AFontMatcher object
+ * Creates a new AFontMatcher object.
+ *
+ * Available since API level 29.
*/
AFontMatcher* _Nonnull AFontMatcher_create() __INTRODUCED_IN(29);
/**
* Destroy the matcher object.
*
+ * Available since API level 29.
+ *
* \param matcher a matcher object. Passing NULL is not allowed.
*/
void AFontMatcher_destroy(AFontMatcher* _Nonnull matcher) __INTRODUCED_IN(29);
@@ -147,6 +151,8 @@
* If this function is not called, the matcher performs with {@link ASYSTEM_FONT_WEIGHT_NORMAL}
* with non-italic style.
*
+ * Available since API level 29.
+ *
* \param matcher a matcher object. Passing NULL is not allowed.
* \param weight a font weight value. Only from 0 to 1000 value is valid
* \param italic true if italic, otherwise false.
@@ -161,6 +167,8 @@
*
* If this function is not called, the matcher performs with empty locale list.
*
+ * Available since API level 29.
+ *
* \param matcher a matcher object. Passing NULL is not allowed.
* \param languageTags a null character terminated comma separated IETF BCP47 compliant language
* tags.
@@ -174,6 +182,8 @@
*
* If this function is not called, the matcher performs with {@link AFAMILY_VARIANT_DEFAULT}.
*
+ * Available since API level 29.
+ *
* \param matcher a matcher object. Passing NULL is not allowed.
* \param familyVariant Must be one of {@link AFAMILY_VARIANT_DEFAULT},
* {@link AFAMILY_VARIANT_COMPACT} or {@link AFAMILY_VARIANT_ELEGANT} is valid.
@@ -190,6 +200,8 @@
* Even if no font can render the given text, this function will return a non-null result for
* drawing Tofu character.
*
+ * Available since API level 29.
+ *
* \param matcher a matcher object. Passing NULL is not allowed.
* \param familyName a null character terminated font family name
* \param text a UTF-16 encoded text buffer to be rendered. Do not pass empty string.
diff --git a/include/android/hardware_buffer_jni.h b/include/android/hardware_buffer_jni.h
index aedf369..293e5ac 100644
--- a/include/android/hardware_buffer_jni.h
+++ b/include/android/hardware_buffer_jni.h
@@ -42,6 +42,8 @@
* that is returned. To keep the AHardwareBuffer live after the Java
* HardwareBuffer object got garbage collected, be sure to use AHardwareBuffer_acquire()
* to acquire an additional reference.
+ *
+ * Available since API level 26.
*/
AHardwareBuffer* AHardwareBuffer_fromHardwareBuffer(JNIEnv* env,
jobject hardwareBufferObj) __INTRODUCED_IN(26);
@@ -49,6 +51,8 @@
/**
* Return a new Java HardwareBuffer object that wraps the passed native
* AHardwareBuffer object.
+ *
+ * Available since API level 26.
*/
jobject AHardwareBuffer_toHardwareBuffer(JNIEnv* env,
AHardwareBuffer* hardwareBuffer) __INTRODUCED_IN(26);
diff --git a/include/android/input.h b/include/android/input.h
index cfade6c..ce439c6 100644
--- a/include/android/input.h
+++ b/include/android/input.h
@@ -986,10 +986,8 @@
*/
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
+int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event);
/**
* Get a bitfield indicating which edges, if any, were touched by this motion event.
@@ -1054,14 +1052,12 @@
*/
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
+int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index);
/**
* Get the original raw X coordinate of this event.
@@ -1151,11 +1147,9 @@
*/
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
+ int32_t axis, size_t pointer_index);
/**
* Get the number of historical points in this event. These are movements that
@@ -1286,14 +1280,12 @@
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
+ int32_t axis, size_t pointer_index, size_t history_index);
struct AInputQueue;
diff --git a/include/android/multinetwork.h b/include/android/multinetwork.h
index d31d1f1..59b1deb 100644
--- a/include/android/multinetwork.h
+++ b/include/android/multinetwork.h
@@ -69,6 +69,7 @@
*
* This is the equivalent of: [android.net.Network#bindSocket()](https://developer.android.com/reference/android/net/Network.html#bindSocket(java.net.Socket))
*
+ * Available since API level 23.
*/
int android_setsocknetwork(net_handle_t network, int fd) __INTRODUCED_IN(23);
@@ -86,6 +87,7 @@
*
* This is the equivalent of: [android.net.ConnectivityManager#setProcessDefaultNetwork()](https://developer.android.com/reference/android/net/ConnectivityManager.html#setProcessDefaultNetwork(android.net.Network))
*
+ * Available since API level 23.
*/
int android_setprocnetwork(net_handle_t network) __INTRODUCED_IN(23);
@@ -103,6 +105,7 @@
*
* This is the equivalent of: [android.net.Network#getAllByName()](https://developer.android.com/reference/android/net/Network.html#getAllByName(java.lang.String))
*
+ * Available since API level 23.
*/
int android_getaddrinfofornetwork(net_handle_t network,
const char *node, const char *service,
@@ -144,6 +147,8 @@
*
* Returns a file descriptor to watch for read events, or a negative
* POSIX error code (see errno.h) if an immediate error occurs.
+ *
+ * Available since API level 29.
*/
int android_res_nquery(net_handle_t network,
const char *dname, int ns_class, int ns_type, uint32_t flags) __INTRODUCED_IN(29);
@@ -155,6 +160,8 @@
*
* Returns a file descriptor to watch for read events, or a negative
* POSIX error code (see errno.h) if an immediate error occurs.
+ *
+ * Available since API level 29.
*/
int android_res_nsend(net_handle_t network,
const uint8_t *msg, size_t msglen, uint32_t flags) __INTRODUCED_IN(29);
@@ -163,6 +170,8 @@
* Read a result for the query associated with the |fd| descriptor.
* Closes |fd| before returning.
*
+ * Available since 29.
+ *
* Returns:
* < 0: negative POSIX error code (see errno.h for possible values). |rcode| is not set.
* >= 0: length of |answer|. |rcode| is the resolver return code (e.g., ns_r_nxdomain)
@@ -173,6 +182,8 @@
/**
* Attempts to cancel the in-progress query associated with the |nsend_fd|
* descriptor.
+ *
+ * Available since API level 29.
*/
void android_res_cancel(int nsend_fd) __INTRODUCED_IN(29);
diff --git a/include/android/native_window_jni.h b/include/android/native_window_jni.h
index 0c196b9..3a77ffe 100644
--- a/include/android/native_window_jni.h
+++ b/include/android/native_window_jni.h
@@ -51,6 +51,8 @@
* the ANativeWindow; maintains it through general Java object's life cycle;
* and will automatically release the reference when the Java object gets garbage
* collected.
+ *
+ * Available since API level 26.
*/
jobject ANativeWindow_toSurface(JNIEnv* env, ANativeWindow* window) __INTRODUCED_IN(26);
#endif
diff --git a/include/android/sensor.h b/include/android/sensor.h
index e9d5c16..3ebe79f 100644
--- a/include/android/sensor.h
+++ b/include/android/sensor.h
@@ -564,6 +564,7 @@
*
* ASensorManager* sensorManager = ASensorManager_getInstanceForPackage("foo.bar.baz");
*
+ * Available since API level 26.
*/
ASensorManager* ASensorManager_getInstanceForPackage(const char* packageName) __INTRODUCED_IN(26);
#endif
@@ -583,6 +584,8 @@
/**
* Returns the default sensor with the given type and wakeUp properties or NULL if no sensor
* of this type and wakeUp properties exists.
+ *
+ * Available since API level 21.
*/
ASensor const* ASensorManager_getDefaultSensorEx(ASensorManager* manager, int type, bool wakeUp) __INTRODUCED_IN(21);
#endif
@@ -609,6 +612,8 @@
* Create a direct channel of {@link ASENSOR_DIRECT_CHANNEL_TYPE_SHARED_MEMORY} to be used
* for configuring sensor direct report.
*
+ * Available since API level 26.
+ *
* \param manager the {@link ASensorManager} instance obtained from
* {@link ASensorManager_getInstanceForPackage}.
* \param fd file descriptor representing a shared memory created by
@@ -627,6 +632,8 @@
* Create a direct channel of {@link ASENSOR_DIRECT_CHANNEL_TYPE_HARDWARE_BUFFER} type to be used
* for configuring sensor direct report.
*
+ * Available since API level 26.
+ *
* \param manager the {@link ASensorManager} instance obtained from
* {@link ASensorManager_getInstanceForPackage}.
* \param buffer {@link AHardwareBuffer} instance created by {@link AHardwareBuffer_allocate}.
@@ -646,6 +653,8 @@
* The buffer used for creating direct channel does not get destroyed with
* {@link ASensorManager_destroy} and has to be close or released separately.
*
+ * Available since API level 26.
+ *
* \param manager the {@link ASensorManager} instance obtained from
* {@link ASensorManager_getInstanceForPackage}.
* \param channelId channel id (a positive integer) returned from
@@ -678,6 +687,8 @@
*
* ASensorManager_configureDirectReport(manager, sensor, channel_id, ASENSOR_DIRECT_RATE_FAST);
*
+ * Available since API level 26.
+ *
* \param manager the {@link ASensorManager} instance obtained from
* {@link ASensorManager_getInstanceForPackage}.
* \param sensor a {@link ASensor} to denote which sensor to be operate. It can be NULL if rate
@@ -780,7 +791,7 @@
*/
ssize_t ASensorEventQueue_getEvents(ASensorEventQueue* queue, ASensorEvent* events, size_t count);
-#if __ANDROID_API__ >= __ANDROID_API_Q__
+#if __ANDROID_API__ >= 29
/**
* Request that {@link ASENSOR_TYPE_ADDITIONAL_INFO} events to be delivered on
* the given {@link ASensorEventQueue}.
@@ -796,13 +807,15 @@
* {@link AAdditionalInfoEvent#type}, as new values may be defined in the future
* and may delivered to the client.
*
+ * Available since API level 29.
+ *
* \param queue {@link ASensorEventQueue} to configure
* \param enable true to request {@link ASENSOR_TYPE_ADDITIONAL_INFO} events,
* false to stop receiving events
* \return 0 on success or a negative error code on failure
*/
-int ASensorEventQueue_requestAdditionalInfoEvents(ASensorEventQueue* queue, bool enable);
-#endif /* __ANDROID_API__ >= __ANDRDOID_API_Q__ */
+int ASensorEventQueue_requestAdditionalInfoEvents(ASensorEventQueue* queue, bool enable) __INTRODUCED_IN(29);
+#endif /* __ANDROID_API__ >= 29 */
/*****************************************************************************/
@@ -837,26 +850,36 @@
/**
* Returns the maximum size of batches for this sensor. Batches will often be
* smaller, as the hardware fifo might be used for other sensors.
+ *
+ * Available since API level 21.
*/
int ASensor_getFifoMaxEventCount(ASensor const* sensor) __INTRODUCED_IN(21);
/**
* Returns the hardware batch fifo size reserved to this sensor.
+ *
+ * Available since API level 21.
*/
int ASensor_getFifoReservedEventCount(ASensor const* sensor) __INTRODUCED_IN(21);
/**
* Returns this sensor's string type.
+ *
+ * Available since API level 21.
*/
const char* ASensor_getStringType(ASensor const* sensor) __INTRODUCED_IN(21);
/**
* Returns the reporting mode for this sensor. One of AREPORTING_MODE_* constants.
+ *
+ * Available since API level 21.
*/
int ASensor_getReportingMode(ASensor const* sensor) __INTRODUCED_IN(21);
/**
* Returns true if this is a wake up sensor, false otherwise.
+ *
+ * Available since API level 21.
*/
bool ASensor_isWakeUpSensor(ASensor const* sensor) __INTRODUCED_IN(21);
#endif /* __ANDROID_API__ >= 21 */
@@ -865,6 +888,8 @@
/**
* Test if sensor supports a certain type of direct channel.
*
+ * Available since API level 26.
+ *
* \param sensor a {@link ASensor} to denote the sensor to be checked.
* \param channelType Channel type constant, either
* {@ASENSOR_DIRECT_CHANNEL_TYPE_SHARED_MEMORY}
@@ -874,7 +899,9 @@
bool ASensor_isDirectChannelTypeSupported(ASensor const* sensor, int channelType) __INTRODUCED_IN(26);
/**
- * Get the highest direct rate level that a sensor support.
+ * Get the highest direct rate level that a sensor supports.
+ *
+ * Available since API level 26.
*
* \param sensor a {@link ASensor} to denote the sensor to be checked.
*
@@ -885,7 +912,7 @@
int ASensor_getHighestDirectReportRateLevel(ASensor const* sensor) __INTRODUCED_IN(26);
#endif /* __ANDROID_API__ >= 26 */
-#if __ANDROID_API__ >= __ANDROID_API_Q__
+#if __ANDROID_API__ >= 29
/**
* Returns the sensor's handle.
*
@@ -899,9 +926,11 @@
* It is important to note that the value returned by {@link ASensor_getHandle} is not the same as
* the value returned by the Java API {@link android.hardware.Sensor#getId} and no mapping exists
* between the values.
+ *
+ * Available since API level 29.
*/
-int ASensor_getHandle(ASensor const* sensor) __INTRODUCED_IN(__ANDROID_API_Q__);
-#endif /* __ANDROID_API__ >= ANDROID_API_Q__ */
+int ASensor_getHandle(ASensor const* sensor) __INTRODUCED_IN(29);
+#endif /* __ANDROID_API__ >= 29 */
#ifdef __cplusplus
};
diff --git a/include/android/surface_control.h b/include/android/surface_control.h
index abb8368..31abb66 100644
--- a/include/android/surface_control.h
+++ b/include/android/surface_control.h
@@ -46,7 +46,7 @@
*/
typedef struct ASurfaceControl ASurfaceControl;
-/*
+/**
* Creates an ASurfaceControl with either ANativeWindow or an ASurfaceControl as its parent.
* |debug_name| is a debug name associated with this surface. It can be used to
* identify this surface in the SurfaceFlinger's layer tree. It must not be
@@ -54,10 +54,17 @@
*
* The caller takes ownership of the ASurfaceControl returned and must release it
* using ASurfaceControl_release below.
+ *
+ * Available since API level 29.
*/
ASurfaceControl* ASurfaceControl_createFromWindow(ANativeWindow* parent, const char* debug_name)
__INTRODUCED_IN(29);
+/**
+ * See ASurfaceControl_createFromWindow.
+ *
+ * Available since API level 29.
+ */
ASurfaceControl* ASurfaceControl_create(ASurfaceControl* parent, const char* debug_name)
__INTRODUCED_IN(29);
@@ -65,6 +72,8 @@
* Releases the |surface_control| object. After releasing the ASurfaceControl the caller no longer
* has ownership of the AsurfaceControl. The surface and it's children may remain on display as long
* as their parent remains on display.
+ *
+ * Available since API level 29.
*/
void ASurfaceControl_release(ASurfaceControl* surface_control) __INTRODUCED_IN(29);
@@ -79,11 +88,15 @@
/**
* The caller takes ownership of the transaction and must release it using
* ASurfaceControl_delete below.
+ *
+ * Available since API level 29.
*/
ASurfaceTransaction* ASurfaceTransaction_create() __INTRODUCED_IN(29);
/**
* Destroys the |transaction| object.
+ *
+ * Available since API level 29.
*/
void ASurfaceTransaction_delete(ASurfaceTransaction* transaction) __INTRODUCED_IN(29);
@@ -93,6 +106,8 @@
* Note that the transaction is guaranteed to be applied atomically. The
* transactions which are applied on the same thread are also guaranteed to be
* applied in order.
+ *
+ * Available since API level 29.
*/
void ASurfaceTransaction_apply(ASurfaceTransaction* transaction) __INTRODUCED_IN(29);
@@ -116,6 +131,8 @@
*
* THREADING
* The transaction completed callback can be invoked on any thread.
+ *
+ * Available since API level 29.
*/
typedef void (*ASurfaceTransaction_OnComplete)(void* context, ASurfaceTransactionStats* stats)
__INTRODUCED_IN(29);
@@ -123,6 +140,8 @@
/**
* Returns the timestamp of when the frame was latched by the framework. Once a frame is
* latched by the framework, it is presented at the following hardware vsync.
+ *
+ * Available since API level 29.
*/
int64_t ASurfaceTransactionStats_getLatchTime(ASurfaceTransactionStats* surface_transaction_stats)
__INTRODUCED_IN(29);
@@ -131,6 +150,8 @@
* Returns a sync fence that signals when the transaction has been presented.
* The recipient of the callback takes ownership of the fence and is responsible for closing
* it. If a device does not support present fences, a -1 will be returned.
+ *
+ * Available since API level 29.
*/
int ASurfaceTransactionStats_getPresentFenceFd(ASurfaceTransactionStats* surface_transaction_stats)
__INTRODUCED_IN(29);
@@ -141,6 +162,8 @@
* When the client is done using the array, it must release it by calling
* ASurfaceTransactionStats_releaseASurfaceControls.
*
+ * Available since API level 29.
+ *
* |outASurfaceControlsSize| returns the size of the ASurfaceControls array.
*/
void ASurfaceTransactionStats_getASurfaceControls(ASurfaceTransactionStats* surface_transaction_stats,
@@ -150,6 +173,8 @@
/**
* Releases the array of ASurfaceControls that were returned by
* ASurfaceTransactionStats_getASurfaceControls.
+ *
+ * Available since API level 29.
*/
void ASurfaceTransactionStats_releaseASurfaceControls(ASurfaceControl** surface_controls)
__INTRODUCED_IN(29);
@@ -158,6 +183,8 @@
* Returns the timestamp of when the CURRENT buffer was acquired. A buffer is considered
* acquired when its acquire_fence_fd has signaled. A buffer cannot be latched or presented until
* it is acquired. If no acquire_fence_fd was provided, this timestamp will be set to -1.
+ *
+ * Available since API level 29.
*/
int64_t ASurfaceTransactionStats_getAcquireTime(ASurfaceTransactionStats* surface_transaction_stats,
ASurfaceControl* surface_control)
@@ -180,6 +207,8 @@
*
* The client must ensure that all pending refs on a buffer are released before attempting to reuse
* this buffer, otherwise synchronization errors may occur.
+ *
+ * Available since API level 29.
*/
int ASurfaceTransactionStats_getPreviousReleaseFenceFd(
ASurfaceTransactionStats* surface_transaction_stats,
@@ -190,6 +219,8 @@
* Sets the callback that will be invoked when the updates from this transaction
* are presented. For details on the callback semantics and data, see the
* comments on the ASurfaceTransaction_OnComplete declaration above.
+ *
+ * Available since API level 29.
*/
void ASurfaceTransaction_setOnComplete(ASurfaceTransaction* transaction, void* context,
ASurfaceTransaction_OnComplete func) __INTRODUCED_IN(29);
@@ -199,6 +230,8 @@
* Any children of the* reparented |surface_control| will remain children of the |surface_control|.
*
* The |new_parent| can be null. Surface controls with a null parent do not appear on the display.
+ *
+ * Available since API level 29.
*/
void ASurfaceTransaction_reparent(ASurfaceTransaction* transaction,
ASurfaceControl* surface_control, ASurfaceControl* new_parent)
@@ -213,6 +246,8 @@
* Updates the visibility of |surface_control|. If show is set to
* ASURFACE_TRANSACTION_VISIBILITY_HIDE, the |surface_control| and all surfaces in its subtree will
* be hidden.
+ *
+ * Available since API level 29.
*/
void ASurfaceTransaction_setVisibility(ASurfaceTransaction* transaction,
ASurfaceControl* surface_control, int8_t visibility)
@@ -224,6 +259,8 @@
* the same z order is undefined.
*
* Z orders may be from MIN_INT32 to MAX_INT32. A layer's default z order index is 0.
+ *
+ * Available since API level 29.
*/
void ASurfaceTransaction_setZOrder(ASurfaceTransaction* transaction,
ASurfaceControl* surface_control, int32_t z_order)
@@ -236,6 +273,8 @@
*
* The frameworks takes ownership of the |acquire_fence_fd| passed and is responsible
* for closing it.
+ *
+ * Available since API level 29.
*/
void ASurfaceTransaction_setBuffer(ASurfaceTransaction* transaction,
ASurfaceControl* surface_control, AHardwareBuffer* buffer,
@@ -246,6 +285,8 @@
* ASurfaceControl visible in transparent regions of the surface. Colors |r|, |g|,
* and |b| must be within the range that is valid for |dataspace|. |dataspace| and |alpha|
* will be the dataspace and alpha set for the background color layer.
+ *
+ * Available since API level 29.
*/
void ASurfaceTransaction_setColor(ASurfaceTransaction* transaction,
ASurfaceControl* surface_control, float r, float g, float b,
@@ -264,6 +305,8 @@
* |transform| the transform applied after the source rect is applied to the buffer. This parameter
* should be set to 0 for no transform. To specify a transfrom use the NATIVE_WINDOW_TRANSFORM_*
* enum.
+ *
+ * Available since API level 29.
*/
void ASurfaceTransaction_setGeometry(ASurfaceTransaction* transaction,
ASurfaceControl* surface_control, const ARect& source,
@@ -281,6 +324,8 @@
* Updates whether the content for the buffer associated with this surface is
* completely opaque. If true, every pixel of content inside the buffer must be
* opaque or visual errors can occur.
+ *
+ * Available since API level 29.
*/
void ASurfaceTransaction_setBufferTransparency(ASurfaceTransaction* transaction,
ASurfaceControl* surface_control,
@@ -290,6 +335,8 @@
/**
* Updates the region for the content on this surface updated in this
* transaction. If unspecified, the complete surface is assumed to be damaged.
+ *
+ * Available since API level 29.
*/
void ASurfaceTransaction_setDamageRegion(ASurfaceTransaction* transaction,
ASurfaceControl* surface_control, const ARect rects[],
@@ -304,6 +351,8 @@
*
* If an earlier transaction has a desired present time of x, and a later transaction has a desired
* present time that is before x, the later transaction will not preempt the earlier transaction.
+ *
+ * Available since API level 29.
*/
void ASurfaceTransaction_setDesiredPresentTime(ASurfaceTransaction* transaction,
int64_t desiredPresentTime) __INTRODUCED_IN(29);
@@ -312,6 +361,8 @@
* Sets the alpha for the buffer. It uses a premultiplied blending.
*
* The |alpha| must be between 0.0 and 1.0.
+ *
+ * Available since API level 29.
*/
void ASurfaceTransaction_setBufferAlpha(ASurfaceTransaction* transaction,
ASurfaceControl* surface_control, float alpha)
@@ -321,6 +372,8 @@
* Sets the data space of the surface_control's buffers.
*
* If no data space is set, the surface control defaults to ADATASPACE_SRGB.
+ *
+ * Available since API level 29.
*/
void ASurfaceTransaction_setBufferDataSpace(ASurfaceTransaction* transaction,
ASurfaceControl* surface_control, ADataSpace data_space)
@@ -331,6 +384,8 @@
*
* When |metadata| is set to null, the framework does not use any smpte2086 metadata when rendering
* the surface's buffer.
+ *
+ * Available since API level 29.
*/
void ASurfaceTransaction_setHdrMetadata_smpte2086(ASurfaceTransaction* transaction,
ASurfaceControl* surface_control,
@@ -342,6 +397,8 @@
*
* When |metadata| is set to null, the framework does not use any cta861.3 metadata when rendering
* the surface's buffer.
+ *
+ * Available since API level 29.
*/
void ASurfaceTransaction_setHdrMetadata_cta861_3(ASurfaceTransaction* transaction,
ASurfaceControl* surface_control,
diff --git a/include/android/surface_texture.h b/include/android/surface_texture.h
index 540d23a..dde7eaa 100644
--- a/include/android/surface_texture.h
+++ b/include/android/surface_texture.h
@@ -65,6 +65,9 @@
* Release the reference to the native ASurfaceTexture acquired with
* ASurfaceTexture_fromSurfaceTexture().
* Failing to do so will result in leaked memory and graphic resources.
+ *
+ * Available since API level 28.
+ *
* \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture()
*/
void ASurfaceTexture_release(ASurfaceTexture* st) __INTRODUCED_IN(28);
@@ -73,6 +76,8 @@
* Returns a reference to an ANativeWindow (i.e. the Producer) for this SurfaceTexture.
* This is equivalent to Java's: Surface sur = new Surface(surfaceTexture);
*
+ * Available since API level 28.
+ *
* \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture()
* @return A reference to an ANativeWindow. This reference MUST BE released when no longer needed
* using ANativeWindow_release(). Failing to do so will result in leaked resources. nullptr is
@@ -90,6 +95,8 @@
* contexts. Note, however, that the image contents are only accessible from one OpenGL ES
* context at a time.
*
+ * Available since API level 28.
+ *
* \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture()
* \param texName The name of the OpenGL ES texture that will be created. This texture name
* must be unusued in the OpenGL ES context that is current on the calling thread.
@@ -108,6 +115,8 @@
* contexts. Note, however, that the image contents are only accessible from one OpenGL ES
* context at a time.
*
+ * Available since API level 28.
+ *
* \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture()
* \return 0 on success, negative posix error code otherwise (see <errno.h>)
*/
@@ -118,6 +127,8 @@
* called while the OpenGL ES context that owns the texture is current on the calling thread.
* It will implicitly bind its texture to the GL_TEXTURE_EXTERNAL_OES texture target.
*
+ * Available since API level 28.
+ *
* \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture()
* \return 0 on success, negative posix error code otherwise (see <errno.h>)
*/
@@ -135,6 +146,8 @@
* The matrix is stored in column-major order so that it may be passed directly to OpenGL ES via
* the glLoadMatrixf or glUniformMatrix4fv functions.
*
+ * Available since API level 28.
+ *
* \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture()
* \param mtx the array into which the 4x4 matrix will be stored. The array must have exactly
* 16 elements.
@@ -156,6 +169,8 @@
* For EGL/Vulkan producers, this timestamp is the desired present time set with the
* EGL_ANDROID_presentation_time or VK_GOOGLE_display_timing extensions
*
+ * Available since API level 28.
+ *
* \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture()
*/
int64_t ASurfaceTexture_getTimestamp(ASurfaceTexture* st) __INTRODUCED_IN(28);
diff --git a/include/android/surface_texture_jni.h b/include/android/surface_texture_jni.h
index b0e1edd..2266d54 100644
--- a/include/android/surface_texture_jni.h
+++ b/include/android/surface_texture_jni.h
@@ -32,6 +32,8 @@
__BEGIN_DECLS
+#if __ANDROID_API__ >= 28
+
/**
* Get a reference to the native ASurfaceTexture from the corresponding java object.
*
@@ -40,13 +42,17 @@
* properly once the Java object gets finalized.
* However, this will not result in program termination.
*
+ * Available since API level 28.
+ *
* \param env JNI environment
* \param surfacetexture Instance of Java SurfaceTexture object
* \return native ASurfaceTexture reference or nullptr if the java object is not a SurfaceTexture.
* The returned reference MUST BE released when it's no longer needed using
* ASurfaceTexture_release().
*/
-ASurfaceTexture* ASurfaceTexture_fromSurfaceTexture(JNIEnv* env, jobject surfacetexture);
+ASurfaceTexture* ASurfaceTexture_fromSurfaceTexture(JNIEnv* env, jobject surfacetexture) __INTRODUCED_IN(28);
+
+#endif
__END_DECLS
diff --git a/include/android/system_fonts.h b/include/android/system_fonts.h
index f0485a1..6fd7d2c 100644
--- a/include/android/system_fonts.h
+++ b/include/android/system_fonts.h
@@ -102,6 +102,8 @@
*
* Use ASystemFont_close() to close the iterator.
*
+ * Available since API level 29.
+ *
* \return a pointer for a newly allocated iterator, nullptr on failure.
*/
ASystemFontIterator* _Nullable ASystemFontIterator_open() __INTRODUCED_IN(29);
@@ -109,6 +111,8 @@
/**
* Close an opened system font iterator, freeing any related resources.
*
+ * Available since API level 29.
+ *
* \param iterator a pointer of an iterator for the system fonts. Do nothing if NULL is passed.
*/
void ASystemFontIterator_close(ASystemFontIterator* _Nullable iterator) __INTRODUCED_IN(29);
@@ -116,6 +120,8 @@
/**
* Move to the next system font.
*
+ * Available since API level 29.
+ *
* \param iterator an iterator for the system fonts. Passing NULL is not allowed.
* \return a font. If no more font is available, returns nullptr. You need to release the returned
* font by ASystemFont_close when it is no longer needed.
diff --git a/include/android/trace.h b/include/android/trace.h
index bb7ff28..d59690a 100644
--- a/include/android/trace.h
+++ b/include/android/trace.h
@@ -74,7 +74,7 @@
#endif /* __ANDROID_API__ >= 23 */
-#if __ANDROID_API__ >= __ANDROID_API_Q__
+#if __ANDROID_API__ >= 29
/**
* Writes a trace message to indicate that a given section of code has
@@ -83,6 +83,8 @@
* asynchronous events do not need to be nested. The name and cookie used to
* begin an event must be used to end it.
*
+ * Available since API level 29.
+ *
* \param sectionName The method name to appear in the trace.
* \param cookie Unique identifier for distinguishing simultaneous events
*/
@@ -93,6 +95,8 @@
* Must be called exactly once for each call to {@link ATrace_beginAsyncSection}
* using the same name and cookie.
*
+ * Available since API level 29.
+ *
* \param methodName The method name to appear in the trace.
* \param cookie Unique identifier for distinguishing simultaneous events
*/
@@ -101,6 +105,8 @@
/**
* Writes trace message to indicate the value of a given counter.
*
+ * Available since API level 29.
+ *
* \param counterName The counter name to appear in the trace.
* \param counterValue The counter value.
*/
diff --git a/libs/binder/IUidObserver.cpp b/libs/binder/IUidObserver.cpp
index 038e6bf..b21af96 100644
--- a/libs/binder/IUidObserver.cpp
+++ b/libs/binder/IUidObserver.cpp
@@ -56,13 +56,15 @@
remote()->transact(ON_UID_IDLE_TRANSACTION, data, &reply, IBinder::FLAG_ONEWAY);
}
- virtual void onUidStateChanged(uid_t uid, int32_t procState, int64_t procStateSeq)
+ virtual void onUidStateChanged(uid_t uid, int32_t procState, int64_t procStateSeq,
+ int32_t capability)
{
Parcel data, reply;
data.writeInterfaceToken(IUidObserver::getInterfaceDescriptor());
data.writeInt32((int32_t) uid);
data.writeInt32(procState);
data.writeInt64(procStateSeq);
+ data.writeInt32(capability);
remote()->transact(ON_UID_STATE_CHANGED_TRANSACTION, data, &reply, IBinder::FLAG_ONEWAY);
}
};
@@ -104,7 +106,8 @@
uid_t uid = data.readInt32();
int32_t procState = data.readInt32();
int64_t procStateSeq = data.readInt64();
- onUidStateChanged(uid, procState, procStateSeq);
+ int32_t capability = data.readInt32();
+ onUidStateChanged(uid, procState, procStateSeq, capability);
return NO_ERROR;
} break;
default:
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 7219b47..a9f8ae6 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -1449,41 +1449,38 @@
return err;
}
-status_t Parcel::readByteVectorInternal(int8_t* data, size_t size) const {
- if (size_t(size) > dataAvail()) {
- return BAD_VALUE;
- }
- return read(data, size);
-}
-
status_t Parcel::readByteVector(std::vector<int8_t>* val) const {
- if (status_t status = resizeOutVector(val); status != OK) return status;
- return readByteVectorInternal(val->data(), val->size());
+ size_t size;
+ if (status_t status = reserveOutVector(val, &size); status != OK) return status;
+ return readByteVectorInternal(val, size);
}
status_t Parcel::readByteVector(std::vector<uint8_t>* val) const {
- if (status_t status = resizeOutVector(val); status != OK) return status;
- return readByteVectorInternal(reinterpret_cast<int8_t*>(val->data()), val->size());
+ size_t size;
+ if (status_t status = reserveOutVector(val, &size); status != OK) return status;
+ return readByteVectorInternal(val, size);
}
status_t Parcel::readByteVector(std::unique_ptr<std::vector<int8_t>>* val) const {
- if (status_t status = resizeOutVector(val); status != OK) return status;
+ size_t size;
+ if (status_t status = reserveOutVector(val, &size); status != OK) return status;
if (val->get() == nullptr) {
- // resizeOutVector does not create the out vector if size is < 0.
+ // reserveOutVector does not create the out vector if size is < 0.
// This occurs when writing a null byte vector.
return OK;
}
- return readByteVectorInternal((*val)->data(), (*val)->size());
+ return readByteVectorInternal(val->get(), size);
}
status_t Parcel::readByteVector(std::unique_ptr<std::vector<uint8_t>>* val) const {
- if (status_t status = resizeOutVector(val); status != OK) return status;
+ size_t size;
+ if (status_t status = reserveOutVector(val, &size); status != OK) return status;
if (val->get() == nullptr) {
- // resizeOutVector does not create the out vector if size is < 0.
+ // reserveOutVector does not create the out vector if size is < 0.
// This occurs when writing a null byte vector.
return OK;
}
- return readByteVectorInternal(reinterpret_cast<int8_t*>((*val)->data()), (*val)->size());
+ return readByteVectorInternal(val->get(), size);
}
status_t Parcel::readInt32Vector(std::unique_ptr<std::vector<int32_t>>* val) const {
diff --git a/libs/binder/include/binder/IServiceManager.h b/libs/binder/include/binder/IServiceManager.h
index 4a44c5a..bd77567 100644
--- a/libs/binder/include/binder/IServiceManager.h
+++ b/libs/binder/include/binder/IServiceManager.h
@@ -114,6 +114,13 @@
}
template<typename INTERFACE>
+sp<INTERFACE> waitForVintfService(
+ const String16& instance = String16("default")) {
+ return waitForDeclaredService<INTERFACE>(
+ INTERFACE::descriptor + String16("/") + instance);
+}
+
+template<typename INTERFACE>
status_t getService(const String16& name, sp<INTERFACE>* outService)
{
const sp<IServiceManager> sm = defaultServiceManager();
diff --git a/libs/binder/include/binder/IUidObserver.h b/libs/binder/include/binder/IUidObserver.h
index 09e50a9..d070390 100644
--- a/libs/binder/include/binder/IUidObserver.h
+++ b/libs/binder/include/binder/IUidObserver.h
@@ -34,7 +34,8 @@
virtual void onUidGone(uid_t uid, bool disabled) = 0;
virtual void onUidActive(uid_t uid) = 0;
virtual void onUidIdle(uid_t uid, bool disabled) = 0;
- virtual void onUidStateChanged(uid_t uid, int32_t procState, int64_t procStateSeq) = 0;
+ virtual void onUidStateChanged(uid_t uid, int32_t procState, int64_t procStateSeq,
+ int32_t capability) = 0;
enum {
ON_UID_GONE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
diff --git a/libs/binder/include/binder/Parcel.h b/libs/binder/include/binder/Parcel.h
index 0f8abab..d4bb85b 100644
--- a/libs/binder/include/binder/Parcel.h
+++ b/libs/binder/include/binder/Parcel.h
@@ -356,6 +356,11 @@
status_t resizeOutVector(std::vector<T>* val) const;
template<typename T>
status_t resizeOutVector(std::unique_ptr<std::vector<T>>* val) const;
+ template<typename T>
+ status_t reserveOutVector(std::vector<T>* val, size_t* size) const;
+ template<typename T>
+ status_t reserveOutVector(std::unique_ptr<std::vector<T>>* val,
+ size_t* size) const;
// Like Parcel.java's readExceptionCode(). Reads the first int32
// off of a Parcel's header, returning 0 or the negative error
@@ -475,7 +480,8 @@
status_t readEnum(T* pArg) const;
status_t writeByteVectorInternal(const int8_t* data, size_t size);
- status_t readByteVectorInternal(int8_t* data, size_t size) const;
+ template<typename T>
+ status_t readByteVectorInternal(std::vector<T>* val, size_t size) const;
template<typename T, typename U>
status_t unsafeReadTypedVector(std::vector<T>* val,
@@ -720,6 +726,42 @@
}
template<typename T>
+status_t Parcel::reserveOutVector(std::vector<T>* val, size_t* size) const {
+ int32_t read_size;
+ status_t err = readInt32(&read_size);
+ if (err != NO_ERROR) {
+ return err;
+ }
+
+ if (read_size < 0) {
+ return UNEXPECTED_NULL;
+ }
+ *size = static_cast<size_t>(read_size);
+ val->reserve(*size);
+ return OK;
+}
+
+template<typename T>
+status_t Parcel::reserveOutVector(std::unique_ptr<std::vector<T>>* val,
+ size_t* size) const {
+ int32_t read_size;
+ status_t err = readInt32(&read_size);
+ if (err != NO_ERROR) {
+ return err;
+ }
+
+ if (read_size >= 0) {
+ *size = static_cast<size_t>(read_size);
+ val->reset(new std::vector<T>());
+ (*val)->reserve(*size);
+ } else {
+ val->reset();
+ }
+
+ return OK;
+}
+
+template<typename T>
status_t Parcel::readStrongBinder(sp<T>* val) const {
sp<IBinder> tmp;
status_t ret = readStrongBinder(&tmp);
@@ -988,20 +1030,33 @@
return readInt64(reinterpret_cast<int64_t *>(pArg));
}
+template<typename T>
+inline status_t Parcel::readByteVectorInternal(std::vector<T>* val, size_t size) const {
+ // readByteVectorInternal expects a vector that has been reserved (but not
+ // resized) to have the provided size.
+ const T* data = reinterpret_cast<const T*>(readInplace(size));
+ if (!data) return BAD_VALUE;
+ val->clear();
+ val->insert(val->begin(), data, data+size);
+ return NO_ERROR;
+}
+
template<typename T, std::enable_if_t<std::is_enum_v<T> && std::is_same_v<typename std::underlying_type_t<T>,int8_t>, bool>>
status_t Parcel::readEnumVector(std::vector<T>* val) const {
- if (status_t status = resizeOutVector(val); status != OK) return status;
- return readByteVectorInternal(reinterpret_cast<int8_t*>(val->data()), val->size());
+ size_t size;
+ if (status_t status = reserveOutVector(val, &size); status != OK) return status;
+ return readByteVectorInternal(val, size);
}
template<typename T, std::enable_if_t<std::is_enum_v<T> && std::is_same_v<typename std::underlying_type_t<T>,int8_t>, bool>>
status_t Parcel::readEnumVector(std::unique_ptr<std::vector<T>>* val) const {
- if (status_t status = resizeOutVector(val); status != OK) return status;
+ size_t size;
+ if (status_t status = reserveOutVector(val, &size); status != OK) return status;
if (val->get() == nullptr) {
- // resizeOutVector does not create the out vector if size is < 0.
+ // reserveOutVector does not create the out vector if size is < 0.
// This occurs when writing a null Enum vector.
return OK;
}
- return readByteVectorInternal(reinterpret_cast<int8_t*>((*val)->data()), (*val)->size());
+ return readByteVectorInternal(val->get(), size);
}
template<typename T, std::enable_if_t<std::is_enum_v<T> && !std::is_same_v<typename std::underlying_type_t<T>,int8_t>, bool>>
status_t Parcel::readEnumVector(std::vector<T>* val) const {
diff --git a/libs/binder/ndk/Android.bp b/libs/binder/ndk/Android.bp
index 22344b6..fa07d04 100644
--- a/libs/binder/ndk/Android.bp
+++ b/libs/binder/ndk/Android.bp
@@ -22,6 +22,8 @@
cflags: [
"-D__INTRODUCED_IN(n)=",
"-D__assert(a,b,c)=",
+ // We want all the APIs to be available on the host.
+ "-D__ANDROID_API__=10000",
],
},
},
diff --git a/libs/binder/ndk/include_ndk/android/binder_auto_utils.h b/libs/binder/ndk/include_ndk/android/binder_auto_utils.h
index dc3c8d2..8f37c5e 100644
--- a/libs/binder/ndk/include_ndk/android/binder_auto_utils.h
+++ b/libs/binder/ndk/include_ndk/android/binder_auto_utils.h
@@ -21,7 +21,7 @@
/**
* @file binder_auto_utils.h
- * @brief These objects provide a more C++-like thin interface to the .
+ * @brief These objects provide a more C++-like thin interface to the binder.
*/
#pragma once
@@ -219,9 +219,31 @@
binder_status_t getStatus() const { return AStatus_getStatus(get()); }
/**
- * Convenience method for okay status.
+ * See AStatus_getMessage
+ */
+ const char* getMessage() const { return AStatus_getMessage(get()); }
+
+ /**
+ * Convenience methods for creating scoped statuses.
*/
static ScopedAStatus ok() { return ScopedAStatus(AStatus_newOk()); }
+ static ScopedAStatus fromExceptionCode(binder_exception_t exception) {
+ return ScopedAStatus(AStatus_fromExceptionCode(exception));
+ }
+ static ScopedAStatus fromExceptionCodeWithMessage(binder_exception_t exception,
+ const char* message) {
+ return ScopedAStatus(AStatus_fromExceptionCodeWithMessage(exception, message));
+ }
+ static ScopedAStatus fromServiceSpecificError(int32_t serviceSpecific) {
+ return ScopedAStatus(AStatus_fromServiceSpecificError(serviceSpecific));
+ }
+ static ScopedAStatus fromServiceSpecificErrorWithMessage(int32_t serviceSpecific,
+ const char* message) {
+ return ScopedAStatus(AStatus_fromServiceSpecificErrorWithMessage(serviceSpecific, message));
+ }
+ static ScopedAStatus fromStatus(binder_status_t status) {
+ return ScopedAStatus(AStatus_fromStatus(status));
+ }
};
/**
diff --git a/libs/binder/ndk/include_ndk/android/binder_ibinder.h b/libs/binder/ndk/include_ndk/android/binder_ibinder.h
index 160739b..4d5c044 100644
--- a/libs/binder/ndk/include_ndk/android/binder_ibinder.h
+++ b/libs/binder/ndk/include_ndk/android/binder_ibinder.h
@@ -34,7 +34,7 @@
#include <android/binder_status.h>
__BEGIN_DECLS
-#if __ANDROID_API__ >= __ANDROID_API_Q__
+#if __ANDROID_API__ >= 29
// Also see TF_* in kernel's binder.h
typedef uint32_t binder_flags_t;
@@ -165,6 +165,8 @@
*
* None of these parameters can be null.
*
+ * Available since API level 29.
+ *
* \param interfaceDescriptor this is a unique identifier for the class. This is used internally for
* sanity checks on transactions.
* \param onCreate see AIBinder_Class_onCreate.
@@ -199,6 +201,8 @@
* If this isn't set, nothing will be dumped when dump is called (for instance with
* android.os.Binder#dump). Must be called before any instance of the class is created.
*
+ * Available since API level 29.
+ *
* \param dump function to call when an instance of this binder class is being dumped.
*/
void AIBinder_Class_setOnDump(AIBinder_Class* clazz, AIBinder_onDump onDump) __INTRODUCED_IN(29);
@@ -220,6 +224,8 @@
* these two objects are actually equal using the AIBinder pointer alone (which they should be able
* to do). Also see the suggested memory ownership model suggested above.
*
+ * Available since API level 29.
+ *
* \param clazz the type of the object to be created.
* \param args the args to pass to AIBinder_onCreate for that class.
*
@@ -231,6 +237,8 @@
/**
* If this is hosted in a process other than the current one.
*
+ * Available since API level 29.
+ *
* \param binder the binder being queried.
*
* \return true if the AIBinder represents an object in another process.
@@ -244,6 +252,8 @@
* updated as the result of a transaction made using AIBinder_transact, but it will also be updated
* based on the results of bookkeeping or other transactions made internally.
*
+ * Available since API level 29.
+ *
* \param binder the binder being queried.
*
* \return true if the binder is alive.
@@ -255,6 +265,8 @@
* return. Usually this is used to make sure that a binder is alive, as a placeholder call, or as a
* sanity check.
*
+ * Available since API level 29.
+ *
* \param binder the binder being queried.
*
* \return STATUS_OK if the ping succeeds.
@@ -264,7 +276,9 @@
/**
* Built-in transaction for all binder objects. This dumps information about a given binder.
*
- * See also AIBinder_Class_setOnDump, AIBinder_onDump
+ * See also AIBinder_Class_setOnDump, AIBinder_onDump.
+ *
+ * Available since API level 29.
*
* \param binder the binder to dump information about
* \param fd where information should be dumped to
@@ -287,6 +301,8 @@
*
* If binder is local, this will return STATUS_INVALID_OPERATION.
*
+ * Available since API level 29.
+ *
* \param binder the binder object you want to receive death notifications from.
* \param recipient the callback that will receive notifications when/if the binder dies.
* \param cookie the value that will be passed to the death recipient on death.
@@ -306,6 +322,8 @@
* If the binder dies, it will automatically unlink. If the binder is deleted, it will be
* automatically unlinked.
*
+ * Available since API level 29.
+ *
* \param binder the binder object to remove a previously linked death recipient from.
* \param recipient the callback to remove.
* \param cookie the cookie used to link to death.
@@ -322,9 +340,11 @@
* This can be used with higher-level system services to determine the caller's identity and check
* permissions.
*
+ * Available since API level 29.
+ *
* \return calling uid or the current process's UID if this thread isn't processing a transaction.
*/
-uid_t AIBinder_getCallingUid();
+uid_t AIBinder_getCallingUid() __INTRODUCED_IN(29);
/**
* This returns the calling PID assuming that this thread is called from a thread that is processing
@@ -335,14 +355,18 @@
* calling process dies and is replaced with another process with elevated permissions and the same
* PID.
*
+ * Available since API level 29.
+ *
* \return calling pid or the current process's PID if this thread isn't processing a transaction.
* If the transaction being processed is a oneway transaction, then this method will return 0.
*/
-pid_t AIBinder_getCallingPid();
+pid_t AIBinder_getCallingPid() __INTRODUCED_IN(29);
/**
* This can only be called if a strong reference to this object already exists in process.
*
+ * Available since API level 29.
+ *
* \param binder the binder object to add a refcount to.
*/
void AIBinder_incStrong(AIBinder* binder) __INTRODUCED_IN(29);
@@ -350,6 +374,8 @@
/**
* This will delete the object and call onDestroy once the refcount reaches zero.
*
+ * Available since API level 29.
+ *
* \param binder the binder object to remove a refcount from.
*/
void AIBinder_decStrong(AIBinder* binder) __INTRODUCED_IN(29);
@@ -357,6 +383,8 @@
/**
* For debugging only!
*
+ * Available since API level 29.
+ *
* \param binder the binder object to retrieve the refcount of.
*
* \return the number of strong-refs on this binder in this process. If binder is null, this will be
@@ -373,6 +401,8 @@
* This returns true if the class association succeeds. If it fails, no change is made to the
* binder object.
*
+ * Available since API level 29.
+ *
* \param binder the object to attach the class to.
* \param clazz the clazz to attach to binder.
*
@@ -383,6 +413,8 @@
/**
* Returns the class that this binder was constructed with or associated with.
*
+ * Available since API level 29.
+ *
* \param binder the object that is being queried.
*
* \return the class that this binder is associated with. If this binder wasn't created with
@@ -394,6 +426,8 @@
* Value returned by onCreate for a local binder. For stateless classes (if onCreate returns
* null), this also returns null. For a remote binder, this will always return null.
*
+ * Available since API level 29.
+ *
* \param binder the object that is being queried.
*
* \return the userdata returned from AIBinder_onCreate when this object was created. This may be
@@ -422,6 +456,8 @@
* AIBinder_transact. Alternatively, if there is an error while filling out the parcel, it can be
* deleted with AParcel_delete.
*
+ * Available since API level 29.
+ *
* \param binder the binder object to start a transaction on.
* \param in out parameter for input data to the transaction.
*
@@ -442,6 +478,8 @@
* This does not affect the ownership of binder. The out parcel's ownership is passed to the caller
* and must be released with AParcel_delete when finished reading.
*
+ * Available since API level 29.
+ *
* \param binder the binder object to transact on.
* \param code the implementation-specific code representing which transaction should be taken.
* \param in the implementation-specific input data to this transaction.
@@ -459,6 +497,8 @@
* This does not take any ownership of the input binder, but it can be used to retrieve it if
* something else in some process still holds a reference to it.
*
+ * Available since API level 29.
+ *
* \param binder object to create a weak pointer to.
*
* \return object representing a weak pointer to binder (or null if binder is null).
@@ -469,6 +509,8 @@
/**
* Deletes the weak reference. This will have no impact on the lifetime of the binder.
*
+ * Available since API level 29.
+ *
* \param weakBinder object created with AIBinder_Weak_new.
*/
void AIBinder_Weak_delete(AIBinder_Weak* weakBinder) __INTRODUCED_IN(29);
@@ -477,6 +519,8 @@
* If promotion succeeds, result will have one strong refcount added to it. Otherwise, this returns
* null.
*
+ * Available since API level 29.
+ *
* \param weakBinder weak pointer to attempt retrieving the original object from.
*
* \return an AIBinder object with one refcount given to the caller or null.
@@ -487,6 +531,8 @@
/**
* This function is executed on death receipt. See AIBinder_linkToDeath/AIBinder_unlinkToDeath.
*
+ * Available since API level 29.
+ *
* \param cookie the cookie passed to AIBinder_linkToDeath.
*/
typedef void (*AIBinder_DeathRecipient_onBinderDied)(void* cookie) __INTRODUCED_IN(29);
@@ -494,6 +540,8 @@
/**
* Creates a new binder death recipient. This can be attached to multiple different binder objects.
*
+ * Available since API level 29.
+ *
* \param onBinderDied the callback to call when this death recipient is invoked.
*
* \return the newly constructed object (or null if onBinderDied is null).
@@ -505,19 +553,23 @@
* Deletes a binder death recipient. It is not necessary to call AIBinder_unlinkToDeath before
* calling this as these will all be automatically unlinked.
*
+ * Available since API level 29.
+ *
* \param recipient the binder to delete (previously created with AIBinder_DeathRecipient_new).
*/
void AIBinder_DeathRecipient_delete(AIBinder_DeathRecipient* recipient) __INTRODUCED_IN(29);
-#endif //__ANDROID_API__ >= __ANDROID_API_Q__
+#endif //__ANDROID_API__ >= 29
-#if __ANDROID_API__ >= __ANDROID_API_R__
+#if __ANDROID_API__ >= 30
/**
* Gets the extension registered with AIBinder_setExtension.
*
* See AIBinder_setExtension.
*
+ * Available since API level 30.
+ *
* \param binder the object to get the extension of.
* \param outExt the returned extension object. Will be null if there is no extension set or
* non-null with one strong ref count.
@@ -570,6 +622,8 @@
* // if bar is null, then there is no extension or a different
* // type of extension
*
+ * Available since API level 30.
+ *
* \param binder the object to get the extension on. Must be local.
* \param ext the extension to set (binder will hold a strong reference to this)
*
@@ -578,7 +632,7 @@
*/
binder_status_t AIBinder_setExtension(AIBinder* binder, AIBinder* ext) __INTRODUCED_IN(30);
-#endif //__ANDROID_API__ >= __ANDROID_API_R__
+#endif //__ANDROID_API__ >= 30
__END_DECLS
diff --git a/libs/binder/ndk/include_ndk/android/binder_ibinder_jni.h b/libs/binder/ndk/include_ndk/android/binder_ibinder_jni.h
index 124f36c..be3029c 100644
--- a/libs/binder/ndk/include_ndk/android/binder_ibinder_jni.h
+++ b/libs/binder/ndk/include_ndk/android/binder_ibinder_jni.h
@@ -31,7 +31,7 @@
#include <jni.h>
__BEGIN_DECLS
-#if __ANDROID_API__ >= __ANDROID_API_Q__
+#if __ANDROID_API__ >= 29
/**
* Converts an android.os.IBinder object into an AIBinder* object.
@@ -40,6 +40,8 @@
* AIBinder object, the original object is returned. The returned object has one refcount
* associated with it, and so this should be accompanied with an AIBinder_decStrong call.
*
+ * Available since API level 29.
+ *
* \param env Java environment.
* \param binder android.os.IBinder java object.
*
@@ -55,6 +57,8 @@
* If either env or the binder is null, null is returned. If this binder object was originally an
* IBinder object, the original java object will be returned.
*
+ * Available since API level 29.
+ *
* \param env Java environment.
* \param binder the object to convert.
*
@@ -63,7 +67,7 @@
__attribute__((warn_unused_result)) jobject AIBinder_toJavaBinder(JNIEnv* env, AIBinder* binder)
__INTRODUCED_IN(29);
-#endif //__ANDROID_API__ >= __ANDROID_API_Q__
+#endif //__ANDROID_API__ >= 29
__END_DECLS
/** @} */
diff --git a/libs/binder/ndk/include_ndk/android/binder_parcel.h b/libs/binder/ndk/include_ndk/android/binder_parcel.h
index 8c41707..86b75b8 100644
--- a/libs/binder/ndk/include_ndk/android/binder_parcel.h
+++ b/libs/binder/ndk/include_ndk/android/binder_parcel.h
@@ -35,7 +35,7 @@
typedef struct AIBinder AIBinder;
__BEGIN_DECLS
-#if __ANDROID_API__ >= __ANDROID_API_Q__
+#if __ANDROID_API__ >= 29
/**
* This object represents a package of data that can be sent between processes. When transacting, an
@@ -49,6 +49,8 @@
/**
* Cleans up a parcel.
*
+ * Available since API level 29.
+ *
* \param parcel A parcel returned by AIBinder_prepareTransaction or AIBinder_transact when a
* transaction is being aborted.
*/
@@ -57,6 +59,8 @@
/**
* Sets the position within the parcel.
*
+ * Available since API level 29.
+ *
* \param parcel The parcel of which to set the position.
* \param position Position of the parcel to set. This must be a value returned by
* AParcel_getDataPosition. Positions are constant for a given parcel between processes.
@@ -69,6 +73,8 @@
/**
* Gets the current position within the parcel.
*
+ * Available since API level 29.
+ *
* \param parcel The parcel of which to get the position.
*
* \return The size of the parcel. This will always be greater than 0. The values returned by this
@@ -389,6 +395,8 @@
* Writes an AIBinder to the next location in a non-null parcel. Can be null. This does not take any
* refcounts of ownership of the binder from the client.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param binder the value to write to the parcel.
*
@@ -400,6 +408,8 @@
* Reads an AIBinder from the next location in a non-null parcel. One strong ref-count of ownership
* is passed to the caller of this function.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param binder the out parameter for what is read from the parcel. This may be null.
*
@@ -414,12 +424,14 @@
*
* This corresponds to the SDK's android.os.ParcelFileDescriptor.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param fd the value to write to the parcel (-1 to represent a null ParcelFileDescriptor).
*
* \return STATUS_OK on successful write.
*/
-binder_status_t AParcel_writeParcelFileDescriptor(AParcel* parcel, int fd);
+binder_status_t AParcel_writeParcelFileDescriptor(AParcel* parcel, int fd) __INTRODUCED_IN(29);
/**
* Reads an int from the next location in a non-null parcel.
@@ -428,13 +440,16 @@
*
* This corresponds to the SDK's android.os.ParcelFileDescriptor.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param fd the out parameter for what is read from the parcel (or -1 to represent a null
* ParcelFileDescriptor)
*
* \return STATUS_OK on successful write.
*/
-binder_status_t AParcel_readParcelFileDescriptor(const AParcel* parcel, int* fd);
+binder_status_t AParcel_readParcelFileDescriptor(const AParcel* parcel, int* fd)
+ __INTRODUCED_IN(29);
/**
* Writes an AStatus object to the next location in a non-null parcel.
@@ -445,6 +460,8 @@
* this happens or if writing the status object itself fails, the return value from this function
* should be propagated to the client, and AParcel_readStatusHeader shouldn't be called.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param status the value to write to the parcel.
*
@@ -457,6 +474,8 @@
* Reads an AStatus from the next location in a non-null parcel. Ownership is passed to the caller
* of this function.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param status the out parameter for what is read from the parcel.
*
@@ -470,6 +489,8 @@
*
* If length is -1, and string is nullptr, this will write a 'null' string to the parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param string the null-terminated string to write to the parcel, at least of size 'length'.
* \param length the length of the string to be written.
@@ -487,6 +508,8 @@
* the output buffer from this read. If there is a 'null' string on the binder buffer, the allocator
* will be called with length -1.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param stringData some external representation of a string.
* \param allocator allocator that will be called once the size of the string is known.
@@ -504,6 +527,8 @@
* returned from this function will be used to fill out the data from the parcel. If length is -1,
* this will write a 'null' string array to the binder buffer.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param arrayData some external representation of an array.
* \param length the length of the array to be written.
@@ -526,6 +551,8 @@
* the contents of the string that is read. If the string array being read is 'null', this will
* instead just pass -1 to AParcel_stringArrayAllocator.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param arrayData some external representation of an array.
* \param allocator the callback that will be called with arrayData once the size of the output
@@ -543,6 +570,8 @@
/**
* Writes an array of parcelables (user-defined types) to the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param arrayData an array of size 'length' (or null if length is -1, may be null if length is 0).
* \param length the length of arrayData or -1 if this represents a null array.
@@ -562,6 +591,8 @@
* length is greater than zero, elementReader will be called for every index to read the
* corresponding parcelable.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param arrayData some external representation of an array.
* \param allocator the callback that will be called to allocate the array.
@@ -578,6 +609,8 @@
/**
* Writes int32_t value to the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param value the value to write to the parcel.
*
@@ -588,6 +621,8 @@
/**
* Writes uint32_t value to the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param value the value to write to the parcel.
*
@@ -598,6 +633,8 @@
/**
* Writes int64_t value to the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param value the value to write to the parcel.
*
@@ -608,6 +645,8 @@
/**
* Writes uint64_t value to the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param value the value to write to the parcel.
*
@@ -618,6 +657,8 @@
/**
* Writes float value to the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param value the value to write to the parcel.
*
@@ -628,6 +669,8 @@
/**
* Writes double value to the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param value the value to write to the parcel.
*
@@ -638,6 +681,8 @@
/**
* Writes bool value to the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param value the value to write to the parcel.
*
@@ -648,6 +693,8 @@
/**
* Writes char16_t value to the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param value the value to write to the parcel.
*
@@ -658,6 +705,8 @@
/**
* Writes int8_t value to the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param value the value to write to the parcel.
*
@@ -668,6 +717,8 @@
/**
* Reads into int32_t value from the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param value the value to read from the parcel.
*
@@ -678,6 +729,8 @@
/**
* Reads into uint32_t value from the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param value the value to read from the parcel.
*
@@ -688,6 +741,8 @@
/**
* Reads into int64_t value from the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param value the value to read from the parcel.
*
@@ -698,6 +753,8 @@
/**
* Reads into uint64_t value from the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param value the value to read from the parcel.
*
@@ -708,6 +765,8 @@
/**
* Reads into float value from the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param value the value to read from the parcel.
*
@@ -718,6 +777,8 @@
/**
* Reads into double value from the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param value the value to read from the parcel.
*
@@ -728,6 +789,8 @@
/**
* Reads into bool value from the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param value the value to read from the parcel.
*
@@ -738,6 +801,8 @@
/**
* Reads into char16_t value from the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param value the value to read from the parcel.
*
@@ -748,6 +813,8 @@
/**
* Reads into int8_t value from the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param value the value to read from the parcel.
*
@@ -758,6 +825,8 @@
/**
* Writes an array of int32_t to the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param arrayData an array of size 'length' (or null if length is -1, may be null if length is 0).
* \param length the length of arrayData or -1 if this represents a null array.
@@ -770,6 +839,8 @@
/**
* Writes an array of uint32_t to the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param arrayData an array of size 'length' (or null if length is -1, may be null if length is 0).
* \param length the length of arrayData or -1 if this represents a null array.
@@ -782,6 +853,8 @@
/**
* Writes an array of int64_t to the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param arrayData an array of size 'length' (or null if length is -1, may be null if length is 0).
* \param length the length of arrayData or -1 if this represents a null array.
@@ -794,6 +867,8 @@
/**
* Writes an array of uint64_t to the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param arrayData an array of size 'length' (or null if length is -1, may be null if length is 0).
* \param length the length of arrayData or -1 if this represents a null array.
@@ -806,6 +881,8 @@
/**
* Writes an array of float to the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param arrayData an array of size 'length' (or null if length is -1, may be null if length is 0).
* \param length the length of arrayData or -1 if this represents a null array.
@@ -818,6 +895,8 @@
/**
* Writes an array of double to the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param arrayData an array of size 'length' (or null if length is -1, may be null if length is 0).
* \param length the length of arrayData or -1 if this represents a null array.
@@ -833,6 +912,8 @@
* getter(arrayData, i) will be called for each i in [0, length) in order to get the underlying
* values to write to the parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param arrayData some external representation of an array.
* \param length the length of arrayData (or -1 if this represents a null array).
@@ -846,6 +927,8 @@
/**
* Writes an array of char16_t to the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param arrayData an array of size 'length' (or null if length is -1, may be null if length is 0).
* \param length the length of arrayData or -1 if this represents a null array.
@@ -858,6 +941,8 @@
/**
* Writes an array of int8_t to the next location in a non-null parcel.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to write to.
* \param arrayData an array of size 'length' (or null if length is -1, may be null if length is 0).
* \param length the length of arrayData or -1 if this represents a null array.
@@ -874,6 +959,8 @@
* length is greater than zero, the buffer returned by the allocator will be filled with the
* corresponding data
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param arrayData some external representation of an array.
* \param allocator the callback that will be called to allocate the array.
@@ -890,6 +977,8 @@
* length is greater than zero, the buffer returned by the allocator will be filled with the
* corresponding data
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param arrayData some external representation of an array.
* \param allocator the callback that will be called to allocate the array.
@@ -906,6 +995,8 @@
* length is greater than zero, the buffer returned by the allocator will be filled with the
* corresponding data
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param arrayData some external representation of an array.
* \param allocator the callback that will be called to allocate the array.
@@ -922,6 +1013,8 @@
* length is greater than zero, the buffer returned by the allocator will be filled with the
* corresponding data
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param arrayData some external representation of an array.
* \param allocator the callback that will be called to allocate the array.
@@ -938,6 +1031,8 @@
* length is greater than zero, the buffer returned by the allocator will be filled with the
* corresponding data
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param arrayData some external representation of an array.
* \param allocator the callback that will be called to allocate the array.
@@ -954,6 +1049,8 @@
* length is greater than zero, the buffer returned by the allocator will be filled with the
* corresponding data
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param arrayData some external representation of an array.
* \param allocator the callback that will be called to allocate the array.
@@ -969,6 +1066,8 @@
* First, allocator will be called with the length of the array. Then, for every i in [0, length),
* setter(arrayData, i, x) will be called where x is the value at the associated index.
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param arrayData some external representation of an array.
* \param allocator the callback that will be called to allocate the array.
@@ -988,6 +1087,8 @@
* length is greater than zero, the buffer returned by the allocator will be filled with the
* corresponding data
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param arrayData some external representation of an array.
* \param allocator the callback that will be called to allocate the array.
@@ -1004,6 +1105,8 @@
* length is greater than zero, the buffer returned by the allocator will be filled with the
* corresponding data
*
+ * Available since API level 29.
+ *
* \param parcel the parcel to read from.
* \param arrayData some external representation of an array.
* \param allocator the callback that will be called to allocate the array.
@@ -1015,7 +1118,7 @@
// @END-PRIMITIVE-READ-WRITE
-#endif //__ANDROID_API__ >= __ANDROID_API_Q__
+#endif //__ANDROID_API__ >= 29
__END_DECLS
/** @} */
diff --git a/libs/binder/ndk/include_ndk/android/binder_status.h b/libs/binder/ndk/include_ndk/android/binder_status.h
index 2671b9b..78d70f8 100644
--- a/libs/binder/ndk/include_ndk/android/binder_status.h
+++ b/libs/binder/ndk/include_ndk/android/binder_status.h
@@ -30,7 +30,7 @@
#include <sys/cdefs.h>
__BEGIN_DECLS
-#if __ANDROID_API__ >= __ANDROID_API_Q__
+#if __ANDROID_API__ >= 29
enum {
STATUS_OK = 0,
@@ -105,6 +105,8 @@
/**
* New status which is considered a success.
*
+ * Available since API level 29.
+ *
* \return a newly constructed status object that the caller owns.
*/
__attribute__((warn_unused_result)) AStatus* AStatus_newOk() __INTRODUCED_IN(29);
@@ -112,6 +114,8 @@
/**
* New status with exception code.
*
+ * Available since API level 29.
+ *
* \param exception the code that this status should represent. If this is EX_NONE, then this
* constructs an non-error status object.
*
@@ -123,6 +127,8 @@
/**
* New status with exception code and message.
*
+ * Available since API level 29.
+ *
* \param exception the code that this status should represent. If this is EX_NONE, then this
* constructs an non-error status object.
* \param message the error message to associate with this status object.
@@ -137,6 +143,8 @@
*
* This is considered to be EX_TRANSACTION_FAILED with extra information.
*
+ * Available since API level 29.
+ *
* \param serviceSpecific an implementation defined error code.
*
* \return a newly constructed status object that the caller owns.
@@ -149,6 +157,8 @@
*
* This is considered to be EX_TRANSACTION_FAILED with extra information.
*
+ * Available since API level 29.
+ *
* \param serviceSpecific an implementation defined error code.
* \param message the error message to associate with this status object.
*
@@ -162,6 +172,8 @@
* is returned by an API on AIBinder or AParcel, and that is to be returned from a method returning
* an AStatus instance.
*
+ * Available since API level 29.
+ *
* \param a low-level error to associate with this status object.
*
* \return a newly constructed status object that the caller owns.
@@ -173,6 +185,8 @@
* Whether this object represents a successful transaction. If this function returns true, then
* AStatus_getExceptionCode will return EX_NONE.
*
+ * Available since API level 29.
+ *
* \param status the status being queried.
*
* \return whether the status represents a successful transaction. For more details, see below.
@@ -182,6 +196,8 @@
/**
* The exception that this status object represents.
*
+ * Available since API level 29.
+ *
* \param status the status being queried.
*
* \return the exception code that this object represents.
@@ -194,6 +210,8 @@
* 0, the status object may still represent a different exception or status. To find out if this
* transaction as a whole is okay, use AStatus_isOk instead.
*
+ * Available since API level 29.
+ *
* \param status the status being queried.
*
* \return the service-specific error code if the exception code is EX_SERVICE_SPECIFIC or 0.
@@ -206,6 +224,8 @@
* object may represent a different exception or a service specific error. To find out if this
* transaction as a whole is okay, use AStatus_isOk instead.
*
+ * Available since API level 29.
+ *
* \param status the status being queried.
*
* \return the status code if the exception code is EX_TRANSACTION_FAILED or 0.
@@ -218,6 +238,8 @@
*
* The returned string has the lifetime of the status object passed into this function.
*
+ * Available since API level 29.
+ *
* \param status the status being queried.
*
* \return the message associated with this error.
@@ -227,11 +249,13 @@
/**
* Deletes memory associated with the status instance.
*
+ * Available since API level 29.
+ *
* \param status the status to delete, returned from AStatus_newOk or one of the AStatus_from* APIs.
*/
void AStatus_delete(AStatus* status) __INTRODUCED_IN(29);
-#endif //__ANDROID_API__ >= __ANDROID_API_Q__
+#endif //__ANDROID_API__ >= 29
__END_DECLS
/** @} */
diff --git a/libs/binder/ndk/parcel.cpp b/libs/binder/ndk/parcel.cpp
index ae2276e..f18e118 100644
--- a/libs/binder/ndk/parcel.cpp
+++ b/libs/binder/ndk/parcel.cpp
@@ -50,7 +50,7 @@
if (length < -1) return STATUS_BAD_VALUE;
if (!isNullArray && length < 0) {
- LOG(ERROR) << __func__ << ": null array must be used with length == -1.";
+ LOG(ERROR) << __func__ << ": non-null array but length is " << length;
return STATUS_BAD_VALUE;
}
if (isNullArray && length > 0) {
diff --git a/libs/binder/ndk/scripts/format.sh b/libs/binder/ndk/scripts/format.sh
deleted file mode 100755
index 698d291..0000000
--- a/libs/binder/ndk/scripts/format.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/env bash
-
-# Copyright (C) 2018 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-set -e
-
-echo "Formatting code"
-
-bpfmt -w $(find $ANDROID_BUILD_TOP/frameworks/native/libs/binder/ndk/ -name "Android.bp")
-clang-format -i $(find $ANDROID_BUILD_TOP/frameworks/native/libs/binder/ndk/ -\( -name "*.cpp" -o -name "*.h" -\))
diff --git a/libs/binder/ndk/update.sh b/libs/binder/ndk/update.sh
deleted file mode 100755
index 1eba892..0000000
--- a/libs/binder/ndk/update.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/env bash
-
-# Copyright (C) 2018 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-set -ex
-
-# This script makes sure that the source code is in sync with the various scripts
-./scripts/gen_parcel_helper.py
-./scripts/format.sh
diff --git a/libs/nativewindow/include/android/hardware_buffer.h b/libs/nativewindow/include/android/hardware_buffer.h
index da959e3..ae5e47b 100644
--- a/libs/nativewindow/include/android/hardware_buffer.h
+++ b/libs/nativewindow/include/android/hardware_buffer.h
@@ -342,6 +342,8 @@
* not compatible with its usage flags, the results are undefined and
* may include program termination.
*
+ * Available since API level 26.
+ *
* \return 0 on success, or an error number of the allocation fails for
* any reason. The returned buffer has a reference count of 1.
*/
@@ -352,18 +354,24 @@
*
* This prevents the object from being deleted until the last reference
* is removed.
+ *
+ * Available since API level 26.
*/
void AHardwareBuffer_acquire(AHardwareBuffer* buffer) __INTRODUCED_IN(26);
/**
* Remove a reference that was previously acquired with
* AHardwareBuffer_acquire() or AHardwareBuffer_allocate().
+ *
+ * Available since API level 26.
*/
void AHardwareBuffer_release(AHardwareBuffer* buffer) __INTRODUCED_IN(26);
/**
* Return a description of the AHardwareBuffer in the passed
* AHardwareBuffer_Desc struct.
+ *
+ * Available since API level 26.
*/
void AHardwareBuffer_describe(const AHardwareBuffer* buffer,
AHardwareBuffer_Desc* outDesc) __INTRODUCED_IN(26);
@@ -413,6 +421,8 @@
* simultaneously, and the contents of the buffer behave like shared
* memory.
*
+ * Available since API level 26.
+ *
* \return 0 on success. -EINVAL if \a buffer is NULL, the usage flags
* are not a combination of AHARDWAREBUFFER_USAGE_CPU_*, or the buffer
* has more than one layer. Error number if the lock fails for any other
@@ -441,6 +451,8 @@
*
* See the AHardwareBuffer_lock documentation for all other locking semantics.
*
+ * Available since API level 29.
+ *
* \return 0 on success. -EINVAL if \a buffer is NULL, the usage flags
* are not a combination of AHARDWAREBUFFER_USAGE_CPU_*, or the buffer
* has more than one layer. Error number if the lock fails for any other
@@ -462,6 +474,8 @@
* completed before the function returned and no further operations are
* necessary.
*
+ * Available since API level 26.
+ *
* \return 0 on success. -EINVAL if \a buffer is NULL. Error number if
* the unlock fails for any reason.
*/
@@ -470,6 +484,8 @@
/**
* Send the AHardwareBuffer to an AF_UNIX socket.
*
+ * Available since API level 26.
+ *
* \return 0 on success, -EINVAL if \a buffer is NULL, or an error
* number if the operation fails for any reason.
*/
@@ -478,6 +494,8 @@
/**
* Receive an AHardwareBuffer from an AF_UNIX socket.
*
+ * Available since API level 26.
+ *
* \return 0 on success, -EINVAL if \a outBuffer is NULL, or an error
* number if the operation fails for any reason.
*/
@@ -501,6 +519,8 @@
* some implementations have implementation-defined limits on texture
* size and layer count.
*
+ * Available since API level 29.
+ *
* \return 1 if the format and usage flag combination is allocatable,
* 0 otherwise.
*/
@@ -514,6 +534,8 @@
* of the locked buffer. If the bytes per pixel or bytes per stride are unknown
* or variable, or if the underlying mapper implementation does not support returning
* additional information, then this call will fail with INVALID_OPERATION
+ *
+ * Available since API level 29.
*/
int AHardwareBuffer_lockAndGetInfo(AHardwareBuffer* buffer, uint64_t usage,
int32_t fence, const ARect* rect, void** outVirtualAddress,
diff --git a/libs/nativewindow/include/android/native_window.h b/libs/nativewindow/include/android/native_window.h
index 6730596..3e436e3 100644
--- a/libs/nativewindow/include/android/native_window.h
+++ b/libs/nativewindow/include/android/native_window.h
@@ -189,6 +189,8 @@
/**
* Set a transform that will be applied to future buffers posted to the window.
*
+ * Available since API level 26.
+ *
* \param transform combination of {@link ANativeWindowTransform} flags
* \return 0 for success, or -EINVAL if \p transform is invalid
*/
@@ -208,6 +210,8 @@
* measurement data instead of color images. The default dataSpace is 0,
* ADATASPACE_UNKNOWN, unless it has been overridden by the producer.
*
+ * Available since API level 28.
+ *
* \param dataSpace data space of all buffers queued after this call.
* \return 0 for success, -EINVAL if window is invalid or the dataspace is not
* supported.
@@ -216,6 +220,9 @@
/**
* Get the dataspace of the buffers in window.
+ *
+ * Available since API level 28.
+ *
* \return the dataspace of buffers in window, ADATASPACE_UNKNOWN is returned if
* dataspace is unknown, or -EINVAL if window is invalid.
*/
diff --git a/libs/vr/libbufferhub/Android.bp b/libs/vr/libbufferhub/Android.bp
index 6d202ae..2fcee7b 100644
--- a/libs/vr/libbufferhub/Android.bp
+++ b/libs/vr/libbufferhub/Android.bp
@@ -29,11 +29,9 @@
sharedLibraries = [
"libbase",
"libcutils",
- "libhardware",
"liblog",
"libui",
"libutils",
- "libnativewindow",
"libpdx_default_transport",
]
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 90cc5c6..af671e6 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -363,7 +363,7 @@
// Poke user activity for this event.
if (mPendingEvent->policyFlags & POLICY_FLAG_PASS_TO_USER) {
- pokeUserActivityLocked(mPendingEvent);
+ pokeUserActivityLocked(*mPendingEvent);
}
// Get ready to dispatch the event.
@@ -404,14 +404,14 @@
case EventEntry::TYPE_KEY: {
KeyEntry* typedEntry = static_cast<KeyEntry*>(mPendingEvent);
if (isAppSwitchDue) {
- if (isAppSwitchKeyEvent(typedEntry)) {
+ if (isAppSwitchKeyEvent(*typedEntry)) {
resetPendingAppSwitchLocked(true);
isAppSwitchDue = false;
} else if (dropReason == DropReason::NOT_DROPPED) {
dropReason = DropReason::APP_SWITCH;
}
}
- if (dropReason == DropReason::NOT_DROPPED && isStaleEvent(currentTime, typedEntry)) {
+ if (dropReason == DropReason::NOT_DROPPED && isStaleEvent(currentTime, *typedEntry)) {
dropReason = DropReason::STALE;
}
if (dropReason == DropReason::NOT_DROPPED && mNextUnblockedEvent) {
@@ -426,7 +426,7 @@
if (dropReason == DropReason::NOT_DROPPED && isAppSwitchDue) {
dropReason = DropReason::APP_SWITCH;
}
- if (dropReason == DropReason::NOT_DROPPED && isStaleEvent(currentTime, typedEntry)) {
+ if (dropReason == DropReason::NOT_DROPPED && isStaleEvent(currentTime, *typedEntry)) {
dropReason = DropReason::STALE;
}
if (dropReason == DropReason::NOT_DROPPED && mNextUnblockedEvent) {
@@ -443,7 +443,7 @@
if (done) {
if (dropReason != DropReason::NOT_DROPPED) {
- dropInboundEventLocked(mPendingEvent, dropReason);
+ dropInboundEventLocked(*mPendingEvent, dropReason);
}
mLastDropReason = dropReason;
@@ -462,16 +462,16 @@
// Optimize app switch latency.
// If the application takes too long to catch up then we drop all events preceding
// the app switch key.
- KeyEntry* keyEntry = static_cast<KeyEntry*>(entry);
+ const KeyEntry& keyEntry = static_cast<const KeyEntry&>(*entry);
if (isAppSwitchKeyEvent(keyEntry)) {
- if (keyEntry->action == AKEY_EVENT_ACTION_DOWN) {
+ if (keyEntry.action == AKEY_EVENT_ACTION_DOWN) {
mAppSwitchSawKeyDown = true;
- } else if (keyEntry->action == AKEY_EVENT_ACTION_UP) {
+ } else if (keyEntry.action == AKEY_EVENT_ACTION_UP) {
if (mAppSwitchSawKeyDown) {
#if DEBUG_APP_SWITCH
ALOGD("App switch is pending!");
#endif
- mAppSwitchDueTime = keyEntry->eventTime + APP_SWITCH_TIMEOUT;
+ mAppSwitchDueTime = keyEntry.eventTime + APP_SWITCH_TIMEOUT;
mAppSwitchSawKeyDown = false;
needWake = true;
}
@@ -591,7 +591,7 @@
}
}
-void InputDispatcher::dropInboundEventLocked(EventEntry* entry, DropReason dropReason) {
+void InputDispatcher::dropInboundEventLocked(const EventEntry& entry, DropReason dropReason) {
const char* reason;
switch (dropReason) {
case DropReason::POLICY:
@@ -626,15 +626,15 @@
}
}
- switch (entry->type) {
+ switch (entry.type) {
case EventEntry::TYPE_KEY: {
CancelationOptions options(CancelationOptions::CANCEL_NON_POINTER_EVENTS, reason);
synthesizeCancelationEventsForAllConnectionsLocked(options);
break;
}
case EventEntry::TYPE_MOTION: {
- MotionEntry* motionEntry = static_cast<MotionEntry*>(entry);
- if (motionEntry->source & AINPUT_SOURCE_CLASS_POINTER) {
+ const MotionEntry& motionEntry = static_cast<const MotionEntry&>(entry);
+ if (motionEntry.source & AINPUT_SOURCE_CLASS_POINTER) {
CancelationOptions options(CancelationOptions::CANCEL_POINTER_EVENTS, reason);
synthesizeCancelationEventsForAllConnectionsLocked(options);
} else {
@@ -651,10 +651,10 @@
keyCode == AKEYCODE_APP_SWITCH;
}
-bool InputDispatcher::isAppSwitchKeyEvent(KeyEntry* keyEntry) {
- return !(keyEntry->flags & AKEY_EVENT_FLAG_CANCELED) && isAppSwitchKeyCode(keyEntry->keyCode) &&
- (keyEntry->policyFlags & POLICY_FLAG_TRUSTED) &&
- (keyEntry->policyFlags & POLICY_FLAG_PASS_TO_USER);
+bool InputDispatcher::isAppSwitchKeyEvent(const KeyEntry& keyEntry) {
+ return !(keyEntry.flags & AKEY_EVENT_FLAG_CANCELED) && isAppSwitchKeyCode(keyEntry.keyCode) &&
+ (keyEntry.policyFlags & POLICY_FLAG_TRUSTED) &&
+ (keyEntry.policyFlags & POLICY_FLAG_PASS_TO_USER);
}
bool InputDispatcher::isAppSwitchPendingLocked() {
@@ -673,8 +673,8 @@
#endif
}
-bool InputDispatcher::isStaleEvent(nsecs_t currentTime, EventEntry* entry) {
- return currentTime - entry->eventTime >= STALE_EVENT_TIMEOUT;
+bool InputDispatcher::isStaleEvent(nsecs_t currentTime, const EventEntry& entry) {
+ return currentTime - entry.eventTime >= STALE_EVENT_TIMEOUT;
}
bool InputDispatcher::haveCommandsLocked() const {
@@ -837,7 +837,7 @@
entry->dispatchInProgress = true;
- logOutboundKeyDetails("dispatchKey - ", entry);
+ logOutboundKeyDetails("dispatchKey - ", *entry);
}
// Handle case where the policy asked us to try again later last time.
@@ -858,7 +858,7 @@
std::unique_ptr<CommandEntry> commandEntry = std::make_unique<CommandEntry>(
&InputDispatcher::doInterceptKeyBeforeDispatchingLockedInterruptible);
sp<InputWindowHandle> focusedWindowHandle =
- getValueByKey(mFocusedWindowHandlesByDisplay, getTargetDisplayId(entry));
+ getValueByKey(mFocusedWindowHandlesByDisplay, getTargetDisplayId(*entry));
if (focusedWindowHandle != nullptr) {
commandEntry->inputChannel = getInputChannelLocked(focusedWindowHandle->getToken());
}
@@ -887,7 +887,7 @@
// Identify targets.
std::vector<InputTarget> inputTargets;
int32_t injectionResult =
- findFocusedWindowTargetsLocked(currentTime, entry, inputTargets, nextWakeupTime);
+ findFocusedWindowTargetsLocked(currentTime, *entry, inputTargets, nextWakeupTime);
if (injectionResult == INPUT_EVENT_INJECTION_PENDING) {
return false;
}
@@ -898,21 +898,21 @@
}
// Add monitor channels from event's or focused display.
- addGlobalMonitoringTargetsLocked(inputTargets, getTargetDisplayId(entry));
+ addGlobalMonitoringTargetsLocked(inputTargets, getTargetDisplayId(*entry));
// Dispatch the key.
dispatchEventLocked(currentTime, entry, inputTargets);
return true;
}
-void InputDispatcher::logOutboundKeyDetails(const char* prefix, const KeyEntry* entry) {
+void InputDispatcher::logOutboundKeyDetails(const char* prefix, const KeyEntry& entry) {
#if DEBUG_OUTBOUND_EVENT_DETAILS
ALOGD("%seventTime=%" PRId64 ", deviceId=%d, source=0x%x, displayId=%" PRId32 ", "
"policyFlags=0x%x, action=0x%x, flags=0x%x, keyCode=0x%x, scanCode=0x%x, "
"metaState=0x%x, repeatCount=%d, downTime=%" PRId64,
- prefix, entry->eventTime, entry->deviceId, entry->source, entry->displayId,
- entry->policyFlags, entry->action, entry->flags, entry->keyCode, entry->scanCode,
- entry->metaState, entry->repeatCount, entry->downTime);
+ prefix, entry.eventTime, entry.deviceId, entry.source, entry.displayId, entry.policyFlags,
+ entry.action, entry.flags, entry.keyCode, entry.scanCode, entry.metaState,
+ entry.repeatCount, entry.downTime);
#endif
}
@@ -923,7 +923,7 @@
if (!entry->dispatchInProgress) {
entry->dispatchInProgress = true;
- logOutboundMotionDetails("dispatchMotion - ", entry);
+ logOutboundMotionDetails("dispatchMotion - ", *entry);
}
// Clean up if dropping the event.
@@ -944,12 +944,12 @@
if (isPointerEvent) {
// Pointer event. (eg. touchscreen)
injectionResult =
- findTouchedWindowTargetsLocked(currentTime, entry, inputTargets, nextWakeupTime,
+ findTouchedWindowTargetsLocked(currentTime, *entry, inputTargets, nextWakeupTime,
&conflictingPointerActions);
} else {
// Non touch event. (eg. trackball)
injectionResult =
- findFocusedWindowTargetsLocked(currentTime, entry, inputTargets, nextWakeupTime);
+ findFocusedWindowTargetsLocked(currentTime, *entry, inputTargets, nextWakeupTime);
}
if (injectionResult == INPUT_EVENT_INJECTION_PENDING) {
return false;
@@ -968,7 +968,7 @@
}
// Add monitor channels from event's or focused display.
- addGlobalMonitoringTargetsLocked(inputTargets, getTargetDisplayId(entry));
+ addGlobalMonitoringTargetsLocked(inputTargets, getTargetDisplayId(*entry));
if (isPointerEvent) {
ssize_t stateIndex = mTouchStatesByDisplay.indexOfKey(entry->displayId);
@@ -996,33 +996,32 @@
return true;
}
-void InputDispatcher::logOutboundMotionDetails(const char* prefix, const MotionEntry* entry) {
+void InputDispatcher::logOutboundMotionDetails(const char* prefix, const MotionEntry& entry) {
#if DEBUG_OUTBOUND_EVENT_DETAILS
ALOGD("%seventTime=%" PRId64 ", deviceId=%d, source=0x%x, displayId=%" PRId32
", policyFlags=0x%x, "
"action=0x%x, actionButton=0x%x, flags=0x%x, "
"metaState=0x%x, buttonState=0x%x,"
"edgeFlags=0x%x, xPrecision=%f, yPrecision=%f, downTime=%" PRId64,
- prefix, entry->eventTime, entry->deviceId, entry->source, entry->displayId,
- entry->policyFlags, entry->action, entry->actionButton, entry->flags, entry->metaState,
- entry->buttonState, entry->edgeFlags, entry->xPrecision, entry->yPrecision,
- entry->downTime);
+ prefix, entry.eventTime, entry.deviceId, entry.source, entry.displayId, entry.policyFlags,
+ entry.action, entry.actionButton, entry.flags, entry.metaState, entry.buttonState,
+ entry.edgeFlags, entry.xPrecision, entry.yPrecision, entry.downTime);
- for (uint32_t i = 0; i < entry->pointerCount; i++) {
+ for (uint32_t i = 0; i < entry.pointerCount; i++) {
ALOGD(" Pointer %d: id=%d, toolType=%d, "
"x=%f, y=%f, pressure=%f, size=%f, "
"touchMajor=%f, touchMinor=%f, toolMajor=%f, toolMinor=%f, "
"orientation=%f",
- i, entry->pointerProperties[i].id, entry->pointerProperties[i].toolType,
- entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_X),
- entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_Y),
- entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_PRESSURE),
- entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_SIZE),
- entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR),
- entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR),
- entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR),
- entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR),
- entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION));
+ i, entry.pointerProperties[i].id, entry.pointerProperties[i].toolType,
+ entry.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_X),
+ entry.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_Y),
+ entry.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_PRESSURE),
+ entry.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_SIZE),
+ entry.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR),
+ entry.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR),
+ entry.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR),
+ entry.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR),
+ entry.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION));
}
#endif
}
@@ -1036,7 +1035,7 @@
ALOG_ASSERT(eventEntry->dispatchInProgress); // should already have been set to true
- pokeUserActivityLocked(eventEntry);
+ pokeUserActivityLocked(*eventEntry);
for (const InputTarget& inputTarget : inputTargets) {
sp<Connection> connection = getConnectionLocked(inputTarget.inputChannel);
@@ -1053,7 +1052,7 @@
}
int32_t InputDispatcher::handleTargetsNotReadyLocked(
- nsecs_t currentTime, const EventEntry* entry,
+ nsecs_t currentTime, const EventEntry& entry,
const sp<InputApplicationHandle>& applicationHandle,
const sp<InputWindowHandle>& windowHandle, nsecs_t* nextWakeupTime, const char* reason) {
if (applicationHandle == nullptr && windowHandle == nullptr) {
@@ -1103,7 +1102,7 @@
}
if (currentTime >= mInputTargetWaitTimeoutTime) {
- onANRLocked(currentTime, applicationHandle, windowHandle, entry->eventTime,
+ onANRLocked(currentTime, applicationHandle, windowHandle, entry.eventTime,
mInputTargetWaitStartTime, reason);
// Force poll loop to wake up immediately on next iteration once we get the
@@ -1175,21 +1174,21 @@
* then it should be dispatched to that display. Otherwise, the event goes to the focused display.
* Focused display is the display that the user most recently interacted with.
*/
-int32_t InputDispatcher::getTargetDisplayId(const EventEntry* entry) {
+int32_t InputDispatcher::getTargetDisplayId(const EventEntry& entry) {
int32_t displayId;
- switch (entry->type) {
+ switch (entry.type) {
case EventEntry::TYPE_KEY: {
- const KeyEntry* typedEntry = static_cast<const KeyEntry*>(entry);
- displayId = typedEntry->displayId;
+ const KeyEntry& keyEntry = static_cast<const KeyEntry&>(entry);
+ displayId = keyEntry.displayId;
break;
}
case EventEntry::TYPE_MOTION: {
- const MotionEntry* typedEntry = static_cast<const MotionEntry*>(entry);
- displayId = typedEntry->displayId;
+ const MotionEntry& motionEntry = static_cast<const MotionEntry&>(entry);
+ displayId = motionEntry.displayId;
break;
}
default: {
- ALOGE("Unsupported event type '%" PRId32 "' for target display.", entry->type);
+ ALOGE("Unsupported event type '%" PRId32 "' for target display.", entry.type);
return ADISPLAY_ID_NONE;
}
}
@@ -1197,7 +1196,7 @@
}
int32_t InputDispatcher::findFocusedWindowTargetsLocked(nsecs_t currentTime,
- const EventEntry* entry,
+ const EventEntry& entry,
std::vector<InputTarget>& inputTargets,
nsecs_t* nextWakeupTime) {
int32_t injectionResult;
@@ -1230,7 +1229,7 @@
}
// Check permissions.
- if (!checkInjectionPermission(focusedWindowHandle, entry->injectionState)) {
+ if (!checkInjectionPermission(focusedWindowHandle, entry.injectionState)) {
injectionResult = INPUT_EVENT_INJECTION_PERMISSION_DENIED;
goto Failed;
}
@@ -1264,7 +1263,7 @@
}
int32_t InputDispatcher::findTouchedWindowTargetsLocked(nsecs_t currentTime,
- const MotionEntry* entry,
+ const MotionEntry& entry,
std::vector<InputTarget>& inputTargets,
nsecs_t* nextWakeupTime,
bool* outConflictingPointerActions) {
@@ -1277,8 +1276,8 @@
// For security reasons, we defer updating the touch state until we are sure that
// event injection will be allowed.
- int32_t displayId = entry->displayId;
- int32_t action = entry->action;
+ int32_t displayId = entry.displayId;
+ int32_t action = entry.action;
int32_t maskedAction = action & AMOTION_EVENT_ACTION_MASK;
// Update the touch state as needed based on the properties of the touch event.
@@ -1298,14 +1297,14 @@
bool isSplit = mTempTouchState.split;
bool switchedDevice = mTempTouchState.deviceId >= 0 && mTempTouchState.displayId >= 0 &&
- (mTempTouchState.deviceId != entry->deviceId ||
- mTempTouchState.source != entry->source || mTempTouchState.displayId != displayId);
+ (mTempTouchState.deviceId != entry.deviceId || mTempTouchState.source != entry.source ||
+ mTempTouchState.displayId != displayId);
bool isHoverAction = (maskedAction == AMOTION_EVENT_ACTION_HOVER_MOVE ||
maskedAction == AMOTION_EVENT_ACTION_HOVER_ENTER ||
maskedAction == AMOTION_EVENT_ACTION_HOVER_EXIT);
bool newGesture = (maskedAction == AMOTION_EVENT_ACTION_DOWN ||
maskedAction == AMOTION_EVENT_ACTION_SCROLL || isHoverAction);
- const bool isFromMouse = entry->source == AINPUT_SOURCE_MOUSE;
+ const bool isFromMouse = entry.source == AINPUT_SOURCE_MOUSE;
bool wrongDevice = false;
if (newGesture) {
bool down = maskedAction == AMOTION_EVENT_ACTION_DOWN;
@@ -1323,8 +1322,8 @@
}
mTempTouchState.reset();
mTempTouchState.down = down;
- mTempTouchState.deviceId = entry->deviceId;
- mTempTouchState.source = entry->source;
+ mTempTouchState.deviceId = entry.deviceId;
+ mTempTouchState.source = entry.source;
mTempTouchState.displayId = displayId;
isSplit = false;
} else if (switchedDevice && maskedAction == AMOTION_EVENT_ACTION_MOVE) {
@@ -1348,11 +1347,11 @@
int32_t pointerIndex = getMotionEventActionPointerIndex(action);
// Always dispatch mouse events to cursor position.
if (isFromMouse) {
- x = int32_t(entry->xCursorPosition);
- y = int32_t(entry->yCursorPosition);
+ x = int32_t(entry.xCursorPosition);
+ y = int32_t(entry.yCursorPosition);
} else {
- x = int32_t(entry->pointerCoords[pointerIndex].getAxisValue(AMOTION_EVENT_AXIS_X));
- y = int32_t(entry->pointerCoords[pointerIndex].getAxisValue(AMOTION_EVENT_AXIS_Y));
+ x = int32_t(entry.pointerCoords[pointerIndex].getAxisValue(AMOTION_EVENT_AXIS_X));
+ y = int32_t(entry.pointerCoords[pointerIndex].getAxisValue(AMOTION_EVENT_AXIS_Y));
}
bool isDown = maskedAction == AMOTION_EVENT_ACTION_DOWN;
sp<InputWindowHandle> newTouchedWindowHandle =
@@ -1410,7 +1409,7 @@
// Update the temporary touch state.
BitSet32 pointerIds;
if (isSplit) {
- uint32_t pointerId = entry->pointerProperties[pointerIndex].id;
+ uint32_t pointerId = entry.pointerProperties[pointerIndex].id;
pointerIds.markBit(pointerId);
}
mTempTouchState.addOrUpdateWindow(newTouchedWindowHandle, targetFlags, pointerIds);
@@ -1432,10 +1431,10 @@
}
// Check whether touches should slip outside of the current foreground window.
- if (maskedAction == AMOTION_EVENT_ACTION_MOVE && entry->pointerCount == 1 &&
+ if (maskedAction == AMOTION_EVENT_ACTION_MOVE && entry.pointerCount == 1 &&
mTempTouchState.isSlippery()) {
- int32_t x = int32_t(entry->pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_X));
- int32_t y = int32_t(entry->pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_Y));
+ int32_t x = int32_t(entry.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_X));
+ int32_t y = int32_t(entry.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_Y));
sp<InputWindowHandle> oldTouchedWindowHandle =
mTempTouchState.getFirstForegroundWindowHandle();
@@ -1469,7 +1468,7 @@
BitSet32 pointerIds;
if (isSplit) {
- pointerIds.markBit(entry->pointerProperties[0].id);
+ pointerIds.markBit(entry.pointerProperties[0].id);
}
mTempTouchState.addOrUpdateWindow(newTouchedWindowHandle, targetFlags, pointerIds);
}
@@ -1507,7 +1506,7 @@
for (const TouchedWindow& touchedWindow : mTempTouchState.windows) {
if (touchedWindow.targetFlags & InputTarget::FLAG_FOREGROUND) {
haveForegroundWindow = true;
- if (!checkInjectionPermission(touchedWindow.windowHandle, entry->injectionState)) {
+ if (!checkInjectionPermission(touchedWindow.windowHandle, entry.injectionState)) {
injectionResult = INPUT_EVENT_INJECTION_PERMISSION_DENIED;
injectionPermission = INJECTION_PERMISSION_DENIED;
goto Failed;
@@ -1613,7 +1612,7 @@
Failed:
// Check injection permission once and for all.
if (injectionPermission == INJECTION_PERMISSION_UNKNOWN) {
- if (checkInjectionPermission(nullptr, entry->injectionState)) {
+ if (checkInjectionPermission(nullptr, entry.injectionState)) {
injectionPermission = INJECTION_PERMISSION_GRANTED;
} else {
injectionPermission = INJECTION_PERMISSION_DENIED;
@@ -1642,8 +1641,8 @@
mTempTouchState.reset();
if (maskedAction == AMOTION_EVENT_ACTION_HOVER_ENTER ||
maskedAction == AMOTION_EVENT_ACTION_HOVER_MOVE) {
- mTempTouchState.deviceId = entry->deviceId;
- mTempTouchState.source = entry->source;
+ mTempTouchState.deviceId = entry.deviceId;
+ mTempTouchState.source = entry.source;
mTempTouchState.displayId = displayId;
}
} else if (maskedAction == AMOTION_EVENT_ACTION_UP ||
@@ -1662,7 +1661,7 @@
// One pointer went up.
if (isSplit) {
int32_t pointerIndex = getMotionEventActionPointerIndex(action);
- uint32_t pointerId = entry->pointerProperties[pointerIndex].id;
+ uint32_t pointerId = entry.pointerProperties[pointerIndex].id;
for (size_t i = 0; i < mTempTouchState.windows.size();) {
TouchedWindow& touchedWindow = mTempTouchState.windows[i];
@@ -1822,7 +1821,7 @@
std::string InputDispatcher::checkWindowReadyForMoreInputLocked(
nsecs_t currentTime, const sp<InputWindowHandle>& windowHandle,
- const EventEntry* eventEntry, const char* targetType) {
+ const EventEntry& eventEntry, const char* targetType) {
// If the window is paused then keep waiting.
if (windowHandle->getInfo()->paused) {
return StringPrintf("Waiting because the %s window is paused.", targetType);
@@ -1854,7 +1853,7 @@
}
// Ensure that the dispatch queues aren't too far backed up for this event.
- if (eventEntry->type == EventEntry::TYPE_KEY) {
+ if (eventEntry.type == EventEntry::TYPE_KEY) {
// If the event is a key event, then we must wait for all previous events to
// complete before delivering it because previous events may have the
// side-effect of transferring focus to a different window and we want to
@@ -1926,7 +1925,7 @@
}
}
-void InputDispatcher::pokeUserActivityLocked(const EventEntry* eventEntry) {
+void InputDispatcher::pokeUserActivityLocked(const EventEntry& eventEntry) {
int32_t displayId = getTargetDisplayId(eventEntry);
sp<InputWindowHandle> focusedWindowHandle =
getValueByKey(mFocusedWindowHandlesByDisplay, displayId);
@@ -1941,21 +1940,21 @@
}
int32_t eventType = USER_ACTIVITY_EVENT_OTHER;
- switch (eventEntry->type) {
+ switch (eventEntry.type) {
case EventEntry::TYPE_MOTION: {
- const MotionEntry* motionEntry = static_cast<const MotionEntry*>(eventEntry);
- if (motionEntry->action == AMOTION_EVENT_ACTION_CANCEL) {
+ const MotionEntry& motionEntry = static_cast<const MotionEntry&>(eventEntry);
+ if (motionEntry.action == AMOTION_EVENT_ACTION_CANCEL) {
return;
}
- if (MotionEvent::isTouchEvent(motionEntry->source, motionEntry->action)) {
+ if (MotionEvent::isTouchEvent(motionEntry.source, motionEntry.action)) {
eventType = USER_ACTIVITY_EVENT_TOUCH;
}
break;
}
case EventEntry::TYPE_KEY: {
- const KeyEntry* keyEntry = static_cast<const KeyEntry*>(eventEntry);
- if (keyEntry->flags & AKEY_EVENT_FLAG_CANCELED) {
+ const KeyEntry& keyEntry = static_cast<const KeyEntry&>(eventEntry);
+ if (keyEntry.flags & AKEY_EVENT_FLAG_CANCELED) {
return;
}
eventType = USER_ACTIVITY_EVENT_BUTTON;
@@ -1965,7 +1964,7 @@
std::unique_ptr<CommandEntry> commandEntry =
std::make_unique<CommandEntry>(&InputDispatcher::doPokeUserActivityLockedInterruptible);
- commandEntry->eventTime = eventEntry->eventTime;
+ commandEntry->eventTime = eventEntry.eventTime;
commandEntry->userActivityEventType = eventType;
postCommandLocked(std::move(commandEntry));
}
@@ -2003,8 +2002,8 @@
if (inputTarget->flags & InputTarget::FLAG_SPLIT) {
ALOG_ASSERT(eventEntry->type == EventEntry::TYPE_MOTION);
- MotionEntry* originalMotionEntry = static_cast<MotionEntry*>(eventEntry);
- if (inputTarget->pointerIds.count() != originalMotionEntry->pointerCount) {
+ const MotionEntry& originalMotionEntry = static_cast<const MotionEntry&>(*eventEntry);
+ if (inputTarget->pointerIds.count() != originalMotionEntry.pointerCount) {
MotionEntry* splitMotionEntry =
splitMotionEvent(originalMotionEntry, inputTarget->pointerIds);
if (!splitMotionEntry) {
@@ -2013,7 +2012,7 @@
if (DEBUG_FOCUS) {
ALOGD("channel '%s' ~ Split motion event.",
connection->getInputChannelName().c_str());
- logOutboundMotionDetails(" ", splitMotionEntry);
+ logOutboundMotionDetails(" ", *splitMotionEntry);
}
enqueueDispatchEntriesLocked(currentTime, connection, splitMotionEntry, inputTarget);
splitMotionEntry->release();
@@ -2086,9 +2085,9 @@
// Apply target flags and update the connection's input state.
switch (eventEntry->type) {
case EventEntry::TYPE_KEY: {
- KeyEntry* keyEntry = static_cast<KeyEntry*>(eventEntry);
- dispatchEntry->resolvedAction = keyEntry->action;
- dispatchEntry->resolvedFlags = keyEntry->flags;
+ const KeyEntry& keyEntry = static_cast<const KeyEntry&>(*eventEntry);
+ dispatchEntry->resolvedAction = keyEntry.action;
+ dispatchEntry->resolvedFlags = keyEntry.flags;
if (!connection->inputState.trackKey(keyEntry, dispatchEntry->resolvedAction,
dispatchEntry->resolvedFlags)) {
@@ -2103,7 +2102,7 @@
}
case EventEntry::TYPE_MOTION: {
- MotionEntry* motionEntry = static_cast<MotionEntry*>(eventEntry);
+ const MotionEntry& motionEntry = static_cast<const MotionEntry&>(*eventEntry);
if (dispatchMode & InputTarget::FLAG_DISPATCH_AS_OUTSIDE) {
dispatchEntry->resolvedAction = AMOTION_EVENT_ACTION_OUTSIDE;
} else if (dispatchMode & InputTarget::FLAG_DISPATCH_AS_HOVER_EXIT) {
@@ -2115,11 +2114,11 @@
} else if (dispatchMode & InputTarget::FLAG_DISPATCH_AS_SLIPPERY_ENTER) {
dispatchEntry->resolvedAction = AMOTION_EVENT_ACTION_DOWN;
} else {
- dispatchEntry->resolvedAction = motionEntry->action;
+ dispatchEntry->resolvedAction = motionEntry.action;
}
if (dispatchEntry->resolvedAction == AMOTION_EVENT_ACTION_HOVER_MOVE &&
- !connection->inputState.isHovering(motionEntry->deviceId, motionEntry->source,
- motionEntry->displayId)) {
+ !connection->inputState.isHovering(motionEntry.deviceId, motionEntry.source,
+ motionEntry.displayId)) {
#if DEBUG_DISPATCH_CYCLE
ALOGD("channel '%s' ~ enqueueDispatchEntryLocked: filling in missing hover enter "
"event",
@@ -2128,7 +2127,7 @@
dispatchEntry->resolvedAction = AMOTION_EVENT_ACTION_HOVER_ENTER;
}
- dispatchEntry->resolvedFlags = motionEntry->flags;
+ dispatchEntry->resolvedFlags = motionEntry.flags;
if (dispatchEntry->targetFlags & InputTarget::FLAG_WINDOW_IS_OBSCURED) {
dispatchEntry->resolvedFlags |= AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED;
}
@@ -2147,7 +2146,7 @@
return; // skip the inconsistent event
}
- dispatchPointerDownOutsideFocus(motionEntry->source, dispatchEntry->resolvedAction,
+ dispatchPointerDownOutsideFocus(motionEntry.source, dispatchEntry->resolvedAction,
inputTarget->inputChannel->getToken());
break;
@@ -2494,8 +2493,8 @@
nsecs_t currentTime = now();
- std::vector<EventEntry*> cancelationEvents;
- connection->inputState.synthesizeCancelationEvents(currentTime, cancelationEvents, options);
+ std::vector<EventEntry*> cancelationEvents =
+ connection->inputState.synthesizeCancelationEvents(currentTime, options);
if (!cancelationEvents.empty()) {
#if DEBUG_OUTBOUND_EVENT_DETAILS
@@ -2509,11 +2508,12 @@
switch (cancelationEventEntry->type) {
case EventEntry::TYPE_KEY:
logOutboundKeyDetails("cancel - ",
- static_cast<KeyEntry*>(cancelationEventEntry));
+ static_cast<const KeyEntry&>(*cancelationEventEntry));
break;
case EventEntry::TYPE_MOTION:
logOutboundMotionDetails("cancel - ",
- static_cast<MotionEntry*>(cancelationEventEntry));
+ static_cast<const MotionEntry&>(
+ *cancelationEventEntry));
break;
}
@@ -2545,7 +2545,7 @@
}
}
-MotionEntry* InputDispatcher::splitMotionEvent(const MotionEntry* originalMotionEntry,
+MotionEntry* InputDispatcher::splitMotionEvent(const MotionEntry& originalMotionEntry,
BitSet32 pointerIds) {
ALOG_ASSERT(pointerIds.value != 0);
@@ -2553,19 +2553,19 @@
PointerProperties splitPointerProperties[MAX_POINTERS];
PointerCoords splitPointerCoords[MAX_POINTERS];
- uint32_t originalPointerCount = originalMotionEntry->pointerCount;
+ uint32_t originalPointerCount = originalMotionEntry.pointerCount;
uint32_t splitPointerCount = 0;
for (uint32_t originalPointerIndex = 0; originalPointerIndex < originalPointerCount;
originalPointerIndex++) {
const PointerProperties& pointerProperties =
- originalMotionEntry->pointerProperties[originalPointerIndex];
+ originalMotionEntry.pointerProperties[originalPointerIndex];
uint32_t pointerId = uint32_t(pointerProperties.id);
if (pointerIds.hasBit(pointerId)) {
splitPointerIndexMap[splitPointerCount] = originalPointerIndex;
splitPointerProperties[splitPointerCount].copyFrom(pointerProperties);
splitPointerCoords[splitPointerCount].copyFrom(
- originalMotionEntry->pointerCoords[originalPointerIndex]);
+ originalMotionEntry.pointerCoords[originalPointerIndex]);
splitPointerCount += 1;
}
}
@@ -2583,13 +2583,13 @@
return nullptr;
}
- int32_t action = originalMotionEntry->action;
+ int32_t action = originalMotionEntry.action;
int32_t maskedAction = action & AMOTION_EVENT_ACTION_MASK;
if (maskedAction == AMOTION_EVENT_ACTION_POINTER_DOWN ||
maskedAction == AMOTION_EVENT_ACTION_POINTER_UP) {
int32_t originalPointerIndex = getMotionEventActionPointerIndex(action);
const PointerProperties& pointerProperties =
- originalMotionEntry->pointerProperties[originalPointerIndex];
+ originalMotionEntry.pointerProperties[originalPointerIndex];
uint32_t pointerId = uint32_t(pointerProperties.id);
if (pointerIds.hasBit(pointerId)) {
if (pointerIds.count() == 1) {
@@ -2613,19 +2613,19 @@
}
MotionEntry* splitMotionEntry =
- new MotionEntry(originalMotionEntry->sequenceNum, originalMotionEntry->eventTime,
- originalMotionEntry->deviceId, originalMotionEntry->source,
- originalMotionEntry->displayId, originalMotionEntry->policyFlags,
- action, originalMotionEntry->actionButton, originalMotionEntry->flags,
- originalMotionEntry->metaState, originalMotionEntry->buttonState,
- originalMotionEntry->classification, originalMotionEntry->edgeFlags,
- originalMotionEntry->xPrecision, originalMotionEntry->yPrecision,
- originalMotionEntry->xCursorPosition,
- originalMotionEntry->yCursorPosition, originalMotionEntry->downTime,
+ new MotionEntry(originalMotionEntry.sequenceNum, originalMotionEntry.eventTime,
+ originalMotionEntry.deviceId, originalMotionEntry.source,
+ originalMotionEntry.displayId, originalMotionEntry.policyFlags, action,
+ originalMotionEntry.actionButton, originalMotionEntry.flags,
+ originalMotionEntry.metaState, originalMotionEntry.buttonState,
+ originalMotionEntry.classification, originalMotionEntry.edgeFlags,
+ originalMotionEntry.xPrecision, originalMotionEntry.yPrecision,
+ originalMotionEntry.xCursorPosition,
+ originalMotionEntry.yCursorPosition, originalMotionEntry.downTime,
splitPointerCount, splitPointerProperties, splitPointerCoords, 0, 0);
- if (originalMotionEntry->injectionState) {
- splitMotionEntry->injectionState = originalMotionEntry->injectionState;
+ if (originalMotionEntry.injectionState) {
+ splitMotionEntry->injectionState = originalMotionEntry.injectionState;
splitMotionEntry->injectionState->refCount += 1;
}
@@ -4188,8 +4188,7 @@
CommandEntry* commandEntry) {
KeyEntry* entry = commandEntry->keyEntry;
- KeyEvent event;
- initializeKeyEvent(&event, entry);
+ KeyEvent event = createKeyEvent(*entry);
mLock.unlock();
@@ -4309,8 +4308,7 @@
keyEntry->keyCode, keyEntry->action, keyEntry->repeatCount,
keyEntry->policyFlags);
#endif
- KeyEvent event;
- initializeKeyEvent(&event, keyEntry);
+ KeyEvent event = createKeyEvent(*keyEntry);
event.setFlags(event.getFlags() | AKEY_EVENT_FLAG_CANCELED);
mLock.unlock();
@@ -4352,8 +4350,7 @@
"keyCode=%d, action=%d, repeatCount=%d, policyFlags=0x%08x",
keyEntry->keyCode, keyEntry->action, keyEntry->repeatCount, keyEntry->policyFlags);
#endif
- KeyEvent event;
- initializeKeyEvent(&event, keyEntry);
+ KeyEvent event = createKeyEvent(*keyEntry);
mLock.unlock();
@@ -4470,13 +4467,15 @@
mLock.lock();
}
-void InputDispatcher::initializeKeyEvent(KeyEvent* event, const KeyEntry* entry) {
- event->initialize(entry->deviceId, entry->source, entry->displayId, entry->action, entry->flags,
- entry->keyCode, entry->scanCode, entry->metaState, entry->repeatCount,
- entry->downTime, entry->eventTime);
+KeyEvent InputDispatcher::createKeyEvent(const KeyEntry& entry) {
+ KeyEvent event;
+ event.initialize(entry.deviceId, entry.source, entry.displayId, entry.action, entry.flags,
+ entry.keyCode, entry.scanCode, entry.metaState, entry.repeatCount,
+ entry.downTime, entry.eventTime);
+ return event;
}
-void InputDispatcher::updateDispatchStatistics(nsecs_t currentTime, const EventEntry* entry,
+void InputDispatcher::updateDispatchStatistics(nsecs_t currentTime, const EventEntry& entry,
int32_t injectionResult,
nsecs_t timeSpentWaitingForApplication) {
// TODO Write some statistics about how long we spend waiting.
diff --git a/services/inputflinger/dispatcher/InputDispatcher.h b/services/inputflinger/dispatcher/InputDispatcher.h
index 9d22e2c..923d0e9 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.h
+++ b/services/inputflinger/dispatcher/InputDispatcher.h
@@ -144,7 +144,7 @@
bool enqueueInboundEventLocked(EventEntry* entry) REQUIRES(mLock);
// Cleans up input state when dropping an inbound event.
- void dropInboundEventLocked(EventEntry* entry, DropReason dropReason) REQUIRES(mLock);
+ void dropInboundEventLocked(const EventEntry& entry, DropReason dropReason) REQUIRES(mLock);
// Adds an event to a queue of recent events for debugging purposes.
void addRecentEventLocked(EventEntry* entry) REQUIRES(mLock);
@@ -153,12 +153,12 @@
bool mAppSwitchSawKeyDown GUARDED_BY(mLock);
nsecs_t mAppSwitchDueTime GUARDED_BY(mLock);
- bool isAppSwitchKeyEvent(KeyEntry* keyEntry);
+ bool isAppSwitchKeyEvent(const KeyEntry& keyEntry);
bool isAppSwitchPendingLocked() REQUIRES(mLock);
void resetPendingAppSwitchLocked(bool handled) REQUIRES(mLock);
// Stale event latency optimization.
- static bool isStaleEvent(nsecs_t currentTime, EventEntry* entry);
+ static bool isStaleEvent(nsecs_t currentTime, const EventEntry& entry);
// Blocked event latency optimization. Drops old events when the user intends
// to transfer focus to a new application.
@@ -293,8 +293,8 @@
void dispatchEventLocked(nsecs_t currentTime, EventEntry* entry,
const std::vector<InputTarget>& inputTargets) REQUIRES(mLock);
- void logOutboundKeyDetails(const char* prefix, const KeyEntry* entry);
- void logOutboundMotionDetails(const char* prefix, const MotionEntry* entry);
+ void logOutboundKeyDetails(const char* prefix, const KeyEntry& entry);
+ void logOutboundMotionDetails(const char* prefix, const MotionEntry& entry);
// Keeping track of ANR timeouts.
enum InputTargetWaitCause {
@@ -313,7 +313,7 @@
sp<InputWindowHandle> mLastHoverWindowHandle GUARDED_BY(mLock);
// Finding targets for input events.
- int32_t handleTargetsNotReadyLocked(nsecs_t currentTime, const EventEntry* entry,
+ int32_t handleTargetsNotReadyLocked(nsecs_t currentTime, const EventEntry& entry,
const sp<InputApplicationHandle>& applicationHandle,
const sp<InputWindowHandle>& windowHandle,
nsecs_t* nextWakeupTime, const char* reason)
@@ -327,11 +327,11 @@
nsecs_t getTimeSpentWaitingForApplicationLocked(nsecs_t currentTime) REQUIRES(mLock);
void resetANRTimeoutsLocked() REQUIRES(mLock);
- int32_t getTargetDisplayId(const EventEntry* entry);
- int32_t findFocusedWindowTargetsLocked(nsecs_t currentTime, const EventEntry* entry,
+ int32_t getTargetDisplayId(const EventEntry& entry);
+ int32_t findFocusedWindowTargetsLocked(nsecs_t currentTime, const EventEntry& entry,
std::vector<InputTarget>& inputTargets,
nsecs_t* nextWakeupTime) REQUIRES(mLock);
- int32_t findTouchedWindowTargetsLocked(nsecs_t currentTime, const MotionEntry* entry,
+ int32_t findTouchedWindowTargetsLocked(nsecs_t currentTime, const MotionEntry& entry,
std::vector<InputTarget>& inputTargets,
nsecs_t* nextWakeupTime,
bool* outConflictingPointerActions) REQUIRES(mLock);
@@ -350,7 +350,7 @@
void addGlobalMonitoringTargetsLocked(std::vector<InputTarget>& inputTargets, int32_t displayId,
float xOffset = 0, float yOffset = 0) REQUIRES(mLock);
- void pokeUserActivityLocked(const EventEntry* eventEntry) REQUIRES(mLock);
+ void pokeUserActivityLocked(const EventEntry& eventEntry) REQUIRES(mLock);
bool checkInjectionPermission(const sp<InputWindowHandle>& windowHandle,
const InjectionState* injectionState);
bool isWindowObscuredAtPointLocked(const sp<InputWindowHandle>& windowHandle, int32_t x,
@@ -361,7 +361,7 @@
std::string checkWindowReadyForMoreInputLocked(nsecs_t currentTime,
const sp<InputWindowHandle>& windowHandle,
- const EventEntry* eventEntry,
+ const EventEntry& eventEntry,
const char* targetType) REQUIRES(mLock);
// Manage the dispatch cycle for a single connection.
@@ -405,7 +405,7 @@
REQUIRES(mLock);
// Splitting motion events across windows.
- MotionEntry* splitMotionEvent(const MotionEntry* originalMotionEntry, BitSet32 pointerIds);
+ MotionEntry* splitMotionEvent(const MotionEntry& originalMotionEntry, BitSet32 pointerIds);
// Reset and drop everything the dispatcher is doing.
void resetAndDropEverythingLocked(const char* reason) REQUIRES(mLock);
@@ -450,7 +450,7 @@
DispatchEntry* dispatchEntry, MotionEntry* motionEntry,
bool handled) REQUIRES(mLock);
void doPokeUserActivityLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock);
- void initializeKeyEvent(KeyEvent* event, const KeyEntry* entry);
+ KeyEvent createKeyEvent(const KeyEntry& entry);
void doOnPointerDownOutsideFocusLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock);
// Statistics gathering.
@@ -458,7 +458,7 @@
LatencyStatistics mTouchStatistics{TOUCH_STATS_REPORT_PERIOD};
void reportTouchEventForStatistics(const MotionEntry& entry);
- void updateDispatchStatistics(nsecs_t currentTime, const EventEntry* entry,
+ void updateDispatchStatistics(nsecs_t currentTime, const EventEntry& entry,
int32_t injectionResult, nsecs_t timeSpentWaitingForApplication);
void traceInboundQueueLengthLocked() REQUIRES(mLock);
void traceOutboundQueueLength(const sp<Connection>& connection);
diff --git a/services/inputflinger/dispatcher/InputState.cpp b/services/inputflinger/dispatcher/InputState.cpp
index c60700e..c43e304 100644
--- a/services/inputflinger/dispatcher/InputState.cpp
+++ b/services/inputflinger/dispatcher/InputState.cpp
@@ -36,12 +36,12 @@
return false;
}
-bool InputState::trackKey(const KeyEntry* entry, int32_t action, int32_t flags) {
+bool InputState::trackKey(const KeyEntry& entry, int32_t action, int32_t flags) {
switch (action) {
case AKEY_EVENT_ACTION_UP: {
- if (entry->flags & AKEY_EVENT_FLAG_FALLBACK) {
+ if (entry.flags & AKEY_EVENT_FLAG_FALLBACK) {
for (size_t i = 0; i < mFallbackKeys.size();) {
- if (mFallbackKeys.valueAt(i) == entry->keyCode) {
+ if (mFallbackKeys.valueAt(i) == entry.keyCode) {
mFallbackKeys.removeItemsAt(i);
} else {
i += 1;
@@ -65,7 +65,7 @@
#if DEBUG_OUTBOUND_EVENT_DETAILS
ALOGD("Dropping inconsistent key up event: deviceId=%d, source=%08x, "
"keyCode=%d, scanCode=%d",
- entry->deviceId, entry->source, entry->keyCode, entry->scanCode);
+ entry.deviceId, entry.source, entry.keyCode, entry.scanCode);
#endif
return false;
*/
@@ -86,7 +86,7 @@
}
}
-bool InputState::trackMotion(const MotionEntry* entry, int32_t action, int32_t flags) {
+bool InputState::trackMotion(const MotionEntry& entry, int32_t action, int32_t flags) {
int32_t actionMasked = action & AMOTION_EVENT_ACTION_MASK;
switch (actionMasked) {
case AMOTION_EVENT_ACTION_UP:
@@ -99,7 +99,7 @@
#if DEBUG_OUTBOUND_EVENT_DETAILS
ALOGD("Dropping inconsistent motion up or cancel event: deviceId=%d, source=%08x, "
"displayId=%" PRId32 ", actionMasked=%d",
- entry->deviceId, entry->source, entry->displayId, actionMasked);
+ entry.deviceId, entry.source, entry.displayId, actionMasked);
#endif
return false;
}
@@ -116,7 +116,7 @@
case AMOTION_EVENT_ACTION_POINTER_UP:
case AMOTION_EVENT_ACTION_POINTER_DOWN:
case AMOTION_EVENT_ACTION_MOVE: {
- if (entry->source & AINPUT_SOURCE_CLASS_NAVIGATION) {
+ if (entry.source & AINPUT_SOURCE_CLASS_NAVIGATION) {
// Trackballs can send MOVE events with a corresponding DOWN or UP. There's no need
// to generate cancellation events for these since they're based in relative rather
// than absolute units.
@@ -125,20 +125,20 @@
ssize_t index = findMotionMemento(entry, false /*hovering*/);
- if (entry->source & AINPUT_SOURCE_CLASS_JOYSTICK) {
+ if (entry.source & AINPUT_SOURCE_CLASS_JOYSTICK) {
// Joysticks can send MOVE events without a corresponding DOWN or UP. Since all
// joystick axes are normalized to [-1, 1] we can trust that 0 means it's neutral.
// Any other value and we need to track the motion so we can send cancellation
// events for anything generating fallback events (e.g. DPad keys for joystick
// movements).
if (index >= 0) {
- if (entry->pointerCoords[0].isEmpty()) {
+ if (entry.pointerCoords[0].isEmpty()) {
mMotionMementos.erase(mMotionMementos.begin() + index);
} else {
MotionMemento& memento = mMotionMementos[index];
memento.setPointers(entry);
}
- } else if (!entry->pointerCoords[0].isEmpty()) {
+ } else if (!entry.pointerCoords[0].isEmpty()) {
addMotionMemento(entry, flags, false /*hovering*/);
}
@@ -153,7 +153,7 @@
#if DEBUG_OUTBOUND_EVENT_DETAILS
ALOGD("Dropping inconsistent motion pointer up/down or move event: "
"deviceId=%d, source=%08x, displayId=%" PRId32 ", actionMasked=%d",
- entry->deviceId, entry->source, entry->displayId, actionMasked);
+ entry.deviceId, entry.source, entry.displayId, actionMasked);
#endif
return false;
}
@@ -167,7 +167,7 @@
#if DEBUG_OUTBOUND_EVENT_DETAILS
ALOGD("Dropping inconsistent motion hover exit event: deviceId=%d, source=%08x, "
"displayId=%" PRId32,
- entry->deviceId, entry->source, entry->displayId);
+ entry.deviceId, entry.source, entry.displayId);
#endif
return false;
}
@@ -187,79 +187,79 @@
}
}
-ssize_t InputState::findKeyMemento(const KeyEntry* entry) const {
+ssize_t InputState::findKeyMemento(const KeyEntry& entry) const {
for (size_t i = 0; i < mKeyMementos.size(); i++) {
const KeyMemento& memento = mKeyMementos[i];
- if (memento.deviceId == entry->deviceId && memento.source == entry->source &&
- memento.displayId == entry->displayId && memento.keyCode == entry->keyCode &&
- memento.scanCode == entry->scanCode) {
+ if (memento.deviceId == entry.deviceId && memento.source == entry.source &&
+ memento.displayId == entry.displayId && memento.keyCode == entry.keyCode &&
+ memento.scanCode == entry.scanCode) {
return i;
}
}
return -1;
}
-ssize_t InputState::findMotionMemento(const MotionEntry* entry, bool hovering) const {
+ssize_t InputState::findMotionMemento(const MotionEntry& entry, bool hovering) const {
for (size_t i = 0; i < mMotionMementos.size(); i++) {
const MotionMemento& memento = mMotionMementos[i];
- if (memento.deviceId == entry->deviceId && memento.source == entry->source &&
- memento.displayId == entry->displayId && memento.hovering == hovering) {
+ if (memento.deviceId == entry.deviceId && memento.source == entry.source &&
+ memento.displayId == entry.displayId && memento.hovering == hovering) {
return i;
}
}
return -1;
}
-void InputState::addKeyMemento(const KeyEntry* entry, int32_t flags) {
+void InputState::addKeyMemento(const KeyEntry& entry, int32_t flags) {
KeyMemento memento;
- memento.deviceId = entry->deviceId;
- memento.source = entry->source;
- memento.displayId = entry->displayId;
- memento.keyCode = entry->keyCode;
- memento.scanCode = entry->scanCode;
- memento.metaState = entry->metaState;
+ memento.deviceId = entry.deviceId;
+ memento.source = entry.source;
+ memento.displayId = entry.displayId;
+ memento.keyCode = entry.keyCode;
+ memento.scanCode = entry.scanCode;
+ memento.metaState = entry.metaState;
memento.flags = flags;
- memento.downTime = entry->downTime;
- memento.policyFlags = entry->policyFlags;
+ memento.downTime = entry.downTime;
+ memento.policyFlags = entry.policyFlags;
mKeyMementos.push_back(memento);
}
-void InputState::addMotionMemento(const MotionEntry* entry, int32_t flags, bool hovering) {
+void InputState::addMotionMemento(const MotionEntry& entry, int32_t flags, bool hovering) {
MotionMemento memento;
- memento.deviceId = entry->deviceId;
- memento.source = entry->source;
- memento.displayId = entry->displayId;
+ memento.deviceId = entry.deviceId;
+ memento.source = entry.source;
+ memento.displayId = entry.displayId;
memento.flags = flags;
- memento.xPrecision = entry->xPrecision;
- memento.yPrecision = entry->yPrecision;
- memento.xCursorPosition = entry->xCursorPosition;
- memento.yCursorPosition = entry->yCursorPosition;
- memento.downTime = entry->downTime;
+ memento.xPrecision = entry.xPrecision;
+ memento.yPrecision = entry.yPrecision;
+ memento.xCursorPosition = entry.xCursorPosition;
+ memento.yCursorPosition = entry.yCursorPosition;
+ memento.downTime = entry.downTime;
memento.setPointers(entry);
memento.hovering = hovering;
- memento.policyFlags = entry->policyFlags;
+ memento.policyFlags = entry.policyFlags;
mMotionMementos.push_back(memento);
}
-void InputState::MotionMemento::setPointers(const MotionEntry* entry) {
- pointerCount = entry->pointerCount;
- for (uint32_t i = 0; i < entry->pointerCount; i++) {
- pointerProperties[i].copyFrom(entry->pointerProperties[i]);
- pointerCoords[i].copyFrom(entry->pointerCoords[i]);
+void InputState::MotionMemento::setPointers(const MotionEntry& entry) {
+ pointerCount = entry.pointerCount;
+ for (uint32_t i = 0; i < entry.pointerCount; i++) {
+ pointerProperties[i].copyFrom(entry.pointerProperties[i]);
+ pointerCoords[i].copyFrom(entry.pointerCoords[i]);
}
}
-void InputState::synthesizeCancelationEvents(nsecs_t currentTime,
- std::vector<EventEntry*>& outEvents,
- const CancelationOptions& options) {
+std::vector<EventEntry*> InputState::synthesizeCancelationEvents(
+ nsecs_t currentTime, const CancelationOptions& options) {
+ std::vector<EventEntry*> events;
for (KeyMemento& memento : mKeyMementos) {
if (shouldCancelKey(memento, options)) {
- outEvents.push_back(new KeyEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, currentTime,
- memento.deviceId, memento.source, memento.displayId,
- memento.policyFlags, AKEY_EVENT_ACTION_UP,
- memento.flags | AKEY_EVENT_FLAG_CANCELED,
- memento.keyCode, memento.scanCode, memento.metaState,
- 0, memento.downTime));
+ events.push_back(new KeyEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, currentTime,
+ memento.deviceId, memento.source, memento.displayId,
+ memento.policyFlags, AKEY_EVENT_ACTION_UP,
+ memento.flags | AKEY_EVENT_FLAG_CANCELED, memento.keyCode,
+ memento.scanCode, memento.metaState, 0 /*repeatCount*/,
+ memento.downTime));
}
}
@@ -267,18 +267,19 @@
if (shouldCancelMotion(memento, options)) {
const int32_t action = memento.hovering ? AMOTION_EVENT_ACTION_HOVER_EXIT
: AMOTION_EVENT_ACTION_CANCEL;
- outEvents.push_back(
- new MotionEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, currentTime, memento.deviceId,
- memento.source, memento.displayId, memento.policyFlags, action,
- 0 /*actionButton*/, memento.flags, AMETA_NONE,
- 0 /*buttonState*/, MotionClassification::NONE,
- AMOTION_EVENT_EDGE_FLAG_NONE, memento.xPrecision,
- memento.yPrecision, memento.xCursorPosition,
- memento.yCursorPosition, memento.downTime, memento.pointerCount,
- memento.pointerProperties, memento.pointerCoords, 0 /*xOffset*/,
- 0 /*yOffset*/));
+ events.push_back(new MotionEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, currentTime,
+ memento.deviceId, memento.source, memento.displayId,
+ memento.policyFlags, action, 0 /*actionButton*/,
+ memento.flags, AMETA_NONE, 0 /*buttonState*/,
+ MotionClassification::NONE,
+ AMOTION_EVENT_EDGE_FLAG_NONE, memento.xPrecision,
+ memento.yPrecision, memento.xCursorPosition,
+ memento.yCursorPosition, memento.downTime,
+ memento.pointerCount, memento.pointerProperties,
+ memento.pointerCoords, 0 /*xOffset*/, 0 /*yOffset*/));
}
}
+ return events;
}
void InputState::clear() {
diff --git a/services/inputflinger/dispatcher/InputState.h b/services/inputflinger/dispatcher/InputState.h
index 47e9b36..a93f486 100644
--- a/services/inputflinger/dispatcher/InputState.h
+++ b/services/inputflinger/dispatcher/InputState.h
@@ -41,16 +41,16 @@
// Records tracking information for a key event that has just been published.
// Returns true if the event should be delivered, false if it is inconsistent
// and should be skipped.
- bool trackKey(const KeyEntry* entry, int32_t action, int32_t flags);
+ bool trackKey(const KeyEntry& entry, int32_t action, int32_t flags);
// Records tracking information for a motion event that has just been published.
// Returns true if the event should be delivered, false if it is inconsistent
// and should be skipped.
- bool trackMotion(const MotionEntry* entry, int32_t action, int32_t flags);
+ bool trackMotion(const MotionEntry& entry, int32_t action, int32_t flags);
// Synthesizes cancelation events for the current state and resets the tracked state.
- void synthesizeCancelationEvents(nsecs_t currentTime, std::vector<EventEntry*>& outEvents,
- const CancelationOptions& options);
+ std::vector<EventEntry*> synthesizeCancelationEvents(nsecs_t currentTime,
+ const CancelationOptions& options);
// Clears the current state.
void clear();
@@ -100,18 +100,18 @@
bool hovering;
uint32_t policyFlags;
- void setPointers(const MotionEntry* entry);
+ void setPointers(const MotionEntry& entry);
};
std::vector<KeyMemento> mKeyMementos;
std::vector<MotionMemento> mMotionMementos;
KeyedVector<int32_t, int32_t> mFallbackKeys;
- ssize_t findKeyMemento(const KeyEntry* entry) const;
- ssize_t findMotionMemento(const MotionEntry* entry, bool hovering) const;
+ ssize_t findKeyMemento(const KeyEntry& entry) const;
+ ssize_t findMotionMemento(const MotionEntry& entry, bool hovering) const;
- void addKeyMemento(const KeyEntry* entry, int32_t flags);
- void addMotionMemento(const MotionEntry* entry, int32_t flags, bool hovering);
+ void addKeyMemento(const KeyEntry& entry, int32_t flags);
+ void addMotionMemento(const MotionEntry& entry, int32_t flags, bool hovering);
static bool shouldCancelKey(const KeyMemento& memento, const CancelationOptions& options);
static bool shouldCancelMotion(const MotionMemento& memento, const CancelationOptions& options);
diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h
index 060b5eb..fa23da0 100644
--- a/services/sensorservice/SensorService.h
+++ b/services/sensorservice/SensorService.h
@@ -180,7 +180,7 @@
void onUidActive(uid_t uid);
void onUidIdle(uid_t uid, bool disabled);
void onUidStateChanged(uid_t uid __unused, int32_t procState __unused,
- int64_t procStateSeq __unused) {}
+ int64_t procStateSeq __unused, int32_t capability __unused) {}
void addOverrideUid(uid_t uid, bool active);
void removeOverrideUid(uid_t uid);
diff --git a/services/surfaceflinger/BufferQueueLayer.cpp b/services/surfaceflinger/BufferQueueLayer.cpp
index c24cdaa..dc61e49 100644
--- a/services/surfaceflinger/BufferQueueLayer.cpp
+++ b/services/surfaceflinger/BufferQueueLayer.cpp
@@ -374,13 +374,26 @@
void BufferQueueLayer::onFrameDequeued(const uint64_t bufferId) {
const int32_t layerID = getSequence();
+ mFlinger->mFrameTracer->traceNewLayer(layerID, getName().c_str());
mFlinger->mFrameTracer->traceTimestamp(layerID, bufferId, FrameTracer::UNSPECIFIED_FRAME_NUMBER,
- systemTime(), FrameTracer::FrameEvent::DEQUEUE, 3000);
+ systemTime(), FrameTracer::FrameEvent::DEQUEUE);
+}
+
+void BufferQueueLayer::onFrameDetached(const uint64_t bufferId) {
+ const int32_t layerID = getSequence();
+ mFlinger->mFrameTracer->traceNewLayer(layerID, getName().c_str());
+ mFlinger->mFrameTracer->traceTimestamp(layerID, bufferId, FrameTracer::UNSPECIFIED_FRAME_NUMBER,
+ systemTime(), FrameTracer::FrameEvent::DETACH);
+}
+
+void BufferQueueLayer::onFrameCancelled(const uint64_t bufferId) {
+ const int32_t layerID = getSequence();
+ mFlinger->mFrameTracer->traceTimestamp(layerID, bufferId, FrameTracer::UNSPECIFIED_FRAME_NUMBER,
+ systemTime(), FrameTracer::FrameEvent::CANCEL);
}
void BufferQueueLayer::onFrameAvailable(const BufferItem& item) {
const int32_t layerID = getSequence();
- mFlinger->mFrameTracer->traceNewLayer(layerID, getName().c_str());
mFlinger->mFrameTracer->traceTimestamp(layerID, item.mGraphicBuffer->getId(), item.mFrameNumber,
systemTime(), FrameTracer::FrameEvent::QUEUE);
diff --git a/services/surfaceflinger/BufferQueueLayer.h b/services/surfaceflinger/BufferQueueLayer.h
index 95e0b10..1b1fccd 100644
--- a/services/surfaceflinger/BufferQueueLayer.h
+++ b/services/surfaceflinger/BufferQueueLayer.h
@@ -94,6 +94,8 @@
void onFrameReplaced(const BufferItem& item) override;
void onSidebandStreamChanged() override;
void onFrameDequeued(const uint64_t bufferId) override;
+ void onFrameDetached(const uint64_t bufferId) override;
+ void onFrameCancelled(const uint64_t bufferId) override;
// -----------------------------------------------------------------------
public:
diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
index 721e953..ce0222c 100644
--- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
@@ -326,6 +326,9 @@
writeOutputIndependentPerFrameStateToHWC(hwcLayer.get(), outputIndependentState);
writeCompositionTypeToHWC(hwcLayer.get(), requestedCompositionType);
+
+ // Always set the layer color after setting the composition type.
+ writeSolidColorStateToHWC(hwcLayer.get(), outputIndependentState);
}
void OutputLayer::writeOutputDependentGeometryStateToHWC(
@@ -435,7 +438,7 @@
// Content-specific per-frame state
switch (outputIndependentState.compositionType) {
case Hwc2::IComposerClient::Composition::SOLID_COLOR:
- writeSolidColorStateToHWC(hwcLayer, outputIndependentState);
+ // For compatibility, should be written AFTER the composition type.
break;
case Hwc2::IComposerClient::Composition::SIDEBAND:
writeSidebandStateToHWC(hwcLayer, outputIndependentState);
@@ -453,6 +456,10 @@
void OutputLayer::writeSolidColorStateToHWC(HWC2::Layer* hwcLayer,
const LayerFECompositionState& outputIndependentState) {
+ if (outputIndependentState.compositionType != Hwc2::IComposerClient::Composition::SOLID_COLOR) {
+ return;
+ }
+
hwc_color_t color = {static_cast<uint8_t>(std::round(255.0f * outputIndependentState.color.r)),
static_cast<uint8_t>(std::round(255.0f * outputIndependentState.color.g)),
static_cast<uint8_t>(std::round(255.0f * outputIndependentState.color.b)),
diff --git a/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp b/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp
index a338784..88acd04 100644
--- a/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp
+++ b/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp
@@ -33,6 +33,7 @@
namespace {
using testing::_;
+using testing::InSequence;
using testing::Return;
using testing::ReturnRef;
using testing::StrictMock;
@@ -769,8 +770,13 @@
mLayerFEState.compositionType = Hwc2::IComposerClient::Composition::SOLID_COLOR;
expectPerFrameCommonCalls();
- expectSetColorCall();
+
+ // Setting the composition type should happen before setting the color. We
+ // check this in this test only by setting up an testing::InSeqeuence
+ // instance before setting up the two expectations.
+ InSequence s;
expectSetCompositionTypeCall(Hwc2::IComposerClient::Composition::SOLID_COLOR);
+ expectSetColorCall();
mOutputLayer.writeStateToHWC(false);
}
diff --git a/services/surfaceflinger/RegionSamplingThread.cpp b/services/surfaceflinger/RegionSamplingThread.cpp
index 30027de..a484373 100644
--- a/services/surfaceflinger/RegionSamplingThread.cpp
+++ b/services/surfaceflinger/RegionSamplingThread.cpp
@@ -268,16 +268,6 @@
mDescriptors.erase(who);
}
-namespace {
-// Using Rec. 709 primaries
-inline float getLuma(float r, float g, float b) {
- constexpr auto rec709_red_primary = 0.2126f;
- constexpr auto rec709_green_primary = 0.7152f;
- constexpr auto rec709_blue_primary = 0.0722f;
- return rec709_red_primary * r + rec709_green_primary * g + rec709_blue_primary * b;
-}
-} // anonymous namespace
-
float sampleArea(const uint32_t* data, int32_t width, int32_t height, int32_t stride,
uint32_t orientation, const Rect& sample_area) {
if (!sample_area.isValid() || (sample_area.getWidth() > width) ||
@@ -298,30 +288,23 @@
std::swap(area.left, area.right);
}
- std::array<int32_t, 256> brightnessBuckets = {};
- const int32_t majoritySampleNum = area.getWidth() * area.getHeight() / 2;
+ const uint32_t pixelCount = (area.bottom - area.top) * (area.right - area.left);
+ uint32_t accumulatedLuma = 0;
+ // Calculates luma with approximation of Rec. 709 primaries
for (int32_t row = area.top; row < area.bottom; ++row) {
const uint32_t* rowBase = data + row * stride;
for (int32_t column = area.left; column < area.right; ++column) {
uint32_t pixel = rowBase[column];
- const float r = pixel & 0xFF;
- const float g = (pixel >> 8) & 0xFF;
- const float b = (pixel >> 16) & 0xFF;
- const uint8_t luma = std::round(getLuma(r, g, b));
- ++brightnessBuckets[luma];
- if (brightnessBuckets[luma] > majoritySampleNum) return luma / 255.0f;
+ const uint32_t r = pixel & 0xFF;
+ const uint32_t g = (pixel >> 8) & 0xFF;
+ const uint32_t b = (pixel >> 16) & 0xFF;
+ const uint32_t luma = (r * 7 + b * 2 + g * 23) >> 5;
+ accumulatedLuma += luma;
}
}
- int32_t accumulated = 0;
- size_t bucket = 0;
- for (; bucket < brightnessBuckets.size(); bucket++) {
- accumulated += brightnessBuckets[bucket];
- if (accumulated > majoritySampleNum) break;
- }
-
- return bucket / 255.0f;
+ return accumulatedLuma / (255.0f * pixelCount);
}
std::vector<float> RegionSamplingThread::sampleBuffer(
diff --git a/services/surfaceflinger/tests/unittests/RegionSamplingTest.cpp b/services/surfaceflinger/tests/unittests/RegionSamplingTest.cpp
index 160f041..d8de804 100644
--- a/services/surfaceflinger/tests/unittests/RegionSamplingTest.cpp
+++ b/services/surfaceflinger/tests/unittests/RegionSamplingTest.cpp
@@ -69,16 +69,16 @@
n++;
return pixel;
});
+
EXPECT_THAT(sampleArea(buffer.data(), kWidth, kHeight, kStride, kOrientation, whole_area),
- testing::FloatNear(0.083f, 0.01f));
+ testing::FloatNear(0.16f, 0.01f));
}
TEST_F(RegionSamplingTest, bimodal_tiebreaker) {
std::generate(buffer.begin(), buffer.end(),
[n = 0]() mutable { return (n++ % 2) ? kBlack : kWhite; });
- // presently there's no tiebreaking strategy in place, accept either of the means
EXPECT_THAT(sampleArea(buffer.data(), kWidth, kHeight, kStride, kOrientation, whole_area),
- testing::AnyOf(testing::FloatEq(1.0), testing::FloatEq(0.0f)));
+ testing::FloatEq(0.5f));
}
TEST_F(RegionSamplingTest, bounds_checking) {
diff --git a/vulkan/libvulkan/driver.cpp b/vulkan/libvulkan/driver.cpp
index a544bc5..d92f35a 100644
--- a/vulkan/libvulkan/driver.cpp
+++ b/vulkan/libvulkan/driver.cpp
@@ -151,15 +151,12 @@
Hal Hal::hal_;
void* LoadLibrary(const android_dlextinfo& dlextinfo,
- const char* subname,
- int subname_len) {
+ const std::string_view subname) {
ATRACE_CALL();
- const char kLibFormat[] = "vulkan.%*s.so";
- char* name = static_cast<char*>(
- alloca(sizeof(kLibFormat) + static_cast<size_t>(subname_len)));
- sprintf(name, kLibFormat, subname_len, subname);
- return android_dlopen_ext(name, RTLD_LOCAL | RTLD_NOW, &dlextinfo);
+ std::stringstream ss;
+ ss << "vulkan." << subname << ".so";
+ return android_dlopen_ext(ss.str().c_str(), RTLD_LOCAL | RTLD_NOW, &dlextinfo);
}
const std::array<const char*, 2> HAL_SUBNAME_KEY_PROPERTIES = {{
@@ -179,8 +176,9 @@
char prop[PROPERTY_VALUE_MAX];
for (auto key : HAL_SUBNAME_KEY_PROPERTIES) {
int prop_len = property_get(key, prop, nullptr);
- if (prop_len > 0) {
- so = LoadLibrary(dlextinfo, prop, prop_len);
+ if (prop_len > 0 && prop_len <= UINT_MAX) {
+ std::string_view lib_name(prop, static_cast<unsigned int>(prop_len));
+ so = LoadLibrary(dlextinfo, lib_name);
if (so)
break;
}
diff --git a/vulkan/libvulkan/layers_extensions.cpp b/vulkan/libvulkan/layers_extensions.cpp
index 2f33fee..22f92d6 100644
--- a/vulkan/libvulkan/layers_extensions.cpp
+++ b/vulkan/libvulkan/layers_extensions.cpp
@@ -95,9 +95,7 @@
bool EnumerateLayers(size_t library_idx,
std::vector<Layer>& instance_layers) const;
- void* GetGPA(const Layer& layer,
- const char* gpa_name,
- size_t gpa_name_len) const;
+ void* GetGPA(const Layer& layer, const std::string_view gpa_name) const;
const std::string GetFilename() { return filename_; }
@@ -220,9 +218,8 @@
}
// get layer properties
- VkLayerProperties* properties = static_cast<VkLayerProperties*>(alloca(
- (num_instance_layers + num_device_layers) * sizeof(VkLayerProperties)));
- result = enumerate_instance_layers(&num_instance_layers, properties);
+ std::vector<VkLayerProperties> properties(num_instance_layers + num_device_layers);
+ result = enumerate_instance_layers(&num_instance_layers, properties.data());
if (result != VK_SUCCESS) {
ALOGE("vkEnumerateInstanceLayerProperties failed for library '%s': %d",
path_.c_str(), result);
@@ -230,7 +227,7 @@
}
if (num_device_layers > 0) {
result = enumerate_device_layers(VK_NULL_HANDLE, &num_device_layers,
- properties + num_instance_layers);
+ &properties[num_instance_layers]);
if (result != VK_SUCCESS) {
ALOGE(
"vkEnumerateDeviceLayerProperties failed for library '%s': %d",
@@ -315,21 +312,11 @@
return true;
}
-void* LayerLibrary::GetGPA(const Layer& layer,
- const char* gpa_name,
- size_t gpa_name_len) const {
- void* gpa;
- size_t layer_name_len =
- std::max(size_t{2}, strlen(layer.properties.layerName));
- char* name = static_cast<char*>(alloca(layer_name_len + gpa_name_len + 1));
- strcpy(name, layer.properties.layerName);
- strcpy(name + layer_name_len, gpa_name);
- if (!(gpa = GetTrampoline(name))) {
- strcpy(name, "vk");
- strcpy(name + 2, gpa_name);
- gpa = GetTrampoline(name);
- }
- return gpa;
+void* LayerLibrary::GetGPA(const Layer& layer, const std::string_view gpa_name) const {
+ std::string layer_name { layer.properties.layerName };
+ if (void* gpa = GetTrampoline((layer_name.append(gpa_name).c_str())))
+ return gpa;
+ return GetTrampoline((std::string {"vk"}.append(gpa_name)).c_str());
}
// ----------------------------------------------------------------------------
@@ -464,10 +451,9 @@
}
void* GetLayerGetProcAddr(const Layer& layer,
- const char* gpa_name,
- size_t gpa_name_len) {
+ const std::string_view gpa_name) {
const LayerLibrary& library = g_layer_libraries[layer.library_idx];
- return library.GetGPA(layer, gpa_name, gpa_name_len);
+ return library.GetGPA(layer, gpa_name);
}
} // anonymous namespace
@@ -550,13 +536,13 @@
PFN_vkGetInstanceProcAddr LayerRef::GetGetInstanceProcAddr() const {
return layer_ ? reinterpret_cast<PFN_vkGetInstanceProcAddr>(
- GetLayerGetProcAddr(*layer_, "GetInstanceProcAddr", 19))
+ GetLayerGetProcAddr(*layer_, "GetInstanceProcAddr"))
: nullptr;
}
PFN_vkGetDeviceProcAddr LayerRef::GetGetDeviceProcAddr() const {
return layer_ ? reinterpret_cast<PFN_vkGetDeviceProcAddr>(
- GetLayerGetProcAddr(*layer_, "GetDeviceProcAddr", 17))
+ GetLayerGetProcAddr(*layer_, "GetDeviceProcAddr"))
: nullptr;
}