diff options
Diffstat (limited to 'include')
62 files changed, 389 insertions, 190 deletions
diff --git a/include/android/asset_manager.h b/include/android/asset_manager.h index d65483968e..7ef3ecb595 100644 --- a/include/android/asset_manager.h +++ b/include/android/asset_manager.h @@ -26,6 +26,9 @@ #ifndef ANDROID_ASSET_MANAGER_H #define ANDROID_ASSET_MANAGER_H +#include <sys/cdefs.h> +#include <sys/types.h> + #ifdef __cplusplus extern "C" { #endif @@ -131,6 +134,7 @@ int AAsset_read(AAsset* asset, void* buf, size_t count); */ off_t AAsset_seek(AAsset* asset, off_t offset, int whence); +#if __ANDROID_API__ >= 13 /** * Seek to the specified offset within the asset data. 'whence' uses the * same constants as lseek()/fseek(). @@ -141,6 +145,7 @@ off_t AAsset_seek(AAsset* asset, off_t offset, int whence); * Returns the new position on success, or (off64_t) -1 on error. */ off64_t AAsset_seek64(AAsset* asset, off64_t offset, int whence); +#endif /** * Close the asset, freeing all associated resources. @@ -159,23 +164,27 @@ const void* AAsset_getBuffer(AAsset* asset); */ off_t AAsset_getLength(AAsset* asset); +#if __ANDROID_API__ >= 13 /** * Report the total size of the asset data. Reports the size using a 64-bit * number insted of 32-bit as AAsset_getLength. */ off64_t AAsset_getLength64(AAsset* asset); +#endif /** * Report the total amount of asset data that can be read from the current position. */ off_t AAsset_getRemainingLength(AAsset* asset); +#if __ANDROID_API__ >= 13 /** * Report the total amount of asset data that can be read from the current position. * * Uses a 64-bit number instead of a 32-bit number as AAsset_getRemainingLength does. */ off64_t AAsset_getRemainingLength64(AAsset* asset); +#endif /** * Open a new file descriptor that can be used to read the asset data. If the @@ -187,6 +196,7 @@ off64_t AAsset_getRemainingLength64(AAsset* asset); */ int AAsset_openFileDescriptor(AAsset* asset, off_t* outStart, off_t* outLength); +#if __ANDROID_API__ >= 13 /** * Open a new file descriptor that can be used to read the asset data. * @@ -197,6 +207,7 @@ int AAsset_openFileDescriptor(AAsset* asset, off_t* outStart, off_t* outLength); * compressed). */ int AAsset_openFileDescriptor64(AAsset* asset, off64_t* outStart, off64_t* outLength); +#endif /** * Returns whether this asset's internal buffer is allocated in ordinary RAM (i.e. not diff --git a/include/android/choreographer.h b/include/android/choreographer.h index 02c83dc07c..43346fe83f 100644 --- a/include/android/choreographer.h +++ b/include/android/choreographer.h @@ -30,6 +30,8 @@ __BEGIN_DECLS +#if __ANDROID_API__ >= 24 + struct AChoreographer; typedef struct AChoreographer AChoreographer; @@ -62,6 +64,9 @@ void AChoreographer_postFrameCallback(AChoreographer* choreographer, */ void AChoreographer_postFrameCallbackDelayed(AChoreographer* choreographer, AChoreographer_frameCallback callback, void* data, long delayMillis); + +#endif /* __ANDROID_API__ >= 24 */ + __END_DECLS #endif // ANDROID_CHOREOGRAPHER_H diff --git a/include/android/configuration.h b/include/android/configuration.h index 81f71a92cb..8e10f67662 100644 --- a/include/android/configuration.h +++ b/include/android/configuration.h @@ -26,6 +26,8 @@ #ifndef ANDROID_CONFIGURATION_H #define ANDROID_CONFIGURATION_H +#include <sys/cdefs.h> + #include <android/asset_manager.h> #ifdef __cplusplus @@ -628,6 +630,7 @@ int32_t AConfiguration_getUiModeNight(AConfiguration* config); */ void AConfiguration_setUiModeNight(AConfiguration* config, int32_t uiModeNight); +#if __ANDROID_API__ >= 13 /** * Return the current configuration screen width in dp units, or * ACONFIGURATION_SCREEN_WIDTH_DP_ANY if not set. @@ -660,7 +663,9 @@ int32_t AConfiguration_getSmallestScreenWidthDp(AConfiguration* config); * Set the configuration's smallest screen width in dp units. */ void AConfiguration_setSmallestScreenWidthDp(AConfiguration* config, int32_t value); +#endif /* __ANDROID_API__ >= 13 */ +#if __ANDROID_API__ >= 17 /** * Return the configuration's layout direction, or * ACONFIGURATION_LAYOUTDIR_ANY if not set. @@ -671,6 +676,7 @@ int32_t AConfiguration_getLayoutDirection(AConfiguration* config); * Set the configuration's layout direction. */ void AConfiguration_setLayoutDirection(AConfiguration* config, int32_t value); +#endif /* __ANDROID_API__ >= 17 */ /** * Perform a diff between two configurations. Returns a bit mask of diff --git a/include/android/input.h b/include/android/input.h index fd9fa98e70..f928c6e4f0 100644 --- a/include/android/input.h +++ b/include/android/input.h @@ -26,6 +26,8 @@ #ifndef _ANDROID_INPUT_H #define _ANDROID_INPUT_H +#include <sys/cdefs.h> + /****************************************************************** * * IMPORTANT NOTICE: @@ -978,8 +980,10 @@ int32_t AMotionEvent_getFlags(const AInputEvent* motion_event); */ int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event); +#if __ANDROID_API__ >= 14 /** Get the button state of all buttons that are pressed. */ int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event); +#endif /** * Get a bitfield indicating which edges, if any, were touched by this motion event. @@ -1044,12 +1048,14 @@ size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event); */ int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index); +#if __ANDROID_API__ >= 14 /** * Get the tool type of a pointer for the given pointer index. * The tool type indicates the type of tool used to make contact such as a * finger or stylus, if known. */ int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index); +#endif /** * Get the original raw X coordinate of this event. @@ -1139,9 +1145,11 @@ float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_ */ float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index); +#if __ANDROID_API__ >= 13 /** Get the value of the request axis for the given pointer index. */ float AMotionEvent_getAxisValue(const AInputEvent* motion_event, int32_t axis, size_t pointer_index); +#endif /** * Get the number of historical points in this event. These are movements that @@ -1272,12 +1280,14 @@ float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_ float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index, size_t history_index); +#if __ANDROID_API__ >= 13 /** * Get the historical value of the request axis for the given pointer index * that occurred between this event and the previous motion event. */ float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event, int32_t axis, size_t pointer_index, size_t history_index); +#endif struct AInputQueue; diff --git a/include/android/multinetwork.h b/include/android/multinetwork.h index 6c718c9037..be0151881a 100644 --- a/include/android/multinetwork.h +++ b/include/android/multinetwork.h @@ -51,6 +51,7 @@ typedef uint64_t net_handle_t; * on failure with an appropriate errno value set. */ +#if __ANDROID_API__ >= 24 /** * Set the network to be used by the given socket file descriptor. @@ -104,6 +105,8 @@ int android_getaddrinfofornetwork(net_handle_t network, const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res); +#endif /* __ANDROID_API__ >= 24 */ + __END_DECLS #endif // ANDROID_MULTINETWORK_H diff --git a/include/android/native_window.h b/include/android/native_window.h index cf07f1afad..b60b9f1d9c 100644 --- a/include/android/native_window.h +++ b/include/android/native_window.h @@ -26,6 +26,8 @@ #ifndef ANDROID_NATIVE_WINDOW_H #define ANDROID_NATIVE_WINDOW_H +#include <sys/cdefs.h> + #include <android/rect.h> #ifdef __cplusplus diff --git a/include/android/native_window_jni.h b/include/android/native_window_jni.h index 60a36c3f27..1ec2a67c3d 100644 --- a/include/android/native_window_jni.h +++ b/include/android/native_window_jni.h @@ -26,6 +26,8 @@ #ifndef ANDROID_NATIVE_WINDOW_JNI_H #define ANDROID_NATIVE_WINDOW_JNI_H +#include <sys/cdefs.h> + #include <android/native_window.h> #include <jni.h> @@ -42,6 +44,16 @@ extern "C" { */ ANativeWindow* ANativeWindow_fromSurface(JNIEnv* env, jobject surface); +#if __ANDROID_API__ >= 13 +/** + * Return the ANativeWindow associated with a Java SurfaceTexture object, + * for interacting with it through native code. This acquires a reference + * on the ANativeWindow that is returned; be sure to use ANativeWindow_release() + * when done with it so that it doesn't leak. + */ +ANativeWindow* ANativeWindow_fromSurfaceTexture(JNIEnv* env, jobject surfaceTexture); +#endif + #ifdef __cplusplus }; #endif diff --git a/include/android/sensor.h b/include/android/sensor.h index 5a61213f53..b6a42ae34b 100644 --- a/include/android/sensor.h +++ b/include/android/sensor.h @@ -367,12 +367,14 @@ int ASensorManager_getSensorList(ASensorManager* manager, ASensorList* list); */ ASensor const* ASensorManager_getDefaultSensor(ASensorManager* manager, int type); +#if __ANDROID_API__ >= 21 /** * Returns the default sensor with the given type and wakeUp properties or NULL if no sensor * of this type and wakeUp properties exists. */ ASensor const* ASensorManager_getDefaultSensorEx(ASensorManager* manager, int type, bool wakeUp); +#endif /** * Creates a new sensor event queue and associate it with a looper. @@ -471,6 +473,7 @@ float ASensor_getResolution(ASensor const* sensor); */ int ASensor_getMinDelay(ASensor const* sensor); +#if __ANDROID_API__ >= 21 /** * Returns the maximum size of batches for this sensor. Batches will often be * smaller, as the hardware fifo might be used for other sensors. @@ -496,6 +499,7 @@ int ASensor_getReportingMode(ASensor const* sensor); * Returns true if this is a wake up sensor, false otherwise. */ bool ASensor_isWakeUpSensor(ASensor const* sensor); +#endif /* __ANDROID_API__ >= 21 */ #ifdef __cplusplus }; diff --git a/include/android/trace.h b/include/android/trace.h index e42e334102..6cdcfebb78 100644 --- a/include/android/trace.h +++ b/include/android/trace.h @@ -19,11 +19,14 @@ #define ANDROID_NATIVE_TRACE_H #include <stdbool.h> +#include <sys/cdefs.h> #ifdef __cplusplus extern "C" { #endif +#if __ANDROID_API__ >= 23 + /** * Returns true if tracing is enabled. Use this signal to avoid expensive computation only necessary * when tracing is enabled. @@ -48,6 +51,8 @@ void ATrace_beginSection(const char* sectionName); */ void ATrace_endSection(); +#endif /* __ANDROID_API__ >= 23 */ + #ifdef __cplusplus }; #endif diff --git a/include/batteryservice/IBatteryPropertiesListener.h b/include/batteryservice/IBatteryPropertiesListener.h index b02d8e9073..9154076eb3 100644 --- a/include/batteryservice/IBatteryPropertiesListener.h +++ b/include/batteryservice/IBatteryPropertiesListener.h @@ -33,7 +33,7 @@ enum { class IBatteryPropertiesListener : public IInterface { public: - DECLARE_META_INTERFACE(BatteryPropertiesListener); + DECLARE_META_INTERFACE(BatteryPropertiesListener) virtual void batteryPropertiesChanged(struct BatteryProperties props) = 0; }; diff --git a/include/batteryservice/IBatteryPropertiesRegistrar.h b/include/batteryservice/IBatteryPropertiesRegistrar.h index eca075d7ef..b5c3a4d9ab 100644 --- a/include/batteryservice/IBatteryPropertiesRegistrar.h +++ b/include/batteryservice/IBatteryPropertiesRegistrar.h @@ -31,7 +31,7 @@ enum { class IBatteryPropertiesRegistrar : public IInterface { public: - DECLARE_META_INTERFACE(BatteryPropertiesRegistrar); + DECLARE_META_INTERFACE(BatteryPropertiesRegistrar) virtual void registerListener(const sp<IBatteryPropertiesListener>& listener) = 0; virtual void unregisterListener(const sp<IBatteryPropertiesListener>& listener) = 0; diff --git a/include/binder/Binder.h b/include/binder/Binder.h index f849fd4327..34048816cd 100644 --- a/include/binder/Binder.h +++ b/include/binder/Binder.h @@ -80,7 +80,7 @@ private: class BpRefBase : public virtual RefBase { protected: - BpRefBase(const sp<IBinder>& o); + explicit BpRefBase(const sp<IBinder>& o); virtual ~BpRefBase(); virtual void onFirstRef(); virtual void onLastStrongRef(const void* id); diff --git a/include/binder/IAppOpsCallback.h b/include/binder/IAppOpsCallback.h index 7f8eb0168b..b62e9e264d 100644 --- a/include/binder/IAppOpsCallback.h +++ b/include/binder/IAppOpsCallback.h @@ -27,7 +27,7 @@ namespace android { class IAppOpsCallback : public IInterface { public: - DECLARE_META_INTERFACE(AppOpsCallback); + DECLARE_META_INTERFACE(AppOpsCallback) virtual void opChanged(int32_t op, const String16& packageName) = 0; diff --git a/include/binder/IAppOpsService.h b/include/binder/IAppOpsService.h index cd81efa363..dc18045975 100644 --- a/include/binder/IAppOpsService.h +++ b/include/binder/IAppOpsService.h @@ -28,7 +28,7 @@ namespace android { class IAppOpsService : public IInterface { public: - DECLARE_META_INTERFACE(AppOpsService); + DECLARE_META_INTERFACE(AppOpsService) virtual int32_t checkOperation(int32_t code, int32_t uid, const String16& packageName) = 0; virtual int32_t noteOperation(int32_t code, int32_t uid, const String16& packageName) = 0; diff --git a/include/binder/IBatteryStats.h b/include/binder/IBatteryStats.h index 5f3818652b..e15d6f07e9 100644 --- a/include/binder/IBatteryStats.h +++ b/include/binder/IBatteryStats.h @@ -26,7 +26,7 @@ namespace android { class IBatteryStats : public IInterface { public: - DECLARE_META_INTERFACE(BatteryStats); + DECLARE_META_INTERFACE(BatteryStats) virtual void noteStartSensor(int uid, int sensor) = 0; virtual void noteStopSensor(int uid, int sensor) = 0; diff --git a/include/binder/IBinder.h b/include/binder/IBinder.h index 5f1e87cd5e..9097cb3bb9 100644 --- a/include/binder/IBinder.h +++ b/include/binder/IBinder.h @@ -90,12 +90,24 @@ public: Parcel* reply, uint32_t flags = 0) = 0; + // DeathRecipient is pure abstract, there is no virtual method + // implementation to put in a translation unit in order to silence the + // weak vtables warning. + #if defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wweak-vtables" + #endif + class DeathRecipient : public virtual RefBase { public: virtual void binderDied(const wp<IBinder>& who) = 0; }; + #if defined(__clang__) + #pragma clang diagnostic pop + #endif + /** * Register the @a recipient for a notification if this binder * goes away. If this binder object unexpectedly goes away diff --git a/include/binder/IInterface.h b/include/binder/IInterface.h index 4ce361380d..be72d44759 100644 --- a/include/binder/IInterface.h +++ b/include/binder/IInterface.h @@ -63,7 +63,7 @@ template<typename INTERFACE> class BpInterface : public INTERFACE, public BpRefBase { public: - BpInterface(const sp<IBinder>& remote); + explicit BpInterface(const sp<IBinder>& remote); protected: virtual IBinder* onAsBinder(); @@ -105,7 +105,7 @@ protected: #define CHECK_INTERFACE(interface, data, reply) \ - if (!data.checkInterface(this)) { return PERMISSION_DENIED; } \ + if (!(data).checkInterface(this)) { return PERMISSION_DENIED; } \ // ---------------------------------------------------------------------- diff --git a/include/binder/IMediaResourceMonitor.h b/include/binder/IMediaResourceMonitor.h index c671f7a529..b21047fc49 100644 --- a/include/binder/IMediaResourceMonitor.h +++ b/include/binder/IMediaResourceMonitor.h @@ -25,7 +25,7 @@ namespace android { class IMediaResourceMonitor : public IInterface { public: - DECLARE_META_INTERFACE(MediaResourceMonitor); + DECLARE_META_INTERFACE(MediaResourceMonitor) // Values should be in sync with Intent.EXTRA_MEDIA_RESOURCE_TYPE_XXX. enum { diff --git a/include/binder/IMemory.h b/include/binder/IMemory.h index 2d0db001c6..15a104fe6a 100644 --- a/include/binder/IMemory.h +++ b/include/binder/IMemory.h @@ -32,7 +32,7 @@ namespace android { class IMemoryHeap : public IInterface { public: - DECLARE_META_INTERFACE(MemoryHeap); + DECLARE_META_INTERFACE(MemoryHeap) // flags returned by getFlags() enum { @@ -70,7 +70,7 @@ protected: class IMemory : public IInterface { public: - DECLARE_META_INTERFACE(Memory); + DECLARE_META_INTERFACE(Memory) virtual sp<IMemoryHeap> getMemory(ssize_t* offset=0, size_t* size=0) const = 0; diff --git a/include/binder/IPermissionController.h b/include/binder/IPermissionController.h index 4e5fb34838..25f34313f0 100644 --- a/include/binder/IPermissionController.h +++ b/include/binder/IPermissionController.h @@ -28,7 +28,7 @@ namespace android { class IPermissionController : public IInterface { public: - DECLARE_META_INTERFACE(PermissionController); + DECLARE_META_INTERFACE(PermissionController) virtual bool checkPermission(const String16& permission, int32_t pid, int32_t uid) = 0; diff --git a/include/binder/IProcessInfoService.h b/include/binder/IProcessInfoService.h index 69dc9a79f1..2669f9193d 100644 --- a/include/binder/IProcessInfoService.h +++ b/include/binder/IProcessInfoService.h @@ -25,7 +25,7 @@ namespace android { class IProcessInfoService : public IInterface { public: - DECLARE_META_INTERFACE(ProcessInfoService); + DECLARE_META_INTERFACE(ProcessInfoService) virtual status_t getProcessStatesFromPids( size_t length, /*in*/ int32_t* pids, diff --git a/include/binder/IResultReceiver.h b/include/binder/IResultReceiver.h index 02dc6a63b6..e494fba0b8 100644 --- a/include/binder/IResultReceiver.h +++ b/include/binder/IResultReceiver.h @@ -27,7 +27,7 @@ namespace android { class IResultReceiver : public IInterface { public: - DECLARE_META_INTERFACE(ResultReceiver); + DECLARE_META_INTERFACE(ResultReceiver) virtual void send(int32_t resultCode) = 0; diff --git a/include/binder/IServiceManager.h b/include/binder/IServiceManager.h index 7ccd9fefd3..3b23f81e43 100644 --- a/include/binder/IServiceManager.h +++ b/include/binder/IServiceManager.h @@ -30,7 +30,7 @@ namespace android { class IServiceManager : public IInterface { public: - DECLARE_META_INTERFACE(ServiceManager); + DECLARE_META_INTERFACE(ServiceManager) /** * Retrieve an existing service, blocking for a few seconds diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h index 2490b82bb2..bd2213d926 100644 --- a/include/binder/Parcel.h +++ b/include/binder/Parcel.h @@ -20,14 +20,14 @@ #include <string> #include <vector> +#include <android-base/unique_fd.h> #include <cutils/native_handle.h> -#include <nativehelper/ScopedFd.h> #include <utils/Errors.h> #include <utils/RefBase.h> #include <utils/String16.h> #include <utils/Vector.h> #include <utils/Flattenable.h> -#include <linux/binder.h> +#include <linux/android/binder.h> #include <binder/IInterface.h> #include <binder/Parcelable.h> @@ -166,6 +166,10 @@ public: template<typename T> status_t write(const LightFlattenable<T>& val); + template<typename T> + status_t writeVectorSize(const std::vector<T>& val); + template<typename T> + status_t writeVectorSize(const std::unique_ptr<std::vector<T>>& val); // Place a native_handle into the parcel (the native_handle's file- // descriptors are dup'ed, so it is safe to delete the native_handle @@ -186,14 +190,14 @@ public: // semantics of the smart file descriptor. A new descriptor will be // created, and will be closed when the parcel is destroyed. status_t writeUniqueFileDescriptor( - const ScopedFd& fd); + const base::unique_fd& fd); // Place a vector of file desciptors into the parcel. Each descriptor is // dup'd as in writeDupFileDescriptor status_t writeUniqueFileDescriptorVector( - const std::unique_ptr<std::vector<ScopedFd>>& val); + const std::unique_ptr<std::vector<base::unique_fd>>& val); status_t writeUniqueFileDescriptorVector( - const std::vector<ScopedFd>& val); + const std::vector<base::unique_fd>& val); // Writes a blob to the parcel. // If the blob is small, then it is stored in-place, otherwise it is @@ -246,12 +250,14 @@ public: const char* readCString() const; String8 readString8() const; + status_t readString8(String8* pArg) const; String16 readString16() const; status_t readString16(String16* pArg) const; status_t readString16(std::unique_ptr<String16>* pArg) const; const char16_t* readString16Inplace(size_t* outLen) const; sp<IBinder> readStrongBinder() const; status_t readStrongBinder(sp<IBinder>* val) const; + status_t readNullableStrongBinder(sp<IBinder>* val) const; wp<IBinder> readWeakBinder() const; template<typename T> @@ -268,6 +274,9 @@ public: template<typename T> status_t readStrongBinder(sp<T>* val) const; + template<typename T> + status_t readNullableStrongBinder(sp<T>* val) const; + status_t readStrongBinderVector(std::unique_ptr<std::vector<sp<IBinder>>>* val) const; status_t readStrongBinderVector(std::vector<sp<IBinder>>* val) const; @@ -300,6 +309,11 @@ public: template<typename T> status_t read(LightFlattenable<T>& val) const; + template<typename T> + status_t resizeOutVector(std::vector<T>* val) const; + template<typename T> + status_t resizeOutVector(std::unique_ptr<std::vector<T>>* val) const; + // Like Parcel.java's readExceptionCode(). Reads the first int32 // off of a Parcel's header, returning 0 or the negative error // code on exceptions, but also deals with skipping over rich @@ -320,14 +334,14 @@ public: // Retrieve a smart file descriptor from the parcel. status_t readUniqueFileDescriptor( - ScopedFd* val) const; + base::unique_fd* val) const; // Retrieve a vector of smart file descriptors from the parcel. status_t readUniqueFileDescriptorVector( - std::unique_ptr<std::vector<ScopedFd>>* val) const; + std::unique_ptr<std::vector<base::unique_fd>>* val) const; status_t readUniqueFileDescriptorVector( - std::vector<ScopedFd>* val) const; + std::vector<base::unique_fd>* val) const; // Reads a blob from the parcel. // The caller should call release() on the blob after reading its contents. @@ -437,7 +451,7 @@ private: void clear(); void release(); inline size_t size() const { return mSize; } - inline int fd() const { return mFd; }; + inline int fd() const { return mFd; } inline bool isMutable() const { return mMutable; } protected: @@ -449,6 +463,11 @@ private: bool mMutable; }; + #if defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wweak-vtables" + #endif + class FlattenableHelperInterface { protected: ~FlattenableHelperInterface() { } @@ -459,12 +478,18 @@ private: virtual status_t unflatten(void const* buffer, size_t size, int const* fds, size_t count) = 0; }; + #if defined(__clang__) + #pragma clang diagnostic pop + #endif + template<typename T> class FlattenableHelper : public FlattenableHelperInterface { friend class Parcel; const Flattenable<T>& val; - explicit FlattenableHelper(const Flattenable<T>& val) : val(val) { } + explicit FlattenableHelper(const Flattenable<T>& _val) : val(_val) { } + protected: + ~FlattenableHelper() = default; public: virtual size_t getFlattenedSize() const { return val.getFlattenedSize(); @@ -517,7 +542,10 @@ template<typename T> status_t Parcel::write(const LightFlattenable<T>& val) { size_t size(val.getFlattenedSize()); if (!val.isFixedSize()) { - status_t err = writeInt32(size); + if (size > INT32_MAX) { + return BAD_VALUE; + } + status_t err = writeInt32(static_cast<int32_t>(size)); if (err != NO_ERROR) { return err; } @@ -548,7 +576,7 @@ status_t Parcel::read(LightFlattenable<T>& val) const { if (err != NO_ERROR) { return err; } - size = s; + size = static_cast<size_t>(s); } if (size) { void const* buffer = readInplace(size); @@ -559,6 +587,54 @@ status_t Parcel::read(LightFlattenable<T>& val) const { } template<typename T> +status_t Parcel::writeVectorSize(const std::vector<T>& val) { + if (val.size() > INT32_MAX) { + return BAD_VALUE; + } + return writeInt32(static_cast<int32_t>(val.size())); +} + +template<typename T> +status_t Parcel::writeVectorSize(const std::unique_ptr<std::vector<T>>& val) { + if (!val) { + return writeInt32(-1); + } + + return writeVectorSize(*val); +} + +template<typename T> +status_t Parcel::resizeOutVector(std::vector<T>* val) const { + int32_t size; + status_t err = readInt32(&size); + if (err != NO_ERROR) { + return err; + } + + if (size < 0) { + return UNEXPECTED_NULL; + } + val->resize(size_t(size)); + return OK; +} + +template<typename T> +status_t Parcel::resizeOutVector(std::unique_ptr<std::vector<T>>* val) const { + int32_t size; + status_t err = readInt32(&size); + if (err != NO_ERROR) { + return err; + } + + val->reset(); + if (size >= 0) { + val->reset(new std::vector<T>(size_t(size))); + } + + return OK; +} + +template<typename T> status_t Parcel::readStrongBinder(sp<T>* val) const { sp<IBinder> tmp; status_t ret = readStrongBinder(&tmp); @@ -574,6 +650,22 @@ status_t Parcel::readStrongBinder(sp<T>* val) const { return ret; } +template<typename T> +status_t Parcel::readNullableStrongBinder(sp<T>* val) const { + sp<IBinder> tmp; + status_t ret = readNullableStrongBinder(&tmp); + + if (ret == OK) { + *val = interface_cast<T>(tmp); + + if (val->get() == nullptr && tmp.get() != nullptr) { + ret = UNKNOWN_ERROR; + } + } + + return ret; +} + template<typename T, typename U> status_t Parcel::unsafeReadTypedVector( std::vector<T>* val, @@ -593,7 +685,7 @@ status_t Parcel::unsafeReadTypedVector( return NO_MEMORY; } - val->resize(size); + val->resize(static_cast<size_t>(size)); if (val->size() < size) { return NO_MEMORY; @@ -619,7 +711,7 @@ status_t Parcel::readTypedVector(std::vector<T>* val, template<typename T> status_t Parcel::readNullableTypedVector(std::unique_ptr<std::vector<T>>* val, status_t(Parcel::*read_func)(T*) const) const { - const int32_t start = dataPosition(); + const size_t start = dataPosition(); int32_t size; status_t status = readInt32(&size); val->reset(); @@ -647,7 +739,7 @@ status_t Parcel::unsafeWriteTypedVector(const std::vector<T>& val, return BAD_VALUE; } - status_t status = this->writeInt32(val.size()); + status_t status = this->writeInt32(static_cast<int32_t>(val.size())); if (status != OK) { return status; @@ -703,7 +795,7 @@ status_t Parcel::readParcelableVector(std::vector<T>* val) const { template<typename T> status_t Parcel::readParcelableVector(std::unique_ptr<std::vector<std::unique_ptr<T>>>* val) const { - const int32_t start = dataPosition(); + const size_t start = dataPosition(); int32_t size; status_t status = readInt32(&size); val->reset(); @@ -726,7 +818,7 @@ status_t Parcel::readParcelableVector(std::unique_ptr<std::vector<std::unique_pt template<typename T> status_t Parcel::readParcelable(std::unique_ptr<T>* parcelable) const { - const int32_t start = dataPosition(); + const size_t start = dataPosition(); int32_t present; status_t status = readInt32(&present); parcelable->reset(); diff --git a/include/binder/Parcelable.h b/include/binder/Parcelable.h index faf0d34e9f..d5b57ac587 100644 --- a/include/binder/Parcelable.h +++ b/include/binder/Parcelable.h @@ -26,6 +26,11 @@ namespace android { class Parcel; +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wweak-vtables" +#endif + // Abstract interface of all parcelables. class Parcelable { public: @@ -46,6 +51,10 @@ public: virtual status_t readFromParcel(const Parcel* parcel) = 0; }; // class Parcelable +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + } // namespace android #endif // ANDROID_PARCELABLE_H diff --git a/include/binder/PersistableBundle.h b/include/binder/PersistableBundle.h index fe5619fc52..322fef9e4f 100644 --- a/include/binder/PersistableBundle.h +++ b/include/binder/PersistableBundle.h @@ -18,6 +18,7 @@ #define ANDROID_PERSISTABLE_BUNDLE_H #include <map> +#include <set> #include <vector> #include <binder/Parcelable.h> @@ -79,6 +80,19 @@ public: bool getStringVector(const String16& key, std::vector<String16>* out) const; bool getPersistableBundle(const String16& key, PersistableBundle* out) const; + /* Getters for all keys for each value type */ + std::set<String16> getBooleanKeys() const; + std::set<String16> getIntKeys() const; + std::set<String16> getLongKeys() const; + std::set<String16> getDoubleKeys() const; + std::set<String16> getStringKeys() const; + std::set<String16> getBooleanVectorKeys() const; + std::set<String16> getIntVectorKeys() const; + std::set<String16> getLongVectorKeys() const; + std::set<String16> getDoubleVectorKeys() const; + std::set<String16> getStringVectorKeys() const; + std::set<String16> getPersistableBundleKeys() const; + friend bool operator==(const PersistableBundle& lhs, const PersistableBundle& rhs) { return (lhs.mBoolMap == rhs.mBoolMap && lhs.mIntMap == rhs.mIntMap && lhs.mLongMap == rhs.mLongMap && lhs.mDoubleMap == rhs.mDoubleMap && diff --git a/include/binder/Status.h b/include/binder/Status.h index ce947fa3de..dd61616f24 100644 --- a/include/binder/Status.h +++ b/include/binder/Status.h @@ -18,6 +18,7 @@ #define ANDROID_BINDER_STATUS_H #include <cstdint> +#include <sstream> #include <binder/Parcel.h> #include <utils/String8.h> @@ -71,6 +72,7 @@ public: // A more readable alias for the default constructor. static Status ok(); + // Authors should explicitly pick whether their integer is: // - an exception code (EX_* above) // - service specific error code @@ -83,9 +85,15 @@ public: static Status fromExceptionCode(int32_t exceptionCode); static Status fromExceptionCode(int32_t exceptionCode, const String8& message); + static Status fromExceptionCode(int32_t exceptionCode, + const char* message); + static Status fromServiceSpecificError(int32_t serviceSpecificErrorCode); static Status fromServiceSpecificError(int32_t serviceSpecificErrorCode, const String8& message); + static Status fromServiceSpecificError(int32_t serviceSpecificErrorCode, + const char* message); + static Status fromStatusT(status_t status); Status() = default; @@ -142,11 +150,7 @@ private: }; // class Status // For gtest output logging -template<typename T> -T& operator<< (T& stream, const Status& s) { - stream << s.toString8().string(); - return stream; -} +std::stringstream& operator<< (std::stringstream& stream, const Status& s); } // namespace binder } // namespace android diff --git a/include/binder/TextOutput.h b/include/binder/TextOutput.h index 974a194d8c..851e01f4b8 100644 --- a/include/binder/TextOutput.h +++ b/include/binder/TextOutput.h @@ -18,16 +18,15 @@ #define ANDROID_TEXTOUTPUT_H #include <utils/Errors.h> +#include <utils/String8.h> #include <stdint.h> #include <string.h> +#include <sstream> // --------------------------------------------------------------------------- namespace android { -class String8; -class String16; - class TextOutput { public: @@ -66,30 +65,26 @@ TextOutput& endl(TextOutput& to); TextOutput& indent(TextOutput& to); TextOutput& dedent(TextOutput& to); -TextOutput& operator<<(TextOutput& to, const char* str); -TextOutput& operator<<(TextOutput& to, char); // writes raw character -TextOutput& operator<<(TextOutput& to, bool); -TextOutput& operator<<(TextOutput& to, int); -TextOutput& operator<<(TextOutput& to, long); -TextOutput& operator<<(TextOutput& to, unsigned int); -TextOutput& operator<<(TextOutput& to, unsigned long); -TextOutput& operator<<(TextOutput& to, long long); -TextOutput& operator<<(TextOutput& to, unsigned long long); -TextOutput& operator<<(TextOutput& to, float); -TextOutput& operator<<(TextOutput& to, double); +template<typename T> +TextOutput& operator<<(TextOutput& to, const T& val) +{ + std::stringstream strbuf; + strbuf << val; + std::string str = strbuf.str(); + to.print(str.c_str(), str.size()); + return to; +} + TextOutput& operator<<(TextOutput& to, TextOutputManipFunc func); -TextOutput& operator<<(TextOutput& to, const void*); -TextOutput& operator<<(TextOutput& to, const String8& val); -TextOutput& operator<<(TextOutput& to, const String16& val); -class TypeCode +class TypeCode { public: inline TypeCode(uint32_t code); inline ~TypeCode(); inline uint32_t typeCode() const; - + private: uint32_t mCode; }; @@ -124,37 +119,51 @@ private: }; TextOutput& operator<<(TextOutput& to, const HexDump& val); +inline TextOutput& operator<<(TextOutput& to, + decltype(std::endl<char, + std::char_traits<char>>) + /*val*/) { + endl(to); + return to; +} -// --------------------------------------------------------------------------- -// No user servicable parts below. +inline TextOutput& operator<<(TextOutput& to, const char &c) +{ + to.print(&c, 1); + return to; +} -inline TextOutput& endl(TextOutput& to) +inline TextOutput& operator<<(TextOutput& to, const bool &val) { - to.print("\n", 1); + if (val) to.print("true", 4); + else to.print("false", 5); return to; } -inline TextOutput& indent(TextOutput& to) +inline TextOutput& operator<<(TextOutput& to, const String16& val) { - to.moveIndent(1); + to << String8(val).string(); return to; } -inline TextOutput& dedent(TextOutput& to) +// --------------------------------------------------------------------------- +// No user servicable parts below. + +inline TextOutput& endl(TextOutput& to) { - to.moveIndent(-1); + to.print("\n", 1); return to; } -inline TextOutput& operator<<(TextOutput& to, const char* str) +inline TextOutput& indent(TextOutput& to) { - to.print(str, strlen(str)); + to.moveIndent(1); return to; } -inline TextOutput& operator<<(TextOutput& to, char c) +inline TextOutput& dedent(TextOutput& to) { - to.print(&c, 1); + to.moveIndent(-1); return to; } diff --git a/include/gui/BufferItem.h b/include/gui/BufferItem.h index f45d85207a..5232d0f69e 100644 --- a/include/gui/BufferItem.h +++ b/include/gui/BufferItem.h @@ -46,6 +46,8 @@ class BufferItem : public Flattenable<BufferItem> { enum { INVALID_BUFFER_SLOT = -1 }; BufferItem(); ~BufferItem(); + BufferItem(const BufferItem&) = default; + BufferItem& operator=(const BufferItem&) = default; static const char* scalingModeName(uint32_t scalingMode); @@ -72,13 +74,7 @@ class BufferItem : public Flattenable<BufferItem> { // to set by queueBuffer each time this slot is queued. This value // is guaranteed to be monotonically increasing for each newly // acquired buffer. - union { - int64_t mTimestamp; - struct { - uint32_t mTimestampLo; - uint32_t mTimestampHi; - }; - }; + int64_t mTimestamp; // mIsAutoTimestamp indicates whether mTimestamp was generated // automatically when the buffer was queued. @@ -90,13 +86,7 @@ class BufferItem : public Flattenable<BufferItem> { android_dataspace mDataSpace; // mFrameNumber is the number of the queued frame for this slot. - union { - uint64_t mFrameNumber; - struct { - uint32_t mFrameNumberLo; - uint32_t mFrameNumberHi; - }; - }; + uint64_t mFrameNumber; // mSlot is the slot index of this buffer (default INVALID_BUFFER_SLOT). int mSlot; diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h index fe4b1fa830..266f0aa501 100644 --- a/include/gui/BufferQueue.h +++ b/include/gui/BufferQueue.h @@ -60,7 +60,7 @@ public: // weak references. class ProxyConsumerListener : public BnConsumerListener { public: - ProxyConsumerListener(const wp<ConsumerListener>& consumerListener); + explicit ProxyConsumerListener(const wp<ConsumerListener>& consumerListener); virtual ~ProxyConsumerListener(); virtual void onFrameAvailable(const BufferItem& item) override; virtual void onFrameReplaced(const BufferItem& item) override; diff --git a/include/gui/BufferQueueConsumer.h b/include/gui/BufferQueueConsumer.h index 8ec0546c7e..e2bafec4a9 100644 --- a/include/gui/BufferQueueConsumer.h +++ b/include/gui/BufferQueueConsumer.h @@ -144,7 +144,7 @@ public: virtual status_t discardFreeBuffers() override; // dump our state in a String - virtual void dump(String8& result, const char* prefix) const; + virtual void dumpState(String8& result, const char* prefix) const; // Functions required for backwards compatibility. // These will be modified/renamed in IGraphicBufferConsumer and will be diff --git a/include/gui/BufferQueueCore.h b/include/gui/BufferQueueCore.h index 1226feb59a..b1c730a587 100644 --- a/include/gui/BufferQueueCore.h +++ b/include/gui/BufferQueueCore.h @@ -86,7 +86,7 @@ public: private: // Dump our state in a string - void dump(String8& result, const char* prefix) const; + void dumpState(String8& result, const char* prefix) const; // getMinUndequeuedBufferCountLocked returns the minimum number of buffers // that must remain in a state other than DEQUEUED. The async parameter @@ -317,13 +317,13 @@ private: // Cached data about the shared buffer in shared buffer mode struct SharedBufferCache { - SharedBufferCache(Rect _crop, uint32_t _transform, int _scalingMode, - android_dataspace _dataspace) + SharedBufferCache(Rect _crop, uint32_t _transform, + uint32_t _scalingMode, android_dataspace _dataspace) : crop(_crop), transform(_transform), scalingMode(_scalingMode), dataspace(_dataspace) { - }; + } Rect crop; uint32_t transform; diff --git a/include/gui/BufferQueueProducer.h b/include/gui/BufferQueueProducer.h index 8f613ee17d..79e7af2117 100644 --- a/include/gui/BufferQueueProducer.h +++ b/include/gui/BufferQueueProducer.h @@ -22,7 +22,7 @@ namespace android { -class BufferSlot; +struct BufferSlot; class BufferQueueProducer : public BnGraphicBufferProducer, private IBinder::DeathRecipient { diff --git a/include/gui/ConsumerBase.h b/include/gui/ConsumerBase.h index 0490c3cc5b..9f8b638a3a 100644 --- a/include/gui/ConsumerBase.h +++ b/include/gui/ConsumerBase.h @@ -63,11 +63,11 @@ public: // log messages. void setName(const String8& name); - // dump writes the current state to a string. Child classes should add + // dumpState writes the current state to a string. Child classes should add // their state to the dump by overriding the dumpLocked method, which is // called by these methods after locking the mutex. - void dump(String8& result) const; - void dump(String8& result, const char* prefix) const; + void dumpState(String8& result) const; + void dumpState(String8& result, const char* prefix) const; // setFrameAvailableListener sets the listener object that will be notified // when a new frame becomes available. @@ -101,7 +101,7 @@ protected: // buffers from the given IGraphicBufferConsumer. // The controlledByApp flag indicates that this consumer is under the application's // control. - ConsumerBase(const sp<IGraphicBufferConsumer>& consumer, bool controlledByApp = false); + explicit ConsumerBase(const sp<IGraphicBufferConsumer>& consumer, bool controlledByApp = false); // onLastStrongRef gets called by RefBase just before the dtor of the most // derived class. It is used to clean up the buffers so that ConsumerBase diff --git a/include/gui/DisplayEventReceiver.h b/include/gui/DisplayEventReceiver.h index a4718b91c6..cb9b373392 100644 --- a/include/gui/DisplayEventReceiver.h +++ b/include/gui/DisplayEventReceiver.h @@ -35,13 +35,19 @@ namespace android { class BitTube; class IDisplayEventConnection; -// ---------------------------------------------------------------------------- +static inline constexpr uint32_t fourcc(char c1, char c2, char c3, char c4) { + return static_cast<uint32_t>(c1) << 24 | + static_cast<uint32_t>(c2) << 16 | + static_cast<uint32_t>(c3) << 8 | + static_cast<uint32_t>(c4); +} +// ---------------------------------------------------------------------------- class DisplayEventReceiver { public: enum { - DISPLAY_EVENT_VSYNC = 'vsyn', - DISPLAY_EVENT_HOTPLUG = 'plug' + DISPLAY_EVENT_VSYNC = fourcc('v', 's', 'y', 'n'), + DISPLAY_EVENT_HOTPLUG = fourcc('p', 'l', 'u', 'g'), }; struct Event { diff --git a/include/gui/IConsumerListener.h b/include/gui/IConsumerListener.h index 1efcf3cfb5..460a03d91a 100644 --- a/include/gui/IConsumerListener.h +++ b/include/gui/IConsumerListener.h @@ -41,7 +41,7 @@ class BufferItem; class ConsumerListener : public virtual RefBase { public: ConsumerListener() { } - virtual ~ConsumerListener() { } + virtual ~ConsumerListener(); // onFrameAvailable is called from queueBuffer each time an additional // frame becomes available for consumption. This means that frames that @@ -91,7 +91,7 @@ public: class IConsumerListener : public ConsumerListener, public IInterface { public: - DECLARE_META_INTERFACE(ConsumerListener); + DECLARE_META_INTERFACE(ConsumerListener) }; // ---------------------------------------------------------------------------- diff --git a/include/gui/IDisplayEventConnection.h b/include/gui/IDisplayEventConnection.h index 86247de62b..848368c7b6 100644 --- a/include/gui/IDisplayEventConnection.h +++ b/include/gui/IDisplayEventConnection.h @@ -34,7 +34,7 @@ class IDisplayEventConnection : public IInterface { public: - DECLARE_META_INTERFACE(DisplayEventConnection); + DECLARE_META_INTERFACE(DisplayEventConnection) /* * getDataChannel() returns a BitTube where to receive the events from diff --git a/include/gui/IGraphicBufferAlloc.h b/include/gui/IGraphicBufferAlloc.h index 600cf27c4c..acc2f30bf4 100644 --- a/include/gui/IGraphicBufferAlloc.h +++ b/include/gui/IGraphicBufferAlloc.h @@ -33,7 +33,7 @@ namespace android { class IGraphicBufferAlloc : public IInterface { public: - DECLARE_META_INTERFACE(GraphicBufferAlloc); + DECLARE_META_INTERFACE(GraphicBufferAlloc) /* Create a new GraphicBuffer for the client to use. */ diff --git a/include/gui/IGraphicBufferConsumer.h b/include/gui/IGraphicBufferConsumer.h index 3b10d78b58..dcddca46e8 100644 --- a/include/gui/IGraphicBufferConsumer.h +++ b/include/gui/IGraphicBufferConsumer.h @@ -278,10 +278,10 @@ public: virtual status_t discardFreeBuffers() = 0; // dump state into a string - virtual void dump(String8& result, const char* prefix) const = 0; + virtual void dumpState(String8& result, const char* prefix) const = 0; public: - DECLARE_META_INTERFACE(GraphicBufferConsumer); + DECLARE_META_INTERFACE(GraphicBufferConsumer) }; // ---------------------------------------------------------------------------- diff --git a/include/gui/IGraphicBufferProducer.h b/include/gui/IGraphicBufferProducer.h index bf427fe4b9..c2dba50361 100644 --- a/include/gui/IGraphicBufferProducer.h +++ b/include/gui/IGraphicBufferProducer.h @@ -56,7 +56,7 @@ class Surface; class IGraphicBufferProducer : public IInterface { public: - DECLARE_META_INTERFACE(GraphicBufferProducer); + DECLARE_META_INTERFACE(GraphicBufferProducer) enum { // A flag returned by dequeueBuffer when the client needs to call @@ -294,7 +294,7 @@ public: struct QueueBufferInput : public Flattenable<QueueBufferInput> { friend class Flattenable<QueueBufferInput>; - inline QueueBufferInput(const Parcel& parcel); + explicit inline QueueBufferInput(const Parcel& parcel); // timestamp - a monotonically increasing value in nanoseconds // isAutoTimestamp - if the timestamp was synthesized at queue time // dataSpace - description of the contents, interpretation depends on format @@ -305,12 +305,13 @@ public: // set this to Fence::NO_FENCE if the buffer is ready immediately // sticky - the sticky transform set in Surface (only used by the LEGACY // camera mode). - inline QueueBufferInput(int64_t timestamp, bool isAutoTimestamp, - android_dataspace dataSpace, const Rect& crop, int scalingMode, - uint32_t transform, const sp<Fence>& fence, uint32_t sticky = 0) - : timestamp(timestamp), isAutoTimestamp(isAutoTimestamp), - dataSpace(dataSpace), crop(crop), scalingMode(scalingMode), - transform(transform), stickyTransform(sticky), fence(fence), + inline QueueBufferInput(int64_t _timestamp, bool _isAutoTimestamp, + android_dataspace _dataSpace, const Rect& _crop, + int _scalingMode, uint32_t _transform, const sp<Fence>& _fence, + uint32_t _sticky = 0) + : timestamp(_timestamp), isAutoTimestamp(_isAutoTimestamp), + dataSpace(_dataSpace), crop(_crop), scalingMode(_scalingMode), + transform(_transform), stickyTransform(_sticky), fence(_fence), surfaceDamage() { } inline void deflate(int64_t* outTimestamp, bool* outIsAutoTimestamp, android_dataspace* outDataSpace, @@ -351,7 +352,7 @@ public: }; // QueueBufferOutput must be a POD structure - struct __attribute__ ((__packed__)) QueueBufferOutput { + struct QueueBufferOutput { inline QueueBufferOutput() { } // outWidth - filled with default width applied to the buffer // outHeight - filled with default height applied to the buffer diff --git a/include/gui/IProducerListener.h b/include/gui/IProducerListener.h index b7826c677f..e808bd3bc3 100644 --- a/include/gui/IProducerListener.h +++ b/include/gui/IProducerListener.h @@ -33,7 +33,7 @@ class ProducerListener : public virtual RefBase { public: ProducerListener() {} - virtual ~ProducerListener() {} + virtual ~ProducerListener(); // onBufferReleased is called from IGraphicBufferConsumer::releaseBuffer to // notify the producer that a new buffer is free and ready to be dequeued. @@ -61,6 +61,7 @@ public: class DummyProducerListener : public BnProducerListener { public: + virtual ~DummyProducerListener(); virtual void onBufferReleased() {} virtual bool needsReleaseNotify() { return false; } }; diff --git a/include/gui/ISensorEventConnection.h b/include/gui/ISensorEventConnection.h index f64c6b8604..857444b60b 100644 --- a/include/gui/ISensorEventConnection.h +++ b/include/gui/ISensorEventConnection.h @@ -33,7 +33,7 @@ class BitTube; class ISensorEventConnection : public IInterface { public: - DECLARE_META_INTERFACE(SensorEventConnection); + DECLARE_META_INTERFACE(SensorEventConnection) virtual sp<BitTube> getSensorChannel() const = 0; virtual status_t enableDisable(int handle, bool enabled, nsecs_t samplingPeriodNs, diff --git a/include/gui/ISensorServer.h b/include/gui/ISensorServer.h index 571acb5d39..737c430af4 100644 --- a/include/gui/ISensorServer.h +++ b/include/gui/ISensorServer.h @@ -35,7 +35,7 @@ class String8; class ISensorServer : public IInterface { public: - DECLARE_META_INTERFACE(SensorServer); + DECLARE_META_INTERFACE(SensorServer) virtual Vector<Sensor> getSensorList(const String16& opPackageName) = 0; virtual Vector<Sensor> getDynamicSensorList(const String16& opPackageName) = 0; diff --git a/include/gui/ISurfaceComposer.h b/include/gui/ISurfaceComposer.h index 74a4123bb6..555a0cc6ab 100644 --- a/include/gui/ISurfaceComposer.h +++ b/include/gui/ISurfaceComposer.h @@ -35,8 +35,8 @@ namespace android { // ---------------------------------------------------------------------------- -class ComposerState; -class DisplayState; +struct ComposerState; +struct DisplayState; struct DisplayInfo; struct DisplayStatInfo; class HdrCapabilities; @@ -50,7 +50,7 @@ class Rect; */ class ISurfaceComposer: public IInterface { public: - DECLARE_META_INTERFACE(SurfaceComposer); + DECLARE_META_INTERFACE(SurfaceComposer) // flags for setTransactionState() enum { diff --git a/include/gui/ISurfaceComposerClient.h b/include/gui/ISurfaceComposerClient.h index c27a741632..4a4efb631a 100644 --- a/include/gui/ISurfaceComposerClient.h +++ b/include/gui/ISurfaceComposerClient.h @@ -36,7 +36,7 @@ class IGraphicBufferProducer; class ISurfaceComposerClient : public IInterface { public: - DECLARE_META_INTERFACE(SurfaceComposerClient); + DECLARE_META_INTERFACE(SurfaceComposerClient) // flags for createSurface() enum { // (keep in sync with Surface.java) diff --git a/include/gui/OccupancyTracker.h b/include/gui/OccupancyTracker.h index 1d15e7f029..d4de8f2b14 100644 --- a/include/gui/OccupancyTracker.h +++ b/include/gui/OccupancyTracker.h @@ -45,12 +45,12 @@ public: occupancyAverage(0.0f), usedThirdBuffer(false) {} - Segment(nsecs_t totalTime, size_t numFrames, float occupancyAverage, - bool usedThirdBuffer) - : totalTime(totalTime), - numFrames(numFrames), - occupancyAverage(occupancyAverage), - usedThirdBuffer(usedThirdBuffer) {} + Segment(nsecs_t _totalTime, size_t _numFrames, float _occupancyAverage, + bool _usedThirdBuffer) + : totalTime(_totalTime), + numFrames(_numFrames), + occupancyAverage(_occupancyAverage), + usedThirdBuffer(_usedThirdBuffer) {} // Parcelable interface virtual status_t writeToParcel(Parcel* parcel) const override; diff --git a/include/gui/Sensor.h b/include/gui/Sensor.h index 094fd163bc..750683559d 100644 --- a/include/gui/Sensor.h +++ b/include/gui/Sensor.h @@ -61,6 +61,9 @@ public: uuid_t() : b{0} {} }; + Sensor(const Sensor&) = default; + Sensor& operator=(const Sensor&) = default; + Sensor(const char * name = ""); Sensor(struct sensor_t const* hwSensor, int halVersion = 0); Sensor(struct sensor_t const& hwSensor, const uuid_t& uuid, int halVersion = 0); diff --git a/include/gui/Surface.h b/include/gui/Surface.h index f4a22cb733..489d5ea7bf 100644 --- a/include/gui/Surface.h +++ b/include/gui/Surface.h @@ -66,7 +66,7 @@ public: * the controlledByApp flag indicates that this Surface (producer) is * controlled by the application. This flag is used at connect time. */ - Surface(const sp<IGraphicBufferProducer>& bufferProducer, bool controlledByApp = false); + explicit Surface(const sp<IGraphicBufferProducer>& bufferProducer, bool controlledByApp = false); /* getIGraphicBufferProducer() returns the IGraphicBufferProducer this * Surface was created with. Usually it's an error to use the diff --git a/include/gui/SurfaceComposerClient.h b/include/gui/SurfaceComposerClient.h index c4f88b60cc..f2932f2c08 100644 --- a/include/gui/SurfaceComposerClient.h +++ b/include/gui/SurfaceComposerClient.h @@ -38,7 +38,7 @@ namespace android { // --------------------------------------------------------------------------- -class DisplayInfo; +struct DisplayInfo; class Composer; class HdrCapabilities; class ISurfaceComposerClient; diff --git a/include/input/IInputFlinger.h b/include/input/IInputFlinger.h index 629310ff2f..11bb7215d6 100644 --- a/include/input/IInputFlinger.h +++ b/include/input/IInputFlinger.h @@ -30,7 +30,7 @@ namespace android { */ class IInputFlinger : public IInterface { public: - DECLARE_META_INTERFACE(InputFlinger); + DECLARE_META_INTERFACE(InputFlinger) }; diff --git a/include/input/Input.h b/include/input/Input.h index 55787e7c75..cfcafabebf 100644 --- a/include/input/Input.h +++ b/include/input/Input.h @@ -398,7 +398,7 @@ public: inline int32_t getButtonState() const { return mButtonState; } - inline int32_t setButtonState(int32_t buttonState) { mButtonState = buttonState; } + inline void setButtonState(int32_t buttonState) { mButtonState = buttonState; } inline int32_t getActionButton() const { return mActionButton; } diff --git a/include/input/InputEventLabels.h b/include/input/InputEventLabels.h index 0bd14ea3a1..20154eb10e 100644 --- a/include/input/InputEventLabels.h +++ b/include/input/InputEventLabels.h @@ -425,30 +425,30 @@ static const char* lookupLabelByValue(int value, const InputEventLabel* list) { return NULL; } -static int32_t getKeyCodeByLabel(const char* label) { +static inline int32_t getKeyCodeByLabel(const char* label) { return int32_t(lookupValueByLabel(label, KEYCODES)); } -static const char* getLabelByKeyCode(int32_t keyCode) { - if (keyCode >= 0 && keyCode < size(KEYCODES)) { +static inline const char* getLabelByKeyCode(int32_t keyCode) { + if (keyCode >= 0 && keyCode < static_cast<int32_t>(size(KEYCODES))) { return KEYCODES[keyCode].literal; } return NULL; } -static uint32_t getKeyFlagByLabel(const char* label) { +static inline uint32_t getKeyFlagByLabel(const char* label) { return uint32_t(lookupValueByLabel(label, FLAGS)); } -static int32_t getAxisByLabel(const char* label) { +static inline int32_t getAxisByLabel(const char* label) { return int32_t(lookupValueByLabel(label, AXES)); } -static const char* getAxisLabel(int32_t axisId) { +static inline const char* getAxisLabel(int32_t axisId) { return lookupLabelByValue(axisId, AXES); } -static int32_t getLedByLabel(const char* label) { +static inline int32_t getLedByLabel(const char* label) { return int32_t(lookupValueByLabel(label, LEDS)); } diff --git a/include/media/hardware/HardwareAPI.h b/include/media/hardware/HardwareAPI.h index 2c50ad6f15..cecf7152f4 100644 --- a/include/media/hardware/HardwareAPI.h +++ b/include/media/hardware/HardwareAPI.h @@ -270,7 +270,7 @@ struct DescribeColorFormatParams { // output: fill out the MediaImage fields MediaImage sMediaImage; - DescribeColorFormatParams(const DescribeColorFormat2Params&); // for internal use only + explicit DescribeColorFormatParams(const DescribeColorFormat2Params&); // for internal use only }; // A pointer to this struct is passed to OMX_GetParameter when the extension diff --git a/include/media/openmax/OMX_Core.h b/include/media/openmax/OMX_Core.h index 88dd585d74..bb974b3f88 100644 --- a/include/media/openmax/OMX_Core.h +++ b/include/media/openmax/OMX_Core.h @@ -738,7 +738,7 @@ typedef struct OMX_TUNNELSETUPTYPE pComponentVersion, \ pSpecVersion, \ pComponentUUID) \ - ((OMX_COMPONENTTYPE*)hComponent)->GetComponentVersion( \ + ((OMX_COMPONENTTYPE*)(hComponent))->GetComponentVersion(\ hComponent, \ pComponentName, \ pComponentVersion, \ @@ -804,7 +804,7 @@ typedef struct OMX_TUNNELSETUPTYPE Cmd, \ nParam, \ pCmdData) \ - ((OMX_COMPONENTTYPE*)hComponent)->SendCommand( \ + ((OMX_COMPONENTTYPE*)(hComponent))->SendCommand( \ hComponent, \ Cmd, \ nParam, \ @@ -843,8 +843,8 @@ typedef struct OMX_TUNNELSETUPTYPE #define OMX_GetParameter( \ hComponent, \ nParamIndex, \ - pComponentParameterStructure) \ - ((OMX_COMPONENTTYPE*)hComponent)->GetParameter( \ + pComponentParameterStructure) \ + ((OMX_COMPONENTTYPE*)(hComponent))->GetParameter( \ hComponent, \ nParamIndex, \ pComponentParameterStructure) /* Macro End */ @@ -882,8 +882,8 @@ typedef struct OMX_TUNNELSETUPTYPE #define OMX_SetParameter( \ hComponent, \ nParamIndex, \ - pComponentParameterStructure) \ - ((OMX_COMPONENTTYPE*)hComponent)->SetParameter( \ + pComponentParameterStructure) \ + ((OMX_COMPONENTTYPE*)(hComponent))->SetParameter( \ hComponent, \ nParamIndex, \ pComponentParameterStructure) /* Macro End */ @@ -918,8 +918,8 @@ typedef struct OMX_TUNNELSETUPTYPE #define OMX_GetConfig( \ hComponent, \ nConfigIndex, \ - pComponentConfigStructure) \ - ((OMX_COMPONENTTYPE*)hComponent)->GetConfig( \ + pComponentConfigStructure) \ + ((OMX_COMPONENTTYPE*)(hComponent))->GetConfig( \ hComponent, \ nConfigIndex, \ pComponentConfigStructure) /* Macro End */ @@ -954,8 +954,8 @@ typedef struct OMX_TUNNELSETUPTYPE #define OMX_SetConfig( \ hComponent, \ nConfigIndex, \ - pComponentConfigStructure) \ - ((OMX_COMPONENTTYPE*)hComponent)->SetConfig( \ + pComponentConfigStructure) \ + ((OMX_COMPONENTTYPE*)(hComponent))->SetConfig( \ hComponent, \ nConfigIndex, \ pComponentConfigStructure) /* Macro End */ @@ -989,7 +989,7 @@ typedef struct OMX_TUNNELSETUPTYPE hComponent, \ cParameterName, \ pIndexType) \ - ((OMX_COMPONENTTYPE*)hComponent)->GetExtensionIndex( \ + ((OMX_COMPONENTTYPE*)(hComponent))->GetExtensionIndex( \ hComponent, \ cParameterName, \ pIndexType) /* Macro End */ @@ -1015,7 +1015,7 @@ typedef struct OMX_TUNNELSETUPTYPE #define OMX_GetState( \ hComponent, \ pState) \ - ((OMX_COMPONENTTYPE*)hComponent)->GetState( \ + ((OMX_COMPONENTTYPE*)(hComponent))->GetState( \ hComponent, \ pState) /* Macro End */ @@ -1046,7 +1046,7 @@ typedef struct OMX_TUNNELSETUPTYPE pAppPrivate, \ nSizeBytes, \ pBuffer) \ - ((OMX_COMPONENTTYPE*)hComponent)->UseBuffer( \ + ((OMX_COMPONENTTYPE*)(hComponent))->UseBuffer( \ hComponent, \ ppBufferHdr, \ nPortIndex, \ @@ -1088,7 +1088,7 @@ typedef struct OMX_TUNNELSETUPTYPE nPortIndex, \ pAppPrivate, \ nSizeBytes) \ - ((OMX_COMPONENTTYPE*)hComponent)->AllocateBuffer( \ + ((OMX_COMPONENTTYPE*)(hComponent))->AllocateBuffer( \ hComponent, \ ppBuffer, \ nPortIndex, \ @@ -1122,7 +1122,7 @@ typedef struct OMX_TUNNELSETUPTYPE hComponent, \ nPortIndex, \ pBuffer) \ - ((OMX_COMPONENTTYPE*)hComponent)->FreeBuffer( \ + ((OMX_COMPONENTTYPE*)(hComponent))->FreeBuffer( \ hComponent, \ nPortIndex, \ pBuffer) /* Macro End */ @@ -1153,7 +1153,7 @@ typedef struct OMX_TUNNELSETUPTYPE #define OMX_EmptyThisBuffer( \ hComponent, \ pBuffer) \ - ((OMX_COMPONENTTYPE*)hComponent)->EmptyThisBuffer( \ + ((OMX_COMPONENTTYPE*)(hComponent))->EmptyThisBuffer( \ hComponent, \ pBuffer) /* Macro End */ @@ -1183,7 +1183,7 @@ typedef struct OMX_TUNNELSETUPTYPE #define OMX_FillThisBuffer( \ hComponent, \ pBuffer) \ - ((OMX_COMPONENTTYPE*)hComponent)->FillThisBuffer( \ + ((OMX_COMPONENTTYPE*)(hComponent))->FillThisBuffer( \ hComponent, \ pBuffer) /* Macro End */ @@ -1225,7 +1225,7 @@ typedef struct OMX_TUNNELSETUPTYPE nPortIndex, \ pAppPrivate, \ eglImage) \ - ((OMX_COMPONENTTYPE*)hComponent)->UseEGLImage( \ + ((OMX_COMPONENTTYPE*)(hComponent))->UseEGLImage( \ hComponent, \ ppBufferHdr, \ nPortIndex, \ diff --git a/include/powermanager/IPowerManager.h b/include/powermanager/IPowerManager.h index 461fad7515..32301897bc 100644 --- a/include/powermanager/IPowerManager.h +++ b/include/powermanager/IPowerManager.h @@ -50,7 +50,7 @@ public: CRASH = IBinder::FIRST_CALL_TRANSACTION + 16, }; - DECLARE_META_INTERFACE(PowerManager); + DECLARE_META_INTERFACE(PowerManager) // The parcels created by these methods must be kept in sync with the // corresponding methods from IPowerManager.aidl. diff --git a/include/private/binder/binder_module.h b/include/private/binder/binder_module.h index a8dd64f235..2f11622e70 100644 --- a/include/private/binder/binder_module.h +++ b/include/private/binder/binder_module.h @@ -24,7 +24,7 @@ namespace android { /* obtain structures and constants from the kernel header */ #include <sys/ioctl.h> -#include <linux/binder.h> +#include <linux/android/binder.h> #ifdef __cplusplus } // namespace android diff --git a/include/private/ui/RegionHelper.h b/include/private/ui/RegionHelper.h index 84eb10079b..c7c31607dc 100644 --- a/include/private/ui/RegionHelper.h +++ b/include/private/ui/RegionHelper.h @@ -53,20 +53,20 @@ public: TYPE dy; inline region(const region& rhs) : rects(rhs.rects), count(rhs.count), dx(rhs.dx), dy(rhs.dy) { } - inline region(RECT const* r, size_t c) - : rects(r), count(c), dx(), dy() { } - inline region(RECT const* r, size_t c, TYPE dx, TYPE dy) - : rects(r), count(c), dx(dx), dy(dy) { } + inline region(RECT const* _r, size_t _c) + : rects(_r), count(_c), dx(), dy() { } + inline region(RECT const* _r, size_t _c, TYPE _dx, TYPE _dy) + : rects(_r), count(_c), dx(_dx), dy(_dy) { } }; class region_rasterizer { friend class region_operator; virtual void operator()(const RECT& rect) = 0; public: - virtual ~region_rasterizer() { }; + virtual ~region_rasterizer() { } }; - inline region_operator(int op, const region& lhs, const region& rhs) + inline region_operator(uint32_t op, const region& lhs, const region& rhs) : op_mask(op), spanner(lhs, rhs) { } @@ -79,8 +79,8 @@ public: spannerInner.prepare(inside); do { TYPE left, right; - int inside = spannerInner.next(current.left, current.right); - if ((op_mask >> inside) & 1) { + int inner_inside = spannerInner.next(current.left, current.right); + if ((op_mask >> inner_inside) & 1) { if (current.left < current.right && current.top < current.bottom) { rasterizer(current); @@ -162,8 +162,8 @@ private: region rhs; public: - inline Spanner(const region& lhs, const region& rhs) - : lhs(lhs), rhs(rhs) + inline Spanner(const region& _lhs, const region& _rhs) + : lhs(_lhs), rhs(_rhs) { if (lhs.count) { SpannerBase::lhs_head = lhs.rects->top + lhs.dy; @@ -223,8 +223,8 @@ private: region rhs; public: - inline SpannerInner(const region& lhs, const region& rhs) - : lhs(lhs), rhs(rhs) + inline SpannerInner(const region& _lhs, const region& _rhs) + : lhs(_lhs), rhs(_rhs) { } diff --git a/include/ui/Fence.h b/include/ui/Fence.h index 48a7aa3c5c..1df15f897c 100644 --- a/include/ui/Fence.h +++ b/include/ui/Fence.h @@ -55,7 +55,7 @@ public: // Construct a new Fence object to manage a given fence file descriptor. // When the new Fence object is destructed the file descriptor will be // closed. - Fence(int fenceFd); + explicit Fence(int fenceFd); // Check whether the Fence has an open fence file descriptor. Most Fence // methods treat an invalid file descriptor just like a valid fence that diff --git a/include/ui/FrameStats.h b/include/ui/FrameStats.h index 6bfe635c72..bc9d3ec1f1 100644 --- a/include/ui/FrameStats.h +++ b/include/ui/FrameStats.h @@ -25,7 +25,7 @@ namespace android { class FrameStats : public LightFlattenable<FrameStats> { public: - FrameStats() : refreshPeriodNano(0) {}; + FrameStats() : refreshPeriodNano(0) {} /* * Approximate refresh time, in nanoseconds. diff --git a/include/ui/Gralloc1On0Adapter.h b/include/ui/Gralloc1On0Adapter.h index 97c9a89d32..d523c4f7e7 100644 --- a/include/ui/Gralloc1On0Adapter.h +++ b/include/ui/Gralloc1On0Adapter.h @@ -81,7 +81,7 @@ private: uint32_t* outCount, int32_t* /*gralloc1_capability_t*/ outCapabilities) { getAdapter(device)->doGetCapabilities(outCount, outCapabilities); - }; + } // getFunction @@ -104,7 +104,7 @@ private: // Buffer descriptor lifecycle functions - class Descriptor; + struct Descriptor; gralloc1_error_t createDescriptor( gralloc1_buffer_descriptor_t* outDescriptor); @@ -124,10 +124,10 @@ private: // Buffer descriptor modification functions struct Descriptor : public std::enable_shared_from_this<Descriptor> { - Descriptor(Gralloc1On0Adapter* adapter, - gralloc1_buffer_descriptor_t id) - : adapter(adapter), - id(id), + Descriptor(Gralloc1On0Adapter* _adapter, + gralloc1_buffer_descriptor_t _id) + : adapter(_adapter), + id(_id), width(0), height(0), format(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED), @@ -416,10 +416,10 @@ private: if (!outData) { const auto producerCpuUsage = GRALLOC1_PRODUCER_USAGE_CPU_READ | GRALLOC1_PRODUCER_USAGE_CPU_WRITE; - if (producerUsage & producerCpuUsage != 0) { + if ((producerUsage & producerCpuUsage) != 0) { return static_cast<int32_t>(GRALLOC1_ERROR_BAD_VALUE); } - if (consumerUsage & GRALLOC1_CONSUMER_USAGE_CPU_READ != 0) { + if ((consumerUsage & GRALLOC1_CONSUMER_USAGE_CPU_READ) != 0) { return static_cast<int32_t>(GRALLOC1_ERROR_BAD_VALUE); } } diff --git a/include/ui/Point.h b/include/ui/Point.h index 1d7f64d307..d050ede02d 100644 --- a/include/ui/Point.h +++ b/include/ui/Point.h @@ -34,7 +34,7 @@ public: // Default constructor doesn't initialize the Point inline Point() { } - inline Point(int x, int y) : x(x), y(y) { + inline Point(int _x, int _y) : x(_x), y(_y) { } inline bool operator == (const Point& rhs) const { diff --git a/include/ui/Region.h b/include/ui/Region.h index 810f09860d..778845295f 100644 --- a/include/ui/Region.h +++ b/include/ui/Region.h @@ -147,21 +147,21 @@ private: class rasterizer; friend class rasterizer; - Region& operationSelf(const Rect& r, int op); - Region& operationSelf(const Region& r, int op); - Region& operationSelf(const Region& r, int dx, int dy, int op); - const Region operation(const Rect& rhs, int op) const; - const Region operation(const Region& rhs, int op) const; - const Region operation(const Region& rhs, int dx, int dy, int op) const; - - static void boolean_operation(int op, Region& dst, + Region& operationSelf(const Rect& r, uint32_t op); + Region& operationSelf(const Region& r, uint32_t op); + Region& operationSelf(const Region& r, int dx, int dy, uint32_t op); + const Region operation(const Rect& rhs, uint32_t op) const; + const Region operation(const Region& rhs, uint32_t op) const; + const Region operation(const Region& rhs, int dx, int dy, uint32_t op) const; + + static void boolean_operation(uint32_t op, Region& dst, const Region& lhs, const Region& rhs, int dx, int dy); - static void boolean_operation(int op, Region& dst, + static void boolean_operation(uint32_t op, Region& dst, const Region& lhs, const Rect& rhs, int dx, int dy); - static void boolean_operation(int op, Region& dst, + static void boolean_operation(uint32_t op, Region& dst, const Region& lhs, const Region& rhs); - static void boolean_operation(int op, Region& dst, + static void boolean_operation(uint32_t op, Region& dst, const Region& lhs, const Rect& rhs); static void translate(Region& reg, int dx, int dy); |