[gbinder] use BINDER_TYPE_BINDER for NULL local object
3 reasons: - This is what encode_remote_object() does. I see no reason a NULL local object should be encoded differently than a NULL remote object. - This is what Parcel.cpp does when flattening a NULL binder [1]. This is contrary to what is said in PR #99 [2]; I'm not sure why PR #99 said it uses BINDER_TYPE_HANDLE. - More importantly, BINDER_TYPE_HANDLE number 0 does NOT represent a NULL binder. According to the comment at [3], handle number 0 actually represent the context manager. So, by sending BINDER_TYPE_HANDLE number 0, we're sending context manager, not a NULL binder. [1]: https://android.googlesource.com/platform/frameworks/native/+/refs/tags/android-14.0.0_r1/libs/binder/Parcel.cpp#277 [2]: https://github.com/mer-hybris/libgbinder/pull/99 [3]: https://android.googlesource.com/platform/frameworks/native/+/refs/tags/android-14.0.0_r1/libs/binder/ProcessState.cpp#336
This commit is contained in:
parent
c35d266c77
commit
b81f35d1ff
|
@ -175,12 +175,10 @@ GBINDER_IO_FN(encode_local_object)(
|
|||
struct flat_binder_object* dest = out;
|
||||
|
||||
memset(dest, 0, sizeof(*dest));
|
||||
dest->hdr.type = BINDER_TYPE_BINDER;
|
||||
if (obj) {
|
||||
dest->hdr.type = BINDER_TYPE_BINDER;
|
||||
dest->flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
|
||||
dest->binder = (uintptr_t)obj;
|
||||
} else {
|
||||
dest->hdr.type = BINDER_TYPE_HANDLE;
|
||||
}
|
||||
if (protocol->finish_flatten_binder) {
|
||||
protocol->finish_flatten_binder(dest + 1, obj);
|
||||
|
|
Loading…
Reference in New Issue