summaryrefslogtreecommitdiff
path: root/libs/binder/Parcel.cpp
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2019-08-05 16:45:26 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2019-08-05 16:45:26 +0000
commit9759952af54d91c2be53a8d46ea779d6603f9195 (patch)
tree023f4982d94175e7f1b13ae1b8c03a5f0f4c5ce0 /libs/binder/Parcel.cpp
parent2572cbec548735e91360d1454be926d36677a2cb (diff)
parentbec7c58e8c98d4517296e7001dbafe414a993f2e (diff)
Merge changes from topic "store-interface-stability-aosp"
* changes: Keep Parcel size stable. Binder: support storing interface stability
Diffstat (limited to 'libs/binder/Parcel.cpp')
-rw-r--r--libs/binder/Parcel.cpp74
1 files changed, 48 insertions, 26 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index aa9d1882a8..51ca7b4f02 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -164,14 +164,37 @@ static void release_object(const sp<ProcessState>& proc,
ALOGE("Invalid object type 0x%08x", obj.hdr.type);
}
-inline static status_t finish_flatten_binder(
- const sp<IBinder>& /*binder*/, const flat_binder_object& flat, Parcel* out)
+status_t Parcel::finishFlattenBinder(
+ const sp<IBinder>& /*binder*/, const flat_binder_object& flat)
{
- return out->writeObject(flat, false);
+ status_t status = writeObject(flat, false);
+ if (status != OK) return status;
+
+ // Cannot change wire protocol w/o SM update
+ // return writeInt32(internal::Stability::get(binder.get()));
+ return OK;
+}
+
+status_t Parcel::finishUnflattenBinder(
+ const sp<IBinder>& binder, sp<IBinder>* out) const
+{
+ // int32_t stability;
+ // Cannot change wire protocol w/o SM update
+ // status_t status = readInt32(&stability);
+ // if (status != OK) return status;
+
+ // if (!internal::Stability::check(stability, mRequiredStability)) {
+ // return BAD_TYPE;
+ // }
+
+ // status = internal::Stability::set(binder.get(), stability);
+ // if (status != OK) return status;
+
+ *out = binder;
+ return OK;
}
-static status_t flatten_binder(const sp<ProcessState>& /*proc*/,
- const sp<IBinder>& binder, Parcel* out)
+status_t Parcel::flattenBinder(const sp<IBinder>& binder)
{
flat_binder_object obj;
@@ -209,30 +232,24 @@ static status_t flatten_binder(const sp<ProcessState>& /*proc*/,
obj.cookie = 0;
}
- return finish_flatten_binder(binder, obj, out);
+ return finishFlattenBinder(binder, obj);
}
-inline static status_t finish_unflatten_binder(
- BpBinder* /*proxy*/, const flat_binder_object& /*flat*/,
- const Parcel& /*in*/)
+status_t Parcel::unflattenBinder(sp<IBinder>* out) const
{
- return NO_ERROR;
-}
-
-static status_t unflatten_binder(const sp<ProcessState>& proc,
- const Parcel& in, sp<IBinder>* out)
-{
- const flat_binder_object* flat = in.readObject(false);
+ const flat_binder_object* flat = readObject(false);
if (flat) {
switch (flat->hdr.type) {
- case BINDER_TYPE_BINDER:
- *out = reinterpret_cast<IBinder*>(flat->cookie);
- return finish_unflatten_binder(nullptr, *flat, in);
- case BINDER_TYPE_HANDLE:
- *out = proc->getStrongProxyForHandle(flat->handle);
- return finish_unflatten_binder(
- static_cast<BpBinder*>(out->get()), *flat, in);
+ case BINDER_TYPE_BINDER: {
+ sp<IBinder> binder = reinterpret_cast<IBinder*>(flat->cookie);
+ return finishUnflattenBinder(binder, out);
+ }
+ case BINDER_TYPE_HANDLE: {
+ sp<IBinder> binder =
+ ProcessState::self()->getStrongProxyForHandle(flat->handle);
+ return finishUnflattenBinder(binder, out);
+ }
}
}
return BAD_TYPE;
@@ -337,6 +354,10 @@ status_t Parcel::setDataCapacity(size_t size)
return NO_ERROR;
}
+void Parcel::setTransactingBinder(const sp<IBinder>& binder) const {
+ mRequiredStability = internal::Stability::get(binder.get());
+}
+
status_t Parcel::setData(const uint8_t* buffer, size_t len)
{
if (len > INT32_MAX) {
@@ -965,7 +986,7 @@ status_t Parcel::writeString16(const char16_t* str, size_t len)
status_t Parcel::writeStrongBinder(const sp<IBinder>& val)
{
- return flatten_binder(ProcessState::self(), val, this);
+ return flattenBinder(val);
}
status_t Parcel::writeStrongBinderVector(const std::vector<sp<IBinder>>& val)
@@ -1903,7 +1924,7 @@ status_t Parcel::readStrongBinder(sp<IBinder>* val) const
status_t Parcel::readNullableStrongBinder(sp<IBinder>* val) const
{
- return unflatten_binder(ProcessState::self(), *this, val);
+ return unflattenBinder(val);
}
sp<IBinder> Parcel::readStrongBinder() const
@@ -2592,9 +2613,10 @@ void Parcel::initState()
mObjectsCapacity = 0;
mNextObjectHint = 0;
mObjectsSorted = false;
+ mAllowFds = true;
mHasFds = false;
mFdsKnown = true;
- mAllowFds = true;
+ mRequiredStability = internal::Stability::UNDECLARED;
mOwner = nullptr;
mOpenAshmemSize = 0;