Commit Graph

141 Commits

Author SHA1 Message Date
Slava Monich
6d71a0649c [gbinder] Housekeeping 2024-07-18 05:32:36 +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
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
99b2dd85c1 [unit] Test byte array padding. JB#42956 2024-03-02 02:09:44 +02:00
Slava Monich
11765cd80d [unit] Added test for surrogate pairs 2024-02-10 05:00:25 +02:00
Jami Kettunen
6f0e8a693d [build] Support pkg-config cross-compilation
Previously to cross-compile one would need to add a pkg-config
executable in $PATH wrapping all the search paths required; now one can
e.g.

  make PKG_CONFIG=foreign-arch-target-pkg-config

with the wrapper executable being separate and allowing programs for
host to also be built if needed for example.
2023-11-30 20:54:40 +02:00
Slava Monich
b5bab2431e [unit] Make unit tests independent on system config. JB#42956
System gbinder config shouldn't break unit tests.
2023-11-19 18:41:26 +02:00
Jami Kettunen
a89dcd2702 [build] Use MAKE var instead of explicitly calling make
There are multiple make implementations and nothing guarantees that the
make executable is gmake, which is what this Makefile requires.
2023-09-08 15:20:10 +03:00
Slava Monich
4a913590d9 [gbinder] Require glib 2.32 2023-04-30 06:07:16 +03:00
Slava Monich
05634757d7 [unit] Added tests for byte and int32 type descriptors. JB#42956 2023-02-25 02:59:47 +02:00
Slava Monich
85db18f663 [unit] Handle servicemanager requests on looper thread. JB#42956
Because tests are using synchronous calls blocking the main thread,
2023-01-23 01:29:58 +02:00
Slava Monich
af796828a4 [unit] Fixed possible deadlock in proxy_object test. JB#42956
The /proxy_object/param test could be deadlocked by gbinder_ipc_exit()
blocking the main thread and waiting for all client threads to terminate
one of which waiting for the transaction (the one getting cancelled) to
complete on the main thread blocked by gbinder_ipc_exit().

The deadlock is avoided by making sure that both transactions get completed
before gbinder_ipc_exit() is called.
2023-01-22 04:35:22 +02:00
Slava Monich
d7eacd455f [unit] Refactored binder simulation. JB#42956
The old one was way too hackish and prone to race conditions.
This one is more accurate and hopefully more reliable.
2023-01-04 14:42:19 +02:00
Slava Monich
c94ccbd8bf [gbinder] Fixed serialization issues on big-endian. JB#42956
Note that libhwbinder and libbinder encode TRUE value differently
on big-endian machines (0x01 becomes either first or last of 4 bytes)
but reading uint32 and comparing it with zero works in either case.
2023-01-03 01:56:18 +02:00
Slava Monich
9a0d0a7894 [gbinder] Added gbinder_writer_append_struct_vec(). JB#42956
Appends top-level vec<type>. Allocates GBinderHidlVec for that,
but unlike gbinder_writer_append_hidl_vec(), doesn't copy the
contents of the vector.
2022-11-24 19:48:24 +02:00
Slava Monich
6f9220aedb [gbinder] Added gbinder_writer_append_struct(). JB#42956
It simplifies writing buffers for nested structures.
2022-11-17 03:19:33 +02:00
Slava Monich
f227ae4291 [gbinder] All binder objects need stability field in Android 11. JB#58951
According to Parcel::finishFlattenBinder() in native/libs/binder/Parcel.cpp
2022-10-14 16:16:19 +03:00
Slava Monich
66122a2ce6 [unit] Added unit test for device + protocol combo. JB#42254 2022-07-19 02:01:26 +03:00
Slava Monich
370d2dedb3 [unit] Improved gbinder_config.c coverage. JB#42956 2022-06-22 16:57:15 +03:00
gary-wzl77
ede15da9e2 [gbinder] Add preset gbinder config to support Android API version 31 2022-06-22 18:36:52 +08:00
gary-wzl77
771444a8ac [gbinder] Add "aidl4" variant of service manager
Introduce "aidl4" variant of service manager to adapt the change
to service related protocol for Android 12.

From Android 12, when reading nullable strong binder, the format of
the `stability` field passed on the wire was changed and evolved to
`struct Category`, which consists of the following members with 4 bytes long.
```
struct Category {
  uint8_t version;
  uint8_t reserved[2];
  Level level;        <- bitmask of Stability::Level
}
```
Please check the following link for details:

  https://cs.android.com/android/platform/superproject/+/android-12.0.0_r3:frameworks/native/libs/binder/include/binder/Stability.h;l=140

To honor the change on AOSP side for Android 12, we need to adapt
the protocol change in Service Manager.
2022-06-22 18:36:51 +08:00
Slava Monich
865a29d1dd [unit] Tests should ignore system config 2022-06-11 02:49:02 +03:00
Slava Monich
93fbb5b238 [gbinder] Housekeeping. JB#42254 2022-06-11 02:08:05 +03:00
Alessandro Astone
754fa5bcda Make protocol selectable at runtime 2022-06-10 13:50:01 +02:00
Slava Monich
5822a40c39 [unit] Added tests for invalid parcelables. JB#54354 2022-02-20 03:22:09 +02:00
Slava Monich
3398afd701 [unit] Fixed a memory leak in unit_reader. JB#54354
==642984== HEAP SUMMARY:
==642984==     in use at exit: 1,097,253 bytes in 557 blocks
==642984==   total heap usage: 4,780 allocs, 4,223 frees, 78,991,940 bytes allocated
==642984==
==642984== 1,040,520 (24 direct, 1,040,496 indirect) bytes in 1 blocks are definitely lost in loss record 475 of 475
==642984==    at 0x483B7F3: malloc
==642984==    by 0x4923E98: g_malloc
==642984==    by 0x493C485: g_slice_alloc
==642984==    by 0x493CAAD: g_slice_alloc0
==642984==    by 0x11CA1E: gbinder_buffer_alloc (gbinder_buffer.c:167)
==642984==    by 0x11CAFD: gbinder_buffer_new (gbinder_buffer.c:195)
==642984==    by 0x1192C9: test_parcelable (unit_reader.c:1728)
==642984==    by 0x494658D: ???
==642984==    by 0x4946A79: g_test_run_suite
==642984==    by 0x4946A94: g_test_run
==642984==    by 0x11C719: main (unit_reader.c:2448)
==642984==
2022-02-20 02:40:19 +02:00
Eugenio Paolantonio (g7)
5fd5b423c1 [gbinder] Added reader for parcelables
Signed-off-by: Eugenio Paolantonio (g7) <me@medesimo.eu>
2022-02-19 19:06:12 +01:00
Eugenio Paolantonio (g7)
2acec3f7ce [gbinder] Added writer for parcelables
Parcelables allow to serialize arbitrary objects inside
an AIDL parcel.

The structure is pretty simple, and is as follows:

* (int32) Control integer that signals whether there is content (1),
or not (0)

* (int32) Integer holding the payload size, including itself

* The actual payload

Signed-off-by: Eugenio Paolantonio (g7) <me@medesimo.eu>
2022-02-19 19:06:12 +01:00
Slava Monich
8583a72d11 [gbinder] Disassociate auto-created proxies. JB#56889
They are independent on each other and can be destroyed in any order.
2022-01-07 21:22:32 +02:00
Slava Monich
f5b399d775 [unit] Improved gbinder_ipc_find_local_object coverage 2022-01-03 13:53:37 +02:00
Slava Monich
97831a65da [gbinder] Added readers for int8 and int16. JB#42956 2021-12-27 06:36:22 +02:00
Slava Monich
5798434ead [gbinder] Added writers for int8 and int16. JB#42956
Those have to be padded to 4-byte boundary.
2021-12-27 06:08:53 +02:00
Slava Monich
8b621fe7d3 [gbinder] Don't compile fmq code if __NR_memfd_create is undefined 2021-11-24 17:08:29 +02:00
Matti Lehtimäki
8539f6e944 [gbinder] Replace use of stdatomic.h and linux/memfd.h. 2021-11-24 05:22:32 +02:00
Slava Monich
fd081601a3 [gbinder] Tolerate NULL const GBinderReader pointers.
Non-const pointers are still assumed to point to a valid, presumably
stack-allocated structure.
2021-11-23 19:44:09 +02:00
Slava Monich
7b319ba822 [gbinder] Added gbinder_client_rpc_header(). JB#55014
Mostly for logging purposes.
2021-11-23 19:25:49 +02:00
Slava Monich
d439bd467a [gbinder] Added gbinder_reader_get_data(). JB#55014
Mostly for logging purposes.
2021-11-23 19:25:49 +02:00
Slava Monich
c99df04daf [gbinder] Added gbinder_writer_get_data(). JB#55014
Mostly for logging purposes.
2021-11-23 19:25:49 +02:00
Slava Monich
81b6b7f087 [gbinder] Added gbinder_servicemanager_device(). JB#55014
Returns the associated binder device name.
2021-11-23 19:25:49 +02:00
Slava Monich
ddf67e83eb [gbinder] Housekeeping. JB#54946 2021-11-23 18:10:30 +02:00
Matti Lehtimäki
8148f03ae6 [gbinder] Add FMQ unit tests. JB#54946 2021-11-22 18:56:48 +02:00
Slava Monich
f3cf738265 [unit] Assert that dummy type functions don't get invoked. JB#42956 2021-11-20 02:53:41 +02:00
gary-wzl77
fe2d441e25 [gbinder] Added "aidl3" variant of service manager. JB#56344
Introduce "aidl3" variant of service manager to adapt the changes
to service related protocol in Android 11.

List services command no longer has index parameter and all data
is in single transaction.

Add service command now has additional "stability" parameter.
2021-11-20 00:17:01 +02:00
gary-wzl77
85c7d8f311 [gbinder] Add preset gbinder config to support Android API version 30. JB#56344 2021-11-19 23:12:51 +02:00
gary-wzl77
597fb84367 [gbinder] Added "aidl3" variant of RPC protocol. JB#56344
Due to the following change in the upstream,

d70160f298%5E%21/#F0

The system and vendor binder have a different header in Android 11.
To adapt this change to Android 11, we have to introduce a new
"aidl3" variant of service manager in libgbinder, which target to
Android 11 or higher if the rpc protocol remains for the upcoming
major Android release.
2021-11-11 18:09:13 +02:00
Slava Monich
30242d7124 [unit] Added test for gbinder_local_reply_append_fd() 2021-11-02 01:34:36 +02:00
Slava Monich
a07e0f2a99 [gbinder] Add gbinder_writer_append_hidl_string_copy(). JB#42956 2021-10-22 20:59:08 +03:00
Slava Monich
5801ed4f15 [gbinder] Added gbinder_writer_strdup(). JB#42956 2021-10-10 05:02:06 +03:00
Slava Monich
159708d829 Merge pull request #72 from monich/transact_2way
Serialize execution of /ipc/transact_2way test
2021-09-02 12:23:40 +03:00
Slava Monich
76494c3e3d [unit] Allow side-by-side linking with libglibutil 2021-09-02 02:14:47 +03:00