Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c22eafe49e | ||
|
|
66122a2ce6 | ||
|
|
c1ff25f6ae | ||
|
|
af3c23a18f | ||
|
|
5a14796c4c | ||
|
|
3bb8a38f5f | ||
|
|
f29f0b5a1b | ||
|
|
2da1c7b5ca | ||
|
|
8348bc76bd | ||
|
|
a97a153c94 |
2
Makefile
2
Makefile
@@ -16,7 +16,7 @@
|
||||
|
||||
VERSION_MAJOR = 1
|
||||
VERSION_MINOR = 1
|
||||
VERSION_RELEASE = 22
|
||||
VERSION_RELEASE = 25
|
||||
|
||||
# Version for pkg-config
|
||||
PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
|
||||
|
||||
20
debian/changelog
vendored
20
debian/changelog
vendored
@@ -1,3 +1,21 @@
|
||||
libgbinder (1.1.25) unstable; urgency=low
|
||||
|
||||
* Handle RPC protocol change at run time
|
||||
|
||||
-- Slava Monich <slava.monich@jolla.com> Tue, 19 Jul 2022 02:02:41 +0300
|
||||
|
||||
libgbinder (1.1.24) unstable; urgency=low
|
||||
|
||||
* Bumped debhelper compat level to 7
|
||||
|
||||
-- Slava Monich <slava.monich@jolla.com> Thu, 14 Jul 2022 01:32:11 +0300
|
||||
|
||||
libgbinder (1.1.23) unstable; urgency=low
|
||||
|
||||
* Fixed Debian build dependencies
|
||||
|
||||
-- Slava Monich <slava.monich@jolla.com> Thu, 23 Jun 2022 20:09:35 +0300
|
||||
|
||||
libgbinder (1.1.22) unstable; urgency=low
|
||||
|
||||
* Added support for Android 12 (API level 31)
|
||||
@@ -7,7 +25,7 @@ libgbinder (1.1.22) unstable; urgency=low
|
||||
|
||||
libgbinder (1.1.21) unstable; urgency=low
|
||||
|
||||
* Made Properly finalize GBinderIpc and GBinderServicePoll
|
||||
* Properly finalize GBinderIpc and GBinderServicePoll
|
||||
|
||||
-- Slava Monich <slava.monich@jolla.com> Mon, 20 Jun 2022 18:53:26 +0300
|
||||
|
||||
|
||||
2
debian/compat
vendored
2
debian/compat
vendored
@@ -1 +1 @@
|
||||
5
|
||||
7
|
||||
|
||||
4
debian/control
vendored
4
debian/control
vendored
@@ -2,7 +2,7 @@ Source: libgbinder
|
||||
Section: libs
|
||||
Priority: optional
|
||||
Maintainer: Slava Monich <slava.monich@jolla.com>
|
||||
Build-Depends: debhelper (>= 8.1.3), libglib2.0-dev (>= 2.0), libglibutil (>= 1.0.52), flex, bison
|
||||
Build-Depends: debhelper (>= 8.1.3), libglib2.0-dev (>= 2.0), libglibutil-dev (>= 1.0.52), flex, bison
|
||||
Standards-Version: 3.8.4
|
||||
|
||||
Package: libgbinder
|
||||
@@ -14,7 +14,7 @@ Description: Binder client library
|
||||
Package: libgbinder-dev
|
||||
Section: libdevel
|
||||
Architecture: any
|
||||
Depends: libgbinder (= ${binary:Version}), ${misc:Depends}
|
||||
Depends: libgbinder (= ${binary:Version}), libglibutil-dev (>= 1.0.52)
|
||||
Description: Development files for libgbinder
|
||||
|
||||
Package: libgbinder-tools
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Name: libgbinder
|
||||
|
||||
Version: 1.1.22
|
||||
Version: 1.1.25
|
||||
Release: 0
|
||||
Summary: Binder client library
|
||||
License: BSD
|
||||
|
||||
@@ -64,6 +64,7 @@ struct gbinder_ipc_priv {
|
||||
GBinderIpc* self;
|
||||
GThreadPool* tx_pool;
|
||||
GHashTable* tx_table;
|
||||
char* dev;
|
||||
char* key;
|
||||
const char* name;
|
||||
GBinderObjectRegistry object_registry;
|
||||
@@ -265,6 +266,15 @@ gbinder_ipc_wait(
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static
|
||||
char*
|
||||
gbinder_ipc_make_key(
|
||||
const char* dev,
|
||||
const char* protocol)
|
||||
{
|
||||
return g_strdup_printf("%s:%s", protocol, dev);
|
||||
}
|
||||
|
||||
/*==========================================================================*
|
||||
* GBinderIpcLooperTx
|
||||
*==========================================================================*/
|
||||
@@ -1847,18 +1857,21 @@ gbinder_ipc_new(
|
||||
const char* protocol_name)
|
||||
{
|
||||
GBinderIpc* self = NULL;
|
||||
char* key;
|
||||
const GBinderRpcProtocol* protocol = (protocol_name ?
|
||||
gbinder_rpc_protocol_by_name(protocol_name) : NULL);
|
||||
|
||||
if (!dev || !dev[0]) dev = GBINDER_DEFAULT_BINDER;
|
||||
if (!protocol) protocol = gbinder_rpc_protocol_for_device(dev);
|
||||
key = gbinder_ipc_make_key(dev, protocol->name);
|
||||
|
||||
/* Lock */
|
||||
pthread_mutex_lock(&gbinder_ipc_mutex);
|
||||
if (gbinder_ipc_table) {
|
||||
self = g_hash_table_lookup(gbinder_ipc_table, dev);
|
||||
self = g_hash_table_lookup(gbinder_ipc_table, key);
|
||||
}
|
||||
if (self) {
|
||||
g_free(key);
|
||||
gbinder_ipc_ref(self);
|
||||
} else {
|
||||
GBinderDriver* driver = gbinder_driver_new(dev, protocol);
|
||||
@@ -1869,7 +1882,8 @@ gbinder_ipc_new(
|
||||
self = g_object_new(THIS_TYPE, NULL);
|
||||
priv = self->priv;
|
||||
self->driver = driver;
|
||||
self->dev = priv->key = g_strdup(dev);
|
||||
self->dev = priv->dev = g_strdup(dev);
|
||||
priv->key = key;
|
||||
self->priv->object_registry.io = gbinder_driver_io(driver);
|
||||
/* gbinder_ipc_dispose will remove iself from the table */
|
||||
if (!gbinder_ipc_table) {
|
||||
@@ -1877,8 +1891,10 @@ gbinder_ipc_new(
|
||||
}
|
||||
g_hash_table_replace(gbinder_ipc_table, priv->key, self);
|
||||
/* With "/dev/" prefix, it may be too long to be a thread name */
|
||||
priv->name = priv->key +
|
||||
(g_str_has_prefix(priv->key, "/dev/") ? 5 : 0);
|
||||
priv->name = self->dev +
|
||||
(g_str_has_prefix(priv->dev, "/dev/") ? 5 : 0);
|
||||
} else {
|
||||
g_free(key);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&gbinder_ipc_mutex);
|
||||
@@ -2138,6 +2154,7 @@ gbinder_ipc_finalize(
|
||||
GASSERT(!g_hash_table_size(priv->tx_table));
|
||||
g_hash_table_unref(priv->tx_table);
|
||||
gbinder_driver_unref(self->driver);
|
||||
g_free(priv->dev);
|
||||
g_free(priv->key);
|
||||
G_OBJECT_CLASS(PARENT_CLASS)->finalize(object);
|
||||
}
|
||||
|
||||
@@ -79,26 +79,25 @@ void
|
||||
test_null(
|
||||
void)
|
||||
{
|
||||
GBinderIpc* null = NULL;
|
||||
int status = INT_MAX;
|
||||
|
||||
g_assert(!gbinder_ipc_ref(null));
|
||||
gbinder_ipc_unref(null);
|
||||
g_assert(!gbinder_ipc_sync_main.sync_reply(null, 0, 0, NULL, NULL));
|
||||
g_assert(!gbinder_ipc_sync_main.sync_reply(null, 0, 0, NULL, &status));
|
||||
g_assert(!gbinder_ipc_ref(NULL));
|
||||
gbinder_ipc_unref(NULL);
|
||||
g_assert(!gbinder_ipc_sync_main.sync_reply(NULL, 0, 0, NULL, NULL));
|
||||
g_assert(!gbinder_ipc_sync_main.sync_reply(NULL, 0, 0, NULL, &status));
|
||||
g_assert_cmpint(status, == ,-EINVAL);
|
||||
g_assert(!gbinder_ipc_sync_worker.sync_reply(null, 0, 0, NULL, NULL));
|
||||
g_assert(!gbinder_ipc_sync_worker.sync_reply(null, 0, 0, NULL, &status));
|
||||
g_assert(!gbinder_ipc_sync_worker.sync_reply(NULL, 0, 0, NULL, NULL));
|
||||
g_assert(!gbinder_ipc_sync_worker.sync_reply(NULL, 0, 0, NULL, &status));
|
||||
g_assert_cmpint(status, == ,-EINVAL);
|
||||
g_assert_cmpint(gbinder_ipc_sync_main.sync_oneway(null, 0, 0, NULL), == ,
|
||||
g_assert_cmpint(gbinder_ipc_sync_main.sync_oneway(NULL, 0, 0, NULL), == ,
|
||||
-EINVAL);
|
||||
g_assert_cmpint(gbinder_ipc_sync_worker.sync_oneway(null, 0, 0, NULL), == ,
|
||||
g_assert_cmpint(gbinder_ipc_sync_worker.sync_oneway(NULL, 0, 0, NULL), == ,
|
||||
-EINVAL);
|
||||
g_assert(!gbinder_ipc_transact(null, 0, 0, 0, NULL, NULL, NULL, NULL));
|
||||
g_assert(!gbinder_ipc_transact_custom(null, NULL, NULL, NULL, NULL));
|
||||
g_assert(!gbinder_ipc_object_registry(null));
|
||||
gbinder_ipc_looper_check(null);
|
||||
gbinder_ipc_cancel(null, 0);
|
||||
g_assert(!gbinder_ipc_transact(NULL, 0, 0, 0, NULL, NULL, NULL, NULL));
|
||||
g_assert(!gbinder_ipc_transact_custom(NULL, NULL, NULL, NULL, NULL));
|
||||
g_assert(!gbinder_ipc_object_registry(NULL));
|
||||
gbinder_ipc_looper_check(NULL);
|
||||
gbinder_ipc_cancel(NULL, 0);
|
||||
|
||||
g_assert(!gbinder_object_registry_ref(NULL));
|
||||
gbinder_object_registry_unref(NULL);
|
||||
@@ -167,6 +166,29 @@ test_basic(
|
||||
test_binder_exit_wait(&test_opt, NULL);
|
||||
}
|
||||
|
||||
/*==========================================================================*
|
||||
* protocol
|
||||
*==========================================================================*/
|
||||
|
||||
static
|
||||
void
|
||||
test_protocol(
|
||||
void)
|
||||
{
|
||||
/* GBinderIpc objects are identified by device + protocol combination */
|
||||
GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER, "aidl");
|
||||
GBinderIpc* ipc2 = gbinder_ipc_new(GBINDER_DEFAULT_BINDER, "hidl");
|
||||
|
||||
g_assert(ipc);
|
||||
g_assert(ipc2);
|
||||
g_assert(ipc != ipc2);
|
||||
gbinder_ipc_unref(ipc);
|
||||
gbinder_ipc_unref(ipc2);
|
||||
|
||||
gbinder_ipc_exit();
|
||||
test_binder_exit_wait(&test_opt, NULL);
|
||||
}
|
||||
|
||||
/*==========================================================================*
|
||||
* async_oneway
|
||||
*==========================================================================*/
|
||||
@@ -1350,6 +1372,7 @@ int main(int argc, char* argv[])
|
||||
g_test_init(&argc, &argv, NULL);
|
||||
g_test_add_func(TEST_("null"), test_null);
|
||||
g_test_add_func(TEST_("basic"), test_basic);
|
||||
g_test_add_func(TEST_("protocol"), test_protocol);
|
||||
g_test_add_func(TEST_("async_oneway"), test_async_oneway);
|
||||
g_test_add_func(TEST_("sync_oneway"), test_sync_oneway);
|
||||
g_test_add_func(TEST_("sync_reply_ok"), test_sync_reply_ok);
|
||||
|
||||
Reference in New Issue
Block a user