libbinder: finish{F,Unf}lattenBinder symmetry
Before, both of these functions wrote stability information, but only
finishFlattenBinder wrote binder-specific objects to the Parcel. This
was because in order to function, unflattenBinder needed to read object
data, but flattenBinder was able to delegate this. Now, the
binder-specific object logic is moved into flattenBinder. This
organization makes it easy to re-use finishFlattenBinder for RPC
binders, which would write stability information but not the
binder-driver-specific objects.
Bug: 167966510
Test: boot
Change-Id: I0d1e48bf439dfd928e284c7c8c4284cd955a2850
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 7737d53..a7d8df2 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -164,12 +164,8 @@
ALOGE("Invalid object type 0x%08x", obj.hdr.type);
}
-status_t Parcel::finishFlattenBinder(
- const sp<IBinder>& binder, const flat_binder_object& flat)
+status_t Parcel::finishFlattenBinder(const sp<IBinder>& binder)
{
- status_t status = writeObject(flat, false);
- if (status != OK) return status;
-
internal::Stability::tryMarkCompilationUnit(binder.get());
auto category = internal::Stability::getCategory(binder.get());
return writeInt32(category.repr());
@@ -238,7 +234,10 @@
obj.flags |= schedBits;
- return finishFlattenBinder(binder, obj);
+ status_t status = writeObject(obj, false);
+ if (status != OK) return status;
+
+ return finishFlattenBinder(binder);
}
status_t Parcel::unflattenBinder(sp<IBinder>* out) const