511 Commits

Author SHA1 Message Date
Slava Monich
e176ef0c50 Version 1.1.43 1.1.43 2025-09-17 04:04:04 +03:00
Slava Monich
98719c5240 [license] Freshened up copyright 2025-09-17 04:02:09 +03:00
Slava Monich
0b52f117a1 [gbinder] Housekeeping 2025-09-17 03:58:09 +03:00
Slava Monich
0ac9ea19f4 Merge pull request #144 from mer-hybris/jb61406
Add support for writing AIDL FMQs
2025-09-17 03:55:52 +03:00
Matti Lehtimäki
9f5b53d27c [gbinder] Add support for writing AIDL FMQs. JB#61406 2025-09-15 15:02:06 +03:00
Matti Lehtimäki
d385197788 [gbinder] Add missing implementation for gbinder_writer_append_fds 2025-09-15 00:20:23 +03:00
Slava Monich
a700dddad8 Acknowledge Takuya's contribution 2025-01-02 02:52:49 +02:00
Slava Monich
90db6a5aa0 Merge pull request #142 from pastalian/c23
[gbinder] Explicitly declare function parameters for C23 compatibility. JB#42956
2025-01-01 15:12:04 +02:00
Takuya Wakazono
46d9899f5a Explicitly declare function parameters for C23 compatibility
In C23, void foo() is equivalent to void foo(void). Therefore, functions
must explicitly declare their parameters.
2025-01-01 21:03:48 +09:00
Slava Monich
d3bc7bb63b Version 1.1.42 1.1.42 2024-12-11 06:40:35 +02:00
Slava Monich
f525378b18 Merge pull request #133 from peat-psuwit/for-upstream/libgbinder-stability-android-rs
Correct stability field wire format on Android 12
2024-12-10 18:47:26 +02:00
Slava Monich
43676db1b9 Merge pull request #141 from monich/sm_remove_handlers
Make coverity happy
2024-12-10 11:19:07 +02:00
Slava Monich
18c4f24fd3 Merge pull request #140 from monich/async_watch
Register for sm notifications asynchronously
2024-11-25 16:56:19 +02:00
Slava Monich
4cc22d8256 [gbinder] Delete name watches with no handlers. SX#GULBI-122
There's no need to keep the watch around if no one is listening
for its signals.

This also makes coverity happier. It was complaining about the
'disconnected' variable which wasn't really necessary because
there isn't much to optimize here.
2024-11-24 06:40:34 +02:00
Slava Monich
c836a7da81 [gbinder] Register for sm notifications asynchronously. SX#APPSUPPORT-189
To avoid deadlocks.
2024-11-24 03:15:01 +02:00
Slava Monich
2446d39d4b [unit] Fixed compilation warning
unit_writer.c: In function 'test_local_object':
unit_writer.c:1353:20: warning: unused variable 'offsets' [-Wunused-variable]
 1353 |     GUtilIntArray* offsets;
      |                    ^~~~~~~
2024-11-24 02:44:33 +02:00
Slava Monich
d3233ac89f [gbinder] Removed duplicate typedef
GBinderServiceManager is defined in gbinder_types.h
2024-11-19 02:08:38 +02:00
Slava Monich
ba9fff8a06 Version 1.1.41
[gbinder] JB#42956
1.1.41
2024-11-02 05:14:34 +02:00
Slava Monich
311756ae11 Acknowledge Ratchanan's contribution 2024-10-28 02:46:34 +02:00
Slava Monich
98459e4053 Merge pull request #135 from peat-psuwit/for-upstream/encode-null-binder
Fix sending NULL binder object
2024-10-28 02:44:04 +02:00
Ratchanan Srirattanamet
374526be9c [gbinder] uses aidl3 servicemanager on API level 31 & 32
Nikita (@NotKit) noticed that the change in commit f227ae4291
("[gbinder] All binder objects need stability field in Android 11.
JB#58951") has made the aidl4 servicemanager variant redundant. In fact,
using aidl4 variant will cause an extra stability field to be sent on
the wire (luckily it has not caused any problem).

I've tried using aidl3 variant on Volla Phone X23 which runs Halium 12
(API level 32), and service registration still work, which seems to
validate this theory. Thus, stop using aidl4 servicemanager variant on
any of the API level-based config, as it no longer correspond to any of
Android versions.

Note that this commit doesn't outright remove aidl4 variant, as doing so
would break configurations which explicitly request its use. This commit
doesn't doesn't alias the aidl4 variant to aidl3 variant either.
Manually requesting a certain variant could mean some unusual setup;
aliasing aidl4 to aidl3 could break such setup.
2024-10-13 03:16:10 +07:00
Ratchanan Srirattanamet
62dac7e893 [gbinder] correct stability field wire format on Android 12
On Android 12, the wire format of stability field is changed to also
include so-called "Binder wire format version", which starts at 1 [1].
A 32-bit-sized struct is re-interpreted into a 32-bit integer, with a
layout which makes it incompatible with the old version. Interestingly,
they reverted this idea in Android 13 [2], which makes the wire format
of the stability field the same as Android 11 again (as far as I know).

Add a new RPC protocol variant 'aidl4' to account for this difference.
Use this protocol on API level 31 through 32 and use 'aidl3' from API
level 33 onwards. The only difference from 'aidl3' is `finish_flatten_
binder()` function.

Interestingly, there is also a 16-bit-sized struct variant of the field
too [3]. However, to the best of my knowledge, this version is not used
in any of the released Android versions.

[1]: 89ddfc5f8c
[2]: 16a4106cb7
[3]: 14e4cfae36
2024-10-13 03:16:01 +07:00
Ratchanan Srirattanamet
aa946b4c31 [gbinder] writer: don't write object offset for NULL binder object
Writing offset will trigger the kernel-side code to transform the flat
binder object into the handle form, which (in my understanding) is not
a valid operation for a NULL binder object. Meanwhile, the receiving
side will create a corresponding Binder object from such handle,
tripping the stability check as it will no longer accept UNDECLARED.

OTOH, if the offset is not written, then the receiving side will receive
the flat binder object as-is, with type BINDER and pointer NULL, which
will be interpreted as NULL binder. This is also what Android's
Parcel.cpp does [1][2].

IMO, this is sort of a hack. Binder kernel driver should handle the NULL
binder internally, and not relying on the sender doing the correct
thing. Meanwhile, the receiver should always reject a flat binder object
of type BINDER. But that's how Android work, so... 🤷

[1]: https://github.com/LineageOS/android_frameworks_native/blob/lineage-19.1/libs/binder/Parcel.cpp#L1327-L1332
[2]: https://github.com/LineageOS/android_frameworks_native/blob/lineage-19.1/libs/binder/Parcel.cpp#L2023-L2029
2024-10-05 21:05:37 +07:00
Ratchanan Srirattanamet
b81f35d1ff [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
2024-10-02 23:46:31 +07:00
Slava Monich
c35d266c77 Merge pull request #134 from monich/read_string8
Add gbinder_reader_read_nullable_string8
2024-09-25 14:06:15 +03:00
Slava Monich
3350f51a21 [gbinder] Added gbinder_reader_read_nullable_string8
The equivalent of Android's Parcel::readString8
2024-09-24 18:48:39 +03:00
Slava Monich
5cfe96b891 [gbinder] Check if counted strings are NULL-terminated
That's what Parcel::readString16 does.
2024-09-24 18:35:02 +03:00
Slava Monich
20774aecac [unit] Improved gbinder_reader test coverage 2024-09-24 17:02:07 +03:00
Slava Monich
624bfa843d Version 1.1.40 1.1.40 2024-07-18 05:35:00 +03:00
Slava Monich
6d71a0649c [gbinder] Housekeeping 2024-07-18 05:32:36 +03:00
Slava Monich
c31cd7e964 Acknowledge Nikita's contribution 2024-07-18 05:08:47 +03:00
Slava Monich
c1db86e734 Merge pull request #130 from mer-hybris/aidl-stability
Make stability field of local object configurable
2024-07-18 05:04:50 +03:00
Nikita Ukhrenkov
bfb95f2bf5 [gbinder] Make stability field of local object configurable. JB#61912
AIDL HALs require stability field value to be set to VINTF as
opposed to the default SYSTEM, so expose a way to let the caller
set the value to used by finish_flatten_binder per local object.
2024-07-15 18:42:20 +03:00
Slava Monich
6f4c69d58a Merge pull request #131 from monich/unit_conf
Make more unit tests independent on system config
2024-07-15 17:29:17 +03:00
Slava Monich
c6b09a10d4 [unit] Make more unit tests independent on system config. JB#42956
System gbinder config shouldn't break unit tests.
2024-07-14 06:15:19 +03:00
Slava Monich
545f5bc28d Version 1.1.39 1.1.39 2024-05-05 20:09:11 +03:00
Slava Monich
78e006f1cf Acknowledge Martin's contribution 2024-05-05 20:08:23 +03:00
Slava Monich
3c9cc1711a [spec] Cleaned up macro syntax 2024-04-30 20:25:43 +03:00
Slava Monich
71aa3acc08 [spec] Restore compatibility with rpm < 4.12 (again) 2024-04-30 02:42:25 +03:00
Slava Monich
eee26c5e98 [spec] Restore compatibility with rpm < 4.12 2024-04-30 02:18:18 +03:00
Slava Monich
736a29aa4c Merge pull request #128 from mer-hybris/jb61933
Utilize make_build macro
2024-04-29 19:54:51 +03:00
Martin Kampas
0d7105edbe [gbinder] Utilize make_build macro. JB#61933
Allow the build system to override the way make is invoked.

Cannot use make_install equally as that does not allow to pass
additional arguments to make.
2024-04-16 13:36:50 +02:00
Slava Monich
4420c7b2ae Merge pull request #126 from mer-hybris/jb61912
Eliminate defects found by Coverity
2024-04-12 04:51:00 +03:00
Martin Kampas
52726a07b0 [gbinder] Add model file for Coverity. JB#61912
Eliminate false positive. Help Coverity see there is no resource leak
(CID 444479).
2024-04-11 12:59:39 +02:00
Martin Kampas
12b9fd49ad [gbinder] Avoid double-checked locking in gbinder_ipc_looper_check. JB#61912
Data race condition detected by Coverity (CID 444481, CID 444483).

According to Slava the effect of this particular optimization is
negligible, so let's simply drop it to make Coverity happy.
2024-04-11 12:57:13 +02:00
Martin Kampas
e75959e389 [gbinder] Explicitly ignore return value. JB#61912
Recognized by Coverity (CID 444485) that this is the single call to
gbinder_driver_write out of the total of 9, where the return value is
not checked.

This change is implemented just to make Coverity happy.  The compiler
does not complain.
2024-04-11 12:45:33 +02:00
Slava Monich
9d35ca22fb Merge pull request #127 from monich/set_data
Remove unnecessary checks for NULL
2024-04-11 13:09:34 +03:00
Slava Monich
3e0d0005ce [gbinder] Remove unnecessary checks for NULL. JB#61912
And fix potential use after free.
2024-04-11 03:29:28 +03:00
Slava Monich
29718f921f Version 1.1.38 1.1.38 2024-03-02 02:13:19 +02:00
Slava Monich
99b2dd85c1 [unit] Test byte array padding. JB#42956 2024-03-02 02:09:44 +02:00