Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 53955b2b authored by Jiyong Park's avatar Jiyong Park
Browse files

Add comparison operators for ParcelFileDescriptor

With I9f833d0c1a91c8ec72b1cd80007b2f2c09205435, the AIDL C++ compiler
creates comparison operators for structured parcelables. That implies
that each member of a structure parcelable should also has the
comparison operators defined. That assumption breaks when
ParcelFileDescriptor is used as a member, because ParcelFileDescriptor
does not define the comparison operators. Fixing the issue by adding
them, which delegates the comparisons to the internal unique_fd field.

Bug: 143712561
Test: apply ag/9646381 and `m libincremental_aidl-cpp`

Change-Id: Ibc11eafa268e03dc30f321d692f43c0a99a6af1c
parent 0b5ac42f
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -42,6 +42,24 @@ public:
    android::status_t writeToParcel(android::Parcel* parcel) const override;
    android::status_t readFromParcel(const android::Parcel* parcel) override;

    inline bool operator!=(const ParcelFileDescriptor& rhs) const {
        return mFd != rhs.mFd;
    }
    inline bool operator<(const ParcelFileDescriptor& rhs) const {
        return mFd < rhs.mFd;
    }
    inline bool operator<=(const ParcelFileDescriptor& rhs) const {
        return mFd <= rhs.mFd;
    }
    inline bool operator==(const ParcelFileDescriptor& rhs) const {
        return mFd == rhs.mFd;
    }
    inline bool operator>(const ParcelFileDescriptor& rhs) const {
        return mFd > rhs.mFd;
    }
    inline bool operator>=(const ParcelFileDescriptor& rhs) const {
        return mFd >= rhs.mFd;
    }
private:
    android::base::unique_fd mFd;
};