Commit Graph

53 Commits

Author SHA1 Message Date
huangcaihua fa14d158fe gdbus:Fix method call noreply by keep one uv hanlder for read and write dbus_watch
Signed-off-by: huangcaihua <huangcaihua@xiaomi.com>
2026-04-20 14:50:45 +08:00
huangcaihua e09eba8530 refactor object file for open vela
Signed-off-by: huangcaihua <huangcaihua@xiaomi.com>
2026-04-20 14:50:42 +08:00
huangcaihua df5657181d refactor watch file for open source
Signed-off-by: huangcaihua <huangcaihua@xiaomi.com>
2026-04-20 14:50:42 +08:00
huangcaihua 4a233cc203 Fix: remove signal filter when receive dbus disconnect msg
If the dbus disconnect message has been received,
it means that the current dbus connection is invalid.
The added disconnect message signal filter also needs to be free.

Signed-off-by: huangcaihua <huangcaihua@xiaomi.com>
2026-04-20 14:50:40 +08:00
huangcaihua 46636f9fc3 Fix: Change code to WebKit style
Signed-off-by: huangcaihua <huangcaihua@xiaomi.com>
2026-04-20 14:50:35 +08:00
dongjiuzhu1 90998185f4 gdbus/mainloop: fix memory leak
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-04-20 14:50:34 +08:00
dongjiuzhu1 d3ccfd9120 framework/gdbus: using libuv replace glib loop
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
Signed-off-by: fangzhenwei <fangzhenwei@xiaomi.com>
2026-04-20 14:50:31 +08:00
openvela-robot d0206fcdb5 Merge branch 'dev' of kvdb into dev 2026-04-20 14:50:30 +08:00
openvela-robot 76f262a843 init kvdb
Signed-off-by: zhangning21 <zhangning21@xiaomi.com>
2026-04-20 14:50:30 +08:00
openvela-robot 4a71f2f23a Remove __INTRODUCED_IN from android/set_abort_message.h
since it is Android specific version not suitable for vela at all

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-04-20 14:50:30 +08:00
openvela-robot b4945489fa Move PROP_NAME_MAX and PROP_VALUE_MAX to system_properties.h
and sync system_properties.h with android 13

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-04-20 14:50:29 +08:00
openvela-robot 28798e0839 frameworks/gdbus: fix kasan report error because stack var overflow
When the type of basic value is double, can't using void *value as buffer to get value.

==3263760==ERROR: AddressSanitizer: stack-buffer-overflow on address 0xefe13c30 at pc 0x577c0356 bp 0xefe139b8 sp 0xefe139a8
WRITE of size 8 at 0xefe13c30 thread T0
    #0 0x577c0355 in _dbus_marshal_read_basic dbus/dbus/dbus-marshal-basic.c:581
    #1 0x5783bedb in _dbus_type_reader_read_basic dbus/dbus/dbus-marshal-recursive.c:879
    #2 0x5776ef72 in dbus_message_iter_get_basic dbus/dbus/dbus-message.c:2376
    #3 0x57e06daa in iter_append_iter gdbus/client.c:222
    #4 0x57e070b1 in prop_entry_update gdbus/client.c:265
    #5 0x57e07454 in prop_entry_new gdbus/client.c:286
    #6 0x57e0793a in add_property gdbus/client.c:322
    #7 0x57e09abd in properties_changed_non_standard gdbus/client.c:544
    #8 0x57df2e00 in signal_filter gdbus/watch.c:394
    #9 0x57df4d57 in message_filter gdbus/watch.c:544
    #10 0x57752dc6 in dbus_connection_dispatch dbus/dbus/dbus-connection.c:4703
    #11 0x57dde7d5 in message_dispatch gdbus/mainloop.c:59
    #12 0x5790e3b8 in g_idle_dispatch glib/glib/gmain.c:6157
    #13 0x57900a31 in g_main_dispatch glib/glib/gmain.c:3477
    #14 0x579080d3 in g_main_context_dispatch glib/glib/gmain.c:4195
    #15 0x57908bcc in g_main_context_iterate glib/glib/gmain.c:4271
    #16 0x57909e7f in g_main_loop_run glib/glib/gmain.c:4471
    #17 0x57dde5b7 in telephonytool_main /home/djz/workspace/test/sim/frameworks/telephony/telephony_tool.c:878
    #18 0x56ea66b5 in nxtask_startup sched/task_startup.c:70
    #19 0x56e541a8 in nxtask_start task/task_start.c:134

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-04-20 14:50:29 +08:00
openvela-robot 43f2e18ea9 system_properties: add android system property wrapper layer
There are still three fail test cases (android property test):
1. empty key test, reason: kvdb do not support empty key;
2. long key test, reason: (a) read only property value length can be
   arbitrarily-long in android, kvdb do not support; (b) read only
   property can be set if the property do not exist before, kvdb
   not allowed this action;
3. cached property test, reason: (a) android cached property uses
   serial to judge the [key, value] changed, kvdb can't handle this
   very well; (b) android cached property return the value pointer
   from the shared memory directly for read only property, kvdb
   can't handle this well too.

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2026-04-20 14:50:29 +08:00
dongjiuzhu1 8c512a80c0 frameworks/gdbus: replace glib api
1. using dbus-list api to replace glib list.
2. using dbus-hash api to replace glib hash api.
3. using dbus-string api to replace glib string api.
4. using posix memory api to replace glib memory api.
5. ...

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-04-20 14:50:29 +08:00
dongjiuzhu1 5ef42fa20b framework/gdbus: remove prefix g_ for gdbus api.
1. Remove prefix g_ for all gdbus api
2. Using macro to compatible g_ gdus api

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-04-20 14:50:28 +08:00
Tedd Ho-Jeong An d01eda562a gdbus: Add SPDX License Identifier
This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 GPL-2.0-or-later     :      6

License: GPL-2.0-or-later
   gdbus/mainloop.c
   gdbus/object.c
   gdbus/polkit.c
   gdbus/client.c
   gdbus/watch.c
   gdbus/gdbus.h
2026-04-20 14:50:28 +08:00
Luiz Augusto von Dentz 2429314fb9 gdbus: Close private connection if setup fails
Private connection should be properly closed with dbus_connection_close
otherwise libdbus exits with the following error:

  'The last reference on a connection was dropped without closing the
   connection. This is a bug in an application. See
   dbus_connection_unref() documentation for details. Most likely, the
   application was supposed to call dbus_connection_close(), since this
   is a private connection.'
2026-04-20 14:50:27 +08:00
Luiz Augusto von Dentz df159f0d1a gdbus: Fix crash when watch is toggled or disconnected
This partially reverts 609873e315e705cff3a62ee904675da06d30f7a4 since it
still necessary to take a reference before calling dbus_watch_handle
since internally it can call watch_info_free as in the following trace:

 Invalid read of size 8
   at 0x121085: watch_func (mainloop.c:105)
   by 0x4C72694: g_main_context_dispatch (gmain.c:2539)
   by 0x4C729C7: g_main_context_iterate.isra.23 (gmain.c:3146)
   by 0x4C72DC1: g_main_loop_run (gmain.c:3340)
   by 0x120541: main (main.c:551)
 Address 0x5bbcd90 is 16 bytes inside a block of size 24 free'd
   at 0x4A079AE: free (vg_replace_malloc.c:427)
   by 0x4C7837E: g_free (gmem.c:252)
   by 0x4F708BF: dbus_watch_set_data (dbus-watch.c:614)
   by 0x4F70938: _dbus_watch_unref (dbus-watch.c:132)
   by 0x4F6E9A7: _dbus_transport_handle_watch (dbus-transport.c:884)
   by 0x4F59AFB: _dbus_connection_handle_watch (dbus-connection.c:1497)
   by 0x4F70AF9: dbus_watch_handle (dbus-watch.c:683)
   by 0x121084: watch_func (mainloop.c:103)
   by 0x4C72694: g_main_context_dispatch (gmain.c:2539)
   by 0x4C729C7: g_main_context_iterate.isra.23 (gmain.c:3146)
   by 0x4C72DC1: g_main_loop_run (gmain.c:3340)
   by 0x120541: main (main.c:551)
2026-04-20 14:50:26 +08:00
Luiz Augusto von Dentz a377954b4a gdbus: Replace g_timeout_add with g_idle_add
Passing 0 as timeout to g_timeout_add should equivalent to g_idle_add.
2026-04-20 14:50:26 +08:00
Anderson Lizardo b9eb7fd6c2 gdbus: Fix incorrect DBusConnection reference counting
Commit 94d4f8c35f2e8f301aab7f55a6b7ea8d8c26305e attempted to fix a crash
related to improper reference counting, but the main issue was that the
reference was taken only during the function call (which is usually
unnecessary for single thread), but still passed a pointer to
DBusConnection to a function that is called by the mainloop. This left a
window where the DBusConnection can be destroyed.

Fixes this crash on unit/test-gdbus-client:

==32642== Invalid read of size 4
==32642==    at 0x690D0A6: dbus_connection_ref (in
/lib/i386-linux-gnu/libdbus-1.so.3.7.6)
==32642==    by 0x804CEDB: message_dispatch (mainloop.c:73)
==32642==    by 0x684580E: g_timeout_dispatch (gmain.c:4450)
==32642==    by 0x6844A75: g_main_context_dispatch (gmain.c:3065)
==32642==    by 0x6844E14: g_main_context_iterate.isra.23 (gmain.c:3712)
==32642==    by 0x68452FA: g_main_loop_run (gmain.c:3906)
==32642==    by 0x804C7D3: client_connect_disconnect
(test-gdbus-client.c:188)
==32642==    by 0x6868DB2: g_test_run_suite_internal (gtestutils.c:2067)
==32642==    by 0x6868F8D: g_test_run_suite_internal (gtestutils.c:2138)
==32642==    by 0x6869320: g_test_run_suite (gtestutils.c:2189)
==32642==    by 0x686936B: g_test_run (gtestutils.c:1508)
==32642==    by 0x696D4D2: (below main) (libc-start.c:226)
==32642==  Address 0x709c6e4 is 140 bytes inside a block of size 144
free'd
==32642==    at 0x67E806C: free (in
/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==32642==    by 0x692D62E: dbus_free (in
/lib/i386-linux-gnu/libdbus-1.so.3.7.6)
==32642==    by 0x690E1C2: ??? (in
/lib/i386-linux-gnu/libdbus-1.so.3.7.6)
==32642==    by 0x804AAEC: destroy_context (test-gdbus-client.c:104)
==32642==    by 0x6868DB2: g_test_run_suite_internal (gtestutils.c:2067)
==32642==    by 0x6868F8D: g_test_run_suite_internal (gtestutils.c:2138)
==32642==    by 0x6869320: g_test_run_suite (gtestutils.c:2189)
==32642==    by 0x686936B: g_test_run (gtestutils.c:1508)
==32642==    by 0x696D4D2: (below main) (libc-start.c:226)
2026-04-20 14:50:26 +08:00
Johan Hedberg 5fea097260 Revert "Ensure config.h is included by using CPPFLAGS"
This reverts commit 76919ad7f431167cecdd3d608c1465961aa75423.

The patch needs to be split up and the gdbus/ changes were bogus
compared to the original commit message.

Conflicts:
	Makefile.am
	Makefile.obexd
	profiles/cyclingspeed/cyclingspeed.c
	profiles/heartrate/heartrate.c
	src/error.c
2026-04-20 14:50:23 +08:00
Lucas De Marchi cf6b8a5c15 Ensure config.h is included by using CPPFLAGS
Instead of trying to include config.h in each file over the tree and
possibly forgetting to include it, give a "-include config.h" argument
to the compiler so it's guaranteed that a) it will be included for all
source files and b) it will be the first header included.

gdbus/ directory is left out, since it would break other projects using
it.
2026-04-20 14:50:23 +08:00
Johan Hedberg a23c304f9a gdbus: Fix crash when getting disconnected from the bus
When getting disconnected from the bus sometimes (maybe always?)
dbus_watch_handle() can cause the "info" context to be free'd meaning
that we should not try to access it after the call. The only member we
need access to is the connection pointer and as the code already has a
ref() call for it it's only natural to solve the issue by adding a local
variable not dependent on "info".

The backtrace of the crash fixed looks as follows:

 Invalid read of size 8
   at 0x121085: watch_func (mainloop.c:105)
   by 0x4C72694: g_main_context_dispatch (gmain.c:2539)
   by 0x4C729C7: g_main_context_iterate.isra.23 (gmain.c:3146)
   by 0x4C72DC1: g_main_loop_run (gmain.c:3340)
   by 0x120541: main (main.c:551)
 Address 0x5bbcd90 is 16 bytes inside a block of size 24 free'd
   at 0x4A079AE: free (vg_replace_malloc.c:427)
   by 0x4C7837E: g_free (gmem.c:252)
   by 0x4F708BF: dbus_watch_set_data (dbus-watch.c:614)
   by 0x4F70938: _dbus_watch_unref (dbus-watch.c:132)
   by 0x4F6E9A7: _dbus_transport_handle_watch (dbus-transport.c:884)
   by 0x4F59AFB: _dbus_connection_handle_watch (dbus-connection.c:1497)
   by 0x4F70AF9: dbus_watch_handle (dbus-watch.c:683)
   by 0x121084: watch_func (mainloop.c:103)
   by 0x4C72694: g_main_context_dispatch (gmain.c:2539)
   by 0x4C729C7: g_main_context_iterate.isra.23 (gmain.c:3146)
   by 0x4C72DC1: g_main_loop_run (gmain.c:3340)
   by 0x120541: main (main.c:551)
2026-04-20 14:50:22 +08:00
Marcel Holtmann 0b2abdc4c1 gdbus: Remove unneeded NEED_DBUS_WATCH_GET_UNIX_FD check 2026-04-20 14:50:22 +08:00
Grant Erickson cbaa21e0f7 gdbus: Unconditionally remove D-Bus timeouts
Address an issue in which the daemon incorrectly handles D-Bus main
loop timeouts by only removing timeouts that are not enabled when
D-Bus requests a timeout removal.
2026-04-20 14:50:21 +08:00
Marcel Holtmann 2525b884cf gdbus: Update copyright information 2026-04-20 14:50:21 +08:00
Luiz Augusto von Dentz d314082ea2 gdbus: fix not handling bus disconnects
We where not dispatching data when a bus disconnects which cause
Disconnected signal to not be processed and thus causing the process to
either not exit or to not trigger callbacks registered with
g_dbus_set_disconnect_function.

To fix this now we always schedule a dispatch which will make sure data
still not processed will make its way to the proper handlers even if
disconnected.
2026-04-20 14:50:21 +08:00
Vinicius Costa Gomes 5aa2d80f17 Fix the case when the requested name is already in use
We weren't setting the dbus error in this situation.
2026-04-20 14:50:21 +08:00
Marcel Holtmann 4107b4565d Remove unneeded use of status variable 2026-04-20 14:50:21 +08:00
Forrest Zhao 2a9971501a Introduce g_dbus_setup_private() to gdbus
g_dbus_setup_private() is used to setup private DBusConnection
2026-04-20 14:50:21 +08:00
Marcel Holtmann 84fba9d11f Cleanup of D-Bus mainloop integration 2026-04-20 14:50:21 +08:00
Marcel Holtmann 6ad30cce8f Update copyright information of D-Bus helper library 2026-04-20 14:50:21 +08:00
Luiz Augusto Von Dentz 233964e840 Port gdbus to use g_dbus_add_signal_watch 2026-04-20 14:50:20 +08:00
Daniel Orstadius f0b0dd3d23 Fix D-Bus timeout handling
Timeouts should also be removed in the remove_timeout callback in
addition to the timeout_handler_free function. This is how dbus-glib
does it and it seems to prevent crashes in certain situations.
2026-04-20 14:50:20 +08:00
Claudio Takahasi c4c5d19973 Fix message handling for autostart.
Current implementation of libdbus Request name is blocking, consequently
the first incomming message that triggered the service autostart is not
being processed properly.
2026-04-20 14:50:20 +08:00
Marcel Holtmann 94776541f8 Fix blocking service watch initial connect handling 2026-04-20 14:50:20 +08:00
Marcel Holtmann 9e34662f09 Update copyright information 2026-04-20 14:50:20 +08:00
Marcel Holtmann 8ae5fc0a28 Add missing gdbus function declarations 2026-04-20 14:50:20 +08:00
Marcel Holtmann d23d4c2181 Change file headers for D-Bus helper library 2026-04-20 14:50:19 +08:00
Marcel Holtmann 12228a795e Add function for checking if a service is present 2026-04-20 14:50:19 +08:00
Marcel Holtmann 1cb2eedeec Fix connection disconnect function 2026-04-20 14:50:19 +08:00
Marcel Holtmann f7598806b2 Don't consider mainloop integration of dbus-glib 2026-04-20 14:50:19 +08:00
Marcel Holtmann badd896984 Remove GDBusDisconnectFunction type 2026-04-20 14:50:18 +08:00
Marcel Holtmann 85a530d26d Emulate libgdbus API for mainloop integration 2026-04-20 14:50:17 +08:00
Marcel Holtmann 0f1a53e60c Move D-Bus mainloop integration into libgdbus 2026-04-20 14:50:17 +08:00
Marcel Holtmann bf40f2510b Add skeleton for libgdbus support 2026-04-20 14:50:17 +08:00
openvela-robot bd246bdc0d kvdb/client: fix monitor fd leak
Signed-off-by: chao an <anchao@xiaomi.com>
2026-04-20 14:50:17 +08:00
Xiang Xiao 1b9a11da40 Revert "framework/gdbus: remove glib header file from gdbus.h"
This reverts commit 611fddab6fa2c183170a14811206546df6e6728f.
2026-04-20 14:50:16 +08:00
openvela-robot d3797cfabd Add include to the public search path
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-04-20 14:50:16 +08:00
openvela-robot 34b0f44034 kvdb: add kvdb xx_oneway API
Signed-off-by: ligd <liguiding1@xiaomi.com>
2026-04-20 14:50:16 +08:00