diff options
-rw-r--r-- | libs/binder/Parcel.cpp | 7 | ||||
-rw-r--r-- | libs/binder/Stability.cpp | 1 | ||||
-rw-r--r-- | libs/binder/include/binder/Binder.h | 10 | ||||
-rw-r--r-- | libs/binder/include/binder/Stability.h | 15 |
4 files changed, 17 insertions, 16 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index d19b4d83fb..10188fee6e 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -173,8 +173,8 @@ static void release_object(const sp<ProcessState>& proc, status_t Parcel::finishFlattenBinder(const sp<IBinder>& binder) { internal::Stability::tryMarkCompilationUnit(binder.get()); - auto category = internal::Stability::getCategory(binder.get()); - return writeInt32(category.repr()); + int16_t rep = internal::Stability::getCategory(binder.get()).repr(); + return writeInt32(rep); } status_t Parcel::finishUnflattenBinder( @@ -184,7 +184,8 @@ status_t Parcel::finishUnflattenBinder( status_t status = readInt32(&stability); if (status != OK) return status; - status = internal::Stability::setRepr(binder.get(), stability, true /*log*/); + status = internal::Stability::setRepr(binder.get(), static_cast<int16_t>(stability), + true /*log*/); if (status != OK) return status; *out = binder; diff --git a/libs/binder/Stability.cpp b/libs/binder/Stability.cpp index 601ce96db6..dac381974e 100644 --- a/libs/binder/Stability.cpp +++ b/libs/binder/Stability.cpp @@ -33,7 +33,6 @@ constexpr uint8_t kBinderWireFormatVersion = 1; Stability::Category Stability::Category::currentFromLevel(Level level) { return { .version = kBinderWireFormatVersion, - .reserved = {0}, .level = level, }; } diff --git a/libs/binder/include/binder/Binder.h b/libs/binder/include/binder/Binder.h index 754f87cd7e..27db32c27d 100644 --- a/libs/binder/include/binder/Binder.h +++ b/libs/binder/include/binder/Binder.h @@ -119,10 +119,12 @@ private: std::atomic<Extras*> mExtras; friend ::android::internal::Stability; - union { - int32_t mStability; - void* mReserved0; - }; + int16_t mStability; + int16_t mReserved0; + +#ifdef __LP64__ + int32_t mReserved1; +#endif }; // --------------------------------------------------------------------------- diff --git a/libs/binder/include/binder/Stability.h b/libs/binder/include/binder/Stability.h index 6bc607f298..629b565985 100644 --- a/libs/binder/include/binder/Stability.h +++ b/libs/binder/include/binder/Stability.h @@ -136,14 +136,15 @@ private: VINTF = 0b111111, }; - // This is the format of stability passed on the wire. + // This is the format of stability passed on the wire. It is only 2 bytes + // long, but 2 bytes in addition to this are reserved here. The difference + // in size is in order to free up space in BBinder, which is fixed by + // prebuilts inheriting from it. struct Category { - static inline Category fromRepr(int32_t representation) { + static inline Category fromRepr(int16_t representation) { return *reinterpret_cast<Category*>(&representation); } - int32_t repr() const { - return *reinterpret_cast<const int32_t*>(this); - } + int16_t repr() const { return *reinterpret_cast<const int16_t*>(this); } static inline Category currentFromLevel(Level level); bool operator== (const Category& o) const { @@ -161,12 +162,10 @@ private: // class must write parcels according to the version documented here. uint8_t version; - uint8_t reserved[2]; - // bitmask of Stability::Level Level level; }; - static_assert(sizeof(Category) == sizeof(int32_t)); + static_assert(sizeof(Category) == sizeof(int16_t)); // returns the stability according to how this was built static Level getLocalLevel(); |