ndk backend: comparison operators

These were clearly written in order to support C++ and NDK backend, but
not enabled, so enabling them there.

Bug: 175018841
Test: atest CtsNdkBinderTestCases
Change-Id: I2c0da9653f36f98c28c09715d680de85af0dc59a
Merged-In: I2c0da9653f36f98c28c09715d680de85af0dc59a
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index 0956fa6..c4651c8 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -3375,6 +3375,26 @@
 
   binder_status_t readFromParcel(const AParcel* _parcel);
   binder_status_t writeToParcel(AParcel* _parcel) const;
+
+  inline bool operator!=(const Foo& rhs) const {
+    return _value != rhs._value;
+  }
+  inline bool operator<(const Foo& rhs) const {
+    return _value < rhs._value;
+  }
+  inline bool operator<=(const Foo& rhs) const {
+    return _value <= rhs._value;
+  }
+  inline bool operator==(const Foo& rhs) const {
+    return _value == rhs._value;
+  }
+  inline bool operator>(const Foo& rhs) const {
+    return _value > rhs._value;
+  }
+  inline bool operator>=(const Foo& rhs) const {
+    return _value >= rhs._value;
+  }
+
   static const ::ndk::parcelable_stability_t _aidl_stability = ::ndk::STABILITY_LOCAL;
   template <typename _T> class _has_toString {
     template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
diff --git a/generate_ndk.cpp b/generate_ndk.cpp
index baaaeff..2d963a9 100644
--- a/generate_ndk.cpp
+++ b/generate_ndk.cpp
@@ -1020,6 +1020,9 @@
   out << "\n";
   out << "binder_status_t readFromParcel(const AParcel* parcel);\n";
   out << "binder_status_t writeToParcel(AParcel* parcel) const;\n";
+  out << "\n";
+
+  cpp::GenerateParcelableComparisonOperators(out, defined_type);
 
   out << "static const ::ndk::parcelable_stability_t _aidl_stability = ::ndk::"
       << (defined_type.IsVintfStability() ? "STABILITY_VINTF" : "STABILITY_LOCAL") << ";\n";
@@ -1156,6 +1159,9 @@
 
   out << "binder_status_t readFromParcel(const AParcel* _parcel);\n";
   out << "binder_status_t writeToParcel(AParcel* _parcel) const;\n";
+  out << "\n";
+
+  cpp::GenerateParcelableComparisonOperators(out, defined_type);
 
   out << "static const ::ndk::parcelable_stability_t _aidl_stability = ::ndk::"
       << (defined_type.IsVintfStability() ? "STABILITY_VINTF" : "STABILITY_LOCAL") << ";\n";