diff options
author | 2022-07-28 22:54:19 +0000 | |
---|---|---|
committer | 2022-07-30 13:11:11 -0700 | |
commit | 2a6c186bb0a09c1db725c927d246d7d4a0f1f974 (patch) | |
tree | 63546fb8ae14a81b51dc0c3514475383c30add4c | |
parent | 42456e6a98d00c65daab11291da57ac8abdcd7d2 (diff) |
Deprecate Looper's pollAll
pollAll is racy and can lead to ignoring wake() calls.
Bug: 14257980
Change-Id: I22b28146ff2dc026e66e076fa18e34969a1060c7
-rw-r--r-- | include/android/input.h | 7 | ||||
-rw-r--r-- | include/android/looper.h | 5 | ||||
-rw-r--r-- | include/android/sensor.h | 5 | ||||
-rw-r--r-- | services/surfaceflinger/tests/vsync/vsync.cpp | 6 |
4 files changed, 22 insertions, 1 deletions
diff --git a/include/android/input.h b/include/android/input.h index 38b27bc587..8cd9e9551a 100644 --- a/include/android/input.h +++ b/include/android/input.h @@ -54,7 +54,14 @@ #include <stdint.h> #include <sys/types.h> #include <android/keycodes.h> + +// This file is included by modules that have host support but android/looper.h is not supported +// on host. __REMOVED_IN needs to be defined in order for android/looper.h to be compiled. +#ifndef __BIONIC__ +#define __REMOVED_IN(x) __attribute__((deprecated)) +#endif #include <android/looper.h> + #include <jni.h> #if !defined(__INTRODUCED_IN) diff --git a/include/android/looper.h b/include/android/looper.h index 718f703048..4fe142a8e2 100644 --- a/include/android/looper.h +++ b/include/android/looper.h @@ -201,8 +201,11 @@ int ALooper_pollOnce(int timeoutMillis, int* outFd, int* outEvents, void** outDa * Like ALooper_pollOnce(), but performs all pending callbacks until all * data has been consumed or a file descriptor is available with no callback. * This function will never return ALOOPER_POLL_CALLBACK. + * + * Removed in API 34 as ALooper_pollAll can swallow ALooper_wake calls. + * Use ALooper_pollOnce instead. */ -int ALooper_pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outData); +int ALooper_pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outData) __REMOVED_IN(1); /** * Wakes the poll asynchronously. diff --git a/include/android/sensor.h b/include/android/sensor.h index eef69f4b32..105f9524c7 100644 --- a/include/android/sensor.h +++ b/include/android/sensor.h @@ -45,6 +45,11 @@ * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES */ +// This file is included by modules that have host support but android/looper.h is not supported +// on host. __REMOVED_IN needs to be defined in order for android/looper.h to be compiled. +#ifndef __BIONIC__ +#define __REMOVED_IN(x) __attribute__((deprecated)) +#endif #include <android/looper.h> #include <stdbool.h> diff --git a/services/surfaceflinger/tests/vsync/vsync.cpp b/services/surfaceflinger/tests/vsync/vsync.cpp index 667dfb92d5..9fcce32c38 100644 --- a/services/surfaceflinger/tests/vsync/vsync.cpp +++ b/services/surfaceflinger/tests/vsync/vsync.cpp @@ -18,7 +18,13 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wconversion" +// This file is included by modules that have host support but android/looper.h is not supported +// on host. __REMOVED_IN needs to be defined in order for android/looper.h to be compiled. +#ifndef __BIONIC__ +#define __REMOVED_IN(x) __attribute__((deprecated)) +#endif #include <android/looper.h> + #include <gui/DisplayEventReceiver.h> #include <utils/Looper.h> |