summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2023-10-25 23:41:35 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-10-25 23:41:35 +0000
commit796ed47a31f17c768bedd40a9a7d918bc56f5cd7 (patch)
treea57c8a81ec394cb94a93efe4375024250b14af46
parentf848d1ebf9cc4c9cc916f1b32b27bb8d68e2799d (diff)
parent1715bac153cc8c0ac78b29074e9c590384426c5d (diff)
Merge "NativeWindow: implement functions expected by AIDL" into main
-rw-r--r--libs/nativewindow/include/android/native_window_aidl.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/libs/nativewindow/include/android/native_window_aidl.h b/libs/nativewindow/include/android/native_window_aidl.h
index a252245a10..adc1bf11a8 100644
--- a/libs/nativewindow/include/android/native_window_aidl.h
+++ b/libs/nativewindow/include/android/native_window_aidl.h
@@ -34,6 +34,9 @@
#include <android/native_window.h>
#include <sys/cdefs.h>
+#include <sstream>
+#include <string>
+
__BEGIN_DECLS
/**
@@ -80,7 +83,7 @@ namespace aidl::android::hardware {
* Takes ownership of the ANativeWindow* given to it in reset() and will automatically
* destroy it in the destructor, similar to a smart pointer container
*/
-class NativeWindow {
+class NativeWindow final {
public:
NativeWindow() noexcept {}
explicit NativeWindow(ANativeWindow* _Nullable window) {
@@ -123,15 +126,29 @@ public:
}
mWindow = window;
}
- inline ANativeWindow* _Nullable operator-> () const { return mWindow; }
+
inline ANativeWindow* _Nullable get() const { return mWindow; }
- inline explicit operator bool () const { return mWindow != nullptr; }
NativeWindow& operator=(NativeWindow&& other) noexcept {
mWindow = other.release(); // steal ownership from r-value
return *this;
}
+ inline ANativeWindow* _Nullable operator->() const { return mWindow; }
+ inline explicit operator bool() const { return mWindow != nullptr; }
+ inline bool operator==(const NativeWindow& rhs) const { return mWindow == rhs.mWindow; }
+ inline bool operator!=(const NativeWindow& rhs) const { return !(*this == rhs); }
+ inline bool operator<(const NativeWindow& rhs) const { return mWindow < rhs.mWindow; }
+ inline bool operator>(const NativeWindow& rhs) const { return rhs < *this; }
+ inline bool operator>=(const NativeWindow& rhs) const { return !(*this < rhs); }
+ inline bool operator<=(const NativeWindow& rhs) const { return !(*this > rhs); }
+
+ std::string toString() const {
+ std::ostringstream ss;
+ ss << "NativeWindow: " << mWindow;
+ return ss.str();
+ }
+
/**
* Stops managing any contained ANativeWindow*, returning it to the caller. Ownership
* is released.