[-]
[+]
|
Changed |
_service:tar_git:libgbinder.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -6,7 +6,7 @@
<service name="tar_git">
<param name="url">https://github.com/mer-hybris/libgbinder.git</param>
<param name="branch">master</param>
- <param name="revision">e8c5a0c0bb7f31509f4c1e6d41cb8050afc65c0d</param>
+ <param name="revision">5874c8855986a93e372eba47634ffa83fdf5e499</param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/AUTHORS
^
|
@@ -6,3 +6,6 @@
Rinigus <rinigus.git@gmail.com>
George Hopkins <george-hopkins@null.net>
Bart Ribbers <bribbers@disroot.org>
+Gary Wang <gary.wang@canonical.com>
+Eugenio Paolantonio <me@medesimo.eu>
+Alessandro Astone <ales.astone@gmail.com>
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/LICENSE
^
|
@@ -1,5 +1,5 @@
-Copyright (C) 2018-2021 Jolla Ltd.
-Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+Copyright (C) 2018-2022 Jolla Ltd.
+Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
You may use this file under the terms of BSD license as follows:
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/Makefile
^
|
@@ -16,7 +16,7 @@
VERSION_MAJOR = 1
VERSION_MINOR = 1
-VERSION_RELEASE = 12
+VERSION_RELEASE = 30
# Version for pkg-config
PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
@@ -82,6 +82,7 @@
gbinder_config.c \
gbinder_driver.c \
gbinder_eventloop.c \
+ gbinder_fmq.c \
gbinder_io_32.c \
gbinder_io_64.c \
gbinder_ipc.c \
@@ -103,6 +104,8 @@
gbinder_servicemanager.c \
gbinder_servicemanager_aidl.c \
gbinder_servicemanager_aidl2.c \
+ gbinder_servicemanager_aidl3.c \
+ gbinder_servicemanager_aidl4.c \
gbinder_servicemanager_hidl.c
SRC += \
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/README
^
|
@@ -5,7 +5,7 @@
1. Integration with GLib event loop
2. Detection of 32 vs 64 bit kernel at runtime
3. Asynchronous transactions that don't block the event thread
-4. Stable service manager and low-level transation APIs
+4. Stable service manager and low-level transaction APIs
Android keeps changing both low-level RPC and service manager
protocols from version to version. To counter that, libgbinder
@@ -22,8 +22,8 @@
loaded one by one, overwriting the entries loaded from /etc/gbinder.conf
or from the previously processed file.
-Known protocol and service manager variants are aidl, aidl2 and hidl.
-This list is expected to expand further in the future. The default
+Known protocol and service manager variants are aidl, aidl2, aidl3 and
+hidl. This list is expected to expand further in the future. The default
configuration is as follows:
[Protocol]
@@ -36,9 +36,11 @@
/dev/binder = aidl
/dev/hwbinder = hidl
-Alternatively, one can specify the desired Android API level:
+Alternatively and preferably, one can specify the desired Android API
+level:
[General]
ApiLevel = 29
-and let libgbinder pick the appropriate preset.
+and let libgbinder pick the appropriate preset. Full list of presets can
+be found in src/gbinder_config.c
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/debian/changelog
^
|
@@ -1,3 +1,125 @@
+libgbinder (1.1.30) unstable; urgency=low
+
+ * Fixed BC_ACQUIRE_DONE encoding
+
+ -- Slava Monich <slava.monich@jolla.com> Sun, 04 Dec 2022 19:50:10 +0200
+
+libgbinder (1.1.29) unstable; urgency=low
+
+ * Added gbinder_writer_append_struct_vec
+
+ -- Slava Monich <slava.monich@jolla.com> Fri, 25 Nov 2022 00:01:41 +0200
+
+libgbinder (1.1.28) unstable; urgency=low
+
+ * Allow to pass negative number as a parameter to binder-call
+ * Compile tools as PIE
+
+ -- Slava Monich <slava.monich@jolla.com> Tue, 22 Nov 2022 18:21:29 +0200
+
+libgbinder (1.1.27) unstable; urgency=low
+
+ * Added gbinder_writer_append_struct()
+
+ -- Slava Monich <slava.monich@jolla.com> Thu, 17 Nov 2022 03:25:37 +0200
+
+libgbinder (1.1.26) unstable; urgency=low
+
+ * Use BINDER_TYPE_HANDLE for NULL binders
+ * Fixed binder object encoding in aidl3 protocol
+
+ -- Slava Monich <slava.monich@jolla.com> Fri, 14 Oct 2022 16:48:29 +0300
+
+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)
+ * Made binder device configurable for binder-dump
+
+ -- Slava Monich <slava.monich@jolla.com> Wed, 22 Jun 2022 17:02:20 +0300
+
+libgbinder (1.1.21) unstable; urgency=low
+
+ * Properly finalize GBinderIpc and GBinderServicePoll
+
+ -- Slava Monich <slava.monich@jolla.com> Mon, 20 Jun 2022 18:53:26 +0300
+
+libgbinder (1.1.20) unstable; urgency=low
+
+ * Made RPC protocol selectable at runtime
+
+ -- Slava Monich <slava.monich@jolla.com> Sat, 11 Jun 2022 02:49:49 +0300
+
+libgbinder (1.1.19) unstable; urgency=low
+
+ * Added reader and writer for aidl parcelables
+
+ -- Slava Monich <slava.monich@jolla.com> Sun, 20 Feb 2022 03:26:24 +0200
+
+libgbinder (1.1.18) unstable; urgency=low
+
+ * Disassociate auto-created proxies to stop them from piling up
+
+ -- Slava Monich <slava.monich@jolla.com> Sat, 08 Jan 2022 15:35:56 +0200
+
+libgbinder (1.1.17) unstable; urgency=low
+
+ * Don't release remote proxy handle too early (sometimes hever)
+
+ -- Slava Monich <slava.monich@jolla.com> Fri, 07 Jan 2022 14:43:51 +0200
+
+libgbinder (1.1.16) unstable; urgency=low
+
+ * Make sure stale object pointers don't hang around
+ * Properly shut down remote object inside the proxy
+ * Read ref_count from GObject atomically
+
+ -- Slava Monich <slava.monich@jolla.com> Mon, 03 Jan 2022 13:58:44 +0200
+
+libgbinder (1.1.15) unstable; urgency=low
+
+ * Added readers and writers for int8 and int16
+
+ -- Slava Monich <slava.monich@jolla.com> Mon, 27 Dec 2021 15:13:23 +0200
+
+libgbinder (1.1.14) unstable; urgency=low
+
+ * Support for FMQ (Fast Message Queues)
+ * Support for Android 11 (API level 30)
+ * Made GBinderReader API slightly more NULL tolerant
+ * Added gbinder_client_rpc_header()
+ * Added gbinder_reader_get_data()
+ * Added gbinder_writer_get_data()
+ * Added gbinder_servicemanager_device()
+ * Added gbinder_local_reply_append_fd()
+
+ -- Slava Monich <slava.monich@jolla.com> Wed, 24 Nov 2021 17:15:48 +0200
+
+libgbinder (1.1.13) unstable; urgency=low
+
+ * Added gbinder_writer_strdup()
+ * Added gbinder_writer_append_hidl_string_copy()
+ * Dropped pkgconfig requirement for devel package
+
+ -- Slava Monich <slava.monich@jolla.com> Thu, 28 Oct 2021 14:31:01 +0300
+
libgbinder (1.1.12) unstable; urgency=low
* Added binder-call test tool
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/debian/compat
^
|
@@ -1 +1 @@
-5
+7
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/debian/control
^
|
@@ -2,7 +2,7 @@
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 @@
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
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/debian/copyright
^
|
@@ -1,5 +1,5 @@
-Copyright (C) 2018-2021 Jolla Ltd.
-Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+Copyright (C) 2018-2022 Jolla Ltd.
+Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
You may use this file under the terms of BSD license as follows:
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/include/gbinder.h
^
|
@@ -38,6 +38,7 @@
#include "gbinder_bridge.h"
#include "gbinder_buffer.h"
#include "gbinder_client.h"
+#include "gbinder_fmq.h"
#include "gbinder_local_object.h"
#include "gbinder_local_reply.h"
#include "gbinder_local_request.h"
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/include/gbinder_client.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2020 Jolla Ltd.
- * Copyright (C) 2018-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2021 Jolla Ltd.
+ * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -78,6 +78,11 @@
GBinderClient* client,
guint32 code); /* since 1.0.42 */
+GBytes*
+gbinder_client_rpc_header(
+ GBinderClient* client,
+ guint32 code); /* since 1.1.14 */
+
GBinderLocalRequest*
gbinder_client_new_request(
GBinderClient* client);
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.30.tar.bz2/include/gbinder_fmq.h
^
|
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ *
+ * You may use this file under the terms of BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GBINDER_FMQ_H
+#define GBINDER_FMQ_H
+
+#include <gbinder_types.h>
+
+G_BEGIN_DECLS
+
+/* Since 1.1.14 */
+
+typedef enum gbinder_fmq_type {
+ GBINDER_FMQ_TYPE_SYNC_READ_WRITE = 1,
+ GBINDER_FMQ_TYPE_UNSYNC_WRITE
+} GBINDER_FMQ_TYPE;
+
+typedef enum gbinder_fmq_flags {
+ GBINDER_FMQ_FLAG_CONFIGURE_EVENT_FLAG = 0x1,
+ GBINDER_FMQ_FLAG_NO_RESET_POINTERS = 0x2
+} GBINDER_FMQ_FLAGS;
+
+GBinderFmq*
+gbinder_fmq_new(
+ gsize item_size,
+ gsize max_num_items,
+ GBINDER_FMQ_TYPE type,
+ GBINDER_FMQ_FLAGS flags,
+ gint fd,
+ gsize buffer_size);
+
+GBinderFmq*
+gbinder_fmq_ref(
+ GBinderFmq* fmq);
+
+void
+gbinder_fmq_unref(
+ GBinderFmq* fmq);
+
+/* Functions for checking how many items are available in queue */
+gsize
+gbinder_fmq_available_to_read(
+ GBinderFmq* fmq);
+
+gsize
+gbinder_fmq_available_to_write(
+ GBinderFmq* fmq);
+
+gsize
+gbinder_fmq_available_to_read_contiguous(
+ GBinderFmq* fmq);
+
+gsize
+gbinder_fmq_available_to_write_contiguous(
+ GBinderFmq* fmq);
+
+/* Functions for obtaining data pointer for zero copy read/write */
+const void*
+gbinder_fmq_begin_read(
+ GBinderFmq* fmq,
+ gsize items);
+
+void*
+gbinder_fmq_begin_write(
+ GBinderFmq* fmq,
+ gsize items);
+
+/* Functions for ending zero copy read/write
+ * The number of items must match the value provided to gbinder_fmq_begin_read
+ * or gbinder_fmq_begin_write */
+void
+gbinder_fmq_end_read(
+ GBinderFmq* fmq,
+ gsize items);
+
+void
+gbinder_fmq_end_write(
+ GBinderFmq* fmq,
+ gsize items);
+
+/* Regular read/write functions (non-zero-copy) */
+gboolean
+gbinder_fmq_read(
+ GBinderFmq* fmq,
+ void* data,
+ gsize items);
+
+gboolean
+gbinder_fmq_write(
+ GBinderFmq* fmq,
+ const void* data,
+ gsize items);
+
+/*
+ * Functions for waiting and waking message queue.
+ * Requires configured event flag in message queue.
+ */
+int
+gbinder_fmq_wait_timeout(
+ GBinderFmq* fmq,
+ guint32 bit_mask,
+ guint32* state,
+ int timeout_ms);
+
+#define gbinder_fmq_try_wait(fmq, mask, state) \
+ gbinder_fmq_wait_timeout(fmq, mask, state, 0)
+
+#define gbinder_fmq_wait(fmq, mask, state) \
+ gbinder_fmq_wait_timeout(fmq, mask, state, -1)
+
+int
+gbinder_fmq_wake(
+ GBinderFmq* fmq,
+ guint32 bit_mask);
+
+G_END_DECLS
+
+#endif /* GBINDER_FMQ_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/include/gbinder_local_reply.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018 Jolla Ltd.
- * Copyright (C) 2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2021 Jolla Ltd.
+ * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Jolla Ltd nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -112,6 +112,11 @@
GBinderLocalReply* reply,
GBinderRemoteObject* obj);
+GBinderLocalReply*
+gbinder_local_reply_append_fd(
+ GBinderLocalReply* reply,
+ int fd); /* Since 1.1.14 */
+
G_END_DECLS
#endif /* GBINDER_LOCAL_OBJECT_H */
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/include/gbinder_reader.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -14,8 +14,8 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -66,6 +66,26 @@
gboolean* value);
gboolean
+gbinder_reader_read_int8(
+ GBinderReader* reader,
+ gint8* value); /* Since 1.1.15 */
+
+gboolean
+gbinder_reader_read_uint8(
+ GBinderReader* reader,
+ guint8* value); /* Since 1.1.15 */
+
+gboolean
+gbinder_reader_read_int16(
+ GBinderReader* reader,
+ gint16* value); /* Since 1.1.15 */
+
+gboolean
+gbinder_reader_read_uint16(
+ GBinderReader* reader,
+ guint16* value); /* Since 1.1.15 */
+
+gboolean
gbinder_reader_read_int32(
GBinderReader* reader,
gint32* value);
@@ -123,6 +143,11 @@
G_GNUC_WARN_UNUSED_RESULT;
const void*
+gbinder_reader_read_parcelable(
+ GBinderReader* reader,
+ gsize* size); /* Since 1.1.19 */
+
+const void*
gbinder_reader_read_hidl_struct1(
GBinderReader* reader,
gsize size); /* Since 1.0.9 */
@@ -201,6 +226,11 @@
GBinderReader* reader,
gsize* len); /* Since 1.0.12 */
+const void*
+gbinder_reader_get_data(
+ const GBinderReader* reader,
+ gsize* size); /* Since 1.1.14 */
+
gsize
gbinder_reader_bytes_read(
const GBinderReader* reader);
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/include/gbinder_servicemanager.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2020 Jolla Ltd.
- * Copyright (C) 2018-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -76,7 +76,15 @@
GBinderServiceManager*
gbinder_servicemanager_new(
- const char* dev);
+ const char* dev)
+ G_GNUC_WARN_UNUSED_RESULT;
+
+GBinderServiceManager*
+gbinder_servicemanager_new2(
+ const char* dev,
+ const char* sm_protocol,
+ const char* rpc_protocol) /* Since 1.1.20 */
+ G_GNUC_WARN_UNUSED_RESULT;
GBinderServiceManager*
gbinder_defaultservicemanager_new(
@@ -112,6 +120,10 @@
gbinder_servicemanager_unref(
GBinderServiceManager* sm);
+const char*
+gbinder_servicemanager_device(
+ GBinderServiceManager* sm); /* Since 1.1.14 */
+
gboolean
gbinder_servicemanager_is_present(
GBinderServiceManager* sm); /* Since 1.0.25 */
@@ -189,7 +201,7 @@
gulong* ids,
guint count); /* Since 1.0.25 */
-#define gbinder_servicemanager_remove_all_handlers(r,ids) \
+#define gbinder_servicemanager_remove_all_handlers(sm,ids) \
gbinder_servicemanager_remove_handlers(sm, ids, G_N_ELEMENTS(ids))
G_END_DECLS
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/include/gbinder_types.h
^
|
@@ -62,6 +62,7 @@
typedef struct gbinder_bridge GBinderBridge; /* Since 1.1.5 */
typedef struct gbinder_buffer GBinderBuffer;
typedef struct gbinder_client GBinderClient;
+typedef struct gbinder_fmq GBinderFmq; /* Since 1.1.14 */
typedef struct gbinder_ipc GBinderIpc;
typedef struct gbinder_local_object GBinderLocalObject;
typedef struct gbinder_local_reply GBinderLocalReply;
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/include/gbinder_writer.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018 Jolla Ltd.
- * Copyright (C) 2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -14,8 +14,8 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -55,6 +55,119 @@
guint32 offset;
};
+/*
+ * Note that gbinder_writer_append_struct() doesn't copy the data, it writes
+ * buffer objects pointing to whatever was passed in. The caller must make
+ * sure that those pointers outlive the transaction. That's most commonly
+ * done with by using gbinder_writer_malloc() and friends for allocating
+ * memory for the transaction.
+ *
+ * Below is an example of initializing GBinderWriterType which can then
+ * be passed to gbinder_writer_append_struct(). Fields have to be listed
+ * in the order in which they appear in the structure.
+ *
+ * typedef struct data {
+ * int x;
+ * } Data;
+ *
+ * typedef struct data2 {
+ * int y;
+ * GBinderHidlString str;
+ * GBinderHidlVec vec; // vec<Data>
+ * } Data2;
+ *
+ * static const GBinderWriterType data_t = {
+ * GBINDER_WRITER_STRUCT_NAME_AND_SIZE(Data), NULL
+ * };
+ *
+ * static const GBinderWriterField data2_f[] = {
+ * GBINDER_WRITER_FIELD_HIDL_STRING(Data2,str),
+ * GBINDER_WRITER_FIELD_HIDL_VEC(Data2, vec, &data_t),
+ * GBINDER_WRITER_FIELD_END()
+ * };
+ *
+ * static const GBinderWriterType data2_t = {
+ * GBINDER_WRITER_STRUCT_NAME_AND_SIZE(Data2), data2_f
+ * };
+ */
+
+typedef struct gbinder_writer_type {
+ const char* name;
+ gsize size;
+ const struct gbinder_writer_field* fields;
+} GBinderWriterType; /* Since 1.1.27 */
+
+typedef struct gbinder_writer_field {
+ const char* name;
+ gsize offset;
+ const GBinderWriterType* type;
+ void (*write_buf)(GBinderWriter* writer, const void* ptr,
+ const struct gbinder_writer_field* field, const GBinderParent* parent);
+ gpointer reserved;
+} GBinderWriterField; /* Since 1.1.27 */
+
+#define GBINDER_WRITER_STRUCT_NAME_AND_SIZE(type) \
+ #type, sizeof(type)
+#define GBINDER_WRITER_FIELD_NAME_AND_OFFSET(type,field) \
+ #type "." #field, G_STRUCT_OFFSET(type,field)
+#define GBINDER_WRITER_FIELD_POINTER(type,field,field_type) { \
+ GBINDER_WRITER_FIELD_NAME_AND_OFFSET(type,field), field_type, NULL, NULL }
+#define GBINDER_WRITER_FIELD_HIDL_VEC(type,field,elem) { \
+ GBINDER_WRITER_FIELD_NAME_AND_OFFSET(type,field), elem, \
+ gbinder_writer_field_hidl_vec_write_buf, NULL }
+#define GBINDER_WRITER_FIELD_HIDL_VEC_INT32(type,field) \
+ GBINDER_WRITER_FIELD_HIDL_VEC(type,field, &gbinder_writer_type_int32)
+#define GBINDER_WRITER_FIELD_HIDL_VEC_BYTE(type,field) \
+ GBINDER_WRITER_FIELD_HIDL_VEC(type,field, &gbinder_writer_type_byte)
+#define GBINDER_WRITER_FIELD_HIDL_VEC_STRING(type,field) \
+ GBINDER_WRITER_FIELD_HIDL_VEC(type,field, &gbinder_writer_type_hidl_string)
+#define GBINDER_WRITER_FIELD_HIDL_STRING(type,field) { \
+ GBINDER_WRITER_FIELD_NAME_AND_OFFSET(type,field), NULL, \
+ gbinder_writer_field_hidl_string_write_buf, NULL }
+#define GBINDER_WRITER_FIELD_END() { NULL, 0, NULL, NULL, NULL }
+
+extern const GBinderWriterType gbinder_writer_type_byte; /* Since 1.1.27 */
+extern const GBinderWriterType gbinder_writer_type_int32; /* Since 1.1.27 */
+extern const GBinderWriterType gbinder_writer_type_hidl_string; /* 1.1.27 */
+
+void
+gbinder_writer_append_struct(
+ GBinderWriter* writer,
+ const void* ptr,
+ const GBinderWriterType* type,
+ const GBinderParent* parent); /* Since 1.1.27 */
+
+void
+gbinder_writer_append_struct_vec(
+ GBinderWriter* writer,
+ const void* ptr,
+ guint count,
+ const GBinderWriterType* type); /* Since 1.1.29 */
+
+void
+gbinder_writer_field_hidl_vec_write_buf(
+ GBinderWriter* writer,
+ const void* ptr,
+ const GBinderWriterField* field,
+ const GBinderParent* parent); /* Since 1.1.27 */
+
+void
+gbinder_writer_field_hidl_string_write_buf(
+ GBinderWriter* writer,
+ const void* ptr,
+ const GBinderWriterField* field,
+ const GBinderParent* parent); /* Since 1.1.27 */
+
+void
+gbinder_writer_append_int8(
+ GBinderWriter* writer,
+ guint8 value); /* Since 1.1.15 */
+
+void
+gbinder_writer_append_int16(
+ GBinderWriter* writer,
+ guint16 value); /* Since 1.1.15 */
+
void
gbinder_writer_append_int32(
GBinderWriter* writer,
@@ -119,15 +232,11 @@
GBinderWriter* writer,
int fd); /* Since 1.0.18 */
-gsize
-gbinder_writer_bytes_written(
- GBinderWriter* writer); /* since 1.0.21 */
-
void
-gbinder_writer_overwrite_int32(
+gbinder_writer_append_fds(
GBinderWriter* writer,
- gsize offset,
- gint32 value); /* since 1.0.21 */
+ const GBinderFds* fds,
+ const GBinderParent* parent); /* Since 1.1.14 */
guint
gbinder_writer_append_buffer_object_with_parent(
@@ -143,11 +252,17 @@
gsize len);
void
+gbinder_writer_append_parcelable(
+ GBinderWriter* writer,
+ const void* buf,
+ gsize len); /* Since 1.1.19 */
+
+void
gbinder_writer_append_hidl_vec(
GBinderWriter* writer,
const void* base,
guint count,
- guint elemsize); /* since 1.0.8 */
+ guint elemsize); /* Since 1.0.8 */
void
gbinder_writer_append_hidl_string(
@@ -155,6 +270,11 @@
const char* str);
void
+gbinder_writer_append_hidl_string_copy(
+ GBinderWriter* writer,
+ const char* str); /* Since 1.1.13 */
+
+void
gbinder_writer_append_hidl_string_vec(
GBinderWriter* writer,
const char* data[],
@@ -174,17 +294,39 @@
gbinder_writer_append_byte_array(
GBinderWriter* writer,
const void* byte_array,
- gint32 len); /* since 1.0.12 */
+ gint32 len); /* Since 1.0.12 */
+
+void
+gbinder_writer_append_fmq_descriptor(
+ GBinderWriter* writer,
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_buffer.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -251,6 +251,15 @@
return driver ? gbinder_driver_io(driver) : NULL;
}
+const GBinderRpcProtocol*
+gbinder_buffer_protocol(
+ GBinderBuffer* buf)
+{
+ GBinderDriver* driver = gbinder_buffer_driver(buf);
+
+ return driver ? gbinder_driver_protocol(driver) : NULL;
+}
+
void**
gbinder_buffer_objects(
GBinderBuffer* self)
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_buffer_p.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -73,6 +73,11 @@
GBinderBuffer* buf)
GBINDER_INTERNAL;
+const GBinderRpcProtocol*
+gbinder_buffer_protocol(
+ GBinderBuffer* buf)
+ GBINDER_INTERNAL;
+
void**
gbinder_buffer_objects(
GBinderBuffer* buffer)
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_client.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -282,7 +282,8 @@
priv->ranges = g_new0(GBinderClientIfaceRange, 1);
priv->ranges[0].last_code = UINT_MAX;
priv->ranges[0].basic_req = gbinder_local_request_new
- (gbinder_driver_io(driver), NULL);
+ (gbinder_driver_io(driver), gbinder_driver_protocol(driver),
+ NULL);
}
return self;
}
@@ -351,15 +352,32 @@
return NULL;
}
+GBytes*
+gbinder_client_rpc_header(
+ GBinderClient* self,
+ guint32 code) /* since 1.1.14 */
+{
+ if (G_LIKELY(self)) {
+ const GBinderClientIfaceRange* r =
+ gbinder_client_find_range(gbinder_client_cast(self), code);
+
+ if (r) {
+ return r->rpc_header;
+ }
+ }
+ return NULL;
+}
+
GBinderLocalRequest*
gbinder_client_new_request(
GBinderClient* self)
{
if (G_LIKELY(self)) {
GBinderClientPriv* priv = gbinder_client_cast(self);
- const GBinderIo* io = gbinder_driver_io(self->remote->ipc->driver);
+ GBinderDriver* driver = self->remote->ipc->driver;
- return gbinder_local_request_new(io, priv->ranges->rpc_header);
+ return gbinder_local_request_new(gbinder_driver_io(driver),
+ gbinder_driver_protocol(driver), priv->ranges->rpc_header);
}
return NULL;
}
@@ -371,13 +389,14 @@
{
if (G_LIKELY(self)) {
GBinderClientPriv* priv = gbinder_client_cast(self);
- const GBinderClientIfaceRange* r = gbinder_client_find_range
+ const GBinderClientIfaceRange* range = gbinder_client_find_range
(priv, code);
- if (r) {
- const GBinderIo* io = gbinder_driver_io(self->remote->ipc->driver);
+ if (range) {
+ GBinderDriver* driver = self->remote->ipc->driver;
- return gbinder_local_request_new(io, r->rpc_header);
+ return gbinder_local_request_new(gbinder_driver_io(driver),
+ gbinder_driver_protocol(driver), range->rpc_header);
}
}
return NULL;
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_config.c
^
|
@@ -113,9 +113,45 @@
{ NULL, NULL }
};
+/* API level 30 */
+
+static const GBinderConfigPresetEntry gbinder_config_30_protocol[] = {
+ { "/dev/binder", "aidl3" },
+ { "/dev/vndbinder", "aidl3" },
+ { NULL, NULL }
+};
+
+static const GBinderConfigPresetEntry gbinder_config_30_servicemanager[] = {
+ { "/dev/binder", "aidl3" },
+ { "/dev/vndbinder", "aidl3" },
+ { NULL, NULL }
+};
+
+static const GBinderConfigPresetGroup gbinder_config_30[] = {
+ { GBINDER_CONFIG_GROUP_PROTOCOL, gbinder_config_30_protocol },
+ { GBINDER_CONFIG_GROUP_SERVICEMANAGER, gbinder_config_30_servicemanager },
+ { NULL, NULL }
+};
+
+/* API level 31 */
+
+static const GBinderConfigPresetEntry gbinder_config_31_servicemanager[] = {
+ { "/dev/binder", "aidl4" },
+ { "/dev/vndbinder", "aidl4" },
+ { NULL, NULL }
+};
+
+static const GBinderConfigPresetGroup gbinder_config_31[] = {
+ { GBINDER_CONFIG_GROUP_PROTOCOL, gbinder_config_30_protocol },
+ { GBINDER_CONFIG_GROUP_SERVICEMANAGER, gbinder_config_31_servicemanager },
+ { NULL, NULL }
+};
+
/* Presets sorted by API level in descending order */
static const GBinderConfigPreset gbinder_config_presets[] = {
+ { 31, gbinder_config_31 },
+ { 30, gbinder_config_30 },
{ 29, gbinder_config_29 },
{ 28, gbinder_config_28 }
};
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_driver.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -82,6 +82,7 @@
void* vm;
gsize vmsize;
char* dev;
+ const char* name;
const GBinderIo* io;
const GBinderRpcProtocol* protocol;
};
@@ -169,6 +170,14 @@
GVERBOSE("> %s %d (%u bytes, %u objects)", name,
tx->status, (guint)tx->size, n);
}
+ } else if (tx->code) {
+ if (tx->target) {
+ GVERBOSE("> %s %p 0x%08x (%u bytes, %u objects)", name,
+ tx->target, tx->code, (guint)tx->size, n);
+ } else {
+ GVERBOSE("> %s 0x%08x (%u bytes, %u objects)", name,
+ tx->code, (guint)tx->size, n);
+ }
} else {
if (tx->target) {
GVERBOSE("> %s %p (%u bytes, %u objects)", name,
@@ -187,6 +196,14 @@
GVERBOSE("> %s %d (%u bytes)", name, tx->status, (guint)
tx->size);
}
+ } else if (tx->code) {
+ if (tx->target) {
+ GVERBOSE("> %s %p 0x%08x (%u bytes)", name,
+ tx->target, tx->code, (guint)tx->size);
+ } else {
+ GVERBOSE("> %s 0x%08x (%u bytes)", name,
+ tx->code, (guint)tx->size);
+ }
} else {
if (tx->target) {
GVERBOSE("> %s %p (%u bytes)", name, tx->target, (guint)
@@ -549,7 +566,8 @@
tx.flags, &txstatus);
break;
default:
- GWARN("Unhandled transaction %s 0x%08x", iface, tx.code);
+ GWARN("Unhandled transaction %s 0x%08x from %s", iface, tx.code,
+ self->name);
break;
}
@@ -879,6 +897,9 @@
self->vm = vm;
self->vmsize = vmsize;
self->dev = g_strdup(dev);
+ self->name = self->dev + /* Shorter version for logging */
+ (g_str_has_prefix(self->dev, "/dev/") ? 5 : 0);
+
if (gbinder_system_ioctl(fd, BINDER_SET_MAX_THREADS,
&max_threads) < 0) {
GERR("%s failed to set max threads (%u): %s", dev,
@@ -1303,8 +1324,9 @@
gbinder_driver_local_request_new_ping(
GBinderDriver* self)
{
- GBinderLocalRequest* req = gbinder_local_request_new(self->io, NULL);
GBinderWriter writer;
+ GBinderLocalRequest* req = gbinder_local_request_new(self->io,
+ self->protocol, NULL);
gbinder_local_request_init_writer(req, &writer);
self->protocol->write_ping(&writer);
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_fmq.c
^
|
@@ -0,0 +1,699 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ *
+ * You may use this file under the terms of BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "gbinder_fmq_p.h"
+#include "gbinder_log.h"
+
+#include <gutil_macros.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <linux/futex.h>
+#include <stdint.h>
+#include <sys/mman.h>
+#include <unistd.h>
+
+#if GBINDER_FMQ_SUPPORTED
+
+/* Grantor data positions */
+enum {
+ READ_PTR_POS = 0,
+ WRITE_PTR_POS,
+ DATA_PTR_POS,
+ EVENT_FLAG_PTR_POS
+};
+
+typedef struct gbinder_fmq {
+ GBinderMQDescriptor* desc;
+ guint8* ring;
+ guint64* read_ptr;
+ guint64* write_ptr;
+ guint32* event_flag_ptr;
+ guint32 refcount;
+} GBinderFmq;
+
+GBINDER_INLINE_FUNC
+GBinderFmqGrantorDescriptor*
+gbinder_fmq_get_grantor_descriptor(
+ GBinderFmq* self,
+ gint index)
+{
+ return (GBinderFmqGrantorDescriptor*)(self->desc->grantors.data.ptr) +
+ index;
+}
+
+static
+gsize
+gbinder_fmq_available_to_read_bytes(
+ GBinderFmq* self,
+ gboolean contiguous)
+{
+ const guint64 read_ptr = __atomic_load_n(self->read_ptr, __ATOMIC_ACQUIRE);
+ const gsize available_total = __atomic_load_n(self->write_ptr,
+ __ATOMIC_ACQUIRE) - read_ptr;
+
+ if (contiguous) {
+ /*
+ * The number of bytes that can be read contiguously from
+ * read offset without wrapping around the ring buffer.
+ */
+ const gsize size = gbinder_fmq_get_grantor_descriptor(self,
+ DATA_PTR_POS)->extent;
+ const gsize available_contiguous = size - (read_ptr % size);
+
+ return (available_contiguous < available_total) ?
+ available_contiguous : available_total;
+ } else {
+ return available_total;
+ }
+}
+
+static
+gsize
+gbinder_fmq_available_to_write_bytes(
+ GBinderFmq* self,
+ gboolean contiguous)
+{
+ const guint32 size = gbinder_fmq_get_grantor_descriptor(self,
+ DATA_PTR_POS)->extent;
+ const gsize available_total = size -
+ gbinder_fmq_available_to_read_bytes(self, FALSE);
+
+ if (contiguous) {
+ /*
+ * The number of bytes that can be written contiguously starting from
+ * write_offset without wrapping around the ring buffer.
+ */
+ const guint64 write_ptr = __atomic_load_n(self->write_ptr,
+ __ATOMIC_RELAXED);
+ const gsize available_contiguous = size - (write_ptr % size);
+
+ return (available_contiguous < available_total) ?
+ available_contiguous : available_total;
+ } else {
+ return available_total;
+ }
+}
+
+static
+GBinderFmqGrantorDescriptor*
+gbinder_fmq_create_grantors(
+ gsize queue_size_bytes,
+ gsize num_fds,
+ gboolean configure_event_flag)
+{
+ const gsize num_grantors = configure_event_flag ?
+ (EVENT_FLAG_PTR_POS + 1) : (DATA_PTR_POS + 1);
+ GBinderFmqGrantorDescriptor* grantors =
+ g_new0(GBinderFmqGrantorDescriptor, num_grantors);
+ gsize pos, offset;
+ gsize mem_sizes[] = {
+ sizeof(guint64), /* read pointer counter */
+ sizeof(guint64), /* write pointer counter */
+ queue_size_bytes, /* data buffer */
+ sizeof(guint32) /* event flag pointer */
+ };
+
+ for (pos = 0, offset = 0; pos < num_grantors; pos++) {
+ GBinderFmqGrantorDescriptor* grantor = grantors + pos;
+ guint32 grantor_fd_index;
+ gsize grantor_offset;
+
+ if (pos == DATA_PTR_POS && num_fds == 2) {
+ grantor_fd_index = 1;
+ grantor_offset = 0;
+ } else {
+ grantor_fd_index = 0;
+ grantor_offset = offset;
+ offset += mem_sizes[pos];
+ }
+ grantor->fd_index = grantor_fd_index;
+ grantor->offset = (guint32)G_ALIGN8(grantor_offset);
+ grantor->extent = mem_sizes[pos];
+ }
+ return grantors;
+}
+
+static
+void*
+gbinder_fmq_map_grantor_descriptor(
+ GBinderFmq* self,
+ guint32 index)
+{
+ if (index < self->desc->grantors.count) {
+ const GBinderFmqGrantorDescriptor* desc =
+ gbinder_fmq_get_grantor_descriptor(self, index);
+ /* Offset for mmap must be a multiple of PAGE_SIZE */
+ const guint32 map_offset = (desc->offset & ~(getpagesize()-1));
+ const guint32 map_length = desc->offset - map_offset + desc->extent;
+ const GBinderFds* fds = self->desc->data.fds;
+ void* address = mmap(0, map_length, PROT_READ | PROT_WRITE, MAP_SHARED,
+ gbinder_fds_get_fd(fds, desc->fd_index), map_offset);
+
+ if (address != MAP_FAILED) {
+ return (guint8*)address + (desc->offset - map_offset);
+ } else {
+ GWARN("mmap failed: %d", errno);
+ }
+ }
+ return NULL;
+}
+
+static
+void
+gbinder_fmq_unmap_grantor_descriptor(
+ GBinderFmq* self,
+ void* address,
+ guint index)
+{
+ if (index < self->desc->grantors.count && address) {
+ const GBinderFmqGrantorDescriptor* desc =
+ gbinder_fmq_get_grantor_descriptor(self, index);
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_fmq_p.h
^
|
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ *
+ * You may use this file under the terms of BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GBINDER_FMQ_PRIVATE_H
+#define GBINDER_FMQ_PRIVATE_H
+
+#include <gbinder_fmq.h>
+
+#include "gbinder_types_p.h"
+
+/* FMQ functionality requires __NR_memfd_create syscall */
+#include <sys/syscall.h>
+
+#ifdef __NR_memfd_create
+# define GBINDER_FMQ_SUPPORTED 1
+#else
+# define GBINDER_FMQ_SUPPORTED 0
+#endif
+
+/*
+ * From linux/memfd.h
+ */
+#ifndef MFD_CLOEXEC
+# define MFD_CLOEXEC 0x0001U
+#endif
+
+/*
+ * FMQ types
+ */
+typedef struct gbinder_fmq_grantor_descriptor {
+ guint32 flags GBINDER_ALIGNED(4);
+ guint32 fd_index GBINDER_ALIGNED(4);
+ guint32 offset GBINDER_ALIGNED(4);
+ guint64 extent GBINDER_ALIGNED(8);
+} GBinderFmqGrantorDescriptor;
+
+G_STATIC_ASSERT(G_STRUCT_OFFSET(GBinderFmqGrantorDescriptor, flags) == 0);
+G_STATIC_ASSERT(G_STRUCT_OFFSET(GBinderFmqGrantorDescriptor, fd_index) == 4);
+G_STATIC_ASSERT(G_STRUCT_OFFSET(GBinderFmqGrantorDescriptor, offset) == 8);
+G_STATIC_ASSERT(G_STRUCT_OFFSET(GBinderFmqGrantorDescriptor, extent) == 16);
+G_STATIC_ASSERT(sizeof(GBinderFmqGrantorDescriptor) == 24);
+
+typedef struct gbinder_mq_descriptor {
+ GBinderHidlVec grantors;
+ union {
+ guint64 value;
+ const GBinderFds* fds;
+ } data;
+ guint32 quantum;
+ guint32 flags;
+} GBinderMQDescriptor;
+
+#define GBINDER_MQ_DESCRIPTOR_GRANTORS_OFFSET (0)
+#define GBINDER_MQ_DESCRIPTOR_FDS_OFFSET (16)
+G_STATIC_ASSERT(G_STRUCT_OFFSET(GBinderMQDescriptor, grantors) ==
+ GBINDER_MQ_DESCRIPTOR_GRANTORS_OFFSET);
+G_STATIC_ASSERT(G_STRUCT_OFFSET(GBinderMQDescriptor, data) ==
+ GBINDER_MQ_DESCRIPTOR_FDS_OFFSET);
+G_STATIC_ASSERT(sizeof(GBinderMQDescriptor) == 32);
+
+GBinderMQDescriptor*
+gbinder_fmq_get_descriptor(
+ const GBinderFmq* self)
+ GBINDER_INTERNAL;
+
+#endif /* GBINDER_FMQ_PRIVATE_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_io.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -35,6 +35,7 @@
#include "gbinder_local_object_p.h"
#include "gbinder_remote_object_p.h"
#include "gbinder_object_registry.h"
+#include "gbinder_rpc_protocol.h"
#include "gbinder_writer.h"
#include "gbinder_system.h"
#include "gbinder_log.h"
@@ -94,7 +95,8 @@
static
gsize
GBINDER_IO_FN(object_size)(
- const void* obj)
+ const void* obj,
+ const GBinderRpcProtocol* protocol)
{
if (obj) {
const struct binder_object_header* hdr = obj;
@@ -104,7 +106,8 @@
case BINDER_TYPE_WEAK_BINDER:
case BINDER_TYPE_HANDLE:
case BINDER_TYPE_WEAK_HANDLE:
- return sizeof(struct flat_binder_object);
+ return sizeof(struct flat_binder_object) +
+ protocol->flat_binder_object_extra;
case BINDER_TYPE_FD:
return sizeof(struct binder_fd_object);
case BINDER_TYPE_FDA:
@@ -166,7 +169,8 @@
guint
GBINDER_IO_FN(encode_local_object)(
void* out,
- GBinderLocalObject* obj)
+ GBinderLocalObject* obj,
+ const GBinderRpcProtocol* protocol)
{
struct flat_binder_object* dest = out;
@@ -176,9 +180,14 @@
dest->flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
dest->binder = (uintptr_t)obj;
} else {
- dest->hdr.type = BINDER_TYPE_WEAK_BINDER;
+ dest->hdr.type = BINDER_TYPE_HANDLE;
}
- return sizeof(*dest);
+ if (protocol->finish_flatten_binder) {
+ protocol->finish_flatten_binder(dest + 1, obj);
+ } else if (protocol->flat_binder_object_extra) {
+ memset(dest + 1, 0, protocol->flat_binder_object_extra);
+ }
+ return sizeof(*dest) + protocol->flat_binder_object_extra;
}
static
@@ -215,6 +224,23 @@
return sizeof(*dest);
}
+static
+guint
+GBINDER_IO_FN(encode_fda_object)(
+ void* out,
+ const GBinderFds *fds,
+ const GBinderParent* parent)
+{
+ struct binder_fd_array_object* dest = out;
+
+ memset(dest, 0, sizeof(*dest));
+ dest->hdr.type = BINDER_TYPE_FDA;
+ dest->num_fds = fds->num_fds;
+ dest->parent = parent->index;
+ dest->parent_offset = parent->offset;
+ return sizeof(*dest);
+}
+
/* Encodes binder_buffer_object */
static
guint
@@ -263,7 +289,7 @@
/* We never send these cookies and don't expect them back */
dest->ptr = (uintptr_t)obj;
dest->cookie = 0;
- return sizeof(dest);
+ return sizeof(*dest);
}
/* Fills binder_transaction_data for BC_TRANSACTION/REPLY */
@@ -483,7 +509,8 @@
guint
GBINDER_IO_FN(decode_binder_handle)(
const void* data,
- guint32* handle)
+ guint32* handle,
+ const GBinderRpcProtocol* protocol)
{
const struct flat_binder_object* obj = data;
@@ -492,7 +519,7 @@
if (handle) {
*handle = obj->handle;
}
- return sizeof(*obj);
+ return sizeof(*obj) + protocol->flat_binder_object_extra;
}
return 0;
}
@@ -503,7 +530,8 @@
const void* data,
gsize size,
GBinderObjectRegistry* reg,
- GBinderRemoteObject** out)
+ GBinderRemoteObject** out,
+ const GBinderRpcProtocol* protocol)
{
const struct flat_binder_object* obj = data;
@@ -513,15 +541,18 @@
if (out) {
*out = gbinder_object_registry_get_remote(reg, obj->handle,
REMOTE_REGISTRY_CAN_CREATE_AND_ACQUIRE);
+ if (*out && protocol->finish_unflatten_binder) {
+ protocol->finish_unflatten_binder(obj + 1, *out);
+ }
}
- return sizeof(*obj);
+ return sizeof(*obj) + protocol->flat_binder_object_extra;
case BINDER_TYPE_BINDER:
if (!obj->binder) {
/* That's a NULL reference */
if (out) {
*out = NULL;
}
- return sizeof(*obj);
+ return sizeof(*obj) + protocol->flat_binder_object_extra;
}
/* fallthrough */
default:
@@ -637,6 +668,7 @@
.encode_local_object = GBINDER_IO_FN(encode_local_object),
.encode_remote_object = GBINDER_IO_FN(encode_remote_object),
.encode_fd_object = GBINDER_IO_FN(encode_fd_object),
+ .encode_fda_object = GBINDER_IO_FN(encode_fda_object),
.encode_buffer_object = GBINDER_IO_FN(encode_buffer_object),
.encode_handle_cookie = GBINDER_IO_FN(encode_handle_cookie),
.encode_ptr_cookie = GBINDER_IO_FN(encode_ptr_cookie),
@@ -663,6 +695,10 @@
G_STATIC_ASSERT(GBINDER_POINTER_SIZE <= GBINDER_MAX_POINTER_SIZE);
G_STATIC_ASSERT(sizeof(struct flat_binder_object) <=
GBINDER_MAX_BINDER_OBJECT_SIZE);
+G_STATIC_ASSERT(sizeof(struct binder_fd_object) <=
+ GBINDER_MAX_BUFFER_OBJECT_SIZE);
+G_STATIC_ASSERT(sizeof(struct binder_fd_array_object) <=
+ GBINDER_MAX_BUFFER_OBJECT_SIZE);
G_STATIC_ASSERT(sizeof(struct binder_buffer_object) <=
GBINDER_MAX_BUFFER_OBJECT_SIZE);
G_STATIC_ASSERT(sizeof(struct binder_handle_cookie) <=
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_io.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -126,7 +126,7 @@
} br;
/* Size of the object and its extra data */
- gsize (*object_size)(const void* obj);
+ gsize (*object_size)(const void* obj, const GBinderRpcProtocol* protocol);
gsize (*object_data_size)(const void* obj);
/* Writes pointer to the buffer. The destination buffer must have
@@ -142,10 +142,13 @@
guint (*encode_cookie)(void* out, guint64 cookie);
/* Encode flat_buffer_object */
-#define GBINDER_MAX_BINDER_OBJECT_SIZE (24)
- guint (*encode_local_object)(void* out, GBinderLocalObject* obj);
+#define GBINDER_MAX_BINDER_OBJECT_SIZE (28)
+ guint (*encode_local_object)(void* out, GBinderLocalObject* obj,
+ const GBinderRpcProtocol* protocol);
guint (*encode_remote_object)(void* out, GBinderRemoteObject* obj);
guint (*encode_fd_object)(void* out, int fd);
+ guint (*encode_fda_object)(void* out, const GBinderFds *fds,
+ const GBinderParent* parent);
/* Encode binder_buffer_object */
#define GBINDER_MAX_BUFFER_OBJECT_SIZE (40)
@@ -187,9 +190,11 @@
void (*decode_transaction_data)(const void* data, GBinderIoTxData* tx);
void* (*decode_ptr_cookie)(const void* data);
guint (*decode_cookie)(const void* data, guint64* cookie);
- guint (*decode_binder_handle)(const void* obj, guint32* handle);
+ guint (*decode_binder_handle)(const void* obj, guint32* handle,
+ const GBinderRpcProtocol* protocol);
guint (*decode_binder_object)(const void* data, gsize size,
- GBinderObjectRegistry* reg, GBinderRemoteObject** obj);
+ GBinderObjectRegistry* reg, GBinderRemoteObject** obj,
+ const GBinderRpcProtocol* protocol);
guint (*decode_buffer_object)(GBinderBuffer* buf, gsize offset,
GBinderIoBufferObject* out);
guint (*decode_fd_object)(const void* data, gsize size, int* fd);
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_ipc.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -58,11 +58,13 @@
#include <time.h>
typedef struct gbinder_ipc_looper GBinderIpcLooper;
+typedef GObjectClass GBinderIpcClass;
struct gbinder_ipc_priv {
GBinderIpc* self;
GThreadPool* tx_pool;
GHashTable* tx_table;
+ char* dev;
char* key;
const char* name;
GBinderObjectRegistry object_registry;
@@ -78,11 +80,12 @@
GBinderIpcLooper* blocked_loopers;
};
-typedef GObjectClass GBinderIpcClass;
+#define PARENT_CLASS gbinder_ipc_parent_class
+#define THIS_TYPE gbinder_ipc_get_type()
+#define THIS(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, THIS_TYPE, GBinderIpc)
+
+GType THIS_TYPE GBINDER_INTERNAL;
G_DEFINE_TYPE(GBinderIpc, gbinder_ipc, G_TYPE_OBJECT)
-#define GBINDER_TYPE_IPC (gbinder_ipc_get_type())
-#define GBINDER_IPC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- GBINDER_TYPE_IPC, GBinderIpc))
/*
* Binder requests are blocking, worker threads are needed in order to
@@ -207,9 +210,6 @@
GDestroyNotify fn_custom_destroy;
} GBinderIpcTxCustom;
-GBINDER_INLINE_FUNC const char* gbinder_ipc_name(GBinderIpc* self)
- { return self->priv->name; }
-
static
GBinderIpcLooper*
gbinder_ipc_looper_new(
@@ -266,6 +266,15 @@
return FALSE;
}
+static
+char*
+gbinder_ipc_make_key(
+ const char* dev,
+ const char* protocol)
+{
+ return g_strdup_printf("%s:%s", protocol, dev);
+}
+
/*==========================================================================*
* GBinderIpcLooperTx
*==========================================================================*/
@@ -1117,6 +1126,23 @@
static
void
+gbinder_ipc_invalidate_local_object_locked(
+ GBinderIpc* self,
+ GBinderLocalObject* obj)
+{
+ GBinderIpcPriv* priv = self->priv;
+
+ if (priv->local_objects && g_hash_table_remove(priv->local_objects, obj)) {
+ GVERBOSE_("%p %s", obj, gbinder_ipc_name(self));
+ if (g_hash_table_size(priv->local_objects) == 0) {
+ g_hash_table_unref(priv->local_objects);
+ priv->local_objects = NULL;
+ }
+ }
+}
+
+static
+void
gbinder_ipc_invalidate_remote_handle_locked(
GBinderIpc* self,
guint32 handle)
@@ -1141,6 +1167,20 @@
}
void
+gbinder_ipc_invalidate_local_object(
+ GBinderIpc* self,
+ GBinderLocalObject* obj)
+{
+ GBinderIpcPriv* priv = self->priv;
+
+ /* Lock */
+ g_mutex_lock(&priv->local_objects_mutex);
+ gbinder_ipc_invalidate_local_object_locked(self, obj);
+ g_mutex_unlock(&priv->local_objects_mutex);
+ /* Unlock */
+}
+
+void
gbinder_ipc_invalidate_remote_handle(
GBinderIpc* self,
guint32 handle)
@@ -1183,14 +1223,8 @@
/* Lock */
g_mutex_lock(&priv->local_objects_mutex);
- if (obj->object.ref_count == 1 && priv->local_objects) {
- if (g_hash_table_remove(priv->local_objects, obj)) {
- GVERBOSE_("%p %s", obj, gbinder_ipc_name(self));
- if (g_hash_table_size(priv->local_objects) == 0) {
- g_hash_table_unref(priv->local_objects);
- priv->local_objects = NULL;
- }
- }
+ if (g_atomic_int_get(&obj->object.ref_count) == 1) {
+ gbinder_ipc_invalidate_local_object_locked(self, obj);
}
g_mutex_unlock(&priv->local_objects_mutex);
/* Unlock */
@@ -1203,9 +1237,32 @@
{
GBinderIpcPriv* priv = self->priv;
+ /*
+ * Check of ref_count for 1 makes it possible (albeit quite unlikely)
+ * that GBinderRemoteObject still remains in remote_objects table
+ * when it's being finalized.
+ *
+ * For this to happen, other thread must re-reference GBinderRemoteObject
+ * right before we grab the lock here (making ref_count greater than 1)
+ * and then release that reference before g_object_unref() re-checks the
+ * refcount.
+ *
+ * That's why another gbinder_ipc_invalidate_remote_handle() call from
+ * gbinder_remote_object_finalize() is necessary to make sure that stale
+ * object pointer isn't stored in the hashtable.
+ *
+ * We still have to invalidate the handle here because it's the last
+ * point when GObject can be legitimately re-referenced and brought
+ * back to life. Which means that GBinderIpc mutex has to acquired
+ * twice during GBinderRemoteObject destruction.
+ *
+ * The same applies to GBinderLocalObject too, except that it calls
+ * gbinder_ipc_invalidate_local_object() from its finalize() handler.
+ */
+
/* Lock */
g_mutex_lock(&priv->remote_objects_mutex);
- if (obj->object.ref_count == 1) {
+ if (g_atomic_int_get(&obj->object.ref_count) == 1) {
gbinder_ipc_invalidate_remote_handle_locked(self, obj->handle);
}
g_mutex_unlock(&priv->remote_objects_mutex);
@@ -1250,10 +1307,10 @@
if (obj) {
gbinder_local_object_ref(obj);
} else {
- GWARN("Unknown local object %p", pointer);
+ GWARN("Unknown local object %p %s", pointer, priv->name);
}
} else {
- GWARN("Unknown local object %p", pointer);
+ GWARN("Unknown local object %p %s", pointer, priv->name);
}
g_mutex_unlock(&priv->local_objects_mutex);
/* Unlock */
@@ -1297,6 +1354,8 @@
}
GVERBOSE_("%p handle %u %s", obj, handle, gbinder_ipc_name(self));
g_hash_table_replace(priv->remote_objects, key, obj);
+ } else {
+ GWARN("Unknown handle %u %s", handle, priv->name);
}
g_mutex_unlock(&priv->remote_objects_mutex);
/* Unlock */
@@ -1794,20 +1853,25 @@
GBinderIpc*
gbinder_ipc_new(
- const char* dev)
+ const char* dev,
+ const char* protocol_name)
{
GBinderIpc* self = NULL;
- const GBinderRpcProtocol* protocol;
+ char* key;
+ const GBinderRpcProtocol* protocol = (protocol_name ?
+ gbinder_rpc_protocol_by_name(protocol_name) : NULL);
if (!dev || !dev[0]) dev = GBINDER_DEFAULT_BINDER;
- protocol = gbinder_rpc_protocol_for_device(dev); /* Never returns NULL */
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_ipc.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -100,7 +100,8 @@
GBinderIpc*
gbinder_ipc_new(
- const char* dev)
+ const char* dev,
+ const char* protocol)
GBINDER_INTERNAL;
GBinderIpc*
@@ -113,6 +114,11 @@
GBinderIpc* ipc)
GBINDER_INTERNAL;
+const char*
+gbinder_ipc_name(
+ GBinderIpc* ipc)
+ GBINDER_INTERNAL;
+
void
gbinder_ipc_looper_check(
GBinderIpc* ipc)
@@ -149,7 +155,7 @@
GBinderRemoteObject*
gbinder_ipc_get_service_manager(
- GBinderIpc* self)
+ GBinderIpc* ipc)
GBINDER_INTERNAL
G_GNUC_WARN_UNUSED_RESULT;
@@ -196,21 +202,27 @@
/* Internal for GBinderLocalObject */
void
gbinder_ipc_local_object_disposed(
- GBinderIpc* self,
+ GBinderIpc* ipc,
+ GBinderLocalObject* obj)
+ GBINDER_INTERNAL;
+
+void
+gbinder_ipc_invalidate_local_object(
+ GBinderIpc* ipc,
GBinderLocalObject* obj)
GBINDER_INTERNAL;
/* Internal for GBinderRemoteObject */
void
gbinder_ipc_remote_object_disposed(
- GBinderIpc* self,
+ GBinderIpc* ipc,
GBinderRemoteObject* obj)
GBINDER_INTERNAL;
/* Needed by unit tests */
gboolean
gbinder_ipc_set_max_threads(
- GBinderIpc* self,
+ GBinderIpc* ipc,
gint max_threads)
GBINDER_INTERNAL;
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_local_object.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -90,6 +90,15 @@
*==========================================================================*/
static
+GBinderLocalReply*
+gbinder_local_object_create_reply(
+ GBinderLocalObject* self)
+{
+ return gbinder_local_reply_new(gbinder_local_object_io(self),
+ gbinder_local_object_protocol(self));
+}
+
+static
GBINDER_LOCAL_TRANSACTION_SUPPORT
gbinder_local_object_default_can_handle_transaction(
GBinderLocalObject* self,
@@ -139,8 +148,7 @@
GBinderRemoteRequest* req,
int* status)
{
- const GBinderIo* io = gbinder_local_object_io(self);
- GBinderLocalReply* reply = gbinder_local_reply_new(io);
+ GBinderLocalReply* reply = gbinder_local_object_create_reply(self);
GVERBOSE(" PING_TRANSACTION");
gbinder_local_reply_append_int32(reply, GBINDER_STATUS_OK);
@@ -155,9 +163,8 @@
GBinderRemoteRequest* req,
int* status)
{
- const GBinderIo* io = gbinder_local_object_io(self);
GBinderLocalObjectPriv* priv = self->priv;
- GBinderLocalReply* reply = gbinder_local_reply_new(io);
+ GBinderLocalReply* reply = gbinder_local_object_create_reply(self);
GVERBOSE(" INTERFACE_TRANSACTION");
gbinder_local_reply_append_string16(reply, priv->ifaces[0]);
@@ -173,8 +180,7 @@
int* status)
{
/*android.hidl.base@1.0::IBase interfaceDescriptor() */
- const GBinderIo* io = gbinder_local_object_io(self);
- GBinderLocalReply* reply = gbinder_local_reply_new(io);
+ GBinderLocalReply* reply = gbinder_local_object_create_reply(self);
GVERBOSE(" HIDL_PING_TRANSACTION \"%s\"",
gbinder_remote_request_interface(req));
@@ -191,9 +197,8 @@
int* status)
{
/*android.hidl.base@1.0::IBase interfaceDescriptor() */
- const GBinderIo* io = gbinder_local_object_io(self);
GBinderLocalObjectPriv* priv = self->priv;
- GBinderLocalReply* reply = gbinder_local_reply_new(io);
+ GBinderLocalReply* reply = gbinder_local_object_create_reply(self);
GBinderWriter writer;
GVERBOSE(" HIDL_GET_DESCRIPTOR_TRANSACTION \"%s\"",
@@ -213,8 +218,7 @@
int* status)
{
/*android.hidl.base@1.0::IBase interfaceChain() */
- const GBinderIo* io = gbinder_local_object_io(self);
- GBinderLocalReply* reply = gbinder_local_reply_new(io);
+ GBinderLocalReply* reply = gbinder_local_object_create_reply(self);
GBinderWriter writer;
GVERBOSE(" HIDL_DESCRIPTOR_CHAIN_TRANSACTION \"%s\"",
@@ -480,7 +484,7 @@
GBinderLocalObject* self)
{
if (G_LIKELY(self)) {
- return gbinder_local_reply_new(gbinder_local_object_io(self));
+ return gbinder_local_object_create_reply(self);
}
return NULL;
}
@@ -644,6 +648,7 @@
GBinderLocalObjectPriv* priv = self->priv;
GASSERT(!self->strong_refs);
+ gbinder_ipc_invalidate_local_object(self->ipc, self);
gbinder_ipc_unref(self->ipc);
g_strfreev(priv->ifaces);
G_OBJECT_CLASS(PARENT_CLASS)->finalize(object);
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_local_object_p.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -92,6 +92,8 @@
#define gbinder_local_object_dev(obj) (gbinder_driver_dev((obj)->ipc->driver))
#define gbinder_local_object_io(obj) (gbinder_driver_io((obj)->ipc->driver))
+#define gbinder_local_object_protocol(obj) \
+ (gbinder_driver_protocol((obj)->ipc->driver))
GBinderLocalObject*
gbinder_local_object_new_with_type(
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_local_reply.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -72,10 +72,12 @@
GBinderLocalReply*
gbinder_local_reply_new(
- const GBinderIo* io)
+ const GBinderIo* io,
+ const GBinderRpcProtocol* protocol)
{
GASSERT(io);
- if (io) {
+ GASSERT(protocol);
+ if (io && protocol) {
GBinderLocalReply* self = g_slice_new0(GBinderLocalReply);
GBinderWriterData* data = &self->data;
GBinderOutputData* out = &self->out;
@@ -87,6 +89,7 @@
g_atomic_int_set(&self->refcount, 1);
data->io = io;
+ data->protocol = protocol;
out->bytes = data->bytes = g_byte_array_new();
out->f = &local_reply_output_fn;
return self;
@@ -306,6 +309,17 @@
}
return self;
}
+
+GBinderLocalReply*
+gbinder_local_reply_append_fd(
+ GBinderLocalReply* self,
+ int fd) /* Since 1.1.14 */
+{
+ if (G_LIKELY(self)) {
+ gbinder_writer_data_append_fd(&self->data, fd);
+ }
+ return self;
+}
/*
* Local Variables:
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_local_reply_p.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -39,7 +39,8 @@
GBinderLocalReply*
gbinder_local_reply_new(
- const GBinderIo* io)
+ const GBinderIo* io,
+ const GBinderRpcProtocol* protocol)
GBINDER_INTERNAL;
GBinderOutputData*
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_local_request.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -74,10 +74,12 @@
GBinderLocalRequest*
gbinder_local_request_new(
const GBinderIo* io,
+ const GBinderRpcProtocol* protocol,
GBytes* init)
{
GASSERT(io);
- if (io) {
+ GASSERT(protocol);
+ if (io && protocol) {
GBinderLocalRequest* self = g_slice_new0(GBinderLocalRequest);
GBinderWriterData* writer = &self->data;
GBinderOutputData* out = &self->out;
@@ -89,6 +91,7 @@
g_atomic_int_set(&self->refcount, 1);
writer->io = io;
+ writer->protocol = protocol;
if (init) {
gsize size;
gconstpointer data = g_bytes_get_data(init, &size);
@@ -111,9 +114,10 @@
const GBinderRpcProtocol* protocol,
const char* iface)
{
- GBinderLocalRequest* self = gbinder_local_request_new(io, NULL);
+ GBinderLocalRequest* self = gbinder_local_request_new(io, protocol, NULL);
- if (self && G_LIKELY(protocol) && G_LIKELY(iface)) {
+ /* gbinder_local_request_new() fails if protocol is NULL */
+ if (self && G_LIKELY(iface)) {
GBinderWriter writer;
gbinder_local_request_init_writer(self, &writer);
@@ -128,7 +132,7 @@
GBinderObjectConverter* convert)
{
GBinderLocalRequest* self = gbinder_local_request_new
- (gbinder_buffer_io(buffer), NULL);
+ (gbinder_buffer_io(buffer), gbinder_buffer_protocol(buffer), NULL);
if (self) {
gbinder_writer_data_append_contents(&self->data, buffer, 0, convert);
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_local_request_p.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -40,6 +40,7 @@
GBinderLocalRequest*
gbinder_local_request_new(
const GBinderIo* io,
+ const GBinderRpcProtocol* protocol,
GBytes* init)
GBINDER_INTERNAL;
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_proxy_object.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2021 Jolla Ltd.
- * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2021-2022 Jolla Ltd.
+ * Copyright (C) 2021-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -60,11 +60,9 @@
};
struct gbinder_proxy_object_priv {
- gulong remote_death_id;
+ gboolean acquired;
gboolean dropped;
GBinderProxyTx* tx;
- GMutex mutex; /* Protects the hashtable below */
- GHashTable* subproxies;
};
G_DEFINE_TYPE(GBinderProxyObject, gbinder_proxy_object, \
@@ -76,79 +74,12 @@
#define THIS_TYPE GBINDER_TYPE_PROXY_OBJECT
#define PARENT_CLASS gbinder_proxy_object_parent_class
-static
-void
-gbinder_proxy_object_subproxy_gone(
- gpointer proxy,
- GObject* subproxy)
-{
- GBinderProxyObject* self = THIS(proxy);
- GBinderProxyObjectPriv* priv = self->priv;
-
- /* Lock */
- g_mutex_lock(&priv->mutex);
- g_hash_table_remove(priv->subproxies, subproxy);
- if (g_hash_table_size(priv->subproxies) == 0) {
- g_hash_table_unref(priv->subproxies);
- priv->subproxies = NULL;
- }
- g_mutex_unlock(&priv->mutex);
- /* Unlock */
-}
-
-static
-void
-gbinder_proxy_object_drop_subproxies(
- GBinderProxyObject* self)
-{
- GBinderProxyObjectPriv* priv = self->priv;
- GSList* list = NULL;
-
- /* Lock */
- g_mutex_lock(&priv->mutex);
- if (priv->subproxies) {
- GHashTableIter it;
- gpointer value;
-
- g_hash_table_iter_init(&it, priv->subproxies);
- while (g_hash_table_iter_next(&it, NULL, &value)) {
- list = g_slist_append(list, gbinder_local_object_ref(value));
- g_object_weak_unref(G_OBJECT(value),
- gbinder_proxy_object_subproxy_gone, self);
- }
- g_hash_table_destroy(priv->subproxies);
- priv->subproxies = NULL;
- }
- g_mutex_unlock(&priv->mutex);
- /* Unlock */
-
- /* Drop (and possibly destroy) the objects outside of the lock */
- g_slist_free_full(list, (GDestroyNotify) gbinder_local_object_drop);
-}
-
-static
-void
-gbinder_proxy_remote_death_proc(
- GBinderRemoteObject* obj,
- void* proxy)
-{
- GBinderProxyObject* self = THIS(proxy);
- GBinderProxyObjectPriv* priv = self->priv;
-
- GDEBUG("Remote object %u died on %s", obj->handle, obj->ipc->dev);
- gbinder_remote_object_remove_handler(obj, priv->remote_death_id);
- priv->remote_death_id = 0;
- /* Drop the implicit reference */
- gbinder_local_object_unref(&self->parent);
-}
-
/*==========================================================================*
* Converter
*==========================================================================*/
typedef struct gbinder_proxy_object_converter {
GBinderObjectConverter pub;
- GBinderProxyObject* proxy;
GBinderIpc* remote;
GBinderIpc* local;
} GBinderProxyObjectConverter;
@@ -182,8 +113,6 @@
guint32 handle)
{
GBinderProxyObjectConverter* c = gbinder_proxy_object_converter_cast(pub);
- GBinderProxyObject* proxy = c->proxy;
- GBinderProxyObjectPriv* priv = proxy->priv;
GBinderObjectRegistry* reg = gbinder_ipc_object_registry(c->remote);
GBinderRemoteObject* remote = gbinder_object_registry_get_remote(reg,
handle, REMOTE_REGISTRY_CAN_CREATE /* but don't acquire */);
@@ -192,32 +121,7 @@
if (!local && !remote->dead) {
/* GBinderProxyObject will reference GBinderRemoteObject */
- GBinderProxyObject* subp = gbinder_proxy_object_new(c->local, remote);
-
- /*
- * Auto-created proxies may get spontaneously destroyed and
- * not necessarily on the UI thread.
- */
- subp->priv->remote_death_id = gbinder_remote_object_add_death_handler
- (remote, gbinder_proxy_remote_death_proc, subp);
-
- /*
- * Remote keeps an implicit reference to this auto-created
- * proxy. The reference gets released when the remote object
- * dies, i.e. by gbinder_proxy_remote_death_proc().
- */
- gbinder_local_object_ref(local = GBINDER_LOCAL_OBJECT(subp));
-
- /* Lock */
- g_mutex_lock(&priv->mutex);
- if (!priv->subproxies) {
- priv->subproxies = g_hash_table_new(g_direct_hash, g_direct_equal);
- }
- g_hash_table_insert(priv->subproxies, subp, subp);
- g_object_weak_ref(G_OBJECT(subp),
- gbinder_proxy_object_subproxy_gone, proxy);
- g_mutex_unlock(&priv->mutex);
- /* Unlock */
+ local = &gbinder_proxy_object_new(c->local, remote)->parent;
}
/* Release the reference returned by gbinder_object_registry_get_remote */
@@ -241,7 +145,6 @@
GBinderIpc* dest = proxy->parent.ipc;
memset(convert, 0, sizeof(*convert));
- convert->proxy = proxy;
convert->remote = remote;
convert->local = local;
pub->f = &gbinder_converter_fn;
@@ -346,7 +249,7 @@
GBinderProxyObjectPriv* priv = self->priv;
GBinderRemoteObject* remote = self->remote;
- if (!priv->dropped && !gbinder_remote_object_is_dead(remote)) {
+ if (!priv->dropped && !remote->dead) {
GBinderLocalRequest* fwd;
GBinderProxyTx* tx = g_slice_new0(GBinderProxyTx);
GBinderProxyObjectConverter convert;
@@ -374,6 +277,7 @@
gbinder_local_request_unref(fwd);
*status = GBINDER_STATUS_OK;
} else {
+ GVERBOSE_("dropped: %d dead:%d", priv->dropped, remote->dead);
*status = (-EBADMSG);
}
return NULL;
@@ -397,11 +301,11 @@
{
GBinderProxyObject* self = THIS(object);
GBinderProxyObjectPriv* priv = self->priv;
+ GBinderRemoteObject* remote = self->remote;
- if (priv->remote_death_id && !object->strong_refs) {
- GBinderRemoteObject* remote = self->remote;
-
- /* First strong ref, acquire the attached remote object */
+ if (!remote->dead && !priv->dropped && !priv->acquired) {
+ /* Not acquired yet */
+ priv->acquired = TRUE;
gbinder_driver_acquire(remote->ipc->driver, remote->handle);
}
GBINDER_LOCAL_OBJECT_CLASS(PARENT_CLASS)->acquire(object);
@@ -409,23 +313,6 @@
static
void
-gbinder_proxy_object_release(
- GBinderLocalObject* object)
-{
- GBinderProxyObject* self = THIS(object);
- GBinderProxyObjectPriv* priv = self->priv;
-
- if (priv->remote_death_id && object->strong_refs == 1) {
- GBinderRemoteObject* remote = self->remote;
-
- /* Last strong ref, release the attached remote object */
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_reader.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -14,8 +14,8 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -90,7 +90,7 @@
{
const GBinderReaderPriv* p = gbinder_reader_cast_c(reader);
- return p->ptr >= p->end;
+ return !p || p->ptr >= p->end;
}
static
@@ -139,6 +139,62 @@
}
gboolean
+gbinder_reader_read_int8(
+ GBinderReader* reader,
+ gint8* value) /* Since 1.1.15 */
+{
+ return gbinder_reader_read_uint8(reader, (guint8*)value);
+}
+
+gboolean
+gbinder_reader_read_uint8(
+ GBinderReader* reader,
+ guint8* value) /* Since 1.1.15 */
+{
+ /* Primitive values are supposed to be padded to 4-byte boundary */
+ if (value) {
+ guint32 padded;
+
+ if (gbinder_reader_read_uint32(reader, &padded)) {
+ *value = (guint8)padded;
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ } else {
+ return gbinder_reader_read_uint32(reader, NULL);
+ }
+}
+
+gboolean
+gbinder_reader_read_int16(
+ GBinderReader* reader,
+ gint16* value) /* Since 1.1.15 */
+{
+ return gbinder_reader_read_uint16(reader, (guint16*)value);
+}
+
+gboolean
+gbinder_reader_read_uint16(
+ GBinderReader* reader,
+ guint16* value) /* Since 1.1.15 */
+{
+ /* Primitive values are supposed to be padded to 4-byte boundary */
+ if (value) {
+ guint32 padded;
+
+ if (gbinder_reader_read_uint32(reader, &padded)) {
+ *value = (guint16)padded;
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ } else {
+ return gbinder_reader_read_uint32(reader, NULL);
+ }
+}
+
+gboolean
gbinder_reader_read_int32(
GBinderReader* reader,
gint32* value)
@@ -296,7 +352,8 @@
if (gbinder_reader_can_read_object(p)) {
const GBinderReaderData* data = p->data;
const guint eaten = data->reg->io->decode_binder_object(p->ptr,
- gbinder_reader_bytes_remaining(reader), data->reg, out);
+ gbinder_reader_bytes_remaining(reader), data->reg, out,
+ gbinder_buffer_protocol(data->buffer));
if (eaten) {
p->ptr += eaten;
@@ -364,6 +421,40 @@
return gbinder_reader_read_buffer_object(reader, NULL);
}
+/*
+ * This is supposed to be used to read aidl parcelables, and is not
+ * guaranteed to work on any other kind of parcelable.
+ */
+const void*
+gbinder_reader_read_parcelable(
+ GBinderReader* reader,
+ gsize* size) /* Since 1.1.19 */
+{
+ guint32 non_null, payload_size = 0;
+
+ if (gbinder_reader_read_uint32(reader, &non_null) && non_null &&
+ gbinder_reader_read_uint32(reader, &payload_size) &&
+ payload_size >= sizeof(payload_size)) {
+ GBinderReaderPriv* p = gbinder_reader_cast(reader);
+
+ payload_size -= sizeof(payload_size);
+ if (p->ptr + payload_size <= p->end) {
+ const void* out = p->ptr;
+
+ /* Success */
+ p->ptr += payload_size;
+ if (size) {
+ *size = payload_size;
+ }
+ return out;
+ }
+ }
+ if (size) {
+ *size = 0;
+ }
+ return NULL;
+}
+
/* Helper for gbinder_reader_read_hidl_struct() macro */
const void*
gbinder_reader_read_hidl_struct1(
@@ -680,13 +771,38 @@
return data;
}
+const void*
+gbinder_reader_get_data(
+ const GBinderReader* reader,
+ gsize* size) /* Since 1.1.14 */
+{
+ const GBinderReaderPriv* p = gbinder_reader_cast_c(reader);
+
+ if (p) {
+ const GBinderReaderData* data = p->data;
+
+ if (data && data->buffer) {
+ if (size) {
+ *size = data->buffer->size;
+ }
+ return data->buffer->data;
+ }
+ }
+
+ /* No data */
+ if (size) {
+ *size = 0;
+ }
+ return NULL;
+}
+
gsize
gbinder_reader_bytes_read(
const GBinderReader* reader)
{
const GBinderReaderPriv* p = gbinder_reader_cast_c(reader);
- return p->ptr - p->start;
+ return p ? (p->ptr - p->start) : 0;
}
gsize
@@ -695,7 +811,7 @@
{
const GBinderReaderPriv* p = gbinder_reader_cast_c(reader);
- return p->end - p->ptr;
+ return p ? (p->end - p->ptr) : 0;
}
void
@@ -703,8 +819,11 @@
GBinderReader* dest,
const GBinderReader* src)
{
- /* It's actually quite simple :) */
- memcpy(dest, src, sizeof(*dest));
+ if (src) {
+ memcpy(dest, src, sizeof(*dest));
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_remote_object.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -149,6 +149,7 @@
GBinderRemoteObjectPriv* priv = self->priv;
self->dead = TRUE;
+ gbinder_driver_clear_death_notification(driver, self);
if (priv->acquired) {
priv->acquired = FALSE;
/* Release the dead node */
@@ -294,6 +295,7 @@
GBinderIpc* ipc = self->ipc;
GBinderDriver* driver = ipc->driver;
+ gbinder_ipc_invalidate_remote_handle(ipc, self->handle);
if (!self->dead) {
gbinder_driver_clear_death_notification(driver, self);
}
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_remote_reply.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -131,8 +131,9 @@
GBinderObjectRegistry* reg = d->reg;
if (reg) {
- return gbinder_local_reply_set_contents
- (gbinder_local_reply_new(reg->io), d->buffer, convert);
+ return gbinder_local_reply_set_contents(gbinder_local_reply_new
+ (reg->io, gbinder_buffer_protocol(d->buffer)),
+ d->buffer, convert);
}
}
return NULL;
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_rpc_protocol.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2020 Jolla Ltd.
- * Copyright (C) 2018-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -40,6 +40,9 @@
#define BINDER_RPC_FLAGS (STRICT_MODE_PENALTY_GATHER)
#define UNSET_WORK_SOURCE (-1)
+#define BINDER_VND_HEADER GBINDER_FOURCC('V', 'N', 'D', 'R')
+#define BINDER_SYS_HEADER GBINDER_FOURCC('S', 'Y', 'S', 'T')
+
/*==========================================================================*
* GBinderIpcProtocol callbacks (see Parcel::writeInterfaceToken in Android)
* Note that there are two slightly different kinds of Parcels:
@@ -174,6 +177,61 @@
};
/*==========================================================================*
+ * AIDL protocol appeared in Android 11 (API level 30)
+ *==========================================================================*/
+
+static
+void
+gbinder_rpc_protocol_aidl3_write_rpc_header(
+ GBinderWriter* writer,
+ const char* iface)
+{
+ gbinder_writer_append_int32(writer, BINDER_RPC_FLAGS);
+ gbinder_writer_append_int32(writer, UNSET_WORK_SOURCE);
+ gbinder_writer_append_int32(writer, BINDER_SYS_HEADER);
+ gbinder_writer_append_string16(writer, iface);
+}
+
+static
+const char*
+gbinder_rpc_protocol_aidl3_read_rpc_header(
+ GBinderReader* reader,
+ guint32 txcode,
+ char** iface)
+{
+ if (txcode > GBINDER_TRANSACTION(0,0,0)) {
+ *iface = NULL;
+ } else if (gbinder_reader_read_int32(reader, NULL) /* flags */ &&
+ gbinder_reader_read_int32(reader, NULL) /* work source */ &&
+ gbinder_reader_read_int32(reader, NULL) /* sys header */) {
+ *iface = gbinder_reader_read_string16(reader);
+ } else {
+ *iface = NULL;
+ }
+
+ return *iface;
+}
+
+static
+void
+gbinder_rpc_protocol_aidl3_finish_flatten_binder(
+ void* out,
+ GBinderLocalObject* obj)
+{
+ *(guint32*)out = GBINDER_STABILITY_SYSTEM;
+}
+
+static const GBinderRpcProtocol gbinder_rpc_protocol_aidl3 = {
+ .name = "aidl3",
+ .ping_tx = GBINDER_PING_TRANSACTION,
+ .write_ping = gbinder_rpc_protocol_aidl_write_ping, /* no payload */
+ .write_rpc_header = gbinder_rpc_protocol_aidl3_write_rpc_header,
+ .read_rpc_header = gbinder_rpc_protocol_aidl3_read_rpc_header,
+ .flat_binder_object_extra = 4,
+ .finish_flatten_binder = gbinder_rpc_protocol_aidl3_finish_flatten_binder
+};
+
+/*==========================================================================*
* The original /dev/hwbinder protocol.
*==========================================================================*/
@@ -225,6 +283,7 @@
static const GBinderRpcProtocol* gbinder_rpc_protocol_list[] = {
&gbinder_rpc_protocol_aidl,
&gbinder_rpc_protocol_aidl2,
+ &gbinder_rpc_protocol_aidl3,
&gbinder_rpc_protocol_hidl
};
@@ -331,6 +390,13 @@
return gbinder_rpc_protocol_default;
}
+const GBinderRpcProtocol*
+gbinder_rpc_protocol_by_name(
+ const char* protocol_name)
+{
+ return gbinder_rpc_protocol_find(protocol_name);
+}
+
/*
* Local Variables:
* mode: C
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_rpc_protocol.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2020 Jolla Ltd.
- * Copyright (C) 2018-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -47,8 +47,24 @@
void (*write_rpc_header)(GBinderWriter* writer, const char* iface);
const char* (*read_rpc_header)(GBinderReader* reader, guint32 txcode,
char** iface);
+
+ /*
+ * For the sake of simplicity, let's assume that the trailer has a
+ * fixed size and that size is the same on both 32 and 64 bit platforms.
+ * Also note that finish_unflatten_binder() is only invoked for the
+ * remote objects that are not NULL, otherwise flat_binder_object_extra
+ * bytes are just skipped.
+ */
+ gsize flat_binder_object_extra;
+ void (*finish_flatten_binder)(void* out, GBinderLocalObject* obj);
+ void (*finish_unflatten_binder)(const void* in, GBinderRemoteObject* obj);
};
+const GBinderRpcProtocol*
+gbinder_rpc_protocol_by_name(
+ const char* protocol_name)
+ GBINDER_INTERNAL;
+
/* Returns one of the above based on the device name */
const GBinderRpcProtocol*
gbinder_rpc_protocol_for_device(
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_servicemanager.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -82,11 +82,13 @@
static const GBinderServiceManagerType gbinder_servicemanager_types[] = {
{ "aidl", gbinder_servicemanager_aidl_get_type },
{ "aidl2", gbinder_servicemanager_aidl2_get_type },
+ { "aidl3", gbinder_servicemanager_aidl3_get_type },
+ { "aidl4", gbinder_servicemanager_aidl4_get_type },
{ "hidl", gbinder_servicemanager_hidl_get_type }
};
#define SERVICEMANAGER_TYPE_AIDL (gbinder_servicemanager_types + 0)
-#define SERVICEMANAGER_TYPE_HIDL (gbinder_servicemanager_types + 2)
+#define SERVICEMANAGER_TYPE_HIDL (gbinder_servicemanager_types + 4)
#define SERVICEMANAGER_TYPE_DEFAULT SERVICEMANAGER_TYPE_AIDL
static GHashTable* gbinder_servicemanager_map = NULL;
@@ -518,7 +520,8 @@
GBinderServiceManager*
gbinder_servicemanager_new_with_type(
GType type,
- const char* dev)
+ const char* dev,
+ const char* rpc_protocol)
{
GBinderServiceManager* self = NULL;
GBinderServiceManagerClass* klass = gbinder_servicemanager_class_ref(type);
@@ -527,7 +530,7 @@
GBinderIpc* ipc;
if (!dev) dev = klass->default_device;
- ipc = gbinder_ipc_new(dev);
+ ipc = gbinder_ipc_new(dev, rpc_protocol);
if (ipc) {
/* Create a (possibly) dead service manager object */
GBinderRemoteObject* object = gbinder_ipc_get_service_manager(ipc);
@@ -619,25 +622,36 @@
gbinder_servicemanager_new(
const char* dev)
{
- if (dev) {
- const GBinderServiceManagerType* type = NULL;
+ return gbinder_servicemanager_new2(dev, NULL, NULL);
+}
- if (!gbinder_servicemanager_map) {
- const GBinderServiceManagerType* t;
+GBinderServiceManager*
+gbinder_servicemanager_new2(
+ const char* dev,
+ const char* sm_protocol,
+ const char* rpc_protocol) /* Since 1.1.20 */
+{
+ if (!dev) {
+ return NULL;
+ } else if (!sm_protocol) {
+ const GBinderServiceManagerType* type;
- /* One-time initialization */
+ /* One-time initialization */
+ if (!gbinder_servicemanager_map) {
gbinder_servicemanager_map = gbinder_servicemanager_load_config();
/* "Default" is a special value stored in a special variable */
- t = g_hash_table_lookup(gbinder_servicemanager_map, CONF_DEFAULT);
- if (t) {
+ type = g_hash_table_lookup(gbinder_servicemanager_map,
+ CONF_DEFAULT);
+ if (type) {
g_hash_table_remove(gbinder_servicemanager_map, CONF_DEFAULT);
- gbinder_servicemanager_default = t;
+ gbinder_servicemanager_default = type;
} else {
gbinder_servicemanager_default = SERVICEMANAGER_TYPE_DEFAULT;
}
}
+ /* If no protocol is specified, pick one up based on the device name */
type = g_hash_table_lookup(gbinder_servicemanager_map, dev);
if (type) {
GDEBUG("Using %s service manager for %s", type->name, dev);
@@ -645,9 +659,21 @@
type = gbinder_servicemanager_default;
GDEBUG("Using default service manager %s for %s", type->name, dev);
}
- return gbinder_servicemanager_new_with_type(type->get_type(), dev);
+ return gbinder_servicemanager_new_with_type(type->get_type(), dev,
+ rpc_protocol);
+ } else {
+ /* If protocol name is specified, it must be a valid one */
+ const GBinderServiceManagerType* type =
+ gbinder_servicemanager_value_map(sm_protocol);
+
+ if (type) {
+ return gbinder_servicemanager_new_with_type(type->get_type(), dev,
+ rpc_protocol);
+ } else {
+ GWARN("Unknown servicemanager protocol %s", sm_protocol);
+ return NULL;
+ }
}
- return NULL;
}
GBinderLocalObject*
@@ -698,6 +724,13 @@
}
}
+const char*
+gbinder_servicemanager_device(
+ GBinderServiceManager* self) /* Since 1.1.14 */
+{
+ return G_LIKELY(self) ? self->dev : NULL;
+}
+
gboolean
gbinder_servicemanager_is_present(
GBinderServiceManager* self) /* Since 1.0.25 */
@@ -1008,7 +1041,7 @@
const char* dev)
{
return gbinder_servicemanager_new_with_type
- (gbinder_servicemanager_aidl_get_type(), dev);
+ (gbinder_servicemanager_aidl_get_type(), dev, NULL);
}
GBinderServiceManager*
@@ -1016,7 +1049,7 @@
const char* dev)
{
return gbinder_servicemanager_new_with_type
- (gbinder_servicemanager_hidl_get_type(), dev);
+ (gbinder_servicemanager_hidl_get_type(), dev, NULL);
}
/*==========================================================================*
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_servicemanager_aidl.c
^
|
@@ -61,16 +61,6 @@
#define GBINDER_SERVICEMANAGER_AIDL(obj) \
G_TYPE_CHECK_INSTANCE_CAST((obj), GBINDER_TYPE_SERVICEMANAGER_AIDL, \
GBinderServiceManagerAidl)
-#define GBINDER_SERVICEMANAGER_AIDL_GET_CLASS(obj) \
- G_TYPE_INSTANCE_GET_CLASS((obj), GBINDER_TYPE_SERVICEMANAGER_AIDL, \
- GBinderServiceManagerAidlClass)
-
-enum gbinder_servicemanager_aidl_calls {
- GET_SERVICE_TRANSACTION = GBINDER_FIRST_CALL_TRANSACTION,
- CHECK_SERVICE_TRANSACTION,
- ADD_SERVICE_TRANSACTION,
- LIST_SERVICES_TRANSACTION
-};
#define SERVICEMANAGER_AIDL_IFACE "android.os.IServiceManager"
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_servicemanager_aidl.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2020 Jolla Ltd.
- * Copyright (C) 2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2020-2022 Jolla Ltd.
+ * Copyright (C) 2020-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -51,10 +51,20 @@
#define GBINDER_TYPE_SERVICEMANAGER_AIDL \
gbinder_servicemanager_aidl_get_type()
-#define GBINDER_SERVICEMANAGER_AIDL_CLASS(klass) \
- G_TYPE_CHECK_CLASS_CAST((klass), GBINDER_TYPE_SERVICEMANAGER_AIDL, \
+#define GBINDER_SERVICEMANAGER_AIDL_GET_CLASS(obj) \
+ G_TYPE_INSTANCE_GET_CLASS((obj), GBINDER_TYPE_SERVICEMANAGER_AIDL, \
GBinderServiceManagerAidlClass)
+enum gbinder_servicemanager_aidl_calls {
+ GET_SERVICE_TRANSACTION = GBINDER_FIRST_CALL_TRANSACTION,
+ CHECK_SERVICE_TRANSACTION,
+ ADD_SERVICE_TRANSACTION,
+ LIST_SERVICES_TRANSACTION
+};
+
+#define DUMP_FLAG_PRIORITY_DEFAULT (0x08)
+#define DUMP_FLAG_PRIORITY_ALL (0x0f)
+
#endif /* GBINDER_SERVICEMANAGER_AIDL_H */
/*
@@ -64,3 +74,4 @@
* indent-tabs-mode: nil
* End:
*/
+
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_servicemanager_aidl2.c
^
|
@@ -45,8 +45,6 @@
GBINDER_TYPE_SERVICEMANAGER_AIDL)
#define PARENT_CLASS gbinder_servicemanager_aidl2_parent_class
-#define DUMP_FLAG_PRIORITY_DEFAULT (0x08)
-#define DUMP_FLAG_PRIORITY_ALL (0x0f)
static
GBinderLocalRequest*
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_servicemanager_aidl3.c
^
|
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2021-2022 Jolla Ltd.
+ * Copyright (C) 2021-2022 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2021 Gary Wang <gary.wang@canonical.com>
+ * Copyright (C) 2021 Madhushan Nishantha <jlmadushan@gmail.com>
+ *
+ * You may use this file under the terms of BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "gbinder_servicemanager_aidl_p.h"
+#include "gbinder_client_p.h"
+#include "gbinder_reader_p.h"
+
+#include <gbinder_local_request.h>
+#include <gbinder_remote_reply.h>
+
+/* Variant of AIDL servicemanager appeared in Android 11 (API level 30) */
+
+typedef GBinderServiceManagerAidl GBinderServiceManagerAidl3;
+typedef GBinderServiceManagerAidlClass GBinderServiceManagerAidl3Class;
+
+G_DEFINE_TYPE(GBinderServiceManagerAidl3,
+ gbinder_servicemanager_aidl3,
+ GBINDER_TYPE_SERVICEMANAGER_AIDL)
+
+#define PARENT_CLASS gbinder_servicemanager_aidl3_parent_class
+
+GBinderRemoteObject*
+gbinder_servicemanager_aidl3_get_service(
+ GBinderServiceManager* self,
+ const char* name,
+ int* status,
+ const GBinderIpcSyncApi* api)
+{
+ GBinderClient* client = self->client;
+ GBinderLocalRequest* req = gbinder_client_new_request(client);
+ GBinderRemoteObject* obj;
+ GBinderRemoteReply* reply;
+ GBinderReader reader;
+
+ gbinder_local_request_append_string16(req, name);
+ reply = gbinder_client_transact_sync_reply2(client,
+ CHECK_SERVICE_TRANSACTION, req, status, api);
+
+ gbinder_remote_reply_init_reader(reply, &reader);
+ gbinder_reader_read_int32(&reader, NULL /* status? */);
+ obj = gbinder_reader_read_object(&reader);
+
+ gbinder_remote_reply_unref(reply);
+ gbinder_local_request_unref(req);
+ return obj;
+}
+
+char**
+gbinder_servicemanager_aidl3_list(
+ GBinderServiceManager* manager,
+ const GBinderIpcSyncApi* api)
+{
+ GPtrArray* list = g_ptr_array_new();
+ GBinderClient* client = manager->client;
+ GBinderRemoteReply* reply;
+ GBinderLocalRequest* req = gbinder_client_new_request(client);
+
+ /*
+ * Starting from Android 11, no `index` field is required but
+ * only with `dump priority` field to request to list services.
+ * As a result, a vector of strings which stands for service
+ * list is given in the binder response.
+ */
+ gbinder_local_request_append_int32(req, DUMP_FLAG_PRIORITY_ALL);
+ reply = gbinder_client_transact_sync_reply2(client,
+ LIST_SERVICES_TRANSACTION, req, NULL, api);
+
+ if (reply) {
+ GBinderReader reader;
+ gint32 count;
+
+ gbinder_remote_reply_init_reader(reply, &reader);
+ gbinder_reader_read_int32(&reader, NULL /* status */);
+ if (gbinder_reader_read_int32(&reader, &count)) {
+ int i;
+
+ /* Iterate each service name */
+ for (i = 0; i < count; i++) {
+ g_ptr_array_add(list, gbinder_reader_read_string16(&reader));
+ }
+ }
+ gbinder_remote_reply_unref(reply);
+ }
+
+ gbinder_local_request_unref(req);
+ g_ptr_array_add(list, NULL);
+ return (char**)g_ptr_array_free(list, FALSE);
+}
+
+static
+GBinderLocalRequest*
+gbinder_servicemanager_aidl3_add_service_req(
+ GBinderClient* client,
+ const char* name,
+ GBinderLocalObject* obj)
+{
+ GBinderLocalRequest* req = gbinder_client_new_request(client);
+
+ gbinder_local_request_append_string16(req, name);
+ gbinder_local_request_append_local_object(req, obj);
+ gbinder_local_request_append_int32(req, 0);
+ gbinder_local_request_append_int32(req, DUMP_FLAG_PRIORITY_DEFAULT);
+ return req;
+}
+
+static
+void
+gbinder_servicemanager_aidl3_init(
+ GBinderServiceManagerAidl3* self)
+{
+}
+
+static
+void
+gbinder_servicemanager_aidl3_class_init(
+ GBinderServiceManagerAidl3Class* klass)
+{
+ GBinderServiceManagerClass* manager = GBINDER_SERVICEMANAGER_CLASS(klass);
+
+ klass->add_service_req = gbinder_servicemanager_aidl3_add_service_req;
+ manager->list = gbinder_servicemanager_aidl3_list;
+ manager->get_service = gbinder_servicemanager_aidl3_get_service;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_servicemanager_aidl4.c
^
|
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2020-2022 Jolla Ltd.
+ * Copyright (C) 2020-2022 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2021 Gary Wang <gary.wang@canonical.com>
+ * Copyright (C) 2021 Madhushan Nishantha <jlmadushan@gmail.com>
+ *
+ * You may use this file under the terms of BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "gbinder_servicemanager_aidl_p.h"
+#include "gbinder_client_p.h"
+#include "gbinder_reader_p.h"
+
+#include <gbinder_local_request.h>
+#include <gbinder_remote_reply.h>
+
+/* Variant of AIDL servicemanager appeared in Android 12 (API level 31) */
+
+typedef GBinderServiceManagerAidl GBinderServiceManagerAidl4;
+typedef GBinderServiceManagerAidlClass GBinderServiceManagerAidl4Class;
+
+G_DEFINE_TYPE(GBinderServiceManagerAidl4,
+ gbinder_servicemanager_aidl4,
+ GBINDER_TYPE_SERVICEMANAGER_AIDL)
+
+#define PARENT_CLASS gbinder_servicemanager_aidl4_parent_class
+
+#define BINDER_WIRE_FORMAT_VERSION (1)
+
+static
+GBinderLocalRequest*
+gbinder_servicemanager_aidl4_add_service_req(
+ GBinderClient* client,
+ const char* name,
+ GBinderLocalObject* obj)
+{
+ GBinderLocalRequest* req = gbinder_client_new_request(client);
+
+ gbinder_local_request_append_string16(req, name);
+ gbinder_local_request_append_local_object(req, obj);
+
+ /*
+ * When reading nullable strong binder, from Android 12, 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
+ * }
+ *
+ * Hmmm, is that ^ really true?
+ */
+ gbinder_local_request_append_int32(req,
+ GBINDER_FOURCC(GBINDER_STABILITY_SYSTEM, 0, 0,
+ BINDER_WIRE_FORMAT_VERSION));
+ gbinder_local_request_append_int32(req, 0);
+ gbinder_local_request_append_int32(req, DUMP_FLAG_PRIORITY_DEFAULT);
+
+ return req;
+}
+
+static
+void
+gbinder_servicemanager_aidl4_init(
+ GBinderServiceManagerAidl* self)
+{
+}
+
+static
+void
+gbinder_servicemanager_aidl4_class_init(
+ GBinderServiceManagerAidl4Class* cls)
+{
+ GBinderServiceManagerClass* manager = GBINDER_SERVICEMANAGER_CLASS(cls);
+ cls->add_service_req = gbinder_servicemanager_aidl4_add_service_req;
+ manager->list = gbinder_servicemanager_aidl3_list;
+ manager->get_service = gbinder_servicemanager_aidl3_get_service;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_servicemanager_aidl_p.h
^
|
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2018-2021 Jolla Ltd.
+ * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2021 Gary Wang <gary.wang@canonical.com>
+ *
+ * You may use this file under the terms of BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GBINDER_SERVICEMANAGER_AIDL_PRIVATE_H
+#define GBINDER_SERVICEMANAGER_AIDL_PRIVATE_H
+
+#include "gbinder_servicemanager_aidl.h"
+
+char**
+gbinder_servicemanager_aidl3_list(
+ GBinderServiceManager* manager,
+ const GBinderIpcSyncApi* api)
+ GBINDER_INTERNAL;
+
+GBinderRemoteObject*
+gbinder_servicemanager_aidl3_get_service(
+ GBinderServiceManager* manager,
+ const char* name,
+ int* status,
+ const GBinderIpcSyncApi* api)
+ GBINDER_INTERNAL;
+
+#endif /* GBINDER_SERVICEMANAGER_AIDL_PRIVATE_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_servicemanager_p.h
^
|
@@ -90,7 +90,8 @@
GBinderServiceManager*
gbinder_servicemanager_new_with_type(
GType type,
- const char* dev)
+ const char* dev,
+ const char* rpc_protocol)
GBINDER_INTERNAL;
void
@@ -110,6 +111,8 @@
GType gbinder_servicemanager_aidl_get_type(void) GBINDER_INTERNAL;
GType gbinder_servicemanager_aidl2_get_type(void) GBINDER_INTERNAL;
+GType gbinder_servicemanager_aidl3_get_type(void) GBINDER_INTERNAL;
+GType gbinder_servicemanager_aidl4_get_type(void) GBINDER_INTERNAL;
GType gbinder_servicemanager_hidl_get_type(void) GBINDER_INTERNAL;
#endif /* GBINDER_SERVICEMANAGER_PRIVATE_H */
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_servicepoll.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2020 Jolla Ltd.
- * Copyright (C) 2018-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -50,10 +50,12 @@
GBinderEventLoopTimeout* timer;
};
+#define PARENT_CLASS gbinder_servicepoll_parent_class
+#define THIS_TYPE gbinder_servicepoll_get_type()
+#define THIS(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, THIS_TYPE, GBinderServicePoll)
+
+GType THIS_TYPE GBINDER_INTERNAL;
G_DEFINE_TYPE(GBinderServicePoll, gbinder_servicepoll, G_TYPE_OBJECT)
-#define GBINDER_TYPE_SERVICEPOLL (gbinder_servicepoll_get_type())
-#define GBINDER_SERVICEPOLL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- GBINDER_TYPE_SERVICEPOLL, GBinderServicePoll))
enum gbinder_servicepoll_signal {
SIGNAL_NAME_ADDED,
@@ -76,7 +78,7 @@
char** services,
void* user_data)
{
- GBinderServicePoll* self = GBINDER_SERVICEPOLL(user_data);
+ GBinderServicePoll* self = THIS(user_data);
gbinder_servicepoll_ref(self);
self->list_id = 0;
@@ -122,7 +124,7 @@
gbinder_servicepoll_timer(
gpointer user_data)
{
- GBinderServicePoll* self = GBINDER_SERVICEPOLL(user_data);
+ GBinderServicePoll* self = THIS(user_data);
if (!self->list_id) {
self->list_id = gbinder_servicemanager_list(self->manager,
@@ -136,7 +138,7 @@
gbinder_servicepoll_create(
GBinderServiceManager* manager)
{
- GBinderServicePoll* self = g_object_new(GBINDER_TYPE_SERVICEPOLL, NULL);
+ GBinderServicePoll* self = g_object_new(THIS_TYPE, NULL);
self->manager = gbinder_servicemanager_ref(manager);
self->list_id = gbinder_servicemanager_list(manager,
@@ -171,7 +173,7 @@
GBinderServicePoll* self)
{
if (G_LIKELY(self)) {
- g_object_ref(GBINDER_SERVICEPOLL(self));
+ g_object_ref(THIS(self));
return self;
} else {
return NULL;
@@ -183,7 +185,7 @@
GBinderServicePoll* self)
{
if (G_LIKELY(self)) {
- g_object_unref(GBINDER_SERVICEPOLL(self));
+ g_object_unref(THIS(self));
}
}
@@ -240,12 +242,13 @@
gbinder_servicepoll_finalize(
GObject* object)
{
- GBinderServicePoll* self = GBINDER_SERVICEPOLL(object);
+ GBinderServicePoll* self = THIS(object);
gbinder_timeout_remove(self->timer);
gbinder_servicemanager_cancel(self->manager, self->list_id);
gbinder_servicemanager_unref(self->manager);
g_strfreev(self->list);
+ G_OBJECT_CLASS(PARENT_CLASS)->finalize(object);
}
static
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_types_p.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -77,6 +77,13 @@
/* As a special case, ServiceManager's handle is zero */
#define GBINDER_SERVICEMANAGER_HANDLE (0)
+typedef enum gbinder_stability_level {
+ GBINDER_STABILITY_UNDECLARED = 0,
+ GBINDER_STABILITY_VENDOR = 0x03,
+ GBINDER_STABILITY_SYSTEM = 0x0c,
+ GBINDER_STABILITY_VINTF = 0x3f
+} GBINDER_STABILITY_LEVEL;
+
#endif /* GBINDER_TYPES_PRIVATE_H */
/*
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_writer.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -32,6 +32,7 @@
#include "gbinder_writer_p.h"
#include "gbinder_buffer_p.h"
+#include "gbinder_fmq_p.h"
#include "gbinder_local_object.h"
#include "gbinder_object_converter.h"
#include "gbinder_io.h"
@@ -51,6 +52,20 @@
GBinderWriterData* data;
} GBinderWriterPriv;
+const GBinderWriterType gbinder_writer_type_byte = { "int32", 4, NULL };
+const GBinderWriterType gbinder_writer_type_int32 = { "byte", 1, NULL };
+static const GBinderWriterField gbinder_writer_type_hidl_string_f[] = {
+ {
+ "hidl_string.data.str", 0, NULL,
+ gbinder_writer_field_hidl_string_write_buf, NULL
+ },
+ GBINDER_WRITER_FIELD_END()
+};
+const GBinderWriterType gbinder_writer_type_hidl_string = {
+ "hidl_string", sizeof(GBinderHidlString),
+ gbinder_writer_type_hidl_string_f
+};
+
G_STATIC_ASSERT(sizeof(GBinderWriter) >= sizeof(GBinderWriterPriv));
GBINDER_INLINE_FUNC GBinderWriterPriv* gbinder_writer_cast(GBinderWriter* pub)
@@ -91,6 +106,7 @@
gbinder_buffer_contents_ref(contents));
if (objects && *objects) {
const GBinderIo* io = gbinder_buffer_io(buffer);
+ const GBinderRpcProtocol* proto = gbinder_buffer_protocol(buffer);
/* GBinderIo must be the same because it's defined by the kernel */
GASSERT(io == data->io);
@@ -113,21 +129,22 @@
gutil_int_array_append(data->offsets, dest->len);
/* Convert remote object into local if necessary */
- if (convert && io->decode_binder_handle(obj, &handle) &&
+ if (convert && io->decode_binder_handle(obj, &handle, proto) &&
(local = gbinder_object_converter_handle_to_local
(convert, handle))) {
const guint pos = dest->len;
g_byte_array_set_size(dest, pos +
GBINDER_MAX_BINDER_OBJECT_SIZE);
- objsize = io->encode_local_object(dest->data + pos, local);
+ objsize = io->encode_local_object(dest->data + pos,
+ local, proto);
g_byte_array_set_size(dest, pos + objsize);
/* Keep the reference */
data->cleanup = gbinder_cleanup_add(data->cleanup,
(GDestroyNotify) gbinder_local_object_unref, local);
} else {
- objsize = io->object_size(obj);
+ objsize = io->object_size(obj, proto);
g_byte_array_append(dest, obj, objsize);
}
@@ -155,30 +172,6 @@
gutil_int_array_append(data->offsets, offset);
}
-static
-void
-gbinder_writer_data_write_buffer_object(
- GBinderWriterData* data,
- const void* ptr,
- gsize size,
- const GBinderParent* parent)
-{
- GByteArray* buf = data->bytes;
- const guint offset = buf->len;
- guint n;
-
- /* Preallocate enough space */
- g_byte_array_set_size(buf, offset + GBINDER_MAX_BUFFER_OBJECT_SIZE);
- /* Write the object */
- n = data->io->encode_buffer_object(buf->data + offset, ptr, size, parent);
- /* Fix the data size */
- g_byte_array_set_size(buf, offset + n);
- /* Record the offset */
- gbinder_writer_data_record_offset(data, offset);
- /* The driver seems to require each buffer to be 8-byte aligned */
- data->buffers_size += G_ALIGN8(size);
-}
-
void
gbinder_writer_init(
GBinderWriter* self,
@@ -188,12 +181,35 @@
gbinder_writer_cast(self)->data = data;
}
+const void*
+gbinder_writer_get_data(
+ GBinderWriter* self,
+ gsize* size) /* Since 1.1.14 */
+{
+ GBinderWriterData* data = gbinder_writer_data(self);
+
+ if (G_LIKELY(data)) {
+ GByteArray* buf = data->bytes;
+
+ if (size) {
+ *size = buf->len;
+ }
+ return buf->data;
+ } else {
+ if (size) {
+ *size = 0;
+ }
+ return NULL;
+ }
+}
+
gsize
gbinder_writer_bytes_written(
GBinderWriter* self) /* since 1.0.21 */
{
GBinderWriterData* data = gbinder_writer_data(self);
- return data->bytes->len;
+
+ return G_LIKELY(data) ? data->bytes->len : 0;
}
void
@@ -213,12 +229,34 @@
GBinderWriterData* data,
gboolean value)
{
- guint8 padded[4];
+ /* Primitive values are padded to 4-byte boundary */
+ gbinder_writer_data_append_int32(data, value != FALSE);
+}
+
+void
+gbinder_writer_append_int8(
+ GBinderWriter* self,
+ guint8 value) /* Since 1.1.15 */
+{
+ GBinderWriterData* data = gbinder_writer_data(self);
- /* Boolean values are padded to 4-byte boundary */
- padded[0] = (value != FALSE);
- padded[1] = padded[2] = padded[3] = 0;
- g_byte_array_append(data->bytes, padded, sizeof(padded));
+ if (G_LIKELY(data)) {
+ /* Primitive values are padded to 4-byte boundary */
+ gbinder_writer_data_append_int32(data, value);
+ }
+}
+
+void
+gbinder_writer_append_int16(
+ GBinderWriter* self,
+ guint16 value) /* Since 1.1.15 */
+{
+ GBinderWriterData* data = gbinder_writer_data(self);
+
+ if (G_LIKELY(data)) {
+ /* Primitive values are padded to 4-byte boundary */
+ gbinder_writer_data_append_int32(data, value);
+ }
}
void
@@ -582,17 +620,6 @@
}
static
-guint
-gbinder_writer_data_prepare(
- GBinderWriterData* data)
-{
- if (!data->offsets) {
- data->offsets = gutil_int_array_new();
- }
- return data->offsets->count;
-}
-
-static
void
gbinder_writer_data_close_fd(
gpointer data)
@@ -604,7 +631,6 @@
}
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/src/gbinder_writer_p.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -39,6 +39,7 @@
typedef struct gbinder_writer_data {
const GBinderIo* io;
+ const GBinderRpcProtocol* protocol;
GByteArray* bytes;
GUtilIntArray* offsets;
gsize buffers_size;
@@ -131,6 +132,13 @@
GBINDER_INTERNAL;
void
+gbinder_writer_data_append_parcelable(
+ GBinderWriterData* data,
+ const void* ptr,
+ gsize size)
+ GBINDER_INTERNAL;
+
+void
gbinder_writer_data_append_hidl_vec(
GBinderWriterData* data,
const void* base,
@@ -163,6 +171,12 @@
GBinderRemoteObject* obj)
GBINDER_INTERNAL;
+void
+gbinder_writer_data_append_fd(
+ GBinderWriterData* data,
+ int fd)
+ GBINDER_INTERNAL;
+
#endif /* GBINDER_WRITER_PRIVATE_H */
/*
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.30.tar.bz2/test/ashmem-test/Makefile
^
|
@@ -0,0 +1,5 @@
+# -*- Mode: makefile-gmake -*-
+
+EXE = ashmem-test
+
+include ../common/Makefile
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.30.tar.bz2/test/ashmem-test/ashmem-test.c
^
|
@@ -0,0 +1,260 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <gbinder.h>
+
+#include <gutil_misc.h>
+#include <gutil_log.h>
+
+#include <sys/mman.h>
+
+#define RET_OK (0)
+#define RET_NOTFOUND (1)
+#define RET_INVARG (2)
+#define RET_ERR (3)
+
+#define DEFAULT_BINDER GBINDER_DEFAULT_HWBINDER
+#define ALLOCATOR_IFACE "android.hidl.allocator@1.0::IAllocator"
+#define DEFAULT_FQNAME ALLOCATOR_IFACE "/ashmem"
+#define TX_ALLOCATE GBINDER_FIRST_CALL_TRANSACTION
+
+typedef struct app_options {
+ const char* fqname;
+ char* dev;
+ gsize size;
+} AppOptions;
+
+static
+void
+app_dumpmem(
+ const GBinderHidlMemory* mem)
+{
+ const GBinderFds* fds = mem->data.fds;
+
+ GDEBUG("Name: %s", mem->name.data.str);
+ GDEBUG("Size: %" G_GUINT64_FORMAT " bytes", mem->size);
+
+ GASSERT(fds->version == GBINDER_HIDL_FDS_VERSION);
+ GDEBUG("Contains %u fd(s)", fds->num_fds);
+ if (fds->num_fds) {
+ guint i;
+
+ for (i = 0; i < fds->num_fds; i++) {
+ int fd = gbinder_fds_get_fd(fds, i);
+ guint8* ptr = mmap(NULL, mem->size, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, 0);
+
+ if (ptr) {
+ gsize off = 0;
+
+ GDEBUG("fd %d => %p", fd, ptr);
+ while (off < mem->size) {
+ char line[GUTIL_HEXDUMP_BUFSIZE];
+ guint n = gutil_hexdump(line, ptr + off, mem->size - off);
+
+ GDEBUG("%04X: %s", (uint) off, line);
+ off += n;
+ }
+ munmap(ptr, mem->size);
+ } else {
+ GDEBUG("fd %d", fd);
+ }
+ }
+ }
+}
+
+static
+int
+app_allocate(
+ const AppOptions* opt,
+ GBinderClient* client)
+{
+ GBinderLocalRequest* request = gbinder_client_new_request(client);
+ GBinderRemoteReply* reply;
+ int status, ret;
+
+ gbinder_local_request_append_int64(request, opt->size);
+ reply = gbinder_client_transact_sync_reply(client, TX_ALLOCATE,
+ request, &status);
+
+ if (reply) {
+ GBinderReader reader;
+ gint32 tx_status;
+ gboolean success;
+
+ gbinder_remote_reply_init_reader(reply, &reader);
+ if (gbinder_reader_read_int32(&reader, &tx_status) &&
+ gbinder_reader_read_bool(&reader, &success) &&
+ tx_status == GBINDER_STATUS_OK &&
+ success) {
+ const GBinderHidlMemory* mem = gbinder_reader_read_hidl_struct
+ (&reader, GBinderHidlMemory);
+
+ if (mem) {
+ GINFO("OK");
+ app_dumpmem(mem);
+ } else {
+ GINFO("OOPS");
+ }
+ } else {
+ GINFO("FAILED");
+ }
+ ret = RET_OK;
+ } else {
+ GERR("Call failed (%d)", status);
+ ret = RET_ERR;
+ }
+
+ gbinder_local_request_unref(request);
+ gbinder_remote_reply_unref(reply);
+ return ret;
+}
+
+static
+int
+app_run(
+ const AppOptions* opt)
+{
+ int ret = RET_NOTFOUND;
+ GBinderServiceManager* sm = gbinder_servicemanager_new(opt->dev);
+
+ if (sm) {
+ int status = 0;
+ GBinderRemoteObject* remote = gbinder_servicemanager_get_service_sync
+ (sm, opt->fqname, &status);
+
+ if (remote) {
+ GBinderClient* client = gbinder_client_new(remote, ALLOCATOR_IFACE);
+
+ ret = app_allocate(opt, client);
+ gbinder_client_unref(client);
+ } else {
+ GERR("%s not found", opt->fqname);
+ }
+ gbinder_servicemanager_unref(sm);
+ } else {
+ GERR("No servicemanager at %s", opt->dev);
+ }
+ return ret;
+}
+
+static
+gboolean
+app_log_verbose(
+ const gchar* name,
+ const gchar* value,
+ gpointer data,
+ GError** error)
+{
+ gutil_log_default.level = GLOG_LEVEL_VERBOSE;
+ return TRUE;
+}
+
+static
+gboolean
+app_log_quiet(
+ const gchar* name,
+ const gchar* value,
+ gpointer data,
+ GError** error)
+{
+ gutil_log_default.level = GLOG_LEVEL_NONE;
+ return TRUE;
+}
+
+static
+gboolean
+app_init(
+ AppOptions* opt,
+ int argc,
+ char* argv[])
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/test/binder-bridge/Makefile
^
|
@@ -1,154 +1,5 @@
# -*- Mode: makefile-gmake -*-
-.PHONY: all debug release clean cleaner
-.PHONY: libgbinder-release libgbinder-debug
-
-#
-# Required packages
-#
-
-PKGS = glib-2.0 gio-2.0 gio-unix-2.0 libglibutil
-
-#
-# Default target
-#
-
-all: debug release
-
-#
-# Executable
-#
-
EXE = binder-bridge
-#
-# Sources
-#
-
-SRC = $(EXE).c
-
-#
-# Directories
-#
-
-SRC_DIR = .
-BUILD_DIR = build
-LIB_DIR = ../..
-DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
-RELEASE_BUILD_DIR = $(BUILD_DIR)/release
-
-#
-# Tools and flags
-#
-
-CC ?= $(CROSS_COMPILE)gcc
-LD = $(CC)
-WARNINGS = -Wall
-INCLUDES = -I$(LIB_DIR)/include
-BASE_FLAGS = -fPIC
-CFLAGS = $(BASE_FLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
- $(shell pkg-config --cflags $(PKGS))
-LDFLAGS = $(BASE_FLAGS) $(shell pkg-config --libs $(PKGS))
-QUIET_MAKE = make --no-print-directory
-DEBUG_FLAGS = -g
-RELEASE_FLAGS =
-
-ifndef KEEP_SYMBOLS
-KEEP_SYMBOLS = 0
-endif
-
-ifneq ($(KEEP_SYMBOLS),0)
-RELEASE_FLAGS += -g
-SUBMAKE_OPTS += KEEP_SYMBOLS=1
-endif
-
-DEBUG_LDFLAGS = $(LDFLAGS) $(DEBUG_FLAGS)
-RELEASE_LDFLAGS = $(LDFLAGS) $(RELEASE_FLAGS)
-DEBUG_CFLAGS = $(CFLAGS) $(DEBUG_FLAGS) -DDEBUG
-RELEASE_CFLAGS = $(CFLAGS) $(RELEASE_FLAGS) -O2
-
-#
-# Files
-#
-
-DEBUG_OBJS = $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
-RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
-DEBUG_SO_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_so)
-RELEASE_SO_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_so)
-DEBUG_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_link)
-RELEASE_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_link)
-DEBUG_SO = $(LIB_DIR)/$(DEBUG_SO_FILE)
-RELEASE_SO = $(LIB_DIR)/$(RELEASE_SO_FILE)
-
-#
-# Dependencies
-#
-
-DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
-ifneq ($(MAKECMDGOALS),clean)
-ifneq ($(strip $(DEPS)),)
--include $(DEPS)
-endif
-endif
-
-$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
-$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
-
-#
-# Rules
-#
-
-DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
-RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
-
-debug: libgbinder-debug $(DEBUG_EXE)
-
-release: libgbinder-release $(RELEASE_EXE)
-
-clean:
- rm -f *~
- rm -fr $(BUILD_DIR)
-
-cleaner: clean
- @make -C $(LIB_DIR) clean
-
-$(DEBUG_BUILD_DIR):
- mkdir -p $@
-
-$(RELEASE_BUILD_DIR):
- mkdir -p $@
-
-$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(DEBUG_EXE): $(DEBUG_SO) $(DEBUG_BUILD_DIR) $(DEBUG_OBJS)
- $(LD) $(DEBUG_OBJS) $(DEBUG_LDFLAGS) $< -o $@
-
-$(RELEASE_EXE): $(RELEASE_SO) $(RELEASE_BUILD_DIR) $(RELEASE_OBJS)
- $(LD) $(RELEASE_OBJS) $(RELEASE_LDFLAGS) $< -o $@
-ifeq ($(KEEP_SYMBOLS),0)
- strip $@
-endif
-
-libgbinder-debug:
- @make $(SUBMAKE_OPTS) -C $(LIB_DIR) $(DEBUG_SO_FILE) $(DEBUG_LINK_FILE)
-
-libgbinder-release:
- @make $(SUBMAKE_OPTS) -C $(LIB_DIR) $(RELEASE_SO_FILE) $(RELEASE_LINK_FILE)
-
-#
-# Install
-#
-
-INSTALL = install
-
-INSTALL_BIN_DIR = $(DESTDIR)/usr/bin
-
-install: release $(INSTALL_BIN_DIR)
- $(INSTALL) -m 755 $(RELEASE_EXE) $(INSTALL_BIN_DIR)
-
-$(INSTALL_BIN_DIR):
- $(INSTALL) -d $@
+include ../common/Makefile
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/test/binder-call/Makefile
^
|
@@ -49,10 +49,9 @@
LD = $(CC)
WARNINGS = -Wall
INCLUDES = -I$(LIB_DIR)/include -I$(GEN_DIR) -I$(SRC_DIR)
-BASE_FLAGS = -fPIC
-CFLAGS = $(BASE_FLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
+CFLAGS += -fPIC $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
$(shell pkg-config --cflags $(PKGS))
-LDFLAGS = $(BASE_FLAGS) $(shell pkg-config --libs $(PKGS))
+LDFLAGS += -pie $(shell pkg-config --libs $(PKGS))
QUIET_MAKE = make --no-print-directory
DEBUG_FLAGS = -g
RELEASE_FLAGS =
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/test/binder-call/binder-call.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021-2022 Jolla Ltd.
* Copyright (C) 2021 Franz-Josef Haider <franz.haider@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -80,9 +80,11 @@
switch(v->type) {
case INT8_TYPE:
- if (cur_pass == BUILD_TRANSACTION) GDEBUG("int8");
+ if (cur_pass == BUILD_TRANSACTION) {
+ GDEBUG("int8 %u", (guint)(*((guint8*)v->value)));
+ }
if (parent_idx == -1) {
- gbinder_writer_append_int32(&app->writer, *((int*)v->value));
+ gbinder_writer_append_int8(&app->writer, *((guint8*)v->value));
} else if (cur_pass == FILL_BUFFERS) {
*((unsigned char*)(((char*)buf)+offset)) =
*((unsigned char*)v->value);
@@ -91,7 +93,9 @@
break;
case INT32_TYPE:
- if (cur_pass == BUILD_TRANSACTION) GDEBUG("int32");
+ if (cur_pass == BUILD_TRANSACTION) {
+ GDEBUG("int32 %d", *((int*)v->value));
+ }
if (parent_idx == -1) {
gbinder_writer_append_int32(&app->writer, *((int*)v->value));
} else if (cur_pass == FILL_BUFFERS) {
@@ -101,7 +105,9 @@
break;
case INT64_TYPE:
- if (cur_pass == BUILD_TRANSACTION) GDEBUG("int64");
+ if (cur_pass == BUILD_TRANSACTION) {
+ GDEBUG("int64 %" G_GINT64_MODIFIER "d", *((gint64*)v->value));
+ }
if (parent_idx == -1) {
gbinder_writer_append_int64(&app->writer, *((gint64*)v->value));
} else if (cur_pass == FILL_BUFFERS) {
@@ -111,7 +117,9 @@
break;
case FLOAT_TYPE:
- if (cur_pass == BUILD_TRANSACTION) GDEBUG("float");
+ if (cur_pass == BUILD_TRANSACTION) {
+ GDEBUG("float %g", (double)*((float*)v->value));
+ }
if (parent_idx == -1) {
gbinder_writer_append_float(&app->writer, *((float*)v->value));
} else if (cur_pass == FILL_BUFFERS) {
@@ -120,7 +128,9 @@
offset += sizeof(float);
break;
case DOUBLE_TYPE:
- if (cur_pass == BUILD_TRANSACTION) GDEBUG("double");
+ if (cur_pass == BUILD_TRANSACTION) {
+ GDEBUG("double %g", *((double*)v->value));
+ }
if (parent_idx == -1) {
gbinder_writer_append_double(&app->writer,*((double*)v->value));
} else if (cur_pass == FILL_BUFFERS) {
@@ -130,7 +140,9 @@
break;
case STRING8_TYPE:
- if (cur_pass == BUILD_TRANSACTION) GDEBUG("string8");
+ if (cur_pass == BUILD_TRANSACTION) {
+ GDEBUG("string8 %s", (char*)v->value);
+ }
gbinder_writer_append_string8(&app->writer, v->value);
/* offset not incremented since it only makes sense for hidl */
break;
@@ -579,7 +591,7 @@
App* app)
{
const AppOptions* opt = app->opt;
- char* iface = opt->iface ? g_strdup(opt->iface) : NULL;
+ char* iface;
int status = 0;
int rargc = 1;
char* service = opt->argv[rargc++];
@@ -598,7 +610,6 @@
service, &status);
if (!obj) {
GERR("No such service: %s", service);
- g_free(iface);
return;
}
@@ -764,14 +775,34 @@
gutil_log_default.level = GLOG_LEVEL_DEFAULT;
if (g_option_context_parse(options, &argc, &argv, &error)) {
- char* help;
+ int i;
+ /*
+ * Remove the "--" argument. If any of our arguments is a negative
+ * number, the user will have to add the "--" flag to stop the parser.
+ * But "--" is still passed to us and we have to ignore it.
+ */
+ for (i = 1; i < argc; i++) {
+ if (!strcmp(argv[i], "--")) {
+ if (i < (argc - 1)) {
+ memmove(argv + i, argv + (i + 1),
+ sizeof(char*) * (argc - i - 1));
+ }
+ i--;
+ argc--;
+
+ /*
+ * There's no need to have more than one "--", but let's
+ * remove any number of those.
+ */
+ }
+ }
if (argc > 2) {
opt->argc = argc;
opt->argv = argv;
ok = TRUE;
} else {
- help = g_option_context_get_help(options, TRUE, NULL);
+ char* help = g_option_context_get_help(options, TRUE, NULL);
fprintf(stderr, "%s", help);
g_free(help);
}
@@ -800,7 +831,6 @@
GERR("servicemanager seems to be missing");
}
}
- g_free(opt.iface);
g_free(opt.dev);
return app.ret;
}
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/test/binder-call/binder-call.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021-2022 Jolla Ltd.
*
* You may use this file under the terms of BSD license as follows:
*
@@ -36,7 +36,6 @@
typedef struct app_options {
char* dev;
- char* iface;
gboolean oneway;
gboolean aidl;
gint transaction;
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/test/binder-call/cmdline.l
^
|
@@ -55,11 +55,11 @@
"}" { return('}'); }
"[" { return('['); }
"]" { return(']'); }
-{D}*{INT8_SUFFIX} { cmdlinelval.int8_value = atoi(yytext); return(INT8_VALUE); }
-{D}*{INT64_SUFFIX} { cmdlinelval.int64_value = atol(yytext); return(INT64_VALUE); }
-{D}* { cmdlinelval.int32_value = atoi(yytext); return(INT32_VALUE); }
-{D}+"."{D}*{INT64_SUFFIX} { cmdlinelval.double_value = atof(yytext); return(DOUBLE_VALUE); }
-{D}+"."{D}* { cmdlinelval.float_value = atof(yytext); return(FLOAT_VALUE); }
+-?{D}+{INT8_SUFFIX} { cmdlinelval.int8_value = atoi(yytext); return(INT8_VALUE); }
+-?{D}+{INT64_SUFFIX} { cmdlinelval.int64_value = atol(yytext); return(INT64_VALUE); }
+-?{D}+ { cmdlinelval.int32_value = atoi(yytext); return(INT32_VALUE); }
+-?{D}+"."{D}*{INT64_SUFFIX} { cmdlinelval.double_value = atof(yytext); return(DOUBLE_VALUE); }
+-?{D}+"."{D}* { cmdlinelval.float_value = atof(yytext); return(FLOAT_VALUE); }
"reply" { return(REPLY); }
\".*\"{HSTRING_SUFFIX} { cmdlinelval.hstring_value = handle_str(yytext); return(HSTRING_VALUE); }
\".*\"{UTF16_SUFFIX} { cmdlinelval.string16_value = handle_str(yytext); return(STRING16_VALUE); }
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/test/binder-client/Makefile
^
|
@@ -1,140 +1,5 @@
# -*- Mode: makefile-gmake -*-
-.PHONY: all debug release clean cleaner
-.PHONY: libgbinder-release libgbinder-debug
-
-#
-# Required packages
-#
-
-PKGS = glib-2.0 gio-2.0 gio-unix-2.0 libglibutil
-
-#
-# Default target
-#
-
-all: debug release
-
-#
-# Executable
-#
-
EXE = binder-client
-#
-# Sources
-#
-
-SRC = $(EXE).c
-
-#
-# Directories
-#
-
-SRC_DIR = .
-BUILD_DIR = build
-LIB_DIR = ../..
-DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
-RELEASE_BUILD_DIR = $(BUILD_DIR)/release
-
-#
-# Tools and flags
-#
-
-CC ?= $(CROSS_COMPILE)gcc
-LD = $(CC)
-WARNINGS = -Wall
-INCLUDES = -I$(LIB_DIR)/include
-BASE_FLAGS = -fPIC
-CFLAGS = $(BASE_FLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
- $(shell pkg-config --cflags $(PKGS))
-LDFLAGS = $(BASE_FLAGS) $(shell pkg-config --libs $(PKGS))
-QUIET_MAKE = make --no-print-directory
-DEBUG_FLAGS = -g
-RELEASE_FLAGS =
-
-ifndef KEEP_SYMBOLS
-KEEP_SYMBOLS = 0
-endif
-
-ifneq ($(KEEP_SYMBOLS),0)
-RELEASE_FLAGS += -g
-SUBMAKE_OPTS += KEEP_SYMBOLS=1
-endif
-
-DEBUG_LDFLAGS = $(LDFLAGS) $(DEBUG_FLAGS)
-RELEASE_LDFLAGS = $(LDFLAGS) $(RELEASE_FLAGS)
-DEBUG_CFLAGS = $(CFLAGS) $(DEBUG_FLAGS) -DDEBUG
-RELEASE_CFLAGS = $(CFLAGS) $(RELEASE_FLAGS) -O2
-
-#
-# Files
-#
-
-DEBUG_OBJS = $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
-RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
-DEBUG_SO_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_so)
-RELEASE_SO_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_so)
-DEBUG_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_link)
-RELEASE_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_link)
-DEBUG_SO = $(LIB_DIR)/$(DEBUG_SO_FILE)
-RELEASE_SO = $(LIB_DIR)/$(RELEASE_SO_FILE)
-
-#
-# Dependencies
-#
-
-DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
-ifneq ($(MAKECMDGOALS),clean)
-ifneq ($(strip $(DEPS)),)
--include $(DEPS)
-endif
-endif
-
-$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
-$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
-
-#
-# Rules
-#
-
-DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
-RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
-
-debug: libgbinder-debug $(DEBUG_EXE)
-
-release: libgbinder-release $(RELEASE_EXE)
-
-clean:
- rm -f *~
- rm -fr $(BUILD_DIR)
-
-cleaner: clean
- @make -C $(LIB_DIR) clean
-
-$(DEBUG_BUILD_DIR):
- mkdir -p $@
-
-$(RELEASE_BUILD_DIR):
- mkdir -p $@
-
-$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(DEBUG_EXE): $(DEBUG_SO) $(DEBUG_BUILD_DIR) $(DEBUG_OBJS)
- $(LD) $(DEBUG_OBJS) $(DEBUG_LDFLAGS) $< -o $@
-
-$(RELEASE_EXE): $(RELEASE_SO) $(RELEASE_BUILD_DIR) $(RELEASE_OBJS)
- $(LD) $(RELEASE_OBJS) $(RELEASE_LDFLAGS) $< -o $@
-ifeq ($(KEEP_SYMBOLS),0)
- strip $@
-endif
-
-libgbinder-debug:
- @make $(SUBMAKE_OPTS) -C $(LIB_DIR) $(DEBUG_SO_FILE) $(DEBUG_LINK_FILE)
-
-libgbinder-release:
- @make $(SUBMAKE_OPTS) -C $(LIB_DIR) $(RELEASE_SO_FILE) $(RELEASE_LINK_FILE)
+include ../common/Makefile
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/test/binder-dump/Makefile
^
|
@@ -1,140 +1,5 @@
# -*- Mode: makefile-gmake -*-
-.PHONY: all debug release clean cleaner
-.PHONY: libgbinder-release libgbinder-debug
-
-#
-# Required packages
-#
-
-PKGS = glib-2.0 gio-2.0 gio-unix-2.0 libglibutil
-
-#
-# Default target
-#
-
-all: debug release
-
-#
-# Executable
-#
-
EXE = binder-dump
-#
-# Sources
-#
-
-SRC = $(EXE).c
-
-#
-# Directories
-#
-
-SRC_DIR = .
-BUILD_DIR = build
-LIB_DIR = ../..
-DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
-RELEASE_BUILD_DIR = $(BUILD_DIR)/release
-
-#
-# Tools and flags
-#
-
-CC ?= $(CROSS_COMPILE)gcc
-LD = $(CC)
-WARNINGS = -Wall
-INCLUDES = -I$(LIB_DIR)/include
-BASE_FLAGS = -fPIC
-CFLAGS = $(BASE_FLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
- $(shell pkg-config --cflags $(PKGS))
-LDFLAGS = $(BASE_FLAGS) $(shell pkg-config --libs $(PKGS))
-QUIET_MAKE = make --no-print-directory
-DEBUG_FLAGS = -g
-RELEASE_FLAGS =
-
-ifndef KEEP_SYMBOLS
-KEEP_SYMBOLS = 0
-endif
-
-ifneq ($(KEEP_SYMBOLS),0)
-RELEASE_FLAGS += -g
-SUBMAKE_OPTS += KEEP_SYMBOLS=1
-endif
-
-DEBUG_LDFLAGS = $(LDFLAGS) $(DEBUG_FLAGS)
-RELEASE_LDFLAGS = $(LDFLAGS) $(RELEASE_FLAGS)
-DEBUG_CFLAGS = $(CFLAGS) $(DEBUG_FLAGS) -DDEBUG
-RELEASE_CFLAGS = $(CFLAGS) $(RELEASE_FLAGS) -O2
-
-#
-# Files
-#
-
-DEBUG_OBJS = $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
-RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
-DEBUG_SO_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_so)
-RELEASE_SO_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_so)
-DEBUG_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_link)
-RELEASE_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_link)
-DEBUG_SO = $(LIB_DIR)/$(DEBUG_SO_FILE)
-RELEASE_SO = $(LIB_DIR)/$(RELEASE_SO_FILE)
-
-#
-# Dependencies
-#
-
-DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
-ifneq ($(MAKECMDGOALS),clean)
-ifneq ($(strip $(DEPS)),)
--include $(DEPS)
-endif
-endif
-
-$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
-$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
-
-#
-# Rules
-#
-
-DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
-RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
-
-debug: libgbinder-debug $(DEBUG_EXE)
-
-release: libgbinder-release $(RELEASE_EXE)
-
-clean:
- rm -f *~
- rm -fr $(BUILD_DIR)
-
-cleaner: clean
- @make -C $(LIB_DIR) clean
-
-$(DEBUG_BUILD_DIR):
- mkdir -p $@
-
-$(RELEASE_BUILD_DIR):
- mkdir -p $@
-
-$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(DEBUG_EXE): $(DEBUG_SO) $(DEBUG_BUILD_DIR) $(DEBUG_OBJS)
- $(LD) $(DEBUG_OBJS) $(DEBUG_LDFLAGS) $< -o $@
-
-$(RELEASE_EXE): $(RELEASE_SO) $(RELEASE_BUILD_DIR) $(RELEASE_OBJS)
- $(LD) $(RELEASE_OBJS) $(RELEASE_LDFLAGS) $< -o $@
-ifeq ($(KEEP_SYMBOLS),0)
- strip $@
-endif
-
-libgbinder-debug:
- @make $(SUBMAKE_OPTS) -C $(LIB_DIR) $(DEBUG_SO_FILE) $(DEBUG_LINK_FILE)
-
-libgbinder-release:
- @make $(SUBMAKE_OPTS) -C $(LIB_DIR) $(RELEASE_SO_FILE) $(RELEASE_LINK_FILE)
+include ../common/Makefile
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/test/binder-dump/binder-dump.c
^
|
@@ -171,6 +171,8 @@
app_log_verbose, "Enable verbose output", NULL },
{ "quiet", 'q', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
app_log_quiet, "Be quiet", NULL },
+ { "device", 'd', 0, G_OPTION_ARG_STRING, &opt->dev,
+ "Binder device [" DEV_DEFAULT "]", "DEVICE" },
{ NULL }
};
@@ -187,7 +189,7 @@
if (g_option_context_parse(options, &argc, &argv, &error)) {
char* help;
- opt->dev = g_strdup(DEV_DEFAULT);
+ if (!opt->dev || !opt->dev[0]) opt->dev = g_strdup(DEV_DEFAULT);
switch (argc) {
case 2:
opt->service = argv[1];
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/test/binder-list/Makefile
^
|
@@ -1,154 +1,5 @@
# -*- Mode: makefile-gmake -*-
-.PHONY: all debug release clean cleaner
-.PHONY: libgbinder-release libgbinder-debug
-
-#
-# Required packages
-#
-
-PKGS = glib-2.0 gio-2.0 gio-unix-2.0 libglibutil
-
-#
-# Default target
-#
-
-all: debug release
-
-#
-# Executable
-#
-
EXE = binder-list
-#
-# Sources
-#
-
-SRC = $(EXE).c
-
-#
-# Directories
-#
-
-SRC_DIR = .
-BUILD_DIR = build
-LIB_DIR = ../..
-DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
-RELEASE_BUILD_DIR = $(BUILD_DIR)/release
-
-#
-# Tools and flags
-#
-
-CC ?= $(CROSS_COMPILE)gcc
-LD = $(CC)
-WARNINGS = -Wall
-INCLUDES = -I$(LIB_DIR)/include
-BASE_FLAGS = -fPIC
-CFLAGS = $(BASE_FLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
- $(shell pkg-config --cflags $(PKGS))
-LDFLAGS = $(BASE_FLAGS) $(shell pkg-config --libs $(PKGS))
-QUIET_MAKE = make --no-print-directory
-DEBUG_FLAGS = -g
-RELEASE_FLAGS =
-
-ifndef KEEP_SYMBOLS
-KEEP_SYMBOLS = 0
-endif
-
-ifneq ($(KEEP_SYMBOLS),0)
-RELEASE_FLAGS += -g
-SUBMAKE_OPTS += KEEP_SYMBOLS=1
-endif
-
-DEBUG_LDFLAGS = $(LDFLAGS) $(DEBUG_FLAGS)
-RELEASE_LDFLAGS = $(LDFLAGS) $(RELEASE_FLAGS)
-DEBUG_CFLAGS = $(CFLAGS) $(DEBUG_FLAGS) -DDEBUG
-RELEASE_CFLAGS = $(CFLAGS) $(RELEASE_FLAGS) -O2
-
-#
-# Files
-#
-
-DEBUG_OBJS = $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
-RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
-DEBUG_SO_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_so)
-RELEASE_SO_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_so)
-DEBUG_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_link)
-RELEASE_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_link)
-DEBUG_SO = $(LIB_DIR)/$(DEBUG_SO_FILE)
-RELEASE_SO = $(LIB_DIR)/$(RELEASE_SO_FILE)
-
-#
-# Dependencies
-#
-
-DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
-ifneq ($(MAKECMDGOALS),clean)
-ifneq ($(strip $(DEPS)),)
--include $(DEPS)
-endif
-endif
-
-$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
-$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
-
-#
-# Rules
-#
-
-DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
-RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
-
-debug: libgbinder-debug $(DEBUG_EXE)
-
-release: libgbinder-release $(RELEASE_EXE)
-
-clean:
- rm -f *~
- rm -fr $(BUILD_DIR)
-
-cleaner: clean
- @make -C $(LIB_DIR) clean
-
-$(DEBUG_BUILD_DIR):
- mkdir -p $@
-
-$(RELEASE_BUILD_DIR):
- mkdir -p $@
-
-$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(DEBUG_EXE): $(DEBUG_SO) $(DEBUG_BUILD_DIR) $(DEBUG_OBJS)
- $(LD) $(DEBUG_OBJS) $(DEBUG_LDFLAGS) $< -o $@
-
-$(RELEASE_EXE): $(RELEASE_SO) $(RELEASE_BUILD_DIR) $(RELEASE_OBJS)
- $(LD) $(RELEASE_OBJS) $(RELEASE_LDFLAGS) $< -o $@
-ifeq ($(KEEP_SYMBOLS),0)
- strip $@
-endif
-
-libgbinder-debug:
- @make $(SUBMAKE_OPTS) -C $(LIB_DIR) $(DEBUG_SO_FILE) $(DEBUG_LINK_FILE)
-
-libgbinder-release:
- @make $(SUBMAKE_OPTS) -C $(LIB_DIR) $(RELEASE_SO_FILE) $(RELEASE_LINK_FILE)
-
-#
-# Install
-#
-
-INSTALL = install
-
-INSTALL_BIN_DIR = $(DESTDIR)/usr/bin
-
-install: release $(INSTALL_BIN_DIR)
- $(INSTALL) -m 755 $(RELEASE_EXE) $(INSTALL_BIN_DIR)
-
-$(INSTALL_BIN_DIR):
- $(INSTALL) -d $@
+include ../common/Makefile
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/test/binder-ping/Makefile
^
|
@@ -1,154 +1,5 @@
# -*- Mode: makefile-gmake -*-
-.PHONY: all debug release clean cleaner
-.PHONY: libgbinder-release libgbinder-debug
-
-#
-# Required packages
-#
-
-PKGS = glib-2.0 gio-2.0 gio-unix-2.0 libglibutil
-
-#
-# Default target
-#
-
-all: debug release
-
-#
-# Executable
-#
-
EXE = binder-ping
-#
-# Sources
-#
-
-SRC = $(EXE).c
-
-#
-# Directories
-#
-
-SRC_DIR = .
-BUILD_DIR = build
-LIB_DIR = ../..
-DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
-RELEASE_BUILD_DIR = $(BUILD_DIR)/release
-
-#
-# Tools and flags
-#
-
-CC ?= $(CROSS_COMPILE)gcc
-LD = $(CC)
-WARNINGS = -Wall
-INCLUDES = -I$(LIB_DIR)/include
-BASE_FLAGS = -fPIC
-CFLAGS = $(BASE_FLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
- $(shell pkg-config --cflags $(PKGS))
-LDFLAGS = $(BASE_FLAGS) $(shell pkg-config --libs $(PKGS))
-QUIET_MAKE = make --no-print-directory
-DEBUG_FLAGS = -g
-RELEASE_FLAGS =
-
-ifndef KEEP_SYMBOLS
-KEEP_SYMBOLS = 0
-endif
-
-ifneq ($(KEEP_SYMBOLS),0)
-RELEASE_FLAGS += -g
-SUBMAKE_OPTS += KEEP_SYMBOLS=1
-endif
-
-DEBUG_LDFLAGS = $(LDFLAGS) $(DEBUG_FLAGS)
-RELEASE_LDFLAGS = $(LDFLAGS) $(RELEASE_FLAGS)
-DEBUG_CFLAGS = $(CFLAGS) $(DEBUG_FLAGS) -DDEBUG
-RELEASE_CFLAGS = $(CFLAGS) $(RELEASE_FLAGS) -O2
-
-#
-# Files
-#
-
-DEBUG_OBJS = $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
-RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
-DEBUG_SO_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_so)
-RELEASE_SO_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_so)
-DEBUG_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_link)
-RELEASE_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_link)
-DEBUG_SO = $(LIB_DIR)/$(DEBUG_SO_FILE)
-RELEASE_SO = $(LIB_DIR)/$(RELEASE_SO_FILE)
-
-#
-# Dependencies
-#
-
-DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
-ifneq ($(MAKECMDGOALS),clean)
-ifneq ($(strip $(DEPS)),)
--include $(DEPS)
-endif
-endif
-
-$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
-$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
-
-#
-# Rules
-#
-
-DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
-RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
-
-debug: libgbinder-debug $(DEBUG_EXE)
-
-release: libgbinder-release $(RELEASE_EXE)
-
-clean:
- rm -f *~
- rm -fr $(BUILD_DIR)
-
-cleaner: clean
- @make -C $(LIB_DIR) clean
-
-$(DEBUG_BUILD_DIR):
- mkdir -p $@
-
-$(RELEASE_BUILD_DIR):
- mkdir -p $@
-
-$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(DEBUG_EXE): $(DEBUG_SO) $(DEBUG_BUILD_DIR) $(DEBUG_OBJS)
- $(LD) $(DEBUG_OBJS) $(DEBUG_LDFLAGS) $< -o $@
-
-$(RELEASE_EXE): $(RELEASE_SO) $(RELEASE_BUILD_DIR) $(RELEASE_OBJS)
- $(LD) $(RELEASE_OBJS) $(RELEASE_LDFLAGS) $< -o $@
-ifeq ($(KEEP_SYMBOLS),0)
- strip $@
-endif
-
-libgbinder-debug:
- @make $(SUBMAKE_OPTS) -C $(LIB_DIR) $(DEBUG_SO_FILE) $(DEBUG_LINK_FILE)
-
-libgbinder-release:
- @make $(SUBMAKE_OPTS) -C $(LIB_DIR) $(RELEASE_SO_FILE) $(RELEASE_LINK_FILE)
-
-#
-# Install
-#
-
-INSTALL = install
-
-INSTALL_BIN_DIR = $(DESTDIR)/usr/bin
-
-install: release $(INSTALL_BIN_DIR)
- $(INSTALL) -m 755 $(RELEASE_EXE) $(INSTALL_BIN_DIR)
-
-$(INSTALL_BIN_DIR):
- $(INSTALL) -d $@
+include ../common/Makefile
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/test/binder-service/Makefile
^
|
@@ -1,140 +1,5 @@
# -*- Mode: makefile-gmake -*-
-.PHONY: all debug release clean cleaner
-.PHONY: libgbinder-release libgbinder-debug
-
-#
-# Required packages
-#
-
-PKGS = glib-2.0 gio-2.0 gio-unix-2.0 libglibutil
-
-#
-# Default target
-#
-
-all: debug release
-
-#
-# Executable
-#
-
EXE = binder-service
-#
-# Sources
-#
-
-SRC = $(EXE).c
-
-#
-# Directories
-#
-
-SRC_DIR = .
-BUILD_DIR = build
-LIB_DIR = ../..
-DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
-RELEASE_BUILD_DIR = $(BUILD_DIR)/release
-
-#
-# Tools and flags
-#
-
-CC ?= $(CROSS_COMPILE)gcc
-LD = $(CC)
-WARNINGS = -Wall
-INCLUDES = -I$(LIB_DIR)/include
-BASE_FLAGS = -fPIC
-CFLAGS = $(BASE_FLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
- $(shell pkg-config --cflags $(PKGS))
-LDFLAGS = $(BASE_FLAGS) $(shell pkg-config --libs $(PKGS))
-QUIET_MAKE = make --no-print-directory
-DEBUG_FLAGS = -g
-RELEASE_FLAGS =
-
-ifndef KEEP_SYMBOLS
-KEEP_SYMBOLS = 0
-endif
-
-ifneq ($(KEEP_SYMBOLS),0)
-RELEASE_FLAGS += -g
-SUBMAKE_OPTS += KEEP_SYMBOLS=1
-endif
-
-DEBUG_LDFLAGS = $(LDFLAGS) $(DEBUG_FLAGS)
-RELEASE_LDFLAGS = $(LDFLAGS) $(RELEASE_FLAGS)
-DEBUG_CFLAGS = $(CFLAGS) $(DEBUG_FLAGS) -DDEBUG
-RELEASE_CFLAGS = $(CFLAGS) $(RELEASE_FLAGS) -O2
-
-#
-# Files
-#
-
-DEBUG_OBJS = $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
-RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
-DEBUG_SO_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_so)
-RELEASE_SO_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_so)
-DEBUG_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_link)
-RELEASE_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_link)
-DEBUG_SO = $(LIB_DIR)/$(DEBUG_SO_FILE)
-RELEASE_SO = $(LIB_DIR)/$(RELEASE_SO_FILE)
-
-#
-# Dependencies
-#
-
-DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
-ifneq ($(MAKECMDGOALS),clean)
-ifneq ($(strip $(DEPS)),)
--include $(DEPS)
-endif
-endif
-
-$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
-$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
-
-#
-# Rules
-#
-
-DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
-RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
-
-debug: libgbinder-debug $(DEBUG_EXE)
-
-release: libgbinder-release $(RELEASE_EXE)
-
-clean:
- rm -f *~
- rm -fr $(BUILD_DIR)
-
-cleaner: clean
- @make -C $(LIB_DIR) clean
-
-$(DEBUG_BUILD_DIR):
- mkdir -p $@
-
-$(RELEASE_BUILD_DIR):
- mkdir -p $@
-
-$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(DEBUG_EXE): $(DEBUG_SO) $(DEBUG_BUILD_DIR) $(DEBUG_OBJS)
- $(LD) $(DEBUG_OBJS) $(DEBUG_LDFLAGS) $< -o $@
-
-$(RELEASE_EXE): $(RELEASE_SO) $(RELEASE_BUILD_DIR) $(RELEASE_OBJS)
- $(LD) $(RELEASE_OBJS) $(RELEASE_LDFLAGS) $< -o $@
-ifeq ($(KEEP_SYMBOLS),0)
- strip $@
-endif
-
-libgbinder-debug:
- @make $(SUBMAKE_OPTS) -C $(LIB_DIR) $(DEBUG_SO_FILE) $(DEBUG_LINK_FILE)
-
-libgbinder-release:
- @make $(SUBMAKE_OPTS) -C $(LIB_DIR) $(RELEASE_SO_FILE) $(RELEASE_LINK_FILE)
+include ../common/Makefile
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.30.tar.bz2/test/common/Makefile
^
|
@@ -0,0 +1,152 @@
+# -*- Mode: makefile-gmake -*-
+
+.PHONY: all debug release install clean cleaner
+.PHONY: libgbinder-release libgbinder-debug
+
+#
+# Executable must be defined
+#
+
+ifndef EXE
+${error EXE not defined}
+endif
+
+#
+# Required packages
+#
+
+PKGS = glib-2.0 gio-2.0 gio-unix-2.0 libglibutil
+
+#
+# Default target
+#
+
+all: debug release
+
+#
+# Sources
+#
+
+SRC ?= $(EXE).c
+
+#
+# Directories
+#
+
+SRC_DIR = .
+BUILD_DIR = build
+LIB_DIR = ../..
+DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
+RELEASE_BUILD_DIR = $(BUILD_DIR)/release
+
+#
+# Tools and flags
+#
+
+CC ?= $(CROSS_COMPILE)gcc
+LD = $(CC)
+WARNINGS = -Wall
+INCLUDES = -I$(LIB_DIR)/include
+CFLAGS += -fPIC $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
+ $(shell pkg-config --cflags $(PKGS))
+LDFLAGS += -pie $(shell pkg-config --libs $(PKGS))
+QUIET_MAKE = make --no-print-directory
+DEBUG_FLAGS = -g
+RELEASE_FLAGS =
+
+KEEP_SYMBOLS ?= 0
+ifneq ($(KEEP_SYMBOLS),0)
+RELEASE_FLAGS += -g
+SUBMAKE_OPTS += KEEP_SYMBOLS=1
+endif
+
+DEBUG_LDFLAGS = $(LDFLAGS) $(DEBUG_FLAGS)
+RELEASE_LDFLAGS = $(LDFLAGS) $(RELEASE_FLAGS)
+DEBUG_CFLAGS = $(CFLAGS) $(DEBUG_FLAGS) -DDEBUG
+RELEASE_CFLAGS = $(CFLAGS) $(RELEASE_FLAGS) -O2
+
+#
+# Files
+#
+
+DEBUG_OBJS = $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
+RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
+DEBUG_SO_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_so)
+RELEASE_SO_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_so)
+DEBUG_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_link)
+RELEASE_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_link)
+DEBUG_SO = $(LIB_DIR)/$(DEBUG_SO_FILE)
+RELEASE_SO = $(LIB_DIR)/$(RELEASE_SO_FILE)
+
+#
+# Dependencies
+#
+
+DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(strip $(DEPS)),)
+-include $(DEPS)
+endif
+endif
+
+$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
+$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
+
+#
+# Rules
+#
+
+DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
+RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
+
+debug: libgbinder-debug $(DEBUG_EXE)
+
+release: libgbinder-release $(RELEASE_EXE)
+
+clean:
+ rm -f *~
+ rm -fr $(BUILD_DIR)
+
+cleaner: clean
+ @make -C $(LIB_DIR) clean
+
+$(DEBUG_BUILD_DIR):
+ mkdir -p $@
+
+$(RELEASE_BUILD_DIR):
+ mkdir -p $@
+
+$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_EXE): $(DEBUG_SO) $(DEBUG_BUILD_DIR) $(DEBUG_OBJS)
+ $(LD) $(DEBUG_OBJS) $(DEBUG_LDFLAGS) $< -o $@
+
+$(RELEASE_EXE): $(RELEASE_SO) $(RELEASE_BUILD_DIR) $(RELEASE_OBJS)
+ $(LD) $(RELEASE_OBJS) $(RELEASE_LDFLAGS) $< -o $@
+ifeq ($(KEEP_SYMBOLS),0)
+ strip $@
+endif
+
+libgbinder-debug:
+ @$(MAKE) $(SUBMAKE_OPTS) -C $(LIB_DIR) $(DEBUG_SO_FILE) $(DEBUG_LINK_FILE)
+
+libgbinder-release:
+ @$(MAKE) $(SUBMAKE_OPTS) -C $(LIB_DIR) $(RELEASE_SO_FILE) $(RELEASE_LINK_FILE)
+
+#
+# Install
+#
+
+INSTALL = install
+
+INSTALL_BIN_DIR = $(DESTDIR)/usr/bin
+
+install: release $(INSTALL_BIN_DIR)
+ $(INSTALL) -m 755 $(RELEASE_EXE) $(INSTALL_BIN_DIR)
+
+$(INSTALL_BIN_DIR):
+ $(INSTALL) -d $@
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/test/rild-card-status/Makefile
^
|
@@ -1,140 +1,5 @@
# -*- Mode: makefile-gmake -*-
-.PHONY: all debug release clean cleaner
-.PHONY: libgbinder-release libgbinder-debug
-
-#
-# Required packages
-#
-
-PKGS = glib-2.0 gio-2.0 gio-unix-2.0 libglibutil
-
-#
-# Default target
-#
-
-all: debug release
-
-#
-# Executable
-#
-
EXE = rild-card-status
-#
-# Sources
-#
-
-SRC = $(EXE).c
-
-#
-# Directories
-#
-
-SRC_DIR = .
-BUILD_DIR = build
-LIB_DIR = ../..
-DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
-RELEASE_BUILD_DIR = $(BUILD_DIR)/release
-
-#
-# Tools and flags
-#
-
-CC ?= $(CROSS_COMPILE)gcc
-LD = $(CC)
-WARNINGS = -Wall
-INCLUDES = -I$(LIB_DIR)/include
-BASE_FLAGS = -fPIC
-CFLAGS = $(BASE_FLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
- $(shell pkg-config --cflags $(PKGS))
-LDFLAGS = $(BASE_FLAGS) $(shell pkg-config --libs $(PKGS))
-QUIET_MAKE = make --no-print-directory
-DEBUG_FLAGS = -g
-RELEASE_FLAGS =
-
-ifndef KEEP_SYMBOLS
-KEEP_SYMBOLS = 0
-endif
-
-ifneq ($(KEEP_SYMBOLS),0)
-RELEASE_FLAGS += -g
-SUBMAKE_OPTS += KEEP_SYMBOLS=1
-endif
-
-DEBUG_LDFLAGS = $(LDFLAGS) $(DEBUG_FLAGS)
-RELEASE_LDFLAGS = $(LDFLAGS) $(RELEASE_FLAGS)
-DEBUG_CFLAGS = $(CFLAGS) $(DEBUG_FLAGS) -DDEBUG
-RELEASE_CFLAGS = $(CFLAGS) $(RELEASE_FLAGS) -O2
-
-#
-# Files
-#
-
-DEBUG_OBJS = $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
-RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
-DEBUG_SO_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_so)
-RELEASE_SO_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_so)
-DEBUG_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_link)
-RELEASE_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_link)
-DEBUG_SO = $(LIB_DIR)/$(DEBUG_SO_FILE)
-RELEASE_SO = $(LIB_DIR)/$(RELEASE_SO_FILE)
-
-#
-# Dependencies
-#
-
-DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
-ifneq ($(MAKECMDGOALS),clean)
-ifneq ($(strip $(DEPS)),)
--include $(DEPS)
-endif
-endif
-
-$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
-$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
-
-#
-# Rules
-#
-
-DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
-RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
-
-debug: libgbinder-debug $(DEBUG_EXE)
-
-release: libgbinder-release $(RELEASE_EXE)
-
-clean:
- rm -f *~
- rm -fr $(BUILD_DIR)
-
-cleaner: clean
- @make -C $(LIB_DIR) clean
-
-$(DEBUG_BUILD_DIR):
- mkdir -p $@
-
-$(RELEASE_BUILD_DIR):
- mkdir -p $@
-
-$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(DEBUG_EXE): $(DEBUG_SO) $(DEBUG_BUILD_DIR) $(DEBUG_OBJS)
- $(LD) $(DEBUG_OBJS) $(DEBUG_LDFLAGS) $< -o $@
-
-$(RELEASE_EXE): $(RELEASE_SO) $(RELEASE_BUILD_DIR) $(RELEASE_OBJS)
- $(LD) $(RELEASE_OBJS) $(RELEASE_LDFLAGS) $< -o $@
-ifeq ($(KEEP_SYMBOLS),0)
- strip $@
-endif
-
-libgbinder-debug:
- @make $(SUBMAKE_OPTS) -C $(LIB_DIR) $(DEBUG_SO_FILE) $(DEBUG_LINK_FILE)
-
-libgbinder-release:
- @make $(SUBMAKE_OPTS) -C $(LIB_DIR) $(RELEASE_SO_FILE) $(RELEASE_LINK_FILE)
+include ../common/Makefile
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/Makefile
^
|
@@ -9,6 +9,7 @@
@$(MAKE) -C unit_config $*
@$(MAKE) -C unit_driver $*
@$(MAKE) -C unit_eventloop $*
+ @$(MAKE) -C unit_fmq $*
@$(MAKE) -C unit_ipc $*
@$(MAKE) -C unit_local_object $*
@$(MAKE) -C unit_local_reply $*
@@ -23,6 +24,8 @@
@$(MAKE) -C unit_servicemanager $*
@$(MAKE) -C unit_servicemanager_aidl $*
@$(MAKE) -C unit_servicemanager_aidl2 $*
+ @$(MAKE) -C unit_servicemanager_aidl3 $*
+ @$(MAKE) -C unit_servicemanager_aidl4 $*
@$(MAKE) -C unit_servicemanager_hidl $*
@$(MAKE) -C unit_servicename $*
@$(MAKE) -C unit_servicepoll $*
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/common/test_binder.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -55,6 +55,7 @@
static GHashTable* test_node_map = NULL;
static GPrivate test_looper = G_PRIVATE_INIT(NULL);
static GPrivate test_tx_state = G_PRIVATE_INIT(NULL);
+static guint32 last_auto_handle = 0;
G_LOCK_DEFINE_STATIC(test_binder);
static GMainLoop* test_binder_exit_loop = NULL;
@@ -68,11 +69,6 @@
#define BINDER_SET_MAX_THREADS _IOW('b', 5, guint32)
#define BINDER_BUFFER_FLAG_HAS_PARENT 0x01
-#define B_TYPE_LARGE 0x85
-#define BINDER_TYPE_BINDER GBINDER_FOURCC('s', 'b', '*', B_TYPE_LARGE)
-#define BINDER_TYPE_HANDLE GBINDER_FOURCC('s', 'h', '*', B_TYPE_LARGE)
-#define BINDER_TYPE_PTR GBINDER_FOURCC('p', 't', '*', B_TYPE_LARGE)
-
#define TF_ONE_WAY 0x01
#define TF_ROOT_OBJECT 0x04
#define TF_STATUS_CODE 0x08
@@ -125,6 +121,7 @@
struct test_binder_node {
int fd;
char* path;
+ const char* name;
TestBinder* binder;
TestBinderNode* other;
TEST_LOOPER looper_enabled;
@@ -146,7 +143,6 @@
GHashTable* object_map; /* GBinderLocalObject* => handle */
GHashTable* handle_map; /* handle => GBinderLocalObject* */
TestBinderSubmitThread* submit_thread;
- guint32 last_auto_handle;
GMutex mutex;
gboolean passthrough;
TestBinderNode node[2];
@@ -437,13 +433,16 @@
g_assert(!g_hash_table_contains(binder->object_map, obj));
g_assert(!g_hash_table_contains(binder->handle_map, GINT_TO_POINTER(h)));
if (h == AUTO_HANDLE) {
- h = ++(binder->last_auto_handle);
+ h = ++last_auto_handle;
while (g_hash_table_contains(binder->handle_map, GINT_TO_POINTER(h)) ||
g_hash_table_contains(binder->object_map, GINT_TO_POINTER(h))) {
- h = ++(binder->last_auto_handle);
+ h = ++last_auto_handle;
}
+ } else if (last_auto_handle < h) {
+ /* Avoid re-using handles, to make debugging easier */
+ last_auto_handle = h;
}
- GDEBUG("Object %p <=> handle %u", obj, h);
+ GDEBUG("Object %p <=> handle %u %s", obj, h, binder->node[0].name);
g_hash_table_insert(binder->handle_map, GINT_TO_POINTER(h), obj);
g_hash_table_insert(binder->object_map, obj, GINT_TO_POINTER(h));
g_object_weak_ref(G_OBJECT(obj), test_binder_local_object_gone, binder);
@@ -463,10 +462,10 @@
gpointer obj = g_hash_table_lookup(binder->handle_map, key);
GDEBUG("Handle %u => object %p %s", (guint) handle, obj,
- binder->node[0].path);
+ binder->node[0].name);
return GPOINTER_TO_SIZE(obj);
}
- GDEBUG("Unexpected handle %u %s", (guint) handle, binder->node[0].path);
+ GDEBUG("Unexpected handle %u %s", (guint) handle, binder->node[0].name);
return 0;
}
@@ -484,13 +483,13 @@
guint64 handle = GPOINTER_TO_SIZE(value);
GDEBUG("Object %p => handle %u %s", key, (guint) handle,
- binder->node[0].path);
+ binder->node[0].name);
return handle;
} else if (key) {
- GDEBUG("Auto-registering object %p %s", key, binder->node[0].path);
+ GDEBUG("Auto-registering object %p %s", key, binder->node[0].name);
return test_binder_register_object_locked(binder, key, AUTO_HANDLE);
} else {
- GDEBUG("Unexpected object %p %s", key, binder->node[0].path);
+ GDEBUG("Unexpected object %p %s", key, binder->node[0].name);
return 0;
}
}
@@ -565,7 +564,7 @@
const guint32 cmd = node->next_cmd[0];
const guint total = 4 + _IOC_SIZE(cmd);
- /* Alread have one ready */
+ /* Already have one ready */
if (!(test_binder_cmd_read_flags(cmd) & flags)) {
GDEBUG("Cmd 0x%08x not for %d", cmd, gettid());
*bytes_read = 0;
@@ -667,7 +666,7 @@
while (g_atomic_pointer_get(&node->tx_state) != my_tx_state &&
!g_atomic_pointer_compare_and_exchange(&node->tx_state, NULL,
my_tx_state)) {
- GDEBUG("Thread %d is waiting to become a transacton thread",
+ GDEBUG("Thread %d is waiting to become a transaction thread",
my_tx_state->tid);
test_io_short_wait();
}
@@ -696,7 +695,7 @@
my_tx_state->depth--;
my_tx_state->stack = g_renew(TEST_TX_STATE, my_tx_state->stack,
my_tx_state->depth);
- GDEBUG("Thread %d is still a transacton thread", my_tx_state->tid);
+ GDEBUG("Thread %d is still a transaction thread", my_tx_state->tid);
}
}
@@ -843,6 +842,8 @@
buffer->buffer = GPOINTER_TO_SIZE(copy);
g_hash_table_replace(fd->destroy_map, copy, NULL);
}
+ } else {
+ GDEBUG("Unexpected object type 0x%08x", *obj_ptr);
}
}
g_hash_table_replace(fd->destroy_map, data_offsets, NULL);
@@ -1594,6 +1595,7 @@
binder_fd->node = node;
binder_fd->fd = dup(node->fd);
binder_fd->destroy_map = g_hash_table_new(g_direct_hash, g_direct_equal);
+ GDEBUG("fd %d => %d", binder_fd->fd, node->fd);
return binder_fd;
}
@@ -1602,11 +1604,12 @@
const char* path,
int flags)
{
+ static const char path_prefix[] = "/dev/";
static const char binder_suffix[] = "binder";
static const char binder_private_suffix[] = "binder-private";
static const char private_suffix[] = "-private";
- if (path && g_str_has_prefix(path, "/dev/") &&
+ if (path && g_str_has_prefix(path, path_prefix) &&
(g_str_has_suffix(path, binder_suffix) ||
g_str_has_suffix(path, binder_private_suffix))) {
TestBinderFd* fd;
@@ -1631,7 +1634,7 @@
node = binder->node + PRIVATE;
node->path = g_strdup(path);
binder->node[PUBLIC].path = g_strndup(path,
- strlen(path) - strlen(private_suffix) - 1);
+ strlen(path) - strlen(private_suffix));
}
if (!test_node_map) {
@@ -1644,6 +1647,7 @@
this_node->binder = binder;
this_node->fd = fds[i];
this_node->other = binder->node + ((i + 1) % 2);
+ this_node->name = this_node->path + strlen(path_prefix);
g_hash_table_replace(test_node_map, this_node->path, this_node);
}
binder->object_map = g_hash_table_new
@@ -1651,8 +1655,8 @@
binder->handle_map = g_hash_table_new
(g_direct_hash, g_direct_equal);
GDEBUG("Created %s (%d) <=> %s (%d) binder",
- binder->node[0].path, binder->node[0].fd,
- binder->node[1].path, binder->node[1].fd);
+ binder->node[0].name, binder->node[0].fd,
+ binder->node[1].name, binder->node[1].fd);
}
fd = test_binder_fd_new(node);
if (!test_fd_map) {
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/common/test_binder.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -35,6 +35,16 @@
#include "test_common.h"
+#define B_TYPE_LARGE 0x85
+#define BINDER_TYPE_BINDER GBINDER_FOURCC('s', 'b', '*', B_TYPE_LARGE)
+#define BINDER_TYPE_HANDLE GBINDER_FOURCC('s', 'h', '*', B_TYPE_LARGE)
+#define BINDER_TYPE_PTR GBINDER_FOURCC('p', 't', '*', B_TYPE_LARGE)
+
+#define BUFFER_OBJECT_SIZE_32 (24)
+#define BUFFER_OBJECT_SIZE_64 (40)
+#define BINDER_OBJECT_SIZE_32 (16)
+#define BINDER_OBJECT_SIZE_64 (24)
+
typedef struct test_binder TestBinder;
void
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/common/test_common.h
^
|
@@ -80,6 +80,10 @@
/* Helper macros */
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+# define TEST_INT8_BYTES_4(v) \
+ (guint8)(v), 0, 0, 0
+# define TEST_INT16_BYTES_4(v) \
+ (guint8)(v), (guint8)((v) >> 8), 0, 0
# define TEST_INT16_BYTES(v) \
(guint8)(v), (guint8)((v) >> 8)
# define TEST_INT32_BYTES(v) \
@@ -91,6 +95,10 @@
(guint8)(((guint64)(v)) >> 32), (guint8)(((guint64)(v)) >> 40), \
(guint8)(((guint64)(v)) >> 48), (guint8)(((guint64)(v)) >> 56)
#elif G_BYTE_ORDER == G_BIG_ENDIAN
+# define TEST_INT8_BYTES_4(v) \
+ 0, 0, 0, (guint8)(v)
+# define TEST_INT16_BYTES_4(v) \
+ 0, 0, (guint8)((v) >> 8), (guint8)(v)
# define TEST_INT16_BYTES(v) \
(guint8)((v) >> 8), (guint8)(v)
# define TEST_INT32_BYTES(v) \
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/coverage/run
^
|
@@ -11,6 +11,7 @@
unit_config \
unit_driver \
unit_eventloop \
+unit_fmq \
unit_ipc \
unit_local_object \
unit_local_reply \
@@ -25,6 +26,8 @@
unit_servicemanager \
unit_servicemanager_aidl \
unit_servicemanager_aidl2 \
+unit_servicemanager_aidl3 \
+unit_servicemanager_aidl4 \
unit_servicemanager_hidl \
unit_servicename \
unit_servicepoll \
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_bridge/unit_bridge.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2021 Jolla Ltd.
- * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2021-2022 Jolla Ltd.
+ * Copyright (C) 2021-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -183,7 +183,7 @@
test_servicemanager_impl_new(
const char* dev)
{
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
const int fd = gbinder_driver_fd(ipc->driver);
TestServiceManagerHidl* sm = test_servicemanager_hidl_new(ipc);
@@ -357,10 +357,10 @@
test.loop = g_main_loop_new(NULL, FALSE);
/* obj (DEST) <=> bridge <=> (SRC) mirror */
- src_ipc = gbinder_ipc_new(SRC_DEV);
- src_priv_ipc = gbinder_ipc_new(SRC_PRIV_DEV);
- dest_ipc = gbinder_ipc_new(DEST_DEV);
- dest_priv_ipc = gbinder_ipc_new(DEST_PRIV_DEV);
+ src_ipc = gbinder_ipc_new(SRC_DEV, NULL);
+ src_priv_ipc = gbinder_ipc_new(SRC_PRIV_DEV, NULL);
+ dest_ipc = gbinder_ipc_new(DEST_DEV, NULL);
+ dest_priv_ipc = gbinder_ipc_new(DEST_PRIV_DEV, NULL);
test.src_impl = test_servicemanager_impl_new(SRC_PRIV_DEV);
dest_impl = test_servicemanager_impl_new(DEST_PRIV_DEV);
src_fd = gbinder_driver_fd(src_ipc->driver);
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_client/unit_client.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -41,6 +41,7 @@
#include "gbinder_output_data.h"
#include "gbinder_remote_object_p.h"
#include "gbinder_remote_reply.h"
+#include "gbinder_writer.h"
#include <gutil_log.h>
@@ -54,7 +55,7 @@
guint h,
const char* iface)
{
- GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER);
+ GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER, NULL);
GBinderObjectRegistry* reg = gbinder_ipc_object_registry(ipc);
GBinderRemoteObject* obj = gbinder_object_registry_get_remote(reg, h, TRUE);
GBinderClient* client = gbinder_client_new(obj, iface);
@@ -79,6 +80,7 @@
g_assert(!gbinder_client_ref(NULL));
g_assert(!gbinder_client_interface(NULL));
g_assert(!gbinder_client_interface2(NULL, 0));
+ g_assert(!gbinder_client_rpc_header(NULL, 0));
gbinder_client_unref(NULL);
g_assert(!gbinder_client_new_request(NULL));
g_assert(!gbinder_client_new_request2(NULL, 0));
@@ -97,7 +99,7 @@
test_basic(
void)
{
- GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER);
+ GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER, NULL);
GBinderObjectRegistry* reg = gbinder_ipc_object_registry(ipc);
GBinderRemoteObject* obj = gbinder_object_registry_get_remote(reg, 0, TRUE);
const char* iface = "foo";
@@ -123,7 +125,7 @@
test_interfaces(
void)
{
- GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER);
+ GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER, NULL);
GBinderObjectRegistry* reg = gbinder_ipc_object_registry(ipc);
GBinderRemoteObject* obj = gbinder_object_registry_get_remote(reg, 0, TRUE);
static const GBinderClientIfaceInfo ifaces[] = {
@@ -131,6 +133,11 @@
};
GBinderClient* client = gbinder_client_new2(obj, ifaces,
G_N_ELEMENTS(ifaces));
+ GBinderWriter writer;
+ GBinderLocalRequest* req;
+ GBytes* rpc_header;
+ gsize len;
+ const void* hdr;
g_assert(client);
g_assert_cmpstr(gbinder_client_interface(client), == ,"11");
@@ -138,12 +145,25 @@
g_assert_cmpstr(gbinder_client_interface2(client, 22), == ,"22");
g_assert_cmpstr(gbinder_client_interface2(client, 33), == ,"33");
g_assert(!gbinder_client_interface2(client, 34));
+ g_assert(!gbinder_client_rpc_header(client, 34));
g_assert(!gbinder_client_new_request2(client, 34));
/* Those fail to allocate default request for out-of-range codes: */
g_assert(!gbinder_client_transact_sync_reply(client, 34, NULL, NULL));
g_assert_cmpint(gbinder_client_transact_sync_oneway(client, 34, NULL),
== ,-EINVAL);
g_assert(!gbinder_client_transact(client, 34, 0, NULL, NULL, NULL, NULL));
+
+ /* Check the RPC header */
+ rpc_header = gbinder_client_rpc_header(client, 33);
+ req = gbinder_client_new_request2(client, 33);
+ g_assert(rpc_header);
+ g_assert(req);
+ gbinder_local_request_init_writer(req, &writer);
+ hdr = gbinder_writer_get_data(&writer, &len);
+ g_assert(hdr);
+ g_assert_cmpuint(len, == ,g_bytes_get_size(rpc_header));
+ g_assert(!memcmp(hdr, g_bytes_get_data(rpc_header, NULL), len));
+ gbinder_local_request_unref(req);
gbinder_client_unref(client);
/* Client with no interface info */
@@ -257,7 +277,8 @@
GBinderDriver* driver = gbinder_client_ipc(client)->driver;
int fd = gbinder_driver_fd(driver);
const GBinderIo* io = gbinder_driver_io(driver);
- GBinderLocalReply* reply = gbinder_local_reply_new(io);
+ const GBinderRpcProtocol* protocol = gbinder_driver_protocol(driver);
+ GBinderLocalReply* reply = gbinder_local_reply_new(io, protocol);
GBinderRemoteReply* tx_reply;
GBinderOutputData* data;
const guint32 handle = 0;
@@ -360,7 +381,8 @@
GBinderDriver* driver = gbinder_client_ipc(client)->driver;
int fd = gbinder_driver_fd(driver);
const GBinderIo* io = gbinder_driver_io(driver);
- GBinderLocalReply* reply = gbinder_local_reply_new(io);
+ const GBinderRpcProtocol* protocol = gbinder_driver_protocol(driver);
+ GBinderLocalReply* reply = gbinder_local_reply_new(io, protocol);
GBinderOutputData* data;
const guint32 handle = 0;
const guint32 code = 1;
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_config/unit_config.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2020 Jolla Ltd.
- * Copyright (C) 2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2020-2022 Jolla Ltd.
+ * Copyright (C) 2020-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -230,6 +230,8 @@
char* file = g_build_filename(dir, "test.conf", NULL);
char* file1 = g_build_filename(subdir, "a.conf", NULL);
char* file2 = g_build_filename(subdir, "b.conf", NULL);
+ char* file3 = g_build_filename(subdir, "c.conf", NULL);
+ char* file4 = g_build_filename(subdir, "d.conf", NULL);
char* random_file = g_build_filename(subdir, "foo", NULL);
static const char garbage[] = "foo";
static const char config[] =
@@ -246,12 +248,24 @@
"/dev/binder = aidl2\n"
"[ServiceManager]\n"
"/dev/binder = aidl2\n";
+ static const char config3[] =
+ "[Protocol]\n"
+ "/dev/binder3 = aidl3\n"
+ "[ServiceManager]\n"
+ "/dev/binder3 = aidl3\n";
+ static const char config4[] =
+ "[Protocol]\n"
+ "/dev/binder4 = aidl3\n"
+ "[ServiceManager]\n"
+ "/dev/binder4 = aidl4\n";
g_assert_cmpint(mkdir(subdir, 0700), == ,0);
g_assert_cmpint(mkdir(notafile, 0700), == ,0);
g_assert(g_file_set_contents(file, config, -1, NULL));
g_assert(g_file_set_contents(file1, config1, -1, NULL));
g_assert(g_file_set_contents(file2, config2, -1, NULL));
+ g_assert(g_file_set_contents(file3, config3, -1, NULL));
+ g_assert(g_file_set_contents(file4, config4, -1, NULL));
g_assert(g_file_set_contents(random_file, garbage, -1, NULL));
/* Reset the state */
@@ -263,9 +277,13 @@
k = gbinder_config_get();
g_assert(k);
g_assert_cmpstr(test_value(k,"Protocol","/dev/binder",b), == ,"aidl2");
+ g_assert_cmpstr(test_value(k,"Protocol","/dev/binder3",b), == ,"aidl3");
+ g_assert_cmpstr(test_value(k,"Protocol","/dev/binder4",b), == ,"aidl3");
g_assert_cmpstr(test_value(k,"Protocol","/dev/hbinder",b), == ,"hidl");
g_assert_cmpstr(test_value(k,"Protocol","/dev/hwbinder",b), == ,"hidl");
g_assert_cmpstr(test_value(k,"ServiceManager","/dev/binder",b),==,"aidl2");
+ g_assert_cmpstr(test_value(k,"ServiceManager","/dev/binder3",b),==,"aidl3");
+ g_assert_cmpstr(test_value(k,"ServiceManager","/dev/binder4",b),==,"aidl4");
/* Remove the default file and try again */
gbinder_config_exit();
@@ -274,8 +292,12 @@
g_assert(k);
g_assert(!test_value(k,"Protocol","/dev/hbinder",b));
g_assert_cmpstr(test_value(k,"Protocol","/dev/binder",b), == ,"aidl2");
+ g_assert_cmpstr(test_value(k,"Protocol","/dev/binder3",b), == ,"aidl3");
+ g_assert_cmpstr(test_value(k,"Protocol","/dev/binder4",b), == ,"aidl3");
g_assert_cmpstr(test_value(k,"Protocol","/dev/hwbinder",b), == ,"hidl");
g_assert_cmpstr(test_value(k,"ServiceManager","/dev/binder",b),==,"aidl2");
+ g_assert_cmpstr(test_value(k,"ServiceManager","/dev/binder3",b),==,"aidl3");
+ g_assert_cmpstr(test_value(k,"ServiceManager","/dev/binder4",b),==,"aidl4");
/* Damage one of the files and try again */
gbinder_config_exit();
@@ -285,7 +307,11 @@
g_assert(!test_value(k,"Protocol","/dev/hbinder",b));
g_assert(!test_value(k,"Protocol","/dev/hwbinder",b));
g_assert_cmpstr(test_value(k,"Protocol","/dev/binder",b), == ,"aidl2");
+ g_assert_cmpstr(test_value(k,"Protocol","/dev/binder3",b), == ,"aidl3");
+ g_assert_cmpstr(test_value(k,"Protocol","/dev/binder4",b), == ,"aidl3");
g_assert_cmpstr(test_value(k,"ServiceManager","/dev/binder",b),==,"aidl2");
+ g_assert_cmpstr(test_value(k,"ServiceManager","/dev/binder3",b),==,"aidl3");
+ g_assert_cmpstr(test_value(k,"ServiceManager","/dev/binder4",b),==,"aidl4");
/* Disallow access to one of the files and try again */
gbinder_config_exit();
@@ -295,12 +321,28 @@
g_assert(!test_value(k,"Protocol","/dev/hbinder",b));
g_assert(!test_value(k,"Protocol","/dev/hwbinder",b));
g_assert_cmpstr(test_value(k,"Protocol","/dev/binder",b), == ,"aidl2");
+ g_assert_cmpstr(test_value(k,"Protocol","/dev/binder3",b), == ,"aidl3");
+ g_assert_cmpstr(test_value(k,"Protocol","/dev/binder4",b), == ,"aidl3");
g_assert_cmpstr(test_value(k,"ServiceManager","/dev/binder",b),==,"aidl2");
+ g_assert_cmpstr(test_value(k,"ServiceManager","/dev/binder3",b),==,"aidl3");
+ g_assert_cmpstr(test_value(k,"ServiceManager","/dev/binder4",b),==,"aidl4");
- /* Delete the remaining files and try again */
+ /* Leave only one file (file4) in the subdirectory */
gbinder_config_exit();
g_assert_cmpint(remove(file1), == ,0);
g_assert_cmpint(remove(file2), == ,0);
+ g_assert_cmpint(remove(file3), == ,0);
+ k = gbinder_config_get();
+ g_assert(k);
+ g_assert(!test_value(k,"Protocol","/dev/hbinder",b));
+ g_assert(!test_value(k,"Protocol","/dev/hwbinder",b));
+ g_assert(!test_value(k,"Protocol","/dev/binder3",b));
+ g_assert_cmpstr(test_value(k,"Protocol","/dev/binder4",b),==,"aidl3");
+ g_assert_cmpstr(test_value(k,"ServiceManager","/dev/binder4",b),==,"aidl4");
+
+ /* Delete the remaining file and try again */
+ gbinder_config_exit();
+ g_assert_cmpint(remove(file4), == ,0);
g_assert(!gbinder_config_get());
/* Undo all the damage */
@@ -312,6 +354,8 @@
g_free(file);
g_free(file1);
g_free(file2);
+ g_free(file3);
+ g_free(file4);
g_free(random_file);
remove(notafile);
@@ -464,6 +508,34 @@
"[ServiceManager]\n"
"/dev/binder = aidl2\n"
"/dev/vndbinder = aidl2\n"
+ },{
+ "30",
+
+ "[General]\n"
+ "ApiLevel = 30",
+
+ "[General]\n"
+ "ApiLevel = 30\n"
+ "[Protocol]\n"
+ "/dev/binder = aidl3\n"
+ "/dev/vndbinder = aidl3\n"
+ "[ServiceManager]\n"
+ "/dev/binder = aidl3\n"
+ "/dev/vndbinder = aidl3\n"
+ },{
+ "31",
+
+ "[General]\n"
+ "ApiLevel = 31",
+
+ "[General]\n"
+ "ApiLevel = 31\n"
+ "[Protocol]\n"
+ "/dev/binder = aidl3\n"
+ "/dev/vndbinder = aidl3\n"
+ "[ServiceManager]\n"
+ "/dev/binder = aidl4\n"
+ "/dev/vndbinder = aidl4\n"
}
};
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_driver/unit_driver.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -32,6 +32,7 @@
#include "test_binder.h"
+#include "gbinder_config.h"
#include "gbinder_driver.h"
#include "gbinder_handler.h"
#include "gbinder_local_request_p.h"
@@ -140,12 +141,31 @@
int main(int argc, char* argv[])
{
+ const char* default_config_dir;
+ const char* default_config_file;
+ char* config_dir = g_dir_make_tmp("gbinder-test-driver-XXXXXX", NULL);
+ char* config_file = g_build_filename(config_dir, "test.conf", NULL);
+ int result;
+
+ /* Point gbinder_config_file to a non-existent file */
+ default_config_dir = gbinder_config_dir;
+ default_config_file = gbinder_config_file;
+ gbinder_config_dir = config_dir;
+ gbinder_config_file = config_file;
+
g_test_init(&argc, &argv, NULL);
g_test_add_func(TEST_PREFIX "basic", test_basic);
g_test_add_func(TEST_PREFIX "noop", test_noop);
g_test_add_func(TEST_PREFIX "local_request", test_local_request);
test_init(&test_opt, argc, argv);
- return g_test_run();
+ result = g_test_run();
+
+ gbinder_config_dir = default_config_dir;
+ gbinder_config_file = default_config_file;
+ remove(config_dir);
+ g_free(config_dir);
+ g_free(config_file);
+ return result;
}
/*
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_fmq/Makefile
^
|
@@ -0,0 +1,5 @@
+# -*- Mode: makefile-gmake -*-
+
+EXE = unit_fmq
+
+include ../common/Makefile
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_fmq/unit_fmq.c
^
|
@@ -0,0 +1,597 @@
+/*
+ * Copyright (C) 2018-2021 Jolla Ltd.
+ *
+ * You may use this file under the terms of BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "test_common.h"
+
+#include "gbinder_fmq_p.h"
+
+#if GBINDER_FMQ_SUPPORTED
+
+#include "gbinder_log.h"
+
+#include <errno.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+static TestOpt test_opt;
+
+typedef struct test_fmq_data {
+ const char* name;
+ gsize item_size;
+ gsize max_num_items;
+ gint type;
+ gint flags;
+ gint fd;
+ gsize buffer_size;
+} TestFmqData;
+
+/*==========================================================================*
+ * null
+ *==========================================================================*/
+
+static const TestFmqData test_fmq_tests_null[] = {
+ { "wrong_size", 0, 8,
+ GBINDER_FMQ_TYPE_SYNC_READ_WRITE, 0, -1, 0 },
+ { "wrong_count", sizeof(guint32), 0,
+ GBINDER_FMQ_TYPE_SYNC_READ_WRITE, 0, -1, 0 },
+ { "wrong_buffer_size", sizeof(guint32), 8,
+ GBINDER_FMQ_TYPE_SYNC_READ_WRITE, 0, 1, 0 },
+};
+
+static
+void
+test_null(
+ gconstpointer test_data)
+{
+ const TestFmqData* test = test_data;
+ GBinderFmq* fmq = gbinder_fmq_new(test->item_size, test->max_num_items,
+ test->type, test->flags, test->fd, test->buffer_size);
+
+ g_assert(!fmq);
+ g_assert(!gbinder_fmq_ref(fmq));
+ gbinder_fmq_unref(fmq);
+
+ g_assert(gbinder_fmq_available_to_read(fmq) == 0);
+ g_assert(gbinder_fmq_available_to_write(fmq) == 0);
+ g_assert(gbinder_fmq_available_to_read_contiguous(fmq) == 0);
+ g_assert(gbinder_fmq_available_to_write_contiguous(fmq) == 0);
+
+ g_assert(!gbinder_fmq_begin_read(fmq, 1));
+ g_assert(!gbinder_fmq_begin_read((GBinderFmq*)0x1, 0));
+ g_assert(!gbinder_fmq_begin_write(fmq, 1));
+ g_assert(!gbinder_fmq_begin_write((GBinderFmq*)0x1, 0));
+
+ g_assert(!gbinder_fmq_read(fmq, (void*)0x1, 1));
+ g_assert(!gbinder_fmq_read((GBinderFmq*)0x1, NULL, 1));
+ g_assert(!gbinder_fmq_read((GBinderFmq*)0x1, (void*)0x1, 0));
+
+ g_assert(!gbinder_fmq_write(fmq, (const void*)0x1, 1));
+ g_assert(!gbinder_fmq_write((GBinderFmq*)0x1, NULL, 1));
+ g_assert(!gbinder_fmq_write((GBinderFmq*)0x1, (const void*)0x1, 0));
+
+ g_assert(gbinder_fmq_wait_timeout(fmq, 0, (guint32*)0x1, 0) == -EINVAL);
+ g_assert(gbinder_fmq_wait_timeout((GBinderFmq*)0x1, 0, NULL, 0) == -EINVAL);
+ g_assert(gbinder_fmq_wait(fmq, 0, (guint32*)0x1) == -EINVAL);
+ g_assert(gbinder_fmq_wait((GBinderFmq*)0x1, 0, NULL) == -EINVAL);
+ g_assert(gbinder_fmq_wake(fmq, 0) == -EINVAL);
+}
+
+/*==========================================================================*
+ * read/write guint8
+ *==========================================================================*/
+
+static const TestFmqData test_fmq_tests_read_write_guint8[] = {
+ { "event_flag", sizeof(guint8), 8, GBINDER_FMQ_TYPE_SYNC_READ_WRITE,
+ GBINDER_FMQ_FLAG_CONFIGURE_EVENT_FLAG, -1, 0 },
+ { "no_event_flag", sizeof(guint8), 8, GBINDER_FMQ_TYPE_SYNC_READ_WRITE,
+ 0, -1, 0 },
+ { "no_reset", sizeof(guint8), 8, GBINDER_FMQ_TYPE_SYNC_READ_WRITE,
+ GBINDER_FMQ_FLAG_CONFIGURE_EVENT_FLAG |
+ GBINDER_FMQ_FLAG_NO_RESET_POINTERS, -1, 0 },
+ { "unsync", sizeof(guint8), 8, GBINDER_FMQ_TYPE_UNSYNC_WRITE,
+ GBINDER_FMQ_FLAG_CONFIGURE_EVENT_FLAG, -1, 0 },
+ { "unsync_no_reset", sizeof(guint8), 8, GBINDER_FMQ_TYPE_UNSYNC_WRITE,
+ GBINDER_FMQ_FLAG_CONFIGURE_EVENT_FLAG |
+ GBINDER_FMQ_FLAG_NO_RESET_POINTERS, -1, 0 },
+};
+
+static
+void
+test_read_write_guint8(
+ gconstpointer test_data)
+{
+ const TestFmqData* test = test_data;
+ guint i;
+ guint8 in_data[test->max_num_items];
+ guint8 out_data[test->max_num_items];
+ GBinderFmq* fmq = gbinder_fmq_new(test->item_size, test->max_num_items,
+ test->type, test->flags, test->fd, test->buffer_size);
+
+ g_assert(fmq);
+
+ /* Intiailize input data with random numbers */
+ for (i = 0; i < test->max_num_items; ++i) {
+ in_data[i] = g_random_int() % G_MAXUINT8;
+ }
+ memset(out_data, 0, test->max_num_items);
+
+ /* Write data one value at a time */
+ for (i = 0; i < test->max_num_items; ++i) {
+ g_assert(gbinder_fmq_write(fmq, &in_data[i], 1));
+ g_assert(gbinder_fmq_available_to_read(fmq) == i + 1);
+ }
+
+ /* Try to write one item to full buffer
+ * only sync write fails if buffer is full */
+ if (test->type == GBINDER_FMQ_TYPE_SYNC_READ_WRITE) {
+ g_assert(!gbinder_fmq_write(fmq, &in_data[0], 1));
+ g_assert(gbinder_fmq_available_to_read(fmq) == test->max_num_items);
+ }
+
+ /* Read data one value at a time */
+ for (i = 0; i < test->max_num_items; ++i) {
+ g_assert(gbinder_fmq_read(fmq, &out_data, 1));
+ g_assert(out_data[0] == in_data[i]);
+ g_assert(gbinder_fmq_available_to_read(fmq) ==
+ test->max_num_items - i - 1);
+ }
+ /* Try to read when there is no data */
+ g_assert(!gbinder_fmq_read(fmq, &out_data, 1));
+
+ memset(out_data, 0, test->max_num_items);
+
+ /* Fill whole buffer with data */
+ g_assert(gbinder_fmq_write(fmq, in_data, test->max_num_items));
+ g_assert(gbinder_fmq_available_to_read(fmq) == test->max_num_items);
+ /* Read whole buffer */
+ g_assert(gbinder_fmq_read(fmq, &out_data, test->max_num_items));
+ g_assert(!memcmp(in_data, out_data, test->max_num_items * test->item_size));
+
+ memset(out_data, 0, test->max_num_items);
+
+ /* Try to write too many items */
+ g_assert(!gbinder_fmq_write(fmq, in_data, test->max_num_items + 1));
+
+ /* Overwrite unsync queue */
+ if (test->type == GBINDER_FMQ_TYPE_UNSYNC_WRITE) {
+ g_assert(gbinder_fmq_write(fmq, in_data, test->max_num_items));
+ g_assert(gbinder_fmq_write(fmq, in_data, 1));
+ /* Writing too much data to unsync queue causes read pointer to reset
+ * on next read */
+ g_assert(!gbinder_fmq_read(fmq, &out_data, 1));
+ g_assert(gbinder_fmq_available_to_read(fmq) == 0);
+ }
+
+ gbinder_fmq_unref(fmq);
+}
+
+/*==========================================================================*
+ * read/write gint64
+ *==========================================================================*/
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_ipc/unit_ipc.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -70,6 +70,24 @@
test_quit_later((GMainLoop*)loop);
}
+static
+GBinderLocalRequest*
+test_local_request_new(
+ GBinderIpc* ipc)
+{
+ return gbinder_local_request_new(gbinder_driver_io(ipc->driver),
+ gbinder_driver_protocol(ipc->driver), NULL);
+}
+
+static
+GBinderLocalReply*
+test_local_reply_new(
+ GBinderIpc* ipc)
+{
+ return gbinder_local_reply_new(gbinder_driver_io(ipc->driver),
+ gbinder_driver_protocol(ipc->driver));
+}
+
/*==========================================================================*
* null
*==========================================================================*/
@@ -79,26 +97,25 @@
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);
@@ -121,12 +138,22 @@
}
static
+gboolean
+test_basic_find(
+ GBinderLocalObject* obj,
+ void* user_data)
+{
+ return obj == user_data;
+}
+
+static
void
test_basic(
void)
{
- GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER);
- GBinderIpc* ipc2 = gbinder_ipc_new(GBINDER_DEFAULT_HWBINDER);
+ GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER, NULL);
+ GBinderIpc* ipc2 = gbinder_ipc_new(GBINDER_DEFAULT_HWBINDER, NULL);
+ GBinderLocalObject* obj;
g_assert(ipc);
g_assert(ipc2);
@@ -136,16 +163,45 @@
g_assert(!gbinder_ipc_find_local_object(NULL, test_basic_find_none, NULL));
g_assert(!gbinder_ipc_find_local_object(ipc, test_basic_find_none, NULL));
+ obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
+ g_assert(obj);
+ g_assert(!gbinder_ipc_find_local_object(ipc, test_basic_find_none, NULL));
+ g_assert(gbinder_ipc_find_local_object(ipc, test_basic_find, obj) == obj);
+ gbinder_local_object_unref(obj); /* Above call added a reference */
+ gbinder_local_object_unref(obj);
/* Second gbinder_ipc_new returns the same (default) object */
- g_assert(gbinder_ipc_new(NULL) == ipc);
- g_assert(gbinder_ipc_new("") == ipc);
+ g_assert(gbinder_ipc_new(NULL, NULL) == ipc);
+ g_assert(gbinder_ipc_new("", NULL) == ipc);
gbinder_ipc_unref(ipc);
gbinder_ipc_unref(ipc);
gbinder_ipc_unref(ipc);
/* Invalid path */
- g_assert(!gbinder_ipc_new("invalid path"));
+ g_assert(!gbinder_ipc_new("invalid path", NULL));
+
+ gbinder_ipc_exit();
+ 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);
@@ -173,10 +229,9 @@
test_async_oneway(
void)
{
- GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER);
- const GBinderIo* io = gbinder_driver_io(ipc->driver);
+ GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER, NULL);
+ GBinderLocalRequest* req = test_local_request_new(ipc);
const int fd = gbinder_driver_fd(ipc->driver);
- GBinderLocalRequest* req = gbinder_local_request_new(io, NULL);
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
gulong id;
@@ -200,10 +255,9 @@
test_sync_oneway(
void)
{
- GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER);
- const GBinderIo* io = gbinder_driver_io(ipc->driver);
+ GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER, NULL);
+ GBinderLocalRequest* req = test_local_request_new(ipc);
const int fd = gbinder_driver_fd(ipc->driver);
- GBinderLocalRequest* req = gbinder_local_request_new(io, NULL);
test_binder_br_transaction_complete(fd);
g_assert_cmpint(gbinder_ipc_sync_main.sync_oneway(ipc, 0, 1, req), == ,0);
@@ -222,13 +276,12 @@
test_sync_reply_ok_status(
int* status)
{
- GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER);
- const GBinderIo* io = gbinder_driver_io(ipc->driver);
- const int fd = gbinder_driver_fd(ipc->driver);
- GBinderLocalRequest* req = gbinder_local_request_new(io, NULL);
- GBinderLocalReply* reply = gbinder_local_reply_new(io);
+ GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER, NULL);
+ GBinderLocalRequest* req = test_local_request_new(ipc);
+ GBinderLocalReply* reply = test_local_reply_new(ipc);
GBinderRemoteReply* tx_reply;
GBinderOutputData* data;
+ const int fd = gbinder_driver_fd(ipc->driver);
const guint32 handle = 0;
const guint32 code = 1;
const char* result_in = "foo";
@@ -279,10 +332,9 @@
test_sync_reply_error(
void)
{
- GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER);
- const GBinderIo* io = gbinder_driver_io(ipc->driver);
+ GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER, NULL);
+ GBinderLocalRequest* req = test_local_request_new(ipc);
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_local_object/unit_local_object.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -33,6 +33,7 @@
#include "test_binder.h"
#include "gbinder_buffer_p.h"
+#include "gbinder_config.h"
#include "gbinder_driver.h"
#include "gbinder_ipc.h"
#include "gbinder_local_object_p.h"
@@ -152,7 +153,7 @@
{
const char* const ifaces_foo[] = { "foo", NULL };
const char* const ifaces_bar[] = { "bar", NULL };
- GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER);
+ GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER, NULL);
GBinderObjectRegistry* reg = gbinder_ipc_object_registry(ipc);
GBinderLocalObject* foo;
GBinderLocalObject* bar;
@@ -201,7 +202,7 @@
int status = INT_MAX;
const char* dev = GBINDER_DEFAULT_HWBINDER;
const GBinderRpcProtocol* prot = gbinder_rpc_protocol_for_device(dev);
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
GBinderObjectRegistry* reg = gbinder_ipc_object_registry(ipc);
GBinderRemoteRequest* req = gbinder_remote_request_new(reg, prot, 0, 0);
GBinderLocalObject* obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
@@ -247,7 +248,7 @@
const char* dev = GBINDER_DEFAULT_HWBINDER;
const GBinderRpcProtocol* prot = gbinder_rpc_protocol_for_device(dev);
const char* const ifaces[] = { "x", NULL };
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
GBinderObjectRegistry* reg = gbinder_ipc_object_registry(ipc);
GBinderRemoteRequest* req = gbinder_remote_request_new(reg, prot, 0, 0);
GBinderLocalObject* obj = gbinder_local_object_new(ipc, ifaces, NULL, NULL);
@@ -296,7 +297,7 @@
int status = INT_MAX;
const char* dev = GBINDER_DEFAULT_HWBINDER;
const GBinderRpcProtocol* prot = gbinder_rpc_protocol_for_device(dev);
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
GBinderObjectRegistry* reg = gbinder_ipc_object_registry(ipc);
GBinderRemoteRequest* req = gbinder_remote_request_new(reg, prot, 0, 0);
GBinderLocalObject* obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
@@ -346,7 +347,7 @@
int status = INT_MAX;
const char* dev = GBINDER_DEFAULT_HWBINDER;
const GBinderRpcProtocol* prot = gbinder_rpc_protocol_for_device(dev);
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
GBinderObjectRegistry* reg = gbinder_ipc_object_registry(ipc);
GBinderRemoteRequest* req = gbinder_remote_request_new(reg, prot, 0, 0);
GBinderLocalObject* obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
@@ -402,7 +403,7 @@
const char* dev = GBINDER_DEFAULT_HWBINDER;
const char* const ifaces[] = { "android.hidl.base@1.0::IBase", NULL };
const GBinderRpcProtocol* prot = gbinder_rpc_protocol_for_device(dev);
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
GBinderObjectRegistry* reg = gbinder_ipc_object_registry(ipc);
GBinderRemoteRequest* req = gbinder_remote_request_new(reg, prot, 0, 0);
GBinderLocalObject* obj = gbinder_local_object_new(ipc, ifaces, NULL, NULL);
@@ -476,7 +477,7 @@
int count = 0, status = INT_MAX;
const char* dev = GBINDER_DEFAULT_HWBINDER;
const GBinderRpcProtocol* prot = gbinder_rpc_protocol_for_device(dev);
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
GBinderObjectRegistry* reg = gbinder_ipc_object_registry(ipc);
GBinderRemoteRequest* req = gbinder_remote_request_new(reg, prot, 0, 0);
GBinderLocalObject* obj = gbinder_local_object_new(ipc, ifaces,
@@ -583,7 +584,7 @@
int count = 0, status = 0;
const char* dev = GBINDER_DEFAULT_HWBINDER;
const GBinderRpcProtocol* prot = gbinder_rpc_protocol_for_device(dev);
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
GBinderObjectRegistry* reg = gbinder_ipc_object_registry(ipc);
GBinderRemoteRequest* req = gbinder_remote_request_new(reg, prot, 0, 0);
GBinderLocalObject* obj = gbinder_local_object_new(ipc, ifaces,
@@ -624,7 +625,7 @@
test_increfs_run(
void)
{
- GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER);
+ GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER, NULL);
GBinderLocalObject* obj = gbinder_local_object_new
(ipc, NULL, NULL, NULL);
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
@@ -675,7 +676,7 @@
test_decrefs_run(
void)
{
- GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER);
+ GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER, NULL);
GBinderLocalObject* obj = gbinder_local_object_new
(ipc, NULL, NULL, NULL);
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
@@ -726,7 +727,7 @@
test_acquire_run(
void)
{
- GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER);
+ GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER, NULL);
GBinderLocalObject* obj = gbinder_local_object_new
(ipc, NULL, NULL, NULL);
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
@@ -777,7 +778,7 @@
test_release_run(
void)
{
- GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER);
+ GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER, NULL);
GBinderLocalObject* obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
int fd = gbinder_driver_fd(ipc->driver);
@@ -815,6 +816,18 @@
int main(int argc, char* argv[])
{
+ const char* default_config_dir;
+ const char* default_config_file;
+ char* config_dir = g_dir_make_tmp("gbinder-test-local-object-XXXXXX", NULL);
+ char* config_file = g_build_filename(config_dir, "test.conf", NULL);
+ int result;
+
+ /* Point gbinder_config_file to a non-existent file */
+ default_config_dir = gbinder_config_dir;
+ default_config_file = gbinder_config_file;
+ gbinder_config_dir = config_dir;
+ gbinder_config_file = config_file;
+
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
g_type_init();
G_GNUC_END_IGNORE_DEPRECATIONS;
@@ -833,7 +846,14 @@
g_test_add_func(TEST_PREFIX "acquire", test_acquire);
g_test_add_func(TEST_PREFIX "release", test_release);
test_init(&test_opt, argc, argv);
- return g_test_run();
+ result = g_test_run();
+
+ gbinder_config_dir = default_config_dir;
+ gbinder_config_file = default_config_file;
+ remove(config_dir);
+ g_free(config_dir);
+ g_free(config_file);
+ return result;
}
/*
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_local_reply/unit_local_reply.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -36,6 +36,7 @@
#include "gbinder_local_object.h"
#include "gbinder_local_reply_p.h"
#include "gbinder_output_data.h"
+#include "gbinder_rpc_protocol.h"
#include "gbinder_buffer_p.h"
#include "gbinder_driver.h"
#include "gbinder_writer.h"
@@ -46,11 +47,6 @@
static TestOpt test_opt;
-#define BUFFER_OBJECT_SIZE_32 (24)
-#define BUFFER_OBJECT_SIZE_64 (GBINDER_MAX_BUFFER_OBJECT_SIZE)
-#define BINDER_OBJECT_SIZE_32 (16)
-#define BINDER_OBJECT_SIZE_64 (GBINDER_MAX_BINDER_OBJECT_SIZE)
-
static
void
test_int_inc(
@@ -70,6 +66,14 @@
return gbinder_buffer_new(driver, bytes->data, bytes->len, NULL);
}
+static
+GBinderLocalReply*
+test_local_reply_new()
+{
+ return gbinder_local_reply_new(&gbinder_io_32,
+ gbinder_rpc_protocol_for_device(NULL));
+}
+
/*==========================================================================*
* null
*==========================================================================*/
@@ -82,7 +86,10 @@
GBinderWriter writer;
int count = 0;
- g_assert(!gbinder_local_reply_new(NULL));
+ g_assert(!gbinder_local_reply_new(NULL, NULL));
+ g_assert(!gbinder_local_reply_new(&gbinder_io_32, NULL));
+ g_assert(!gbinder_local_reply_new(NULL,
+ gbinder_rpc_protocol_for_device(NULL)));
g_assert(!gbinder_local_reply_ref(NULL));
gbinder_local_reply_unref(NULL);
gbinder_local_reply_init_writer(NULL, NULL);
@@ -106,6 +113,7 @@
g_assert(!gbinder_local_reply_append_hidl_string_vec(NULL, NULL, 0));
g_assert(!gbinder_local_reply_append_local_object(NULL, NULL));
g_assert(!gbinder_local_reply_append_remote_object(NULL, NULL));
+ g_assert(!gbinder_local_reply_append_fd(NULL, 0));
}
/*==========================================================================*
@@ -117,7 +125,7 @@
test_cleanup(
void)
{
- GBinderLocalReply* reply = gbinder_local_reply_new(&gbinder_io_32);
+ GBinderLocalReply* reply = test_local_reply_new();
int count = 0;
gbinder_local_reply_cleanup(reply, NULL, &count);
@@ -140,7 +148,7 @@
{
static const guint8 output_true[] = { 0x01, 0x00, 0x00, 0x00 };
static const guint8 output_false[] = { 0x00, 0x00, 0x00, 0x00 };
- GBinderLocalReply* reply = gbinder_local_reply_new(&gbinder_io_32);
+ GBinderLocalReply* reply = test_local_reply_new();
GBinderOutputData* data;
gbinder_local_reply_append_bool(reply, FALSE);
@@ -151,7 +159,7 @@
g_assert(!memcmp(data->bytes->data, output_false, data->bytes->len));
gbinder_local_reply_unref(reply);
- reply = gbinder_local_reply_new(&gbinder_io_32);
+ reply = test_local_reply_new();
gbinder_local_reply_append_bool(reply, TRUE);
data = gbinder_local_reply_data(reply);
g_assert(!gbinder_output_data_offsets(data));
@@ -160,7 +168,7 @@
g_assert(!memcmp(data->bytes->data, output_true, data->bytes->len));
gbinder_local_reply_unref(reply);
- reply = gbinder_local_reply_new(&gbinder_io_32);
+ reply = test_local_reply_new();
gbinder_local_reply_append_bool(reply, 42);
data = gbinder_local_reply_data(reply);
g_assert(!gbinder_output_data_offsets(data));
@@ -171,6 +179,31 @@
}
/*==========================================================================*
+ * fd
+ *==========================================================================*/
+
+static
+void
+test_fd(
+ void)
+{
+ const gint32 fd = 1;
+ GBinderLocalReply* reply = test_local_reply_new();
+ GBinderOutputData* data;
+ GUtilIntArray* offsets;
+
+ g_assert(gbinder_local_reply_append_fd(reply, fd));
+ data = gbinder_local_reply_data(reply);
+ offsets = gbinder_output_data_offsets(data);
+ g_assert(offsets);
+ g_assert(offsets->count == 1);
+ g_assert(offsets->data[0] == 0);
+ g_assert(!gbinder_output_data_buffers_size(data));
+ g_assert(data->bytes->len == BINDER_OBJECT_SIZE_32);
+ gbinder_local_reply_unref(reply);
+}
+
+/*==========================================================================*
* int32
*==========================================================================*/
@@ -180,7 +213,7 @@
void)
{
const guint32 value = 1234567;
- GBinderLocalReply* reply = gbinder_local_reply_new(&gbinder_io_32);
+ GBinderLocalReply* reply = test_local_reply_new();
GBinderOutputData* data;
GBinderWriter writer;
@@ -195,7 +228,7 @@
gbinder_local_reply_unref(reply);
/* Same with writer */
- reply = gbinder_local_reply_new(&gbinder_io_32);
+ reply = test_local_reply_new();
gbinder_local_reply_init_writer(reply, &writer);
gbinder_writer_append_int32(&writer, value);
data = gbinder_local_reply_data(reply);
@@ -216,7 +249,7 @@
void)
{
const guint64 value = 123456789;
- GBinderLocalReply* reply = gbinder_local_reply_new(&gbinder_io_32);
+ GBinderLocalReply* reply = test_local_reply_new();
GBinderOutputData* data;
gbinder_local_reply_append_int64(reply, value);
@@ -238,7 +271,7 @@
void)
{
const gfloat value = 123456789;
- GBinderLocalReply* reply = gbinder_local_reply_new(&gbinder_io_32);
+ GBinderLocalReply* reply = test_local_reply_new();
GBinderOutputData* data;
gbinder_local_reply_append_float(reply, value);
@@ -260,7 +293,7 @@
void)
{
const gdouble value = 123456789;
- GBinderLocalReply* reply = gbinder_local_reply_new(&gbinder_io_32);
+ GBinderLocalReply* reply = test_local_reply_new();
GBinderOutputData* data;
gbinder_local_reply_append_double(reply, value);
@@ -284,7 +317,7 @@
/* The size of the string gets aligned at 4-byte boundary */
static const char input[] = "test";
static const guint8 output[] = { 't', 'e', 's', 't', 0, 0, 0, 0 };
- GBinderLocalReply* reply = gbinder_local_reply_new(&gbinder_io_32);
+ GBinderLocalReply* reply = test_local_reply_new();
GBinderOutputData* data;
gbinder_local_reply_append_string8(reply, input);
@@ -296,7 +329,7 @@
gbinder_local_reply_unref(reply);
/* NULL string doesn't get encoded at all (should it be?) */
- reply = gbinder_local_reply_new(&gbinder_io_32);
+ reply = test_local_reply_new();
gbinder_local_reply_append_string8(reply, NULL);
data = gbinder_local_reply_data(reply);
g_assert(!gbinder_output_data_offsets(data));
@@ -320,7 +353,7 @@
TEST_INT16_BYTES('x'), 0x00, 0x00
};
const gint32 null_output = -1;
- GBinderLocalReply* reply = gbinder_local_reply_new(&gbinder_io_32);
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_local_request/unit_local_request.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -35,6 +35,7 @@
#include "gbinder_local_request_p.h"
#include "gbinder_output_data.h"
+#include "gbinder_rpc_protocol.h"
#include "gbinder_buffer_p.h"
#include "gbinder_driver.h"
#include "gbinder_writer.h"
@@ -44,11 +45,6 @@
static TestOpt test_opt;
-#define BUFFER_OBJECT_SIZE_32 (24)
-#define BUFFER_OBJECT_SIZE_64 (GBINDER_MAX_BUFFER_OBJECT_SIZE)
-#define BINDER_OBJECT_SIZE_32 (16)
-#define BINDER_OBJECT_SIZE_64 (GBINDER_MAX_BINDER_OBJECT_SIZE)
-
static
void
test_int_inc(
@@ -80,6 +76,14 @@
return gbinder_buffer_new(driver, bytes->data, bytes->len, objects);
}
+static
+GBinderLocalRequest*
+test_local_request_new()
+{
+ return gbinder_local_request_new(&gbinder_io_32,
+ gbinder_rpc_protocol_for_device(NULL), NULL);
+}
+
/*==========================================================================*
* null
*==========================================================================*/
@@ -92,7 +96,10 @@
GBinderWriter writer;
int count = 0;
- g_assert(!gbinder_local_request_new(NULL, NULL));
+ g_assert(!gbinder_local_request_new(NULL, NULL, NULL));
+ g_assert(!gbinder_local_request_new(&gbinder_io_32, NULL, NULL));
+ g_assert(!gbinder_local_request_new(NULL,
+ gbinder_rpc_protocol_for_device(NULL), NULL));
g_assert(!gbinder_local_request_ref(NULL));
g_assert(!gbinder_local_request_new_from_data(NULL, NULL));
gbinder_local_request_unref(NULL);
@@ -125,7 +132,7 @@
test_cleanup(
void)
{
- GBinderLocalRequest* req = gbinder_local_request_new(&gbinder_io_32, NULL);
+ GBinderLocalRequest* req = test_local_request_new();
int count = 0;
gbinder_local_request_cleanup(req, NULL, &count);
@@ -149,7 +156,7 @@
const guint8 init_data[] = { 0x01, 0x02, 0x03, 0x04 };
GBytes* init_bytes = g_bytes_new_static(init_data, sizeof(init_data));
GBinderLocalRequest* req = gbinder_local_request_new
- (&gbinder_io_32, init_bytes);
+ (&gbinder_io_32, gbinder_rpc_protocol_for_device(NULL), init_bytes);
GBinderOutputData* data;
data = gbinder_local_request_data(req);
@@ -161,7 +168,7 @@
gbinder_local_request_unref(req);
gbinder_local_request_unref(req);
- req = gbinder_local_request_new(&gbinder_io_32, NULL);
+ req = test_local_request_new();
data = gbinder_local_request_data(req);
g_assert(data->bytes);
g_assert(!data->bytes->len);
@@ -181,7 +188,7 @@
{
static const guint8 output_true[] = { 0x01, 0x00, 0x00, 0x00 };
static const guint8 output_false[] = { 0x00, 0x00, 0x00, 0x00 };
- GBinderLocalRequest* req = gbinder_local_request_new(&gbinder_io_32, NULL);
+ GBinderLocalRequest* req = test_local_request_new();
GBinderOutputData* data;
gbinder_local_request_append_bool(req, FALSE);
@@ -192,7 +199,7 @@
g_assert(!memcmp(data->bytes->data, output_false, data->bytes->len));
gbinder_local_request_unref(req);
- req = gbinder_local_request_new(&gbinder_io_32, NULL);
+ req = test_local_request_new();
gbinder_local_request_append_bool(req, TRUE);
data = gbinder_local_request_data(req);
g_assert(!gbinder_output_data_offsets(data));
@@ -201,7 +208,7 @@
g_assert(!memcmp(data->bytes->data, output_true, data->bytes->len));
gbinder_local_request_unref(req);
- req = gbinder_local_request_new(&gbinder_io_32, NULL);
+ req = test_local_request_new();
gbinder_local_request_append_bool(req, 42);
data = gbinder_local_request_data(req);
g_assert(!gbinder_output_data_offsets(data));
@@ -221,7 +228,7 @@
void)
{
const guint32 value = 1234567;
- GBinderLocalRequest* req = gbinder_local_request_new(&gbinder_io_32, NULL);
+ GBinderLocalRequest* req = test_local_request_new();
GBinderOutputData* data;
gbinder_local_request_append_int32(req, value);
@@ -243,7 +250,7 @@
void)
{
const guint64 value = 123456789;
- GBinderLocalRequest* req = gbinder_local_request_new(&gbinder_io_32, NULL);
+ GBinderLocalRequest* req = test_local_request_new();
GBinderOutputData* data;
gbinder_local_request_append_int64(req, value);
@@ -265,7 +272,7 @@
void)
{
const gfloat value = 123456789;
- GBinderLocalRequest* req = gbinder_local_request_new(&gbinder_io_32, NULL);
+ GBinderLocalRequest* req = test_local_request_new();
GBinderOutputData* data;
gbinder_local_request_append_float(req, value);
@@ -287,7 +294,7 @@
void)
{
const gdouble value = 123456789;
- GBinderLocalRequest* req = gbinder_local_request_new(&gbinder_io_32, NULL);
+ GBinderLocalRequest* req = test_local_request_new();
GBinderOutputData* data;
gbinder_local_request_append_double(req, value);
@@ -311,7 +318,7 @@
/* The size of the string gets aligned at 4-byte boundary */
static const char input[] = "test";
static const guint8 output[] = { 't', 'e', 's', 't', 0, 0, 0, 0 };
- GBinderLocalRequest* req = gbinder_local_request_new(&gbinder_io_32, NULL);
+ GBinderLocalRequest* req = test_local_request_new();
GBinderOutputData* data;
gbinder_local_request_append_string8(req, input);
@@ -323,7 +330,7 @@
gbinder_local_request_unref(req);
/* NULL string doesn't get encoded at all (should it be?) */
- req = gbinder_local_request_new(&gbinder_io_32, NULL);
+ req = test_local_request_new();
gbinder_local_request_append_string8(req, NULL);
data = gbinder_local_request_data(req);
g_assert(!gbinder_output_data_offsets(data));
@@ -347,7 +354,7 @@
TEST_INT16_BYTES('x'), 0x00, 0x00
};
const gint32 null_output = -1;
- GBinderLocalRequest* req = gbinder_local_request_new(&gbinder_io_32, NULL);
+ GBinderLocalRequest* req = test_local_request_new();
GBinderOutputData* data;
gbinder_local_request_append_string16(req, input);
@@ -359,7 +366,7 @@
gbinder_local_request_unref(req);
/* NULL string gets encoded as -1 */
- req = gbinder_local_request_new(&gbinder_io_32, NULL);
+ req = test_local_request_new();
gbinder_local_request_append_string16(req, NULL);
data = gbinder_local_request_data(req);
g_assert(!gbinder_output_data_offsets(data));
@@ -378,7 +385,7 @@
test_hidl_string(
void)
{
- GBinderLocalRequest* req = gbinder_local_request_new(&gbinder_io_32, NULL);
+ GBinderLocalRequest* req = test_local_request_new();
GBinderOutputData* data;
GUtilIntArray* offsets;
@@ -401,7 +408,7 @@
test_hidl_string_vec(
void)
{
- GBinderLocalRequest* req = gbinder_local_request_new(&gbinder_io_32, NULL);
+ GBinderLocalRequest* req = test_local_request_new();
GBinderOutputData* data;
GUtilIntArray* offsets;
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_protocol/unit_protocol.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2020 Jolla Ltd.
- * Copyright (C) 2018-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -49,6 +49,7 @@
#define STRICT_MODE_PENALTY_GATHER (0x40 << 16)
#define BINDER_RPC_FLAGS (STRICT_MODE_PENALTY_GATHER)
#define UNSET_WORK_SOURCE (-1)
+#define BINDER_SYS_HEADER GBINDER_FOURCC('S', 'Y', 'S', 'T')
typedef struct test_data {
const char* name;
@@ -80,6 +81,15 @@
TEST_INT16_BYTES('o'), 0x00, 0x00
};
+static const guint8 test_header_aidl3 [] = {
+ TEST_INT32_BYTES(BINDER_RPC_FLAGS),
+ TEST_INT32_BYTES(UNSET_WORK_SOURCE),
+ TEST_INT32_BYTES(BINDER_SYS_HEADER),
+ TEST_INT32_BYTES(3),
+ TEST_INT16_BYTES('f'), TEST_INT16_BYTES('o'),
+ TEST_INT16_BYTES('o'), 0x00, 0x00
+};
+
static const guint8 test_header_hidl [] = {
'f', 'o', 'o', 0x00
};
@@ -97,6 +107,14 @@
test_header_aidl2, 5 }, /* Short packet */
{ "aidl2/short/3", "adl2", GBINDER_DEFAULT_BINDER, NULL,
test_header_aidl2, 9 }, /* Short packet */
+ { "aidl3/ok", "aidl3", GBINDER_DEFAULT_BINDER, "foo",
+ TEST_ARRAY_AND_SIZE(test_header_aidl3) },
+ { "aidl3/short/1", "aidl3", GBINDER_DEFAULT_BINDER, NULL,
+ test_header_aidl3, 1 }, /* Short packet */
+ { "aidl3/short/2", "aidl3", GBINDER_DEFAULT_BINDER, NULL,
+ test_header_aidl3, 5 }, /* Short packet */
+ { "aidl3/short/3", "adl3", GBINDER_DEFAULT_BINDER, NULL,
+ test_header_aidl3, 9 }, /* Short packet */
{ "hidl/ok", "hidl", GBINDER_DEFAULT_HWBINDER, "foo",
TEST_ARRAY_AND_SIZE(test_header_hidl) },
{ "hidl/short", "hidl", GBINDER_DEFAULT_HWBINDER, NULL,
@@ -166,6 +184,9 @@
void)
{
const GBinderRpcProtocol* p;
+ TestConfig config;
+
+ test_config_init(&config, "");
p = gbinder_rpc_protocol_for_device(NULL);
g_assert(p);
@@ -178,6 +199,8 @@
p = gbinder_rpc_protocol_for_device(GBINDER_DEFAULT_HWBINDER);
g_assert(p);
g_assert_cmpstr(p->name, == ,"hidl");
+
+ test_config_cleanup(&config);
}
/*==========================================================================*
@@ -348,6 +371,7 @@
static const TestData test_no_header_data[] = {
{ "aidl", "aidl", GBINDER_DEFAULT_BINDER },
{ "aidl2", "aidl2", GBINDER_DEFAULT_BINDER },
+ { "aidl3", "aidl3", GBINDER_DEFAULT_BINDER },
};
/*==========================================================================*
@@ -369,7 +393,8 @@
test_config_init2(&config, test->dev, test->prot);
prot = gbinder_rpc_protocol_for_device(test->dev);
- req = gbinder_local_request_new(&gbinder_io_32, NULL);
+ req = gbinder_local_request_new(&gbinder_io_32,
+ gbinder_rpc_protocol_for_device(NULL), NULL);
gbinder_local_request_init_writer(req, &writer);
prot->write_rpc_header(&writer, test->iface);
data = gbinder_local_request_data(req);
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_proxy_object/unit_proxy_object.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2021 Jolla Ltd.
- * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2021-2022 Jolla Ltd.
+ * Copyright (C) 2021-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -198,8 +198,8 @@
int fd_obj, fd_proxy, n = 0;
test_config_init(&config, NULL);
- ipc_proxy = gbinder_ipc_new(DEV);
- ipc_obj = gbinder_ipc_new(DEV_PRIV);
+ ipc_proxy = gbinder_ipc_new(DEV, NULL);
+ ipc_obj = gbinder_ipc_new(DEV_PRIV, NULL);
fd_proxy = gbinder_driver_fd(ipc_proxy->driver);
fd_obj = gbinder_driver_fd(ipc_obj->driver);
obj = gbinder_local_object_new(ipc_obj, TEST_IFACES, test_basic_cb, &n);
@@ -362,10 +362,10 @@
int fd_obj, fd_proxy, n = 0;
test_config_init(&config, NULL);
- ipc_obj = gbinder_ipc_new(DEV);
- ipc_remote_obj = gbinder_ipc_new(DEV_PRIV);
- ipc_proxy = gbinder_ipc_new(DEV2);
- ipc_remote_proxy = gbinder_ipc_new(DEV2_PRIV);
+ ipc_obj = gbinder_ipc_new(DEV, NULL);
+ ipc_remote_obj = gbinder_ipc_new(DEV_PRIV, NULL);
+ ipc_proxy = gbinder_ipc_new(DEV2, NULL);
+ ipc_remote_proxy = gbinder_ipc_new(DEV2_PRIV, NULL);
fd_proxy = gbinder_driver_fd(ipc_proxy->driver);
fd_obj = gbinder_driver_fd(ipc_obj->driver);
obj = gbinder_local_object_new(ipc_obj, TEST_IFACES, test_param_cb, &n);
@@ -438,7 +438,7 @@
typedef struct test_obj_data {
GMainLoop* loop;
- GBinderLocalObject* tmp_proxy;
+ GBinderLocalObject* obj2;
gboolean obj_call_handled;
gboolean obj_call_finished;
gboolean obj2_call_handled;
@@ -539,9 +539,9 @@
g_assert(gbinder_reader_at_end(&reader));
/* Make sure temporary proxy won't get destroyed too early */
- test->tmp_proxy = test_binder_object(gbinder_driver_fd(obj->ipc->driver),
+ test->obj2 = test_binder_object(gbinder_driver_fd(obj->ipc->driver),
obj2->handle);
- g_assert(test->tmp_proxy);
+ g_assert(test->obj2);
/* Call remote object */
client2 = gbinder_client_new(obj2, TEST_IFACE2);
@@ -599,39 +599,55 @@
GBinderRemoteObject* remote_obj;
GBinderRemoteObject* remote_proxy;
GBinderClient* proxy_client;
+ GBinderIpc* ipc_remote_obj;
GBinderIpc* ipc_obj;
GBinderIpc* ipc_proxy;
+ GBinderIpc* ipc_remote_proxy;
GBinderLocalRequest* req;
- int fd_obj, fd_proxy;
+ int fd_remote_obj, fd_obj, fd_proxy, fd_remote_proxy;
test_config_init(&config, NULL);
memset(&test, 0, sizeof(test));
test.loop = g_main_loop_new(NULL, FALSE);
- ipc_proxy = gbinder_ipc_new(DEV);
- ipc_obj = gbinder_ipc_new(DEV_PRIV);
- fd_proxy = gbinder_driver_fd(ipc_proxy->driver);
+ ipc_remote_obj = gbinder_ipc_new(DEV_PRIV, NULL);
+ ipc_obj = gbinder_ipc_new(DEV, NULL);
+ ipc_proxy = gbinder_ipc_new(DEV2, NULL);
+ ipc_remote_proxy = gbinder_ipc_new(DEV2_PRIV, NULL);
+
+ fd_remote_obj = gbinder_driver_fd(ipc_remote_obj->driver);
fd_obj = gbinder_driver_fd(ipc_obj->driver);
- obj = gbinder_local_object_new(ipc_obj, TEST_IFACES, test_obj_cb, &test);
- obj2 = gbinder_local_object_new(ipc_obj, TEST_IFACES2, test_obj2_cb, &test);
- remote_obj = gbinder_remote_object_new(ipc_proxy,
+ fd_proxy = gbinder_driver_fd(ipc_proxy->driver);
+ fd_remote_proxy = gbinder_driver_fd(ipc_remote_proxy->driver);
+
+ obj = gbinder_local_object_new(ipc_remote_obj, TEST_IFACES,
+ test_obj_cb, &test);
+ GDEBUG("obj %p", obj);
+ remote_obj = gbinder_remote_object_new(ipc_obj,
test_binder_register_object(fd_obj, obj, AUTO_HANDLE),
REMOTE_OBJECT_CREATE_ALIVE);
- /* remote_proxy(DEV_PRIV) => proxy (DEV) => obj (DEV) => DEV_PRIV */
- g_assert(!gbinder_proxy_object_new(NULL, remote_obj));
+ /* remote_proxy(DEV2_PRIV) => proxy (DEV) => obj(DEV2_PRIV) */
g_assert((proxy = gbinder_proxy_object_new(ipc_proxy, remote_obj)));
- remote_proxy = gbinder_remote_object_new(ipc_obj,
+ GDEBUG("proxy %p", proxy);
+ remote_proxy = gbinder_remote_object_new(ipc_remote_proxy,
test_binder_register_object(fd_proxy, &proxy->parent, AUTO_HANDLE),
REMOTE_OBJECT_CREATE_ALIVE);
proxy_client = gbinder_client_new(remote_proxy, TEST_IFACE);
+ test_binder_set_passthrough(fd_remote_obj, TRUE);
test_binder_set_passthrough(fd_obj, TRUE);
test_binder_set_passthrough(fd_proxy, TRUE);
+ test_binder_set_passthrough(fd_remote_proxy, TRUE);
+
+ test_binder_set_looper_enabled(fd_remote_obj, TEST_LOOPER_ENABLE);
test_binder_set_looper_enabled(fd_obj, TEST_LOOPER_ENABLE);
test_binder_set_looper_enabled(fd_proxy, TEST_LOOPER_ENABLE);
+ test_binder_set_looper_enabled(fd_remote_proxy, TEST_LOOPER_ENABLE);
/* Pass object reference via proxy */
+ obj2 = gbinder_local_object_new(ipc_remote_proxy, TEST_IFACES2, test_obj2_cb, &test);
+ GDEBUG("obj2 %p", obj2);
req = gbinder_client_new_request(proxy_client);
gbinder_local_request_append_int32(req, TX_PARAM1);
gbinder_local_request_append_local_object(req, obj2);
@@ -646,19 +662,24 @@
g_assert(test.obj_call_finished);
g_assert(test.obj2_call_handled);
g_assert(test.obj2_call_finished);
- g_assert(test.tmp_proxy);
- gbinder_local_object_unref(test.tmp_proxy);
+ g_assert(test.obj2);
+ gbinder_local_object_unref(test.obj2);
+ test_binder_unregister_objects(fd_remote_obj);
test_binder_unregister_objects(fd_obj);
test_binder_unregister_objects(fd_proxy);
+ test_binder_unregister_objects(fd_remote_proxy);
+
gbinder_local_object_drop(obj);
gbinder_local_object_drop(obj2);
gbinder_local_object_drop(&proxy->parent);
gbinder_remote_object_unref(remote_obj);
gbinder_remote_object_unref(remote_proxy);
gbinder_client_unref(proxy_client);
+ gbinder_ipc_unref(ipc_remote_obj);
gbinder_ipc_unref(ipc_obj);
gbinder_ipc_unref(ipc_proxy);
+ gbinder_ipc_unref(ipc_remote_proxy);
gbinder_ipc_exit();
test_binder_exit_wait(&test_opt, test.loop);
test_config_deinit(&config);
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_reader/unit_reader.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -39,6 +39,8 @@
#include "gbinder_remote_object_p.h"
#include "gbinder_io.h"
+#include <gutil_misc.h>
+
#include <unistd.h>
#include <fcntl.h>
@@ -65,6 +67,41 @@
#define BUFFER_OBJECT_SIZE_64 (GBINDER_MAX_BUFFER_OBJECT_SIZE)
G_STATIC_ASSERT(sizeof(BinderObject64) == BUFFER_OBJECT_SIZE_64);
+static
+void
+test_init_reader(
+ GBinderDriver* driver,
+ GBinderReaderData* data,
+ GBinderReader* reader,
+ const void* bytes,
+ gsize size)
+{
+ data->buffer = gbinder_buffer_new(driver, gutil_memdup(bytes, size),
+ size, NULL);
+ gbinder_reader_init(reader, data, 0, size);
+}
+
+/*==========================================================================*
+ * null
+ *==========================================================================*/
+
+static
+void
+test_null(
+ void)
+{
+ GBinderReader reader;
+
+ /* NULL const pointers are tolerated */
+ g_assert(gbinder_reader_at_end(NULL));
+ g_assert(!gbinder_reader_bytes_read(NULL));
+ g_assert(!gbinder_reader_bytes_remaining(NULL));
+ g_assert(!gbinder_reader_get_data(NULL, NULL));
+
+ gbinder_reader_copy(&reader, NULL);
+ g_assert(gbinder_reader_at_end(&reader));
+}
+
/*==========================================================================*
* empty
*==========================================================================*/
@@ -76,14 +113,19 @@
{
GBinderReader reader;
gsize count = 1, elemsize = 1;
- gsize len;
+ gsize size = 1;
gbinder_reader_init(&reader, NULL, 0, 0);
g_assert(gbinder_reader_at_end(&reader));
+ g_assert(!gbinder_reader_get_data(&reader, NULL));
+ g_assert(!gbinder_reader_get_data(&reader, &size));
+ g_assert(!size);
g_assert(!gbinder_reader_bytes_read(&reader));
g_assert(!gbinder_reader_bytes_remaining(&reader));
g_assert(!gbinder_reader_read_byte(&reader, NULL));
g_assert(!gbinder_reader_read_bool(&reader, NULL));
+ g_assert(!gbinder_reader_read_int8(&reader, NULL));
+ g_assert(!gbinder_reader_read_int16(&reader, NULL));
g_assert(!gbinder_reader_read_int32(&reader, NULL));
g_assert(!gbinder_reader_read_uint32(&reader, NULL));
g_assert(!gbinder_reader_read_int64(&reader, NULL));
@@ -93,6 +135,7 @@
g_assert(!gbinder_reader_read_object(&reader));
g_assert(!gbinder_reader_read_nullable_object(&reader, NULL));
g_assert(!gbinder_reader_read_buffer(&reader));
+ g_assert(!gbinder_reader_read_parcelable(&reader, NULL));
g_assert(!gbinder_reader_read_hidl_struct1(&reader, 1));
g_assert(!gbinder_reader_read_hidl_vec(&reader, NULL, NULL));
g_assert(!gbinder_reader_read_hidl_vec(&reader, &count, &elemsize));
@@ -107,7 +150,7 @@
g_assert(!gbinder_reader_read_string8(&reader));
g_assert(!gbinder_reader_read_string16(&reader));
g_assert(!gbinder_reader_skip_string16(&reader));
- g_assert(!gbinder_reader_read_byte_array(&reader, &len));
+ g_assert(!gbinder_reader_read_byte_array(&reader, &size));
}
/*==========================================================================*
@@ -152,8 +195,8 @@
test_bool(
void)
{
- const guint8 in_true[4] = { 0x01, 0xff, 0xff, 0xff };
- const guint8 in_false[4] = { 0x00, 0xff, 0xff, 0xff };
+ const guint8 in_true[] = { TEST_INT8_BYTES_4(TRUE) };
+ const guint8 in_false[] = { TEST_INT8_BYTES_4(FALSE) };
gboolean out = FALSE;
GBinderDriver* driver = gbinder_driver_new(GBINDER_DEFAULT_BINDER, NULL);
GBinderReader reader;
@@ -193,6 +236,108 @@
}
/*==========================================================================*
+ * int8
+ *==========================================================================*/
+
+static
+void
+test_int8(
+ void)
+{
+ const guint8 in = 42;
+ const guint8 in4[] = { TEST_INT8_BYTES_4(42) };
+ guint8 out1 = 0;
+ gint8 out2 = 0;
+ GBinderDriver* driver = gbinder_driver_new(GBINDER_DEFAULT_BINDER, NULL);
+ GBinderReader reader;
+ GBinderReaderData data;
+
+ g_assert(driver);
+ memset(&data, 0, sizeof(data));
+
+ /* Not enough data */
+ data.buffer = gbinder_buffer_new(driver, g_memdup(&in, sizeof(in)),
+ sizeof(in), NULL);
+
+ gbinder_reader_init(&reader, &data, 0, sizeof(in));
+ g_assert(!gbinder_reader_read_uint8(&reader, &out1));
+ g_assert(!gbinder_reader_at_end(&reader));
+ gbinder_buffer_free(data.buffer);
+
+ /* Enough data */
+ data.buffer = gbinder_buffer_new(driver, g_memdup(in4, sizeof(in4)),
+ sizeof(in4), NULL);
+
+ gbinder_reader_init(&reader, &data, 0, sizeof(in4));
+ g_assert(gbinder_reader_read_uint8(&reader, &out1));
+ g_assert(gbinder_reader_at_end(&reader));
+ g_assert_cmpuint(in, == ,out1);
+
+ gbinder_reader_init(&reader, &data, 0, sizeof(in4));
+ g_assert(gbinder_reader_read_int8(&reader, &out2));
+ g_assert(gbinder_reader_at_end(&reader));
+ g_assert_cmpint(in, == ,out2);
+
+ gbinder_reader_init(&reader, &data, 0, sizeof(in4));
+ g_assert(gbinder_reader_read_int8(&reader, NULL));
+ g_assert(gbinder_reader_at_end(&reader));
+
+ gbinder_buffer_free(data.buffer);
+ gbinder_driver_unref(driver);
+}
+
+/*==========================================================================*
+ * int16
+ *==========================================================================*/
+
+static
+void
+test_int16(
+ void)
+{
+ const guint16 in = 42;
+ const guint8 in4[] = { TEST_INT16_BYTES_4(42) };
+ guint16 out1 = 0;
+ gint16 out2 = 0;
+ GBinderDriver* driver = gbinder_driver_new(GBINDER_DEFAULT_BINDER, NULL);
+ GBinderReader reader;
+ GBinderReaderData data;
+
+ g_assert(driver);
+ memset(&data, 0, sizeof(data));
+
+ /* Not enough data */
+ data.buffer = gbinder_buffer_new(driver, g_memdup(&in, sizeof(in)),
+ sizeof(in), NULL);
+
+ gbinder_reader_init(&reader, &data, 0, sizeof(in));
+ g_assert(!gbinder_reader_read_uint16(&reader, &out1));
+ g_assert(!gbinder_reader_at_end(&reader));
+ gbinder_buffer_free(data.buffer);
+
+ /* Enough data */
+ data.buffer = gbinder_buffer_new(driver, g_memdup(in4, sizeof(in4)),
+ sizeof(in4), NULL);
+
+ gbinder_reader_init(&reader, &data, 0, sizeof(in4));
+ g_assert(gbinder_reader_read_uint16(&reader, &out1));
+ g_assert(gbinder_reader_at_end(&reader));
+ g_assert_cmpuint(in, == ,out1);
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_remote_object/unit_remote_object.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -68,7 +68,7 @@
test_basic(
void)
{
- GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER);
+ GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER, NULL);
GBinderObjectRegistry* reg = gbinder_ipc_object_registry(ipc);
GBinderRemoteObject* obj1 = gbinder_object_registry_get_remote(reg,1,TRUE);
GBinderRemoteObject* obj2 = gbinder_object_registry_get_remote(reg,2,TRUE);
@@ -112,7 +112,7 @@
{
const guint h = 1;
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
- GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER);
+ GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER, NULL);
GBinderObjectRegistry* reg = gbinder_ipc_object_registry(ipc);
const int fd = gbinder_driver_fd(ipc->driver);
GBinderRemoteObject* obj = gbinder_object_registry_get_remote(reg, h, TRUE);
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_remote_reply/unit_remote_reply.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -31,6 +31,7 @@
*/
#include "test_common.h"
+#include "test_binder.h"
#include "gbinder_buffer_p.h"
#include "gbinder_driver.h"
@@ -44,9 +45,6 @@
static TestOpt test_opt;
-#define BINDER_TYPE_BINDER GBINDER_FOURCC('s', 'b', '*', 0x85)
-#define BINDER_OBJECT_SIZE_64 (GBINDER_MAX_BINDER_OBJECT_SIZE)
-
/*==========================================================================*
* Dummy GBinderObjectRegistry functions
*==========================================================================*/
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_remote_request/unit_remote_request.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -31,8 +31,10 @@
*/
#include "test_common.h"
+#include "test_binder.h"
#include "gbinder_buffer_p.h"
+#include "gbinder_config.h"
#include "gbinder_driver.h"
#include "gbinder_reader.h"
#include "gbinder_remote_request_p.h"
@@ -58,9 +60,6 @@
#define HIDL_RPC_HEADER \
'f', 'o', 'o', 0x00
-#define BINDER_TYPE_BINDER GBINDER_FOURCC('s', 'b', '*', 0x85)
-#define BINDER_OBJECT_SIZE_64 (GBINDER_MAX_BINDER_OBJECT_SIZE)
-
/*==========================================================================*
* null
*==========================================================================*/
@@ -369,6 +368,18 @@
int main(int argc, char* argv[])
{
+ const char* default_config_dir;
+ const char* default_config_file;
+ char* conf_dir = g_dir_make_tmp("gbinder-test-remote-request-XXXXXX", NULL);
+ char* conf_file = g_build_filename(conf_dir, "test.conf", NULL);
+ int result;
+
+ /* Point gbinder_config_file to a non-existent file */
+ default_config_dir = gbinder_config_dir;
+ default_config_file = gbinder_config_file;
+ gbinder_config_dir = conf_dir;
+ gbinder_config_file = conf_file;
+
g_test_init(&argc, &argv, NULL);
g_test_add_func(TEST_PREFIX "null", test_null);
g_test_add_func(TEST_PREFIX "basic", test_basic);
@@ -378,7 +389,14 @@
g_test_add_func(TEST_PREFIX "string16", test_string16);
g_test_add_func(TEST_PREFIX "to_local", test_to_local);
test_init(&test_opt, argc, argv);
- return g_test_run();
+ result = g_test_run();
+
+ gbinder_config_dir = default_config_dir;
+ gbinder_config_file = default_config_file;
+ remove(conf_dir);
+ g_free(conf_dir);
+ g_free(conf_file);
+ return result;
}
/*
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_servicemanager/unit_servicemanager.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -386,8 +386,25 @@
GType
gbinder_servicemanager_aidl2_get_type()
{
- /* Avoid pulling in gbinder_servicemanager_aidl2 object */
- return TEST_TYPE_DEFSERVICEMANAGER;
+ /* Dummy function to avoid pulling in gbinder_servicemanager_aidl2 */
+ g_assert_not_reached();
+ return 0;
+}
+
+GType
+gbinder_servicemanager_aidl3_get_type()
+{
+ /* Dummy function to avoid pulling in gbinder_servicemanager_aidl3 */
+ g_assert_not_reached();
+ return 0;
+}
+
+GType
+gbinder_servicemanager_aidl4_get_type()
+{
+ /* Dummy function to avoid pulling in gbinder_servicemanager_aidl4 */
+ g_assert_not_reached();
+ return 0;
}
/*==========================================================================*
@@ -400,9 +417,10 @@
void)
{
g_assert(!gbinder_servicemanager_new(NULL));
- g_assert(!gbinder_servicemanager_new_with_type(0, NULL));
+ g_assert(!gbinder_servicemanager_new_with_type(0, NULL, NULL));
g_assert(!gbinder_servicemanager_new_local_object(NULL, NULL, NULL, NULL));
g_assert(!gbinder_servicemanager_ref(NULL));
+ g_assert(!gbinder_servicemanager_device(NULL));
g_assert(!gbinder_servicemanager_is_present(NULL));
g_assert(!gbinder_servicemanager_wait(NULL, 0));
g_assert(!gbinder_servicemanager_list(NULL, NULL, NULL));
@@ -432,14 +450,15 @@
{
int status = 0;
const char* dev = GBINDER_DEFAULT_HWBINDER;
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
GBinderServiceManager* sm;
gulong id = 0;
test_setup_ping(ipc);
+ g_assert(!gbinder_servicemanager_new2(GBINDER_DEFAULT_HWBINDER, "a", NULL));
sm = gbinder_servicemanager_new(dev);
g_assert(!gbinder_servicemanager_new_with_type(GBINDER_TYPE_LOCAL_OBJECT,
- NULL));
+ NULL, NULL));
g_assert(TEST_IS_HWSERVICEMANAGER(sm));
g_assert(!gbinder_servicemanager_list(sm, NULL, NULL));
g_assert(!gbinder_servicemanager_get_service(sm, "foo", NULL, NULL));
@@ -477,7 +496,7 @@
void)
{
const char* dev = GBINDER_DEFAULT_HWBINDER;
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
GBinderServiceManager* sm;
GBinderLocalObject* obj;
@@ -487,6 +506,7 @@
obj = gbinder_servicemanager_new_local_object(sm, "foo.bar",
test_transact_func, NULL);
g_assert(obj);
+ g_assert_cmpstr(gbinder_servicemanager_device(sm), == ,dev);
gbinder_local_object_unref(obj);
g_assert(gbinder_servicemanager_ref(sm) == sm);
@@ -507,7 +527,7 @@
{
const char* otherdev = "/dev/otherbinder";
const char* dev = GBINDER_DEFAULT_HWBINDER;
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
GBinderServiceManager* sm;
/* Reset the state */
@@ -528,7 +548,7 @@
gbinder_ipc_unref(ipc);
/* Legacy default */
- ipc = gbinder_ipc_new(otherdev);
+ ipc = gbinder_ipc_new(otherdev, NULL);
test_setup_ping(ipc);
sm = gbinder_servicemanager_new(otherdev);
g_assert(TEST_IS_DEFSERVICEMANAGER(sm));
@@ -571,7 +591,7 @@
gbinder_config_file = file;
/* Unknown device instantiates the default */
- ipc = gbinder_ipc_new(strange_name);
+ ipc = gbinder_ipc_new(strange_name, NULL);
test_setup_ping(ipc);
sm = gbinder_servicemanager_new(strange_name);
g_assert(TEST_IS_HWSERVICEMANAGER(sm));
@@ -579,7 +599,7 @@
gbinder_ipc_unref(ipc);
/* This one was redefined */
- ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER);
+ ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER, NULL);
test_setup_ping(ipc);
sm = gbinder_servicemanager_new(GBINDER_DEFAULT_BINDER);
g_assert(TEST_IS_HWSERVICEMANAGER(sm));
@@ -587,7 +607,7 @@
gbinder_ipc_unref(ipc);
/* This one was not (since name was invalid) */
- ipc = gbinder_ipc_new(GBINDER_DEFAULT_HWBINDER);
+ ipc = gbinder_ipc_new(GBINDER_DEFAULT_HWBINDER, NULL);
test_setup_ping(ipc);
sm = gbinder_servicemanager_new(GBINDER_DEFAULT_HWBINDER);
g_assert(TEST_IS_HWSERVICEMANAGER(sm));
@@ -595,13 +615,21 @@
gbinder_ipc_unref(ipc);
/* This one points to legacy manager */
- ipc = gbinder_ipc_new(legacy_name);
+ ipc = gbinder_ipc_new(legacy_name, NULL);
test_setup_ping(ipc);
sm = gbinder_servicemanager_new(legacy_name);
g_assert(TEST_IS_DEFSERVICEMANAGER(sm));
gbinder_servicemanager_unref(sm);
gbinder_ipc_unref(ipc);
+ /* Overwrite the legacy manager with "hidl" */
+ ipc = gbinder_ipc_new(legacy_name, "hidl");
+ test_setup_ping(ipc);
+ sm = gbinder_servicemanager_new2(legacy_name, "hidl", "hidl");
+ g_assert(TEST_IS_HWSERVICEMANAGER(sm));
+ gbinder_servicemanager_unref(sm);
+ gbinder_ipc_unref(ipc);
+
/* Clear the state */
gbinder_servicemanager_exit();
gbinder_config_exit();
@@ -623,7 +651,7 @@
void)
{
const char* dev = GBINDER_DEFAULT_HWBINDER;
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
const int fd = gbinder_driver_fd(ipc->driver);
GBinderServiceManager* sm;
@@ -648,7 +676,7 @@
void)
{
const char* dev = GBINDER_DEFAULT_HWBINDER;
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
const int fd = gbinder_driver_fd(ipc->driver);
const glong forever = (test_opt.flags & TEST_FLAG_DEBUG) ?
(TEST_TIMEOUT_SEC * 1000) : -1;
@@ -699,7 +727,7 @@
void)
{
const char* dev = GBINDER_DEFAULT_HWBINDER;
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
const int fd = gbinder_driver_fd(ipc->driver);
GBinderServiceManager* sm;
gulong id;
@@ -745,7 +773,7 @@
void)
{
const char* dev = GBINDER_DEFAULT_HWBINDER;
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
const int fd = gbinder_driver_fd(ipc->driver);
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
GBinderServiceManager* sm;
@@ -789,7 +817,7 @@
test_death_run()
{
const char* dev = GBINDER_DEFAULT_HWBINDER;
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
const int fd = gbinder_driver_fd(ipc->driver);
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
GBinderServiceManager* sm;
@@ -866,7 +894,7 @@
void)
{
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_servicemanager_aidl/unit_servicemanager_aidl.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2020-2021 Jolla Ltd.
- * Copyright (C) 2020-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2020-2022 Jolla Ltd.
+ * Copyright (C) 2020-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -50,14 +50,32 @@
GType
gbinder_servicemanager_hidl_get_type()
{
- /* Avoid pulling in gbinder_servicemanager_hidl object */
+ /* Dummy function to avoid pulling in gbinder_servicemanager_hidl */
+ g_assert_not_reached();
return 0;
}
GType
gbinder_servicemanager_aidl2_get_type()
{
- /* Avoid pulling in gbinder_servicemanager_aidl2 object */
+ /* Dummy function to avoid pulling in gbinder_servicemanager_aidl2 */
+ g_assert_not_reached();
+ return 0;
+}
+
+GType
+gbinder_servicemanager_aidl3_get_type()
+{
+ /* Dummy function to avoid pulling in gbinder_servicemanager_aidl3 */
+ g_assert_not_reached();
+ return 0;
+}
+
+GType
+gbinder_servicemanager_aidl4_get_type()
+{
+ /* Dummy function to avoid pulling in gbinder_servicemanager_aidl4 */
+ g_assert_not_reached();
return 0;
}
@@ -172,7 +190,7 @@
{
ServiceManagerAidl* self = g_object_new(SERVICE_MANAGER_AIDL_TYPE, NULL);
GBinderLocalObject* obj = GBINDER_LOCAL_OBJECT(self);
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
const int fd = gbinder_driver_fd(ipc->driver);
self->handle_on_looper_thread = handle_on_looper_thread;
@@ -312,7 +330,7 @@
{
const char* dev = GBINDER_DEFAULT_BINDER;
const char* other_dev = GBINDER_DEFAULT_BINDER "-private";
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
ServiceManagerAidl* smsvc = servicemanager_aidl_new(other_dev, FALSE);
GBinderLocalObject* obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
const int fd = gbinder_driver_fd(ipc->driver);
@@ -394,7 +412,7 @@
{
const char* dev = GBINDER_DEFAULT_BINDER;
const char* other_dev = GBINDER_DEFAULT_BINDER "-private";
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
ServiceManagerAidl* smsvc = servicemanager_aidl_new(other_dev, FALSE);
GBinderLocalObject* obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
const int fd = gbinder_driver_fd(ipc->driver);
@@ -473,7 +491,7 @@
{
const char* dev = GBINDER_DEFAULT_BINDER;
const char* other_dev = GBINDER_DEFAULT_BINDER "-private";
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
ServiceManagerAidl* svc = servicemanager_aidl_new(other_dev, FALSE);
GBinderLocalObject* obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
const int fd = gbinder_driver_fd(ipc->driver);
@@ -530,7 +548,7 @@
{
const char* dev = GBINDER_DEFAULT_BINDER;
const char* other_dev = GBINDER_DEFAULT_BINDER "-private";
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
ServiceManagerAidl* smsvc = servicemanager_aidl_new(other_dev, TRUE);
GBinderLocalObject* obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
const int fd = gbinder_driver_fd(ipc->driver);
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_servicemanager_aidl2/unit_servicemanager_aidl2.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2020-2021 Jolla Ltd.
- * Copyright (C) 2020-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2020-2022 Jolla Ltd.
+ * Copyright (C) 2020-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -53,7 +53,8 @@
GType
gbinder_servicemanager_hidl_get_type()
{
- /* Avoid pulling in gbinder_servicemanager_hidl object */
+ /* Dummy function to avoid pulling in gbinder_servicemanager_hidl */
+ g_assert_not_reached();
return 0;
}
@@ -174,7 +175,7 @@
{
ServiceManagerAidl2* self = g_object_new(SERVICE_MANAGER_AIDL2_TYPE, NULL);
GBinderLocalObject* obj = GBINDER_LOCAL_OBJECT(self);
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
const int fd = gbinder_driver_fd(ipc->driver);
self->handle_on_looper_thread = handle_on_looper_thread;
@@ -304,7 +305,7 @@
gbinder_config_dir = test->config_subdir; /* Doesn't exist */
gbinder_config_file = test->config_file;
- ipc = gbinder_ipc_new(dev);
+ ipc = gbinder_ipc_new(dev, NULL);
test->fd = gbinder_driver_fd(ipc->driver);
test->object = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_servicemanager_aidl3/Makefile
^
|
@@ -0,0 +1,5 @@
+# -*- Mode: makefile-gmake -*-
+
+EXE = unit_servicemanager_aidl3
+
+include ../common/Makefile
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_servicemanager_aidl3/unit_servicemanager_aidl3.c
^
|
@@ -0,0 +1,464 @@
+/*
+ * Copyright (C) 2020-2022 Jolla Ltd.
+ * Copyright (C) 2020-2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "test_binder.h"
+
+#include "gbinder_driver.h"
+#include "gbinder_config.h"
+#include "gbinder_ipc.h"
+#include "gbinder_reader.h"
+#include "gbinder_servicemanager_p.h"
+#include "gbinder_rpc_protocol.h"
+#include "gbinder_local_object_p.h"
+#include "gbinder_local_reply.h"
+#include "gbinder_remote_request.h"
+#include "gbinder_remote_object.h"
+#include "gbinder_writer.h"
+
+#include <gutil_strv.h>
+#include <gutil_log.h>
+
+static TestOpt test_opt;
+static const char TMP_DIR_TEMPLATE[] =
+ "gbinder-test-servicemanager_aidl3-XXXXXX";
+
+GType
+gbinder_servicemanager_hidl_get_type()
+{
+ /* Dummy function to avoid pulling in gbinder_servicemanager_hidl */
+ g_assert_not_reached();
+ return 0;
+}
+
+/*==========================================================================*
+ * Test service manager
+ *==========================================================================*/
+
+#define SVCMGR_HANDLE (0)
+static const char SVCMGR_IFACE[] = "android.os.IServiceManager";
+enum servicemanager_aidl_tx {
+ GET_SERVICE_TRANSACTION = GBINDER_FIRST_CALL_TRANSACTION,
+ CHECK_SERVICE_TRANSACTION,
+ ADD_SERVICE_TRANSACTION,
+ LIST_SERVICES_TRANSACTION
+};
+
+const char* const servicemanager_aidl_ifaces[] = { SVCMGR_IFACE, NULL };
+
+typedef GBinderLocalObjectClass ServiceManagerAidl3Class;
+typedef struct service_manager_aidl3 {
+ GBinderLocalObject parent;
+ GHashTable* objects;
+ gboolean handle_on_looper_thread;
+} ServiceManagerAidl3;
+
+#define SERVICE_MANAGER_AIDL3_TYPE (service_manager_aidl3_get_type())
+#define SERVICE_MANAGER_AIDL3(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ SERVICE_MANAGER_AIDL3_TYPE, ServiceManagerAidl3))
+G_DEFINE_TYPE(ServiceManagerAidl3, service_manager_aidl3, \
+ GBINDER_TYPE_LOCAL_OBJECT)
+
+static
+GBinderLocalReply*
+servicemanager_aidl3_handler(
+ GBinderLocalObject* obj,
+ GBinderRemoteRequest* req,
+ guint code,
+ guint flags,
+ int* status,
+ void* user_data)
+{
+ ServiceManagerAidl3* self = user_data;
+ GBinderLocalReply* reply = NULL;
+ GBinderReader reader;
+ GBinderRemoteObject* remote_obj;
+ guint32 allow_isolated, dumpsys_priority;
+ char* str;
+
+ g_assert(!flags);
+ GDEBUG("%s %u", gbinder_remote_request_interface(req), code);
+ g_assert_cmpstr(gbinder_remote_request_interface(req), == ,SVCMGR_IFACE);
+ *status = -1;
+ switch (code) {
+ case GET_SERVICE_TRANSACTION:
+ case CHECK_SERVICE_TRANSACTION:
+ gbinder_remote_request_init_reader(req, &reader);
+ str = gbinder_reader_read_string16(&reader);
+ if (str) {
+ GBinderWriter writer;
+
+ remote_obj = g_hash_table_lookup(self->objects, str);
+ reply = gbinder_local_object_new_reply(obj);
+
+ gbinder_local_reply_init_writer(reply, &writer);
+ gbinder_writer_append_int32(&writer, GBINDER_STATUS_OK);
+ gbinder_writer_append_remote_object(&writer, remote_obj);
+ if (remote_obj) {
+ GDEBUG("Found name '%s' => %p", str, remote_obj);
+ } else {
+ GDEBUG("Name '%s' not found", str);
+ }
+ g_free(str);
+ }
+ break;
+ case ADD_SERVICE_TRANSACTION:
+ gbinder_remote_request_init_reader(req, &reader);
+ str = gbinder_reader_read_string16(&reader);
+ remote_obj = gbinder_reader_read_object(&reader);
+ if (str && remote_obj &&
+ gbinder_reader_read_uint32(&reader, &allow_isolated) &&
+ gbinder_reader_read_uint32(&reader, &dumpsys_priority)) {
+ GDEBUG("Adding '%s'", str);
+ g_hash_table_replace(self->objects, str, remote_obj);
+ remote_obj = NULL;
+ str = NULL;
+ reply = gbinder_local_object_new_reply(obj);
+ *status = GBINDER_STATUS_OK;
+ }
+ g_free(str);
+ gbinder_remote_object_unref(remote_obj);
+ break;
+ case LIST_SERVICES_TRANSACTION:
+ gbinder_remote_request_init_reader(req, &reader);
+ if (gbinder_reader_read_uint32(&reader, &dumpsys_priority)) {
+ if (g_hash_table_size(self->objects) == 1) {
+ GList* keys = g_hash_table_get_keys(self->objects);
+ GList* l = g_list_nth(keys, 0);
+ gint32 srv_size = 1;
+ GBinderWriter writer;
+
+ reply = gbinder_local_object_new_reply(obj);
+ gbinder_local_reply_init_writer(reply, &writer);
+ gbinder_writer_append_int32(&writer, GBINDER_STATUS_OK);
+ gbinder_writer_append_int32(&writer, srv_size);
+ gbinder_writer_append_string16(&writer, l->data);
+ g_list_free(keys);
+ *status = GBINDER_STATUS_OK;
+ } else {
+ GDEBUG("Incorrect number of services %u",
+ g_hash_table_size(self->objects));
+ }
+ }
+ break;
+ default:
+ GDEBUG("Unhandled command %u", code);
+ break;
+ }
+ return reply;
+}
+
+static
+ServiceManagerAidl3*
+servicemanager_aidl3_new(
+ const char* dev,
+ gboolean handle_on_looper_thread)
+{
+ ServiceManagerAidl3* self = g_object_new(SERVICE_MANAGER_AIDL3_TYPE, NULL);
+ GBinderLocalObject* obj = GBINDER_LOCAL_OBJECT(self);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
+ const int fd = gbinder_driver_fd(ipc->driver);
+
+ self->handle_on_looper_thread = handle_on_looper_thread;
+ gbinder_local_object_init_base(obj, ipc, servicemanager_aidl_ifaces,
+ servicemanager_aidl3_handler, self);
+ test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
+ test_binder_register_object(fd, obj, SVCMGR_HANDLE);
+ gbinder_ipc_register_local_object(ipc, obj);
+ gbinder_ipc_unref(ipc);
+ return self;
+}
+
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_servicemanager_aidl4/Makefile
^
|
@@ -0,0 +1,5 @@
+# -*- Mode: makefile-gmake -*-
+
+EXE = unit_servicemanager_aidl4
+
+include ../common/Makefile
|
[-]
[+]
|
Added |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_servicemanager_aidl4/unit_servicemanager_aidl4.c
^
|
@@ -0,0 +1,485 @@
+/*
+ * Copyright (C) 2020-2022 Jolla Ltd.
+ * Copyright (C) 2020-2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "test_binder.h"
+
+#include "gbinder_driver.h"
+#include "gbinder_config.h"
+#include "gbinder_ipc.h"
+#include "gbinder_reader.h"
+#include "gbinder_servicemanager_p.h"
+#include "gbinder_rpc_protocol.h"
+#include "gbinder_local_object_p.h"
+#include "gbinder_local_reply.h"
+#include "gbinder_remote_request.h"
+#include "gbinder_remote_object.h"
+#include "gbinder_writer.h"
+
+#include <gutil_strv.h>
+#include <gutil_log.h>
+
+static TestOpt test_opt;
+static const char TMP_DIR_TEMPLATE[] =
+ "gbinder-test-servicemanager_aidl4-XXXXXX";
+
+GType
+gbinder_servicemanager_hidl_get_type()
+{
+ /* Dummy function to avoid pulling in gbinder_servicemanager_hidl */
+ g_assert_not_reached();
+ return 0;
+}
+
+/*==========================================================================*
+ * Test service manager
+ *==========================================================================*/
+
+#define SVCMGR_HANDLE (0)
+static const char SVCMGR_IFACE[] = "android.os.IServiceManager";
+enum servicemanager_aidl_tx {
+ GET_SERVICE_TRANSACTION = GBINDER_FIRST_CALL_TRANSACTION,
+ CHECK_SERVICE_TRANSACTION,
+ ADD_SERVICE_TRANSACTION,
+ LIST_SERVICES_TRANSACTION
+};
+
+const char* const servicemanager_aidl_ifaces[] = { SVCMGR_IFACE, NULL };
+
+typedef GBinderLocalObjectClass ServiceManagerAidl4Class;
+typedef struct service_manager_aidl4 {
+ GBinderLocalObject parent;
+ GHashTable* objects;
+ gboolean handle_on_looper_thread;
+} ServiceManagerAidl4;
+
+#define SERVICE_MANAGER_AIDL4_TYPE (service_manager_aidl4_get_type())
+#define SERVICE_MANAGER_AIDL4(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ SERVICE_MANAGER_AIDL4_TYPE, ServiceManagerAidl4))
+G_DEFINE_TYPE(ServiceManagerAidl4, service_manager_aidl4, \
+ GBINDER_TYPE_LOCAL_OBJECT)
+
+/* This should be eventually handled at lower level. */
+typedef struct category {
+ /*
+ * This is the version of the wire protocol associated with the host
+ * process of a particular binder. As the wire protocol changes, if
+ * sending a transaction to a binder with an old version, the Parcel
+ * class must write parcels according to the version documented here.
+ */
+ gint8 version;
+ gint8 reserved[2];
+ gint8 level; /* bitmask of Stability::Level */
+} Category;
+
+static
+GBinderLocalReply*
+servicemanager_aidl4_handler(
+ GBinderLocalObject* obj,
+ GBinderRemoteRequest* req,
+ guint code,
+ guint flags,
+ int* status,
+ void* user_data)
+{
+ ServiceManagerAidl4* self = user_data;
+ GBinderLocalReply* reply = NULL;
+ GBinderReader reader;
+ GBinderRemoteObject* remote_obj;
+ guint32 allow_isolated, dumpsys_priority;
+ char* str;
+ Category category;
+
+ g_assert(!flags);
+ GDEBUG("%s %u", gbinder_remote_request_interface(req), code);
+ g_assert_cmpstr(gbinder_remote_request_interface(req), == ,SVCMGR_IFACE);
+ *status = -1;
+ switch (code) {
+ case GET_SERVICE_TRANSACTION:
+ case CHECK_SERVICE_TRANSACTION:
+ gbinder_remote_request_init_reader(req, &reader);
+ str = gbinder_reader_read_string16(&reader);
+ if (str) {
+ reply = gbinder_local_object_new_reply(obj);
+ remote_obj = g_hash_table_lookup(self->objects, str);
+ if (str) {
+ GBinderWriter writer;
+
+ remote_obj = g_hash_table_lookup(self->objects, str);
+ reply = gbinder_local_object_new_reply(obj);
+
+ gbinder_local_reply_init_writer(reply, &writer);
+ gbinder_writer_append_int32(&writer, GBINDER_STATUS_OK);
+ gbinder_writer_append_remote_object(&writer, remote_obj);
+ if (remote_obj) {
+ GDEBUG("Found name '%s' => %p", str, remote_obj);
+ } else {
+ GDEBUG("Name '%s' not found", str);
+ }
+ g_free(str);
+ }
+ }
+ break;
+ case ADD_SERVICE_TRANSACTION:
+ gbinder_remote_request_init_reader(req, &reader);
+ str = gbinder_reader_read_string16(&reader);
+ remote_obj = gbinder_reader_read_object(&reader);
+ gbinder_reader_read_uint32(&reader, (guint32*)&category);
+ if (str && remote_obj &&
+ category.level == GBINDER_STABILITY_SYSTEM &&
+ category.version == 1 &&
+ gbinder_reader_read_uint32(&reader, &allow_isolated) &&
+ gbinder_reader_read_uint32(&reader, &dumpsys_priority)) {
+ GDEBUG("Adding '%s'", str);
+ g_hash_table_replace(self->objects, str, remote_obj);
+ remote_obj = NULL;
+ str = NULL;
+ reply = gbinder_local_object_new_reply(obj);
+ *status = GBINDER_STATUS_OK;
+ }
+ g_free(str);
+ gbinder_remote_object_unref(remote_obj);
+ break;
+ case LIST_SERVICES_TRANSACTION:
+ gbinder_remote_request_init_reader(req, &reader);
+ if (gbinder_reader_read_uint32(&reader, &dumpsys_priority)) {
+ if (g_hash_table_size(self->objects) == 1) {
+ GList* keys = g_hash_table_get_keys(self->objects);
+ GList* l = g_list_nth(keys, 0);
+ gint32 srv_size = 1;
+ GBinderWriter writer;
+
+ reply = gbinder_local_object_new_reply(obj);
+ gbinder_local_reply_init_writer(reply, &writer);
+ gbinder_writer_append_int32(&writer, GBINDER_STATUS_OK);
+ gbinder_writer_append_int32(&writer, srv_size);
+ gbinder_writer_append_string16(&writer, l->data);
+ g_list_free(keys);
+ *status = GBINDER_STATUS_OK;
+ } else {
+ GDEBUG("Incorrect number of services %u",
+ g_hash_table_size(self->objects));
+ }
+ }
+ break;
+ default:
+ GDEBUG("Unhandled command %u", code);
+ break;
+ }
+ return reply;
+}
+
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_servicemanager_hidl/unit_servicemanager_hidl.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2021 Jolla Ltd.
- * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2021-2022 Jolla Ltd.
+ * Copyright (C) 2021-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -61,14 +61,32 @@
GType
gbinder_servicemanager_aidl_get_type()
{
- /* Avoid pulling in gbinder_servicemanager_aidl object */
+ /* Dummy function to avoid pulling in gbinder_servicemanager_aidl */
+ g_assert_not_reached();
return 0;
}
GType
gbinder_servicemanager_aidl2_get_type()
{
- /* Avoid pulling in gbinder_servicemanager_aidl2 object */
+ /* Dummy function to avoid pulling in gbinder_servicemanager_aidl2 */
+ g_assert_not_reached();
+ return 0;
+}
+
+GType
+gbinder_servicemanager_aidl3_get_type()
+{
+ /* Dummy function to avoid pulling in gbinder_servicemanager_aidl3 */
+ g_assert_not_reached();
+ return 0;
+}
+
+GType
+gbinder_servicemanager_aidl4_get_type()
+{
+ /* Dummy function to avoid pulling in gbinder_servicemanager_aidl4 */
+ g_assert_not_reached();
return 0;
}
@@ -112,7 +130,7 @@
test_servicemanager_impl_new(
const char* dev)
{
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
const int fd = gbinder_driver_fd(ipc->driver);
TestServiceManagerHidl* sm = test_servicemanager_hidl_new(ipc);
@@ -181,7 +199,7 @@
const char* name = "android.hidl.base@1.0::IBase/test";
test_config_init(&config, NULL);
- ipc = gbinder_ipc_new(MAIN_DEV);
+ ipc = gbinder_ipc_new(MAIN_DEV, NULL);
smsvc = test_servicemanager_impl_new(OTHER_DEV);
obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
fd = gbinder_driver_fd(ipc->driver);
@@ -276,7 +294,7 @@
test.loop = g_main_loop_new(NULL, FALSE);
test_config_init(&config, NULL);
- ipc = gbinder_ipc_new(MAIN_DEV);
+ ipc = gbinder_ipc_new(MAIN_DEV, NULL);
smsvc = test_servicemanager_impl_new(OTHER_DEV);
obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
fd = gbinder_driver_fd(ipc->driver);
@@ -404,7 +422,7 @@
test.loop = g_main_loop_new(NULL, FALSE);
test_config_init(&config, NULL);
- ipc = gbinder_ipc_new(MAIN_DEV);
+ ipc = gbinder_ipc_new(MAIN_DEV, NULL);
test.smsvc = test_servicemanager_impl_new(OTHER_DEV);
obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
fd = gbinder_driver_fd(ipc->driver);
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_servicename/unit_servicename.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019-2021 Jolla Ltd.
- * Copyright (C) 2019-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2022 Jolla Ltd.
+ * Copyright (C) 2019-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -235,6 +235,18 @@
}
GType
+gbinder_servicemanager_aidl3_get_type()
+{
+ return TEST_TYPE_SERVICEMANAGER;
+}
+
+GType
+gbinder_servicemanager_aidl4_get_type()
+{
+ return TEST_TYPE_SERVICEMANAGER;
+}
+
+GType
gbinder_servicemanager_hidl_get_type()
{
return TEST_TYPE_SERVICEMANAGER;
@@ -250,7 +262,7 @@
void)
{
const char* dev = GBINDER_DEFAULT_BINDER;
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
GBinderServiceManager* sm;
test_setup_ping(ipc);
@@ -277,7 +289,7 @@
const char* obj_name = "test";
const char* dev = GBINDER_DEFAULT_BINDER;
const char* const ifaces[] = { "interface", NULL };
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
GBinderLocalObject* obj;
GBinderServiceManager* sm;
@@ -315,7 +327,7 @@
const char* obj_name = "test";
const char* const ifaces[] = { "interface", NULL };
const char* dev = GBINDER_DEFAULT_BINDER;
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
const int fd = gbinder_driver_fd(ipc->driver);
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
GBinderLocalObject* obj;
@@ -376,7 +388,7 @@
const char* obj_name = "test";
const char* const ifaces[] = { "interface", NULL };
const char* dev = GBINDER_DEFAULT_BINDER;
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
const int fd = gbinder_driver_fd(ipc->driver);
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
GBinderLocalObject* obj;
@@ -421,7 +433,7 @@
const char* obj_name = "test";
const char* const ifaces[] = { "interface", NULL };
const char* dev = GBINDER_DEFAULT_BINDER;
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
const int fd = gbinder_driver_fd(ipc->driver);
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
GBinderLocalObject* obj;
@@ -464,7 +476,7 @@
const char* obj_name = "test";
const char* const ifaces[] = { "interface", NULL };
const char* dev = GBINDER_DEFAULT_BINDER;
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
const int fd = gbinder_driver_fd(ipc->driver);
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
GBinderLocalObject* obj;
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_servicepoll/unit_servicepoll.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2021 Jolla Ltd.
- * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -201,6 +201,18 @@
}
GType
+gbinder_servicemanager_aidl3_get_type()
+{
+ return TEST_TYPE_SERVICEMANAGER;
+}
+
+GType
+gbinder_servicemanager_aidl4_get_type()
+{
+ return TEST_TYPE_SERVICEMANAGER;
+}
+
+GType
gbinder_servicemanager_hidl_get_type()
{
return TEST_TYPE_SERVICEMANAGER;
@@ -233,7 +245,7 @@
void)
{
const char* dev = GBINDER_DEFAULT_BINDER;
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
GBinderServicePoll* weakptr = NULL;
GBinderServiceManager* manager;
GBinderServicePoll* poll;
@@ -309,7 +321,7 @@
void)
{
const char* dev = GBINDER_DEFAULT_BINDER;
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
GBinderServicePoll* weakptr = NULL;
GBinderServiceManager* manager;
@@ -383,7 +395,7 @@
void)
{
const char* dev = GBINDER_DEFAULT_BINDER;
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
GBinderServicePoll* weakptr = NULL;
GBinderServiceManager* manager;
@@ -442,7 +454,7 @@
void)
{
const char* dev = GBINDER_DEFAULT_BINDER;
- GBinderIpc* ipc = gbinder_ipc_new(dev);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
GBinderServicePoll* weakptr = NULL;
GBinderServiceManager* manager;
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.30.tar.bz2/unit/unit_writer/unit_writer.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2020 Jolla Ltd.
- * Copyright (C) 2018-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -31,22 +31,99 @@
*/
#include "test_common.h"
+#include "test_binder.h"
+#include "gbinder_config.h"
+#include "gbinder_fmq_p.h"
#include "gbinder_local_request_p.h"
+#include "gbinder_rpc_protocol.h"
#include "gbinder_output_data.h"
#include "gbinder_writer_p.h"
#include "gbinder_io.h"
#include <gutil_intarray.h>
+#include <gutil_log.h>
#include <unistd.h>
+#include <errno.h>
static TestOpt test_opt;
+static const char TMP_DIR_TEMPLATE[] = "gbinder-test-writer-XXXXXX";
-#define BUFFER_OBJECT_SIZE_32 (24)
-#define BUFFER_OBJECT_SIZE_64 (GBINDER_MAX_BUFFER_OBJECT_SIZE)
-#define BINDER_OBJECT_SIZE_32 (16)
-#define BINDER_OBJECT_SIZE_64 (GBINDER_MAX_BINDER_OBJECT_SIZE)
+static
+GBinderLocalRequest*
+test_local_request_new_with_io(
+ const GBinderIo* io)
+{
+ return gbinder_local_request_new(io,
+ gbinder_rpc_protocol_for_device(GBINDER_DEFAULT_BINDER), NULL);
+}
+
+static
+GBinderLocalRequest*
+test_local_request_new()
+{
+ return test_local_request_new_with_io(&gbinder_io_32);
+}
+
+static
+GBinderLocalRequest*
+test_local_request_new_64()
+{
+ return test_local_request_new_with_io(&gbinder_io_64);
+}
+
+/*==========================================================================*
+ * Test context
+ *==========================================================================*/
+
+typedef struct test_context {
+ const char* default_config_dir;
+ const char* default_config_file;
+ char* config_dir;
+ char* config_subdir;
+ char* config_file;
+} TestContext;
+
+static
+void
+test_context_init(
+ TestContext* test,
+ const char* prot)
+{
+ memset(test, 0, sizeof(*test));
+ test->default_config_dir = gbinder_config_dir;
+ test->default_config_file = gbinder_config_file;
+ test->config_dir = g_dir_make_tmp(TMP_DIR_TEMPLATE, NULL);
+ test->config_subdir = g_build_filename(test->config_dir, "d", NULL);
+ test->config_file = g_build_filename(test->config_dir, "test.conf", NULL);
+ gbinder_config_dir = test->config_subdir; /* Doesn't exist */
+ gbinder_config_file = test->config_file;
+ if (prot) {
+ char* config = g_strdup_printf("[Protocol]\n"
+ GBINDER_DEFAULT_BINDER " = %s", prot);
+
+ GDEBUG("Config file %s", test->config_file);
+ g_assert(g_file_set_contents(test->config_file, config, -1, NULL));
+ g_free(config);
+ }
+}
+
+static
+void
+test_context_deinit(
+ TestContext* test)
+{
+ remove(test->config_file);
+ remove(test->config_dir);
+ g_free(test->config_file);
+ g_free(test->config_subdir);
+ g_free(test->config_dir);
+ gbinder_config_dir = test->default_config_dir;
+ gbinder_config_file = test->default_config_file;
+ gbinder_config_exit();
+ gbinder_rpc_protocol_exit();
+}
/*==========================================================================*
* null
@@ -58,8 +135,13 @@
void)
{
GBinderWriter writer;
+ gsize size = 1;
gbinder_local_request_init_writer(NULL, &writer);
+ gbinder_writer_append_int8(NULL, 0);
+ gbinder_writer_append_int8(&writer, 0);
+ gbinder_writer_append_int16(NULL, 0);
+ gbinder_writer_append_int16(&writer, 0);
gbinder_writer_append_int32(NULL, 0);
gbinder_writer_append_int32(&writer, 0);
gbinder_writer_append_int64(NULL, 0);
@@ -84,6 +166,7 @@
gbinder_writer_append_bytes(&writer, NULL, 0);
gbinder_writer_append_hidl_vec(NULL, NULL, 0, 0);
gbinder_writer_append_hidl_string(NULL, NULL);
+ gbinder_writer_append_hidl_string_copy(NULL, NULL);
gbinder_writer_append_hidl_string(&writer, NULL);
gbinder_writer_append_hidl_string_vec(NULL, NULL, 0);
gbinder_writer_append_hidl_string_vec(&writer, NULL, 0);
@@ -91,6 +174,7 @@
gbinder_writer_append_buffer_object(&writer, NULL, 0);
gbinder_writer_append_buffer_object_with_parent(NULL, NULL, 0, NULL);
gbinder_writer_append_buffer_object_with_parent(&writer, NULL, 0, NULL);
+ gbinder_writer_append_parcelable(NULL, NULL, 0);
gbinder_writer_append_local_object(NULL, NULL);
gbinder_writer_append_local_object(&writer, NULL);
gbinder_writer_append_remote_object(NULL, NULL);
@@ -101,12 +185,23 @@
gbinder_writer_add_cleanup(NULL, g_free, 0);
gbinder_writer_overwrite_int32(NULL, 0, 0);
+#if GBINDER_FMQ_SUPPORTED
+ gbinder_writer_append_fmq_descriptor(NULL, NULL);
+ gbinder_writer_append_fmq_descriptor(&writer, NULL);
+#endif
+
+ g_assert(!gbinder_writer_bytes_written(NULL));
+ g_assert(!gbinder_writer_get_data(NULL, NULL));
+ g_assert(!gbinder_writer_get_data(NULL, &size));
+ g_assert_cmpuint(size, ==, 0);
g_assert(!gbinder_output_data_offsets(NULL));
g_assert(!gbinder_output_data_buffers_size(NULL));
g_assert(!gbinder_writer_malloc(NULL, 0));
g_assert(!gbinder_writer_malloc0(NULL, 0));
g_assert(!gbinder_writer_memdup(&writer, NULL, 0));
g_assert(!gbinder_writer_memdup(NULL, &writer, 0));
+ g_assert(!gbinder_writer_strdup(&writer, NULL));
+ g_assert(!gbinder_writer_strdup(NULL, ""));
}
/*==========================================================================*
@@ -126,22 +221,80 @@
test_cleanup(
void)
{
- GBinderLocalRequest* req = gbinder_local_request_new(&gbinder_io_32, NULL);
+ GBinderLocalRequest* req = test_local_request_new();
GBinderWriter writer;
+ const int value = 42;
+ const char* str = "foo";
int cleanup_count = 0;
- int value = 42;
int* zero;
int* copy;
+ char* scopy;
gbinder_local_request_init_writer(req, &writer);
zero = gbinder_writer_new0(&writer, int);
copy = gbinder_writer_memdup(&writer, &value, sizeof(value));
- g_assert(*zero == 0);
- g_assert(*copy == value);
+ scopy = gbinder_writer_strdup(&writer, str);
+ g_assert_cmpint(*zero, == ,0);
+ g_assert_cmpint(*copy, == ,value);
+ g_assert_cmpstr(scopy, == ,str);
gbinder_writer_add_cleanup(&writer, test_cleanup_fn, &cleanup_count);
gbinder_writer_add_cleanup(&writer, test_cleanup_fn, &cleanup_count);
gbinder_local_request_unref(req);
- g_assert(cleanup_count == 2);
+ g_assert_cmpint(cleanup_count, == ,2);
+}
+
+/*==========================================================================*
+ * int8
|