From e6e130671a0472a2a662caec86fe14c52e916bf8 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Wed, 7 Feb 2018 16:38:03 +0900 Subject: [PATCH 01/16] Clean up display-PROFILE.conf files Change-Id: Iafbf195b2056c3dad65493f4a710b8b96628064b Signed-off-by: Hyotaek Shim --- src/display/core.c | 2 +- src/display/display-mobile.conf | 26 -------------------------- src/display/display-tv.conf | 5 ----- src/display/display-wearable.conf | 26 +------------------------- 4 files changed, 2 insertions(+), 57 deletions(-) diff --git a/src/display/core.c b/src/display/core.c index e236c5d..8c4987b 100644 --- a/src/display/core.c +++ b/src/display/core.c @@ -172,7 +172,7 @@ static const char *lcdoff_sig_lookup[SIGNAL_MAX] = { #define INACTIVE_ACT "inactive" #define LOCK_SCREEN_WATING_TIME 0.3 /* 0.3 second */ -#define LONG_PRESS_INTERVAL 2 /* 2 seconds */ +#define LONG_PRESS_INTERVAL 0.4 /* 0.4 seconds */ #define SAMPLING_INTERVAL 1 /* 1 sec */ #define BRIGHTNESS_CHANGE_STEP 10 #define LCD_ALWAYS_ON 0 diff --git a/src/display/display-mobile.conf b/src/display/display-mobile.conf index 5abea3e..e30b212 100644 --- a/src/display/display-mobile.conf +++ b/src/display/display-mobile.conf @@ -1,31 +1,5 @@ [Display] -# deviced is pending lcd on until lock screen shows. -# This is the maximum pending time. -LockScreenWaitingTime=0.3 #second - -# Power-off popup is launched when power key is long pressed. -# This is duration of pressing power key. -LongPressInterval=0.4 #second - -# This is polling time of auto brightness. -LightSensorSamplingInterval=1 #second - -# display state is changed to SLEEP state after this time. -# If this value is large, it causes power consumption problem. -LCDOffTimeout=500 # milli second - -# This is n step of auto brightness. -# If brightness is change from a to b, brightness's changed n times from a to b. -BrightnessChangeStep=10 - -# If this value is yes, LCD is always on except pressing power key. -# Default value is no, LCD is turned off by lcd timeout. -LCDAlwaysOn=no # yes or no - # Just below application only allow to change display frame rate. # refer to enum refresh_app ChangedFrameRateAllowed=setting # setting ControlDisplay=yes # yes or no - -# LCD is not turned off when this value is yes and key double pressed -PowerKeyDoublePressSupport=no # yes or no diff --git a/src/display/display-tv.conf b/src/display/display-tv.conf index 9a68b75..9a27976 100644 --- a/src/display/display-tv.conf +++ b/src/display/display-tv.conf @@ -7,8 +7,3 @@ LCDAlwaysOn=yes # yes or no # If this value is no, LCD is turned off just by external requests. # Default value is yes. TimeoutEnable=no # yes or no - -# If this value is yes, input events such as screen touchs -# and/or HW key inputs are supported. -# Default value is yes. -InputSupport=yes # yes or no diff --git a/src/display/display-wearable.conf b/src/display/display-wearable.conf index 237c2a0..4933a6a 100644 --- a/src/display/display-wearable.conf +++ b/src/display/display-wearable.conf @@ -1,31 +1,7 @@ [Display] -# deviced is pending lcd on until lock screen shows. -# This is the maximum pending time. -LockScreenWaitingTime=0.3 #second - -# Power-off popup is launched when power key is long pressed. -# This is duration of pressing power key. -LongPressInterval=0.4 #second - -# This is polling time of auto brightness. -LightSensorSamplingInterval=1 #second - -# display state is changed to SLEEP state after this time. -# If this value is large, it causes power consumption problem. -LCDOffTimeout=500 # milli second - -# This is n step of auto brightness. -# If brightness is change from a to b, brightness's changed n times from a to b. -BrightnessChangeStep=10 - -# If this value is yes, LCD is always on except pressing power key. -# Default value is no, LCD is turned off by lcd timeout. -LCDAlwaysOn=no # yes or no - # Just below application only allow to change display frame rate. # refer to enum refresh_app -ChangedFrameRateAllowed=all # all -ControlDisplay=no # yes or no +ChangedFrameRateAllowed=all # all # LCD is not turned off when this value is yes and key double pressed PowerKeyDoublePressSupport=yes # yes or no -- 2.7.4 From 7a82ab30422ab2b51561c4d592e966a0d6b9d1e0 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Thu, 8 Feb 2018 11:53:43 +0900 Subject: [PATCH 02/16] Reorganize .conf files and combine PROFILE rpms into a unified one Change-Id: I013a02fdc716b1bc42aae5c6740acb381d0e81d6 Signed-off-by: Hyotaek Shim --- CMakeLists.txt | 16 +- {src/battery => conf}/battery.conf | 0 {src/cpu => conf}/cpu.conf | 0 conf/display-enable-timer.conf | 2 + conf/display-profile-wearable.conf | 6 + conf/display.conf | 36 ++++ {src/power => conf}/power.conf | 0 {src/usb => conf}/usb-operation.conf | 1 - packaging/deviced.spec | 358 +++++++---------------------------- src/auto-test/CMakeLists.txt | 24 --- src/display/core.c | 8 +- src/display/display-common.conf | 10 - src/display/display-mobile.conf | 5 - src/display/display-tv.conf | 9 - src/display/display-wearable.conf | 13 -- 15 files changed, 130 insertions(+), 358 deletions(-) rename {src/battery => conf}/battery.conf (100%) rename {src/cpu => conf}/cpu.conf (100%) create mode 100644 conf/display-enable-timer.conf create mode 100644 conf/display-profile-wearable.conf create mode 100644 conf/display.conf rename {src/power => conf}/power.conf (100%) rename {src/usb => conf}/usb-operation.conf (99%) delete mode 100644 src/display/display-common.conf delete mode 100644 src/display/display-mobile.conf delete mode 100644 src/display/display-tv.conf delete mode 100644 src/display/display-wearable.conf diff --git a/CMakeLists.txt b/CMakeLists.txt index f34c8f6..2e8a434 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,8 +35,8 @@ MACRO(ADD_SOURCE DIR OUT) ENDMACRO() MACRO(INSTALL_CONF DIR CONF) - SET(T_CONF ${DIR}/${CONF}-${PROFILE}.conf) - SET(E_CONF ${DIR}/${CONF}-emul-${PROFILE}.conf) + SET(T_CONF ${DIR}/${CONF}.conf) + SET(E_CONF ${DIR}/${CONF}-emul.conf) IF(EXISTS ${CMAKE_SOURCE_DIR}/${E_CONF}) SET(T_CONF ${E_CONF}) ENDIF() @@ -239,20 +239,22 @@ INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/deviced/ DESTINATION include/$ PATTERN "*.h") IF(BATTERY_MODULE STREQUAL on) - INSTALL_CONF(src/battery battery) + INSTALL_CONF(conf battery) ENDIF() IF(DISPLAY_MODULE STREQUAL on) - INSTALL_CONF(src/display display) + INSTALL_CONF(conf display) + INSTALL_CONF(conf display-profile-wearable) + INSTALL_CONF(conf display-enable-timer) ENDIF() IF(POWER_MODULE STREQUAL on) - INSTALL_CONF(src/power power) + INSTALL_CONF(conf power) ENDIF() # USB connection IF(USB_MODULE STREQUAL on) - INSTALL_CONF(src/usb usb-operation) + INSTALL_CONF(conf usb-operation) # USB (Manual setting) INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/direct_set_debug.sh DESTINATION bin) @@ -262,7 +264,7 @@ IF(USB_MODULE STREQUAL on) ENDIF() IF(TIZEN_FEATURE_CPU_MODULE STREQUAL on) - INSTALL_CONF(src/cpu cpu) + INSTALL_CONF(conf cpu) ENDIF() INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/deviced.conf DESTINATION /etc/dbus-1/system.d) diff --git a/src/battery/battery.conf b/conf/battery.conf similarity index 100% rename from src/battery/battery.conf rename to conf/battery.conf diff --git a/src/cpu/cpu.conf b/conf/cpu.conf similarity index 100% rename from src/cpu/cpu.conf rename to conf/cpu.conf diff --git a/conf/display-enable-timer.conf b/conf/display-enable-timer.conf new file mode 100644 index 0000000..05e20d8 --- /dev/null +++ b/conf/display-enable-timer.conf @@ -0,0 +1,2 @@ +LCDAlwaysOn=no +TimeoutEnable=yes diff --git a/conf/display-profile-wearable.conf b/conf/display-profile-wearable.conf new file mode 100644 index 0000000..8075ab9 --- /dev/null +++ b/conf/display-profile-wearable.conf @@ -0,0 +1,6 @@ +LCDAlwaysOn=no +TimeoutEnable=yes +ControlDisplay=no +PowerKeyDoublePressSupport=yes +AccelSensorOn=no +ContinuousSampling=no diff --git a/conf/display.conf b/conf/display.conf new file mode 100644 index 0000000..08ec195 --- /dev/null +++ b/conf/display.conf @@ -0,0 +1,36 @@ +[Display] +# deviced is pending lcd on until lock screen shows. +# This is the maximum pending time. +# LockScreenWaitingTime=0.3 (second) + +# Power-off popup is launched when power key is long pressed. +# This is duration of pressing power key. +# LongPressInterval=2 (second) + +# This is polling time of auto brightness. +# LightSensorSamplingInterval=1 (second) + +# display state is changed to SLEEP state after this time. +# If this value is large, it causes power consumption problem. +# LCDOffTimeout=500 (milli second) + +# This is n step of auto brightness. +# If brightness is change from a to b, brightness's changed n times from a to b. +# BrightnessChangeStep=10 + +# Just below application only allow to change display frame rate. +# refer to enum refresh_app +# ChangedFrameRateAllowed=setting (setting or all) +# ControlDisplay=(yes or no) + +# LCD is not turned off when this value is yes and key double pressed +# PowerKeyDoublePressSupport=(yes or no) + +# If this value is yes, LCD is always on except pressing power key. +# Default value is no, LCD is turned off by lcd timeout. +# LCDAlwaysOn=(yes or no) + +# If this value is yes, LCD is turned off by lcd timeout. +# If this value is no, LCD is turned off just by external requests. +# TimeoutEnable=(yes or no) + diff --git a/src/power/power.conf b/conf/power.conf similarity index 100% rename from src/power/power.conf rename to conf/power.conf diff --git a/src/usb/usb-operation.conf b/conf/usb-operation.conf similarity index 99% rename from src/usb/usb-operation.conf rename to conf/usb-operation.conf index 0329b04..da6c71c 100644 --- a/src/usb/usb-operation.conf +++ b/conf/usb-operation.conf @@ -2,7 +2,6 @@ StartService=sdbd.service StopService=sdbd.service - [mtp] StartService=mtp-responder.service StopService=mtp-responder.service diff --git a/packaging/deviced.spec b/packaging/deviced.spec index 86a0e09..0630d54 100644 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -5,7 +5,7 @@ Name: deviced Summary: Deviced -Version: 2.0.0 +Version: 5.0.0 Release: 1 Group: System/Management License: Apache-2.0 @@ -43,58 +43,9 @@ Requires: %{name}-tools = %{version}-%{release} %{?systemd_requires} Requires(post): /usr/bin/vconftool -Requires: %{name}-compat = %{version}-%{release} -Recommends: %{name}-profile_common = %{version}-%{release} - %description deviced -# if profile = common or undefined -%package profile_common -Summary: Deviced binaries targeting common profile -Provides: %{name}-compat = %{version}-%{release} -Conflicts: %{name}-profile_mobile -Conflicts: %{name}-profile_wearable -Conflicts: %{name}-profile_tv -%description profile_common -Deviced binaries targeting common profile. Required by main deviced package. -# if profile = mobile or common or undefined -%package profile_mobile -Summary: Deviced binaries targeting mobile profile -Provides: %{name}-compat = %{version}-%{release} -Conflicts: %{name}-profile_common -Conflicts: %{name}-profile_wearable -Conflicts: %{name}-profile_tv -%description profile_mobile -Deviced binaries targeting mobile profile. Required by main deviced package -# if profile = wearable or common or undefined -%package profile_wearable -Summary: Deviced binaries targeting wearable profile -Provides: %{name}-compat = %{version}-%{release} -Conflicts: %{name}-profile_common -Conflicts: %{name}-profile_mobile -Conflicts: %{name}-profile_tv -%description profile_wearable -Deviced binaries targeting wearable profile. Required by main deviced package -# if profile = tv or common or undefined -%package profile_tv -Summary: Deviced binaries targeting tv profile -Provides: %{name}-compat = %{version}-%{release} -Conflicts: %{name}-profile_common -Conflicts: %{name}-profile_mobile -Conflicts: %{name}-profile_wearable -%description profile_tv -Deviced binaries targeting tv profile. Required by main deviced package - -%package tools -Summary: Deviced tools -Group: System/Utilities - -%description tools -Deviced helper programs. -Deviced-tools is profile-independent; i.e., every profile has the same -binary for deviced-tools. - %package -n libdeviced Summary: Deviced library Group: Development/Libraries @@ -115,14 +66,41 @@ Deviced library for device control (devel). Because this is internal interface, every profile MUST have the same devel package. +%package tools +Summary: Deviced tools +Group: System/Utilities + +%description tools +Deviced helper programs. +Deviced-tools is profile-independent; i.e., every profile has the same +binary for deviced-tools. + %package auto-test -Summary: Deviced auto test tool -Group: System/Utilities +Summary: Deviced auto test tool +Group: System/Utilities %description auto-test Deviced helper programs. This package can be installed optional for auto dbus test. +%package config-profile-wearable +Summary: Configuration files for wearable profile +Group: System/Management +Requires: %{name} = %{version}-%{release} +BuildArch: noarch + +%description config-profile-wearable +This package is used for wearable profile + +%package config-enable-display-timer +Summary: Configuration files for display +Group: System/Management +Requires: %{name} = %{version}-%{release} +BuildArch: noarch + +%description config-enable-display-timer +This package is used for enabling a display timer. + %prep %setup -q @@ -142,18 +120,13 @@ This package can be installed optional for auto dbus test. %define engineer_mode off %endif -# Build per profile -# if profile = mobile or common or undefined -mkdir -p build_mobile -pushd build_mobile -%cmake .. \ +%cmake \ -DTZ_SYS_ETC=%TZ_SYS_ETC \ -DCMAKE_INSTALL_PREFIX=%{_prefix} \ -DARCH=%{ARCH} \ -DARCH_BIT=%{ARCH_BIT} \ -DDPMS=%{DPMS} \ -DENGINEER_MODE=%{engineer_mode} \ - -DPROFILE=mobile \ -DBATTERY_MODULE=on \ -DDISPLAY_MODULE=on \ -DEXTCON_MODULE=on \ @@ -165,154 +138,22 @@ pushd build_mobile -DTZIP_MODULE=on \ -DUSB_MODULE=on \ -DUSBHOST_MODULE=on \ - -DTIZEN_FEATURE_USBHOST_TEST=on \ - -DTIZEN_FEATURE_BATTERY_OVER_TEMPERATURE=off \ + -DTHERMAL_MODULE=on \ -DTIZEN_FEATURE_CPU_MODULE=on \ -DTIZEN_FEATURE_TELEPHONY_MODULE=on \ - -DTHERMAL_MODULE=on \ - #eol -popd - -# if profile = wearable or common or undefined -mkdir -p build_wearable -pushd build_wearable -%cmake .. \ - -DTZ_SYS_ETC=%TZ_SYS_ETC \ - -DCMAKE_INSTALL_PREFIX=%{_prefix} \ - -DARCH=%{ARCH} \ - -DARCH_BIT=%{ARCH_BIT} \ - -DDPMS=%{DPMS} \ - -DENGINEER_MODE=%{engineer_mode} \ - -DPROFILE=wearable \ - -DBATTERY_MODULE=on \ - -DDISPLAY_MODULE=on \ - -DEXTCON_MODULE=on \ - -DIR_MODULE=off \ - -DLED_MODULE=off \ - -DPOWER_MODULE=on \ - -DSDB_PRESTART=%{sdb_prestart} \ - -DTOUCHSCREEN_MODULE=on \ - -DTZIP_MODULE=on \ - -DUSB_MODULE=on \ - -DUSBHOST_MODULE=off \ - -DTIZEN_FEATURE_USBHOST_TEST=off \ - -DTIZEN_FEATURE_BATTERY_OVER_TEMPERATURE=off \ - -DTIZEN_FEATURE_CPU_MODULE=off \ - -DTIZEN_FEATURE_TELEPHONY_MODULE=off \ - -DTHERMAL_MODULE=on \ - #eol -popd - -# if profile = tv or common or undefined -mkdir -p build_tv -pushd build_tv -%cmake .. \ - -DTZ_SYS_ETC=%TZ_SYS_ETC \ - -DCMAKE_INSTALL_PREFIX=%{_prefix} \ - -DARCH=%{ARCH} \ - -DARCH_BIT=%{ARCH_BIT} \ - -DENGINEER_MODE=%{engineer_mode} \ - -DPROFILE=tv \ - -DBATTERY_MODULE=off \ - -DDISPLAY_MODULE=on \ - -DEXTCON_MODULE=on \ - -DIR_MODULE=off \ - -DLED_MODULE=off \ - -DPOWER_MODULE=on \ - -DSDB_PRESTART=%{sdb_prestart} \ - -DTOUCHSCREEN_MODULE=off \ - -DTZIP_MODULE=off \ - -DUSB_MODULE=on \ - -DUSBHOST_MODULE=on \ - -DTIZEN_FEATURE_USBHOST_TEST=off \ - -DTIZEN_FEATURE_BATTERY_OVER_TEMPERATURE=off \ - -DTIZEN_FEATURE_CPU_MODULE=off \ - -DTIZEN_FEATURE_TELEPHONY_MODULE=off \ - -DTHERMAL_MODULE=off \ - #eol -popd - -# if profile = common or undefined -mkdir -p build_common -pushd build_common -%cmake .. \ - -DTZ_SYS_ETC=%TZ_SYS_ETC \ - -DCMAKE_INSTALL_PREFIX=%{_prefix} \ - -DARCH=%{ARCH} \ - -DARCH_BIT=%{ARCH_BIT} \ - -DDPMS=%{DPMS} \ - -DENGINEER_MODE=%{engineer_mode} \ - -DPROFILE=common \ - -DBATTERY_MODULE=off \ - -DDISPLAY_MODULE=on \ - -DEXTCON_MODULE=on \ - -DIR_MODULE=off \ - -DLED_MODULE=off \ - -DPOWER_MODULE=on \ - -DSDB_PRESTART=%{sdb_prestart} \ - -DTOUCHSCREEN_MODULE=on \ - -DTZIP_MODULE=off \ - -DUSB_MODULE=on \ - -DUSBHOST_MODULE=off \ - -DTIZEN_FEATURE_USBHOST_TEST=off \ - -DTIZEN_FEATURE_BATTERY_OVER_TEMPERATURE=off \ - -DTIZEN_FEATURE_CPU_MODULE=off \ - -DTIZEN_FEATURE_TELEPHONY_MODULE=off \ - -DTHERMAL_MODULE=off \ + -DTIZEN_FEATURE_USBHOST_TEST=on \ + -DTIZEN_FEATURE_BATTERY_OVER_TEMPERATURE=on \ #eol -popd %build cp %{SOURCE1} . cp %{SOURCE2} . -# Build per profile -# if profile = mobile or common or undefined -pushd build_mobile -make %{?jobs:-j%jobs} -popd - -# if profile = wearable or common or undefined -pushd build_wearable -make %{?jobs:-j%jobs} -popd - -# if profile = tv or common or undefined -pushd build_tv make %{?jobs:-j%jobs} -popd - -# if profile = common or undefined -pushd build_common -make %{?jobs:-j%jobs} -popd %install rm -rf %{buildroot} -# Build per profile -# if profile = mobile or common or undefined -pushd build_mobile %make_install -mv %{buildroot}%{_bindir}/deviced %{buildroot}%{_bindir}/deviced.mobile -popd - -# if profile = wearable or common or undefined -pushd build_wearable -%make_install -mv %{buildroot}%{_bindir}/deviced %{buildroot}%{_bindir}/deviced.wearable -popd - -# if profile = tv or common or undefined -pushd build_tv -%make_install -mv %{buildroot}%{_bindir}/deviced %{buildroot}%{_bindir}/deviced.tv -popd - -# if profile = common or undefined -pushd build_common -%make_install -mv %{buildroot}%{_bindir}/deviced %{buildroot}%{_bindir}/deviced.common -popd %install_service multi-user.target.wants deviced.service %install_service sockets.target.wants deviced.socket @@ -328,117 +169,59 @@ install -m 775 scripts/dump_pmstate_log.sh %{buildroot}%{TZ_SYS_DUMPGEN}/dump_pm #memory type vconf key init users_gid=$(getent group %{TZ_SYS_USER_GROUP} | cut -f3 -d':') -%postun -systemctl daemon-reload - -%post -n libdeviced -p /sbin/ldconfig - -%postun -n libdeviced -p /sbin/ldconfig - -%post profile_mobile -mv %{_bindir}/deviced.mobile %{_bindir}/deviced -mv %{_sysconfdir}/deviced/display-mobile.conf %{_sysconfdir}/deviced/display.conf - systemctl daemon-reload if [ "$1" == "1" ]; then systemctl restart deviced.service fi -%preun profile_mobile -mv %{_bindir}/deviced %{_bindir}/deviced.mobile - +%postun +systemctl daemon-reload if [ "$1" == "0" ]; then systemctl stop deviced.service fi -%post profile_wearable -mv %{_bindir}/deviced.wearable %{_bindir}/deviced -mv %{_sysconfdir}/deviced/display-wearable.conf %{_sysconfdir}/deviced/display.conf - -systemctl daemon-reload -if [ "$1" == "1" ]; then - systemctl restart deviced.service -fi - -%preun profile_wearable -mv %{_bindir}/deviced %{_bindir}/deviced.wearable +%post -n libdeviced -p /sbin/ldconfig -if [ "$1" == "0" ]; then - systemctl stop deviced.service -fi +%postun -n libdeviced -p /sbin/ldconfig -%post profile_tv -mv %{_bindir}/deviced.tv %{_bindir}/deviced -mv %{_sysconfdir}/deviced/display-tv.conf %{_sysconfdir}/deviced/display.conf -%preun profile_tv -mv %{_bindir}/deviced %{_bindir}/deviced.tv +%post config-profile-wearable +cat %{_sysconfdir}/deviced/display-profile-wearable.conf >> %{_sysconfdir}/deviced/display.conf +rm -rf %{_sysconfdir}/deviced/display-profile-wearable.conf -%post profile_common -mv %{_bindir}/deviced.common %{_bindir}/deviced -mv %{_sysconfdir}/deviced/display-common.conf %{_sysconfdir}/deviced/display.conf -%preun profile_common -mv %{_bindir}/deviced %{_bindir}/deviced.common +%post config-enable-display-timer +cat %{_sysconfdir}/deviced/display-enable-timer.conf >> %{_sysconfdir}/deviced/display.conf +rm -rf %{_sysconfdir}/deviced/display-enable-timer.conf %files %manifest %{name}.manifest %license LICENSE.Apache-2.0 -%config %{_sysconfdir}/dbus-1/system.d/deviced.conf +%{_bindir}/deviced %{_unitdir}/multi-user.target.wants/deviced.service %{_unitdir}/sockets.target.wants/deviced.socket %{_unitdir}/deviced.service %{_unitdir}/deviced.socket -#%if %{?power_module} == on ==? always on -%config %{_sysconfdir}/deviced/power.conf -#%endif -#if #{?usb_module} == on ==> always on -%config %{_sysconfdir}/deviced/usb-operation.conf %if %{?sdb_prestart} == on %{_unitdir}/sdb-prestart.service %{_unitdir}/basic.target.wants/sdb-prestart.service %endif -#endif - -%files profile_mobile -%manifest deviced.manifest -%license LICENSE.Apache-2.0 -%{_bindir}/deviced.mobile -# TIZEN_FEATURE_LAZY_MOUNT == on -# battery_module -%config %{_sysconfdir}/deviced/battery.conf -# usbhost_test -%{_sysconfdir}/deviced/usb-host-test/test_gadget.gs -%{_bindir}/usb-host-ffs-test-daemon -%{_unitdir}/usb-host-ffs-test-daemon.service -%{_unitdir}/usb-host-test.socket -%{_sysconfdir}/deviced/usb-host-test/descs -%{_sysconfdir}/deviced/usb-host-test/strs -# cpu_module +%config %{_sysconfdir}/dbus-1/system.d/deviced.conf %config %{_sysconfdir}/deviced/cpu.conf -#if #{?display_module} == on ==> always on -%config %{_sysconfdir}/deviced/display-mobile.conf - -%files profile_wearable -%manifest deviced.manifest -%license LICENSE.Apache-2.0 -%{_bindir}/deviced.wearable -# battery_module +%config %{_sysconfdir}/deviced/power.conf %config %{_sysconfdir}/deviced/battery.conf -#if #{?display_module} == on ==> always on -%config %{_sysconfdir}/deviced/display-wearable.conf +%config %{_sysconfdir}/deviced/display.conf +%config %{_sysconfdir}/deviced/usb-operation.conf -%files profile_tv +%files -n libdeviced %manifest deviced.manifest %license LICENSE.Apache-2.0 -%{_bindir}/deviced.tv -#if #{?display_module} == on ==> always on -%config %{_sysconfdir}/deviced/display-tv.conf +%defattr(-,root,root,-) +%{_libdir}/libdeviced.so.* -%files profile_common -%manifest deviced.manifest -%license LICENSE.Apache-2.0 -%{_bindir}/deviced.common -#if #{?display_module} == on ==> always on -%config %{_sysconfdir}/deviced/display-common.conf +%files -n libdeviced-devel +%defattr(-,root,root,-) +%{_includedir}/deviced/*.h +%{_libdir}/libdeviced.so +%{_libdir}/pkgconfig/deviced.pc %files tools %manifest deviced.manifest @@ -449,20 +232,25 @@ mv %{_bindir}/deviced %{_bindir}/deviced.common %{TZ_SYS_DUMPGEN}/dump_pmstate_log.sh #endif -%files -n libdeviced +%files auto-test %manifest deviced.manifest %license LICENSE.Apache-2.0 -%defattr(-,root,root,-) -%{_libdir}/libdeviced.so.* +%{_bindir}/deviced-auto-test +%config %{_sysconfdir}/deviced/auto-test.conf +# usbhost_test +%{_sysconfdir}/deviced/usb-host-test/test_gadget.gs +%{_bindir}/usb-host-ffs-test-daemon +%{_unitdir}/usb-host-ffs-test-daemon.service +%{_unitdir}/usb-host-test.socket +%{_sysconfdir}/deviced/usb-host-test/descs +%{_sysconfdir}/deviced/usb-host-test/strs -%files -n libdeviced-devel -%defattr(-,root,root,-) -%{_includedir}/deviced/*.h -%{_libdir}/libdeviced.so -%{_libdir}/pkgconfig/deviced.pc +%files config-profile-wearable +%manifest deviced.manifest +%license LICENSE.Apache-2.0 +%config %{_sysconfdir}/deviced/display-profile-wearable.conf -%files auto-test +%files config-enable-display-timer %manifest deviced.manifest %license LICENSE.Apache-2.0 -%{_bindir}/deviced-auto-test -%config %{_sysconfdir}/deviced/auto-test.conf +%config %{_sysconfdir}/deviced/display-enable-timer.conf diff --git a/src/auto-test/CMakeLists.txt b/src/auto-test/CMakeLists.txt index f37bbac..f7db8ea 100644 --- a/src/auto-test/CMakeLists.txt +++ b/src/auto-test/CMakeLists.txt @@ -3,14 +3,6 @@ PROJECT(deviced-auto-test C) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src) -IF("${PROFILE}" STREQUAL "wearable") - SET(PROFILE wearable) -ELSEIF("${PROFILE}" STREQUAL "tv") - SET(PROFILE tv) -ELSE() - SET(PROFILE mobile) -ENDIF() - IF("$ENV{CFLAGS}" MATCHES "-DTIZEN_ENGINEER_MODE") OPTION(USE_ENGINEER_MODE "Use Engineer mode" ON) ENDIF() @@ -32,22 +24,6 @@ SET(SRCS time.c ) -# extcon test -#SET(SRCS ${SRCS} -# storage.c -# usb.c -# hdmi.c -# earjack.c -#) - -#IF(NOT PROFILE STREQUAL wearable) -#SET(SRCS ${SRCS} -# cradle.c -# keyboard.c -# tvout.c -#) -#ENDIF(NOT PROFILE STREQUAL wearable) - INCLUDE(FindPkgConfig) FOREACH(flag ${pkgs_CFLAGS}) diff --git a/src/display/core.c b/src/display/core.c index 8c4987b..399ade5 100644 --- a/src/display/core.c +++ b/src/display/core.c @@ -172,10 +172,10 @@ static const char *lcdoff_sig_lookup[SIGNAL_MAX] = { #define INACTIVE_ACT "inactive" #define LOCK_SCREEN_WATING_TIME 0.3 /* 0.3 second */ -#define LONG_PRESS_INTERVAL 0.4 /* 0.4 seconds */ +#define LONG_PRESS_INTERVAL 2 /* 2 seconds */ #define SAMPLING_INTERVAL 1 /* 1 sec */ #define BRIGHTNESS_CHANGE_STEP 10 -#define LCD_ALWAYS_ON 0 +#define LCD_ALWAYS_ON 1 #define ACCEL_SENSOR_ON 1 #define CONTINUOUS_SAMPLING 1 #define LCDOFF_TIMEOUT 500 /* milli second */ @@ -193,11 +193,11 @@ struct display_config display_conf = { .brightness_change_step = BRIGHTNESS_CHANGE_STEP, .lcd_always_on = LCD_ALWAYS_ON, .framerate_app = {0, 0, 0, 0}, - .control_display = 0, + .control_display = 1, .powerkey_doublepress = 0, .accel_sensor_on = ACCEL_SENSOR_ON, .continuous_sampling = CONTINUOUS_SAMPLING, - .timeout_enable = true, + .timeout_enable = false, .input_support = true, }; diff --git a/src/display/display-common.conf b/src/display/display-common.conf deleted file mode 100644 index 0457f54..0000000 --- a/src/display/display-common.conf +++ /dev/null @@ -1,10 +0,0 @@ -[Display] -# If this value is yes, LCD is turned off by lcd timeout. -# If this value is no, LCD is turned off just by external requests. -# Default value is yes. -TimeoutEnable=no # yes or no - -# If this value is yes, input events such as screen touchs -# and/or HW key inputs are supported. -# Default value is yes. -InputSupport=no # yes or no diff --git a/src/display/display-mobile.conf b/src/display/display-mobile.conf deleted file mode 100644 index e30b212..0000000 --- a/src/display/display-mobile.conf +++ /dev/null @@ -1,5 +0,0 @@ -[Display] -# Just below application only allow to change display frame rate. -# refer to enum refresh_app -ChangedFrameRateAllowed=setting # setting -ControlDisplay=yes # yes or no diff --git a/src/display/display-tv.conf b/src/display/display-tv.conf deleted file mode 100644 index 9a27976..0000000 --- a/src/display/display-tv.conf +++ /dev/null @@ -1,9 +0,0 @@ -[Display] -# If this value is yes, LCD is always on except pressing power key. -# Default value is no, LCD is turned off by lcd timeout. -LCDAlwaysOn=yes # yes or no - -# If this value is yes, LCD is turned off by lcd timeout. -# If this value is no, LCD is turned off just by external requests. -# Default value is yes. -TimeoutEnable=no # yes or no diff --git a/src/display/display-wearable.conf b/src/display/display-wearable.conf deleted file mode 100644 index 4933a6a..0000000 --- a/src/display/display-wearable.conf +++ /dev/null @@ -1,13 +0,0 @@ -[Display] -# Just below application only allow to change display frame rate. -# refer to enum refresh_app -ChangedFrameRateAllowed=all # all - -# LCD is not turned off when this value is yes and key double pressed -PowerKeyDoublePressSupport=yes # yes or no - -# Use Accelator sensor when autobrightness is on. -AccelSensorOn=no # yes or no - -# Use Continuous Sampling when autobrightness is on. -ContinuousSampling=no # yes or no -- 2.7.4 From 6362937da74c7b84ddd856b9574a2708641cb16b Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Mon, 12 Feb 2018 10:55:49 +0900 Subject: [PATCH 03/16] Usb: change returned value from integer to unsigned integer for the dbus method of GetState and GetMode Change-Id: Iafb5a6beff8dc7f8267a15cf30573b909037e32b Signed-off-by: lokilee73 --- src/usb/usb-dbus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 src/usb/usb-dbus.c diff --git a/src/usb/usb-dbus.c b/src/usb/usb-dbus.c old mode 100644 new mode 100755 index 0823059..d7beb8c --- a/src/usb/usb-dbus.c +++ b/src/usb/usb-dbus.c @@ -180,7 +180,7 @@ GVariant *get_usb_client_state(GDBusConnection *conn, state = get_usb_state(); - return g_variant_new("(i)", state); + return g_variant_new("(u)", state); } GVariant *get_usb_client_mode(GDBusConnection *conn, @@ -191,7 +191,7 @@ GVariant *get_usb_client_mode(GDBusConnection *conn, mode = get_usb_current_mode(); - return g_variant_new("(i)", mode); + return g_variant_new("(u)", mode); } static const dbus_method_s dbus_methods[] = { -- 2.7.4 From 60b9dab178145c11e3d2f82824d5da40627f8a5b Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Thu, 8 Feb 2018 11:51:45 +0900 Subject: [PATCH 04/16] Fix indentation Change-Id: I5984b19abf889e7e48fac9b5c1fc3c82a91d5ac2 Signed-off-by: sanghyeok.oh --- src/auto-test/battery.c | 46 ++--- src/auto-test/display.c | 14 +- src/auto-test/extcon.c | 20 ++- src/auto-test/ir.c | 14 +- src/auto-test/led.c | 12 +- src/auto-test/power.c | 14 +- src/auto-test/proc.c | 13 +- src/auto-test/time.c | 7 +- src/battery/battery-time.c | 8 +- src/battery/lowbat-handler.c | 8 +- src/battery/power-supply.c | 79 +++++---- src/control/control.c | 8 +- src/core/devices.c | 4 +- src/core/event-handler.c | 12 +- src/cpu/pmqos.c | 12 +- src/devicectl/devicectl.c | 54 ++++-- src/display/ambient-mode.c | 6 +- src/display/core.c | 16 +- src/display/display-dbus.c | 117 ++++++------- src/display/dpms-wayland-none.c | 9 +- src/display/key-filter.c | 18 +- src/display/state-tv.c | 30 ++-- src/extcon/cradle.c | 10 +- src/extcon/earjack.c | 6 +- src/extcon/extcon.c | 26 +-- src/extcon/hdmi.c | 10 +- src/ir/ir.c | 12 +- src/led/torch.c | 18 +- src/libdeviced/dbus.c | 202 +++++++++++++--------- src/libdeviced/deviced-conf.c | 12 +- src/libdeviced/deviced-noti.c | 30 +++- src/libdeviced/display.c | 39 +++-- src/libdeviced/haptic.c | 168 +++++++++++-------- src/libdeviced/led.c | 18 +- src/libdeviced/mmc.c | 57 +++++-- src/libdeviced/usbhost.c | 111 ++++++------ src/power/boot.c | 20 ++- src/power/low-power.c | 12 +- src/power/power-handler.c | 28 ++-- src/proc/cpu-info.c | 4 +- src/proc/proc-handler.c | 12 +- src/shared/dbus.c | 344 ++++++++++++++++++++++++-------------- src/shared/dbus.h | 1 - src/time/time-handler.c | 4 +- src/usb-host-test/usb-host-test.c | 8 +- src/usb/usb-dbus.c | 8 +- src/usbhost/usb-host.c | 20 +-- 47 files changed, 1015 insertions(+), 686 deletions(-) diff --git a/src/auto-test/battery.c b/src/auto-test/battery.c index 2a1e3d7..0aa66b5 100644 --- a/src/auto-test/battery.c +++ b/src/auto-test/battery.c @@ -297,14 +297,14 @@ static bool get_battery_info() } if (!dh_get_param_from_var(msg, "(isssiiiii)", &val[0], //return value - &argv[0],//status - &argv[1],//health - &argv[2],//power source - &val[1], //online - &val[2], //present - &val[3], //capacity - &val[4], //current_now - &val[5])) //current_average + &argv[0],//status + &argv[1],//health + &argv[2],//power source + &val[1], //online + &val[2], //present + &val[3], //capacity + &val[4], //current_now + &val[5])) //current_average _E("fail: no message"); else { if (val[0] < 0) { @@ -331,23 +331,23 @@ static bool set_battery_power_supply(int index) GVariant *var; var = g_variant_new("(sisssss)", POWER_SUBSYSTEM, - 5, - power_supply_types[index].capacity, - power_supply_types[index].charge_status, - power_supply_types[index].health, - power_supply_types[index].online, - power_supply_types[index].present); - _I("C(%s , %s) P(%s) STATUS(%s) HEALTH(%s)", - power_supply_types[index].capacity, - power_supply_types[index].online, - power_supply_types[index].present, - power_supply_types[index].charge_status, - power_supply_types[index].health); + 5, + power_supply_types[index].capacity, + power_supply_types[index].charge_status, + power_supply_types[index].health, + power_supply_types[index].online, + power_supply_types[index].present); + _I("C(%s , %s) P(%s) STATUS(%s) HEALTH(%s)", + power_supply_types[index].capacity, + power_supply_types[index].online, + power_supply_types[index].present, + power_supply_types[index].charge_status, + power_supply_types[index].health); msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_BATTERY, - DEVICED_INTERFACE_BATTERY, - POWER_SUBSYSTEM, var); + DEVICED_PATH_BATTERY, + DEVICED_INTERFACE_BATTERY, + POWER_SUBSYSTEM, var); if (!msg) { _E("fail: no reply"); return ret; diff --git a/src/auto-test/display.c b/src/auto-test/display.c index 2686771..b9b3cda 100644 --- a/src/auto-test/display.c +++ b/src/auto-test/display.c @@ -142,9 +142,10 @@ static bool set_display_brightness(int brightness) bool ret = FALSE; msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_DISPLAY, - DEVICED_INTERFACE_DISPLAY, - METHOD_DISPLAY_SETBRIGHTNESS, g_variant_new("(i)", brightness)); + DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + METHOD_DISPLAY_SETBRIGHTNESS, + g_variant_new("(i)", brightness)); if (!msg) { _E("fail : no reply"); return ret; @@ -219,9 +220,10 @@ static bool set_display_autobrightness_min(int min) bool ret = FALSE; msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_DISPLAY, - DEVICED_INTERFACE_DISPLAY, - METHOD_DISPLAY_SETAUTOBRIGHTNESSMIN, g_variant_new("(i)", min)); + DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + METHOD_DISPLAY_SETAUTOBRIGHTNESSMIN, + g_variant_new("(i)", min)); if (!msg) { _E("fail : no reply"); return ret; diff --git a/src/auto-test/extcon.c b/src/auto-test/extcon.c index dbd9acd..f2c5ffc 100644 --- a/src/auto-test/extcon.c +++ b/src/auto-test/extcon.c @@ -31,9 +31,10 @@ static bool request_extcon_method(const char *method, GVariant *param) bool ret = FALSE; msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_EXTCON, - DEVICED_INTERFACE_EXTCON, - method, param); + DEVICED_PATH_EXTCON, + DEVICED_INTERFACE_EXTCON, + method, + param); if (!msg) { _E("fail (%s): no reply", method); return ret; @@ -64,9 +65,9 @@ static bool get_sysnoti_method(const char *method) bool ret = FALSE; msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, - DEVICED_PATH_SYSNOTI, - DEVICED_INTERFACE_SYSNOTI, - method, NULL, NULL); + DEVICED_PATH_SYSNOTI, + DEVICED_INTERFACE_SYSNOTI, + method, NULL, NULL); if (!msg) { _E("fail (%s): no reply", method); return ret; @@ -97,9 +98,10 @@ static bool get_extcon_status(char *device_name) bool ret = FALSE; msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_EXTCON, - DEVICED_INTERFACE_EXTCON, - METHOD_EXTCON_GETSTATUS, g_variant_new("(s)", device_name)); + DEVICED_PATH_EXTCON, + DEVICED_INTERFACE_EXTCON, + METHOD_EXTCON_GETSTATUS, + g_variant_new("(s)", device_name)); if (!msg) { _E("fail : no reply"); return ret; diff --git a/src/auto-test/ir.c b/src/auto-test/ir.c index 8e87057..2a700a7 100644 --- a/src/auto-test/ir.c +++ b/src/auto-test/ir.c @@ -43,9 +43,10 @@ static bool request_ir_method(const char *method, const char *sig, int *param) } msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_IR, - DEVICED_INTERFACE_IR, - method, var); + DEVICED_PATH_IR, + DEVICED_INTERFACE_IR, + method, + var); if (!msg) { _E("fail (%s): no reply", method); return ret; @@ -96,9 +97,10 @@ static bool set_ir_command(char *command) bool ret = FALSE; msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_LED, - DEVICED_INTERFACE_LED, - METHOD_IR_SETIRCOMMAND, g_variant_new("(s)", command)); + DEVICED_PATH_LED, + DEVICED_INTERFACE_LED, + METHOD_IR_SETIRCOMMAND, + g_variant_new("(s)", command)); if (!msg) { _E("fail : no reply"); return ret; diff --git a/src/auto-test/led.c b/src/auto-test/led.c index d4bd1e2..781e1da 100644 --- a/src/auto-test/led.c +++ b/src/auto-test/led.c @@ -39,9 +39,9 @@ static bool get_led_method(const char *method) bool ret = FALSE; msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, - DEVICED_PATH_LED, - DEVICED_INTERFACE_LED, - method, NULL, NULL); + DEVICED_PATH_LED, + DEVICED_INTERFACE_LED, + method, NULL, NULL); if (!msg) { _E("fail (%s): no reply", method); return ret; @@ -65,9 +65,9 @@ static bool set_led_method(const char *method, GVariant *param) bool ret = FALSE; msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_LED, - DEVICED_INTERFACE_LED, - method, param); + DEVICED_PATH_LED, + DEVICED_INTERFACE_LED, + method, param); if (!msg) { _E("fail (%s): no reply", method); return ret; diff --git a/src/auto-test/power.c b/src/auto-test/power.c index ff6cbaa..a31614d 100644 --- a/src/auto-test/power.c +++ b/src/auto-test/power.c @@ -32,9 +32,10 @@ static bool set_reboot_method(const char *method, GVariant *param) bool ret = FALSE; msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_REBOOT, - DEVICED_INTERFACE_REBOOT, - method, param); + DEVICED_PATH_REBOOT, + DEVICED_INTERFACE_REBOOT, + method, + param); if (!msg) { _E("fail (%s): no reply", method); return ret; @@ -82,9 +83,10 @@ static bool request_lowpower_method(const char *method, GVariant *param) while (retry++ < 3) { msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_LOWPOWER, - DEVICED_INTERFACE_LOWPOWER, - method, param); + DEVICED_PATH_LOWPOWER, + DEVICED_INTERFACE_LOWPOWER, + method, + param); if (!msg) { _E("fail (%s): no reply", method); return ret; diff --git a/src/auto-test/proc.c b/src/auto-test/proc.c index 0abd0a7..a35b057 100644 --- a/src/auto-test/proc.c +++ b/src/auto-test/proc.c @@ -29,9 +29,10 @@ static bool set_proc_method(const char *method, GVariant *param) bool ret = FALSE; msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_PROCESS, - DEVICED_INTERFACE_PROCESS, - method, param); + DEVICED_PATH_PROCESS, + DEVICED_INTERFACE_PROCESS, + method, + param); if (!msg) { _E("fail (%s): no reply", method); return ret; @@ -73,9 +74,9 @@ static bool get_sysnoti_revision() bool ret = FALSE; msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, - DEVICED_PATH_SYSNOTI, - DEVICED_INTERFACE_SYSNOTI, - METHOD_SYSNOTI_GETREVISION, NULL, NULL); + DEVICED_PATH_SYSNOTI, + DEVICED_INTERFACE_SYSNOTI, + METHOD_SYSNOTI_GETREVISION, NULL, NULL); if (!msg) { _E("fail : no reply"); return ret; diff --git a/src/auto-test/time.c b/src/auto-test/time.c index 898eaf7..066cf84 100644 --- a/src/auto-test/time.c +++ b/src/auto-test/time.c @@ -27,9 +27,10 @@ static bool request_sysnoti_method(const char *method, GVariant *param) bool ret = FALSE; msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_SYSNOTI, - DEVICED_INTERFACE_SYSNOTI, - method, param); + DEVICED_PATH_SYSNOTI, + DEVICED_INTERFACE_SYSNOTI, + method, + param); if (!msg) { _E("fail (%s): no reply", method); return ret; diff --git a/src/battery/battery-time.c b/src/battery/battery-time.c index 6131ab1..3b2d2cd 100644 --- a/src/battery/battery-time.c +++ b/src/battery/battery-time.c @@ -334,8 +334,8 @@ static void end_battinfo_gathering(void) } GVariant * dbus_get_timetofull(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int val; @@ -347,8 +347,8 @@ GVariant * dbus_get_timetofull(GDBusConnection *conn, } static GVariant * dbus_get_timetoempty(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int val; diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index 5cce925..860d7ab 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -800,8 +800,8 @@ static int lowbat_monitor_init(void *data) static GVariant * dbus_set_lowbat_level(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret = 0; int now; @@ -835,8 +835,8 @@ out: } static GVariant * dbus_get_lowbat_level(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { _D("warning %d", custom_warning_level); return g_variant_new("(i)", custom_warning_level); diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index 43a6674..f6c217b 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -157,12 +157,12 @@ static gboolean health_timer_cb(void *data) } static void abnormal_popup_dbus_signal_handler(GDBusConnection *conn, - const gchar *sender, - const gchar *path, - const gchar *iface, - const gchar *name, - GVariant *param, - gpointer user_data) + const gchar *sender, + const gchar *path, + const gchar *iface, + const gchar *name, + GVariant *param, + gpointer user_data) { if (battery.health == HEALTH_GOOD) @@ -318,8 +318,10 @@ void power_supply_broadcast(char *sig, int status) /*snprintf(str_status, sizeof(str_status), "%d", status); arr[0] = str_status;*/ - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_BATTERY, DEVICED_INTERFACE_BATTERY, - sig, g_variant_new("(i)", status)); + dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_BATTERY, + DEVICED_INTERFACE_BATTERY, + sig, + g_variant_new("(i)", status)); } @@ -888,8 +890,8 @@ static void power_supply_timer_stop(void) } static GVariant *dbus_get_charger_status(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; @@ -901,8 +903,8 @@ static GVariant *dbus_get_charger_status(GDBusConnection *conn, } static GVariant *dbus_get_charge_now(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; @@ -912,8 +914,8 @@ static GVariant *dbus_get_charge_now(GDBusConnection *conn, } static GVariant *dbus_get_charge_level(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; @@ -926,8 +928,8 @@ static GVariant *dbus_get_charge_level(GDBusConnection *conn, } static GVariant *dbus_get_percent(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; @@ -937,8 +939,8 @@ static GVariant *dbus_get_percent(GDBusConnection *conn, } static GVariant *dbus_get_percent_raw(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; @@ -948,8 +950,8 @@ static GVariant *dbus_get_percent_raw(GDBusConnection *conn, } static GVariant *dbus_is_full(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; @@ -959,8 +961,8 @@ static GVariant *dbus_is_full(GDBusConnection *conn, } static GVariant *dbus_get_health(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; @@ -970,8 +972,8 @@ static GVariant *dbus_get_health(GDBusConnection *conn, } static GVariant *dbus_power_supply_handler(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { pid_t pid; int ret = 0; @@ -979,8 +981,13 @@ static GVariant *dbus_power_supply_handler(GDBusConnection *conn, char *type_str; char *argv[5]; - g_variant_get(param, "(sisssss)", &type_str, &argc, - &argv[0], &argv[1], &argv[2], &argv[3], &argv[4]); + g_variant_get(param, "(sisssss)", &type_str, + &argc, + &argv[0], + &argv[1], + &argv[2], + &argv[3], + &argv[4]); if (argc < 0) { _E("message is invalid!"); @@ -1044,8 +1051,8 @@ static void battery_get_info(struct battery_info *info, void *data) } static GVariant *dbus_get_battery_info(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret, val; const char *str; @@ -1102,14 +1109,14 @@ static GVariant *dbus_get_battery_info(GDBusConnection *conn, } return g_variant_new("(isssiiiii)", ret, - battery.status_s, - battery.health_s, - battery.power_source_s, - battery.online, - battery.present, - battery.capacity, - battery.current_now, - battery.current_average); + battery.status_s, + battery.health_s, + battery.power_source_s, + battery.online, + battery.present, + battery.capacity, + battery.current_now, + battery.current_average); } static const dbus_method_s dbus_methods[] = { diff --git a/src/control/control.c b/src/control/control.c index 081d10f..cb60336 100644 --- a/src/control/control.c +++ b/src/control/control.c @@ -127,8 +127,8 @@ static int get_control_handler(int argc, char **argv) } GVariant *dbus_control_handler(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { pid_t pid; int ret; @@ -160,8 +160,8 @@ out: GVariant *dbus_get_control_handler(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { pid_t pid; int ret; diff --git a/src/core/devices.c b/src/core/devices.c index c86625b..1f5e2ba 100644 --- a/src/core/devices.c +++ b/src/core/devices.c @@ -69,8 +69,8 @@ int check_default(const struct device_ops *dev) } GVariant *dbus_device_list(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { dd_list *elem; const struct device_ops *dev; diff --git a/src/core/event-handler.c b/src/core/event-handler.c index 2fe8785..6608710 100644 --- a/src/core/event-handler.c +++ b/src/core/event-handler.c @@ -29,8 +29,8 @@ static device_notifier_state_e state = DEVICE_NOTIFIER_STATE_STOP; GVariant *dbus_start_event_handler(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { if (state != DEVICE_NOTIFIER_STATE_START) { _D("START event-handler"); @@ -41,8 +41,8 @@ GVariant *dbus_start_event_handler(GDBusConnection *conn, } GVariant *dbus_stop_event_handler(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { if (state != DEVICE_NOTIFIER_STATE_STOP) { _D("STOP event-handler"); @@ -53,8 +53,8 @@ GVariant *dbus_stop_event_handler(GDBusConnection *conn, } GVariant *dbus_udev_event_handler(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { char *argv; int argc; diff --git a/src/cpu/pmqos.c b/src/cpu/pmqos.c index de281b6..187c552 100644 --- a/src/cpu/pmqos.c +++ b/src/cpu/pmqos.c @@ -258,8 +258,8 @@ static int pmqos_poweroff(void *data) } static GVariant * dbus_pmqos_handler(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int val, ret; @@ -279,8 +279,8 @@ error: return g_variant_new("(i)", ret); } static GVariant * dbus_wifi_pmqos_handler(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { char names[NAME_MAX]; int bps, val, ret; @@ -305,8 +305,8 @@ error: } static GVariant * dbus_getdefaultlocktime(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; diff --git a/src/devicectl/devicectl.c b/src/devicectl/devicectl.c index 5c288a2..b6560b7 100644 --- a/src/devicectl/devicectl.c +++ b/src/devicectl/devicectl.c @@ -71,8 +71,10 @@ static int start_device(char **args) printf("start %s device!\n", args[1]); msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, - devices[arg_id].path, devices[arg_id].iface, - "start", NULL, NULL); + devices[arg_id].path, + devices[arg_id].iface, + "start", + NULL, NULL); if (!msg) return -EBADMSG; @@ -91,8 +93,10 @@ static int stop_device(char **args) printf("stop %s device!\n", args[1]); msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, - devices[arg_id].path, devices[arg_id].iface, - "stop", NULL, NULL); + devices[arg_id].path, + devices[arg_id].iface, + "stop", + NULL, NULL); if (!msg) return -EBADMSG; @@ -111,8 +115,10 @@ static int dump_mode(char **args) printf("%s (%s %s)!\n", args[1], args[2], args[3]); ret = dbus_method_async_var(DEVICED_BUS_NAME, - devices[arg_id].path, devices[arg_id].iface, - "Dumpmode", g_variant_new("(s)", args[3])); + devices[arg_id].path, + devices[arg_id].iface, + "Dumpmode", + g_variant_new("(s)", args[3])); if (ret < 0) printf("failed to set dump mode (%d)", ret); @@ -129,8 +135,10 @@ static int save_log(char **args) printf("save log %s device!\n", args[1]); ret = dbus_method_async(DEVICED_BUS_NAME, - devices[arg_id].path, devices[arg_id].iface, - "SaveLog", NULL, NULL); + devices[arg_id].path, + devices[arg_id].iface, + "SaveLog", + NULL, NULL); if (ret < 0) printf("failed to save log (%d)", ret); @@ -172,8 +180,10 @@ static int save_dbus_name(char **args) printf("save dbus name!\n"); msg = dbus_method_sync_with_reply(DBUS_BUS_NAME, - DBUS_OBJECT_PATH, DBUS_INTERFACE_NAME, - "ListNames", NULL, NULL); + DBUS_OBJECT_PATH, + DBUS_INTERFACE_NAME, + "ListNames", + NULL, NULL); if (!msg) { printf("failed to get list names"); return -EBADMSG; @@ -209,8 +219,10 @@ static int device_list(char **args) printf("print %s to dlog!\n", args[1]); msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, - devices[arg_id].path, devices[arg_id].iface, - "DeviceList", NULL, NULL); + devices[arg_id].path, + devices[arg_id].iface, + "DeviceList", + NULL, NULL); if (!msg) return -EBADMSG; @@ -239,8 +251,10 @@ static int enable_device(char **args) printf("enable %s device!\n", args[3]); msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - devices[arg_id].path, devices[arg_id].iface, - "enable", g_variant_new("(s)", args[3])); + devices[arg_id].path, + devices[arg_id].iface, + "enable", + g_variant_new("(s)", args[3])); if (!msg) return -EBADMSG; @@ -259,8 +273,10 @@ static int disable_device(char **args) printf("disable %s device!\n", args[3]); msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - devices[arg_id].path, devices[arg_id].iface, - "disable", g_variant_new("(s)", args[3])); + devices[arg_id].path, + devices[arg_id].iface, + "disable", + g_variant_new("(s)", args[3])); if (!msg) return -EBADMSG; @@ -279,8 +295,10 @@ static int power_operation(char **args, char *type) printf("Power %s device!\n", args[2]); msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - devices[arg_id].path, devices[arg_id].iface, - "reboot", g_variant_new("(si)", type, 0)); + devices[arg_id].path, + devices[arg_id].iface, + "reboot", + g_variant_new("(si)", type, 0)); if (!msg) return -EBADMSG; diff --git a/src/display/ambient-mode.c b/src/display/ambient-mode.c index 8190d4f..776130d 100644 --- a/src/display/ambient-mode.c +++ b/src/display/ambient-mode.c @@ -43,8 +43,10 @@ static unsigned int update_count; void broadcast_ambient_state(int state) { - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, - SIGNAL_AMBIENT_MODE, g_variant_new("(i)", (state == 0 ? 0 : 1))); + dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + SIGNAL_AMBIENT_MODE, + g_variant_new("(i)", (state == 0 ? 0 : 1))); } int ambient_get_condition(void) diff --git a/src/display/core.c b/src/display/core.c index 399ade5..6f930c8 100644 --- a/src/display/core.c +++ b/src/display/core.c @@ -227,7 +227,9 @@ static void set_process_active(bool flag, pid_t pid) /* Send dbug to resourced */ ret = dbus_handle_broadcast_dbus_signal_var(RESOURCED_PATH_PROCESS, - RESOURCED_INTERFACE_PROCESS, RESOURCED_METHOD_ACTIVE, g_variant_new("(si)", (flag ? ACTIVE_ACT : INACTIVE_ACT), pid)); + RESOURCED_INTERFACE_PROCESS, + RESOURCED_METHOD_ACTIVE, + g_variant_new("(si)", (flag ? ACTIVE_ACT : INACTIVE_ACT), pid)); if (ret < 0) _E("Fail to send dbus signal to resourced!!"); } @@ -304,8 +306,10 @@ static void broadcast_lcd_on(enum signal_type type, enum device_flags flags) signal = lcdon_sig_lookup[type]; _I("lcdstep : broadcast %s %s", signal, str); - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, - signal, g_variant_new("(s)", str)); + dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + signal, + g_variant_new("(s)", str)); } static void broadcast_lcd_off(enum signal_type type, enum device_flags flags) @@ -330,8 +334,10 @@ static void broadcast_lcd_off(enum signal_type type, enum device_flags flags) str = UNKNOWN_STR; _I("lcdstep : broadcast %s", signal); - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, - signal, g_variant_new("(s)", str)); + dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + signal, + g_variant_new("(s)", str)); } void broadcast_lcd_off_late(enum device_flags flags) diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c index bb2eee2..4dc38ab 100644 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -61,8 +61,8 @@ } while (0) GVariant *dbus_start(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { static const struct device_ops *display_device_ops = NULL; @@ -80,8 +80,8 @@ out: } GVariant *dbus_stop(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { static const struct device_ops *display_device_ops = NULL; @@ -99,8 +99,8 @@ out: } GVariant *dbus_lockstate(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { char *state_str; char *option1_str; @@ -188,8 +188,8 @@ out: } GVariant *dbus_unlockstate(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { char *state_str; char *option_str; @@ -249,8 +249,8 @@ out: } GVariant *dbus_changestate(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { char *state_str; pid_t pid; @@ -322,8 +322,8 @@ out: } GVariant *dbus_getdisplaycount(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; @@ -335,8 +335,8 @@ GVariant *dbus_getdisplaycount(GDBusConnection *conn, } GVariant *dbus_getmaxbrightness(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; @@ -348,8 +348,8 @@ GVariant *dbus_getmaxbrightness(GDBusConnection *conn, } GVariant *dbus_setmaxbrightness(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; @@ -361,8 +361,8 @@ GVariant *dbus_setmaxbrightness(GDBusConnection *conn, } GVariant *dbus_getbrightness(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int brt, ret; @@ -378,8 +378,8 @@ GVariant *dbus_getbrightness(GDBusConnection *conn, } GVariant *dbus_setbrightness(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int brt, autobrt, ret, caps; @@ -425,8 +425,8 @@ error: } GVariant *dbus_holdbrightness(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int brt, autobrt, ret, caps; @@ -471,8 +471,8 @@ error: } GVariant *dbus_releasebrightness(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int bat, charger, changed, setting, brt, autobrt, ret = 0; @@ -536,8 +536,8 @@ error: } GVariant *dbus_setrefreshrate(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int app, val, ret, control; @@ -574,8 +574,8 @@ error: } GVariant *dbus_setautobrightnessmin(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int val, ret; pid_t pid; @@ -608,8 +608,8 @@ error: } GVariant *dbus_setlcdtimeout(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int on, dim, holdkey_block, ret; pid_t pid; @@ -637,8 +637,8 @@ GVariant *dbus_setlcdtimeout(GDBusConnection *conn, } GVariant *dbus_lockscreenbgon(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret = 0; char *on = NULL; @@ -659,8 +659,8 @@ GVariant *dbus_lockscreenbgon(GDBusConnection *conn, } GVariant *dbus_dumpmode(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret = 0; char *on; @@ -683,8 +683,8 @@ GVariant *dbus_dumpmode(GDBusConnection *conn, } GVariant *dbus_savelog(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { if (!device_poweroff(NULL)) save_display_log(); @@ -692,8 +692,8 @@ GVariant *dbus_savelog(GDBusConnection *conn, } GVariant *dbus_powerkeyignore(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret = 0; int on; @@ -709,8 +709,8 @@ GVariant *dbus_powerkeyignore(GDBusConnection *conn, } GVariant *dbus_powerkeylcdoff(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; @@ -725,8 +725,8 @@ GVariant *dbus_powerkeylcdoff(GDBusConnection *conn, } GVariant *dbus_customlcdon(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret = 0; int timeout; @@ -741,8 +741,8 @@ GVariant *dbus_customlcdon(GDBusConnection *conn, } GVariant *dbus_staytouchscreenoff(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret = 0; int val; @@ -757,8 +757,8 @@ GVariant *dbus_staytouchscreenoff(GDBusConnection *conn, } GVariant *dbus_lcdpaneloffmode(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret = 0; int val; @@ -773,8 +773,8 @@ GVariant *dbus_lcdpaneloffmode(GDBusConnection *conn, } GVariant *dbus_actorcontrol(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret = 0, val, actor; char *op; @@ -795,8 +795,8 @@ GVariant *dbus_actorcontrol(GDBusConnection *conn, } GVariant *dbus_getcustombrightness(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int status = 0; @@ -852,8 +852,8 @@ static int get_command(pid_t pid, char *comm, size_t len) } GVariant *dbus_locktimeout_expired(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; char *req_id; @@ -976,8 +976,8 @@ out: } GVariant *dbus_locktimeout_input(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; char *req_id; @@ -1057,7 +1057,7 @@ static void homescreen_signal_handler(GDBusConnection *conn, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, + GVariant *param, gpointer data) { char *screen; @@ -1100,7 +1100,12 @@ int init_pm_dbus(void) if (ret < 0) _E("fail to init dbus method(%d)", ret); - ret = subscribe_dbus_signal(NULL, DEVICED_OBJECT_PATH, DEVICED_INTERFACE_NAME, SIGNAL_HOMESCREEN, homescreen_signal_handler, NULL, NULL); + ret = subscribe_dbus_signal(NULL, + DEVICED_OBJECT_PATH, + DEVICED_INTERFACE_NAME, + SIGNAL_HOMESCREEN, + homescreen_signal_handler, + NULL, NULL); if (ret <= 0) { _E("Failed to register signal handler! %d", ret); return ret; diff --git a/src/display/dpms-wayland-none.c b/src/display/dpms-wayland-none.c index e4f61ef..89f7530 100644 --- a/src/display/dpms-wayland-none.c +++ b/src/display/dpms-wayland-none.c @@ -68,7 +68,11 @@ int dpms_set_power(enum dpms_state state) ret = dbus_method_async_with_reply_var(ENLIGHTENMENT_BUS_NAME, ENLIGHTENMENT_OBJECT_PATH, ENLIGHTENMENT_INTERFACE_NAME, - "set", g_variant_new("(u)", state), dpms_set_cb, -1, NULL); + "set", + g_variant_new("(u)", state), + dpms_set_cb, + -1, + NULL); if (ret < 0) return ret; @@ -86,7 +90,8 @@ int dpms_get_power(enum dpms_state *state) ret = dbus_method_sync(ENLIGHTENMENT_BUS_NAME, ENLIGHTENMENT_OBJECT_PATH, ENLIGHTENMENT_INTERFACE_NAME, - "get", NULL, NULL); + "get", + NULL, NULL); if (ret < 0) return ret; diff --git a/src/display/key-filter.c b/src/display/key-filter.c index 5ff6a82..4128a3f 100644 --- a/src/display/key-filter.c +++ b/src/display/key-filter.c @@ -183,14 +183,18 @@ static inline void check_key_pair(int code, int new, int *old) static inline void broadcast_lcdon_by_powerkey(void) { - dbus_handle_broadcast_dbus_signal(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, - SIGNAL_LCDON_BY_POWERKEY, NULL, NULL); + dbus_handle_broadcast_dbus_signal(DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + SIGNAL_LCDON_BY_POWERKEY, + NULL, NULL); } static inline void broadcast_lcdoff_by_powerkey(void) { - dbus_handle_broadcast_dbus_signal(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, - SIGNAL_LCDOFF_BY_POWERKEY, NULL, NULL); + dbus_handle_broadcast_dbus_signal(DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + SIGNAL_LCDOFF_BY_POWERKEY, + NULL, NULL); } static inline bool switch_on_lcd(void) @@ -471,8 +475,10 @@ static void sound_vibrate_hardkey(void) /* device notify(vibrator) */ /* sound(dbus) */ /* Need to notify to deviced-vibrator. deviced-vibrator receives ChangedHardKey signal */ - dbus_handle_broadcast_dbus_signal(DEVICED_PATH_KEY, DEVICED_INTERFACE_KEY, - SIGNAL_CHANGE_HARDKEY, NULL, NULL); + dbus_handle_broadcast_dbus_signal(DEVICED_PATH_KEY, + DEVICED_INTERFACE_KEY, + SIGNAL_CHANGE_HARDKEY, + NULL, NULL); } static void process_hardkey_backlight(struct input_event *pinput) diff --git a/src/display/state-tv.c b/src/display/state-tv.c index 418ae81..cdcff8a 100644 --- a/src/display/state-tv.c +++ b/src/display/state-tv.c @@ -127,8 +127,10 @@ static int lcdon_pre(void *data) if (pm_cur_state == S_STANDBY) { _I("send pre state change NORMAL"); - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, - SIGNAL_PRE_CHANGE_STATE, g_variant_new("(s)", states[S_LCDON].name)); + dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + SIGNAL_PRE_CHANGE_STATE, + g_variant_new("(s)", states[S_LCDON].name)); /*Give time to process callback */ usleep(PRE_STATE_CHANGE_TIMEOUT); } @@ -138,8 +140,10 @@ static int lcdon_pre(void *data) static int lcdon_post(void *data) { - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, - SIGNAL_CHANGE_STATE, g_variant_new("(s)", states[S_LCDON].name)); + dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + SIGNAL_CHANGE_STATE, + g_variant_new("(s)", states[S_LCDON].name)); /* TODO: set_power */ @@ -205,8 +209,10 @@ static int lcdoff_pre(void *data) static int lcdoff_post(void *data) { /* broadcast to other application */ - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, - SIGNAL_CHANGE_STATE, g_variant_new("(s)", states[S_LCDOFF].name)); + dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + SIGNAL_CHANGE_STATE, + g_variant_new("(s)", states[S_LCDOFF].name)); return 0; } @@ -278,8 +284,10 @@ static int standby_pre(void *data) static int standby_post(void *data) { /* broadcast to other application */ - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, - SIGNAL_CHANGE_STATE, g_variant_new("(s)", states[S_STANDBY].name)); + dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + SIGNAL_CHANGE_STATE, + g_variant_new("(s)", states[S_STANDBY].name)); backlight_ops.off(0); @@ -374,8 +382,10 @@ static int suspend_post(void *data) _E("Fail to change state to next_state(%s)", states[cond].name); /* Broadcast pre-wakeup signal */ - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER, - SIGNAL_PRE_WAKEUP, g_variant_new("(i)", 0)); + dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_POWER, + DEVICED_INTERFACE_POWER, + SIGNAL_PRE_WAKEUP, + g_variant_new("(i)", 0)); /* Notify resume state */ device_notify(DEVICE_NOTIFIER_POWER_RESUME, NULL); diff --git a/src/extcon/cradle.c b/src/extcon/cradle.c index 6bef48b..e1007ae 100644 --- a/src/extcon/cradle.c +++ b/src/extcon/cradle.c @@ -42,8 +42,10 @@ static void cradle_send_broadcast(int status) _I("broadcast cradle status %d", status); old = status; - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI, - SIGNAL_CRADLE_STATE, g_variant_new("(i)", status)); + dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_SYSNOTI, + DEVICED_INTERFACE_SYSNOTI, + SIGNAL_CRADLE_STATE, + g_variant_new("(i)", status)); } static int cradle_update(int status) @@ -86,8 +88,8 @@ static int display_changed(void *data) } GVariant *dbus_cradle_handler(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { return g_variant_new("(i)", cradle_extcon_ops.status); } diff --git a/src/extcon/earjack.c b/src/extcon/earjack.c index 64614ea..3ab2ede 100644 --- a/src/extcon/earjack.c +++ b/src/extcon/earjack.c @@ -40,8 +40,10 @@ static void earjack_send_broadcast(int status) _I("broadcast earjack status %d", status); old = status; - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI, - SIGNAL_EARJACK_STATE, g_variant_new("(i)", status)); + dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_SYSNOTI, + DEVICED_INTERFACE_SYSNOTI, + SIGNAL_EARJACK_STATE, + g_variant_new("(i)", status)); } static void earjack_send_system_event(int status) diff --git a/src/extcon/extcon.c b/src/extcon/extcon.c index 10c2fa0..f004c4d 100644 --- a/src/extcon/extcon.c +++ b/src/extcon/extcon.c @@ -111,8 +111,11 @@ static int extcon_update(const char *name, const char *value) if (dev->enabled == false && strncmp(name, "USB", strlen("USB")) == 0) { if (status > 0) { snprintf(buf, BUF_MAX, "usb-client"); - ret = dbus_method_sync_var(DEVICEMANAGER_BUS_NAME, DEVICEMANAGER_PATH_POPUP, - DEVICEMANAGER_INTERFACE_POPUP, METHOD_SYSPOPUP_SHOW, g_variant_new("(s)", buf)); + ret = dbus_method_sync_var(DEVICEMANAGER_BUS_NAME, + DEVICEMANAGER_PATH_POPUP, + DEVICEMANAGER_INTERFACE_POPUP, + METHOD_SYSPOPUP_SHOW, + g_variant_new("(s)", buf)); if (ret < 0) _E("Failed to launch USB restricted popup(%d)", ret); return ret; @@ -168,8 +171,11 @@ int extcon_disable_device(const char *name) return -ENODEV; snprintf(buf, BUF_MAX, "usb-client"); - ret = dbus_method_sync_var(DEVICEMANAGER_BUS_NAME, DEVICEMANAGER_PATH_POPUP, - DEVICEMANAGER_INTERFACE_POPUP, METHOD_SYSPOPUP_SHOW, g_variant_new("(s)", buf)); + ret = dbus_method_sync_var(DEVICEMANAGER_BUS_NAME, + DEVICEMANAGER_PATH_POPUP, + DEVICEMANAGER_INTERFACE_POPUP, + METHOD_SYSPOPUP_SHOW, + g_variant_new("(s)", buf)); if (ret < 0) _E("Failed to launch USB restricted popup(%d)", ret); @@ -275,8 +281,8 @@ static int get_extcon_init_state(void) } static GVariant * dbus_get_extcon_status(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { struct extcon_ops *dev; char *str; @@ -300,8 +306,8 @@ error: } static GVariant *dbus_enable_device(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { char *device; int ret; @@ -315,8 +321,8 @@ static GVariant *dbus_enable_device(GDBusConnection *conn, } static GVariant *dbus_disable_device(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { char *device; int ret; diff --git a/src/extcon/hdmi.c b/src/extcon/hdmi.c index df2d8f9..9b42fa2 100644 --- a/src/extcon/hdmi.c +++ b/src/extcon/hdmi.c @@ -39,8 +39,10 @@ static void hdmi_send_broadcast(int status) _I("broadcast hdmi status %d", status); old = status; - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI, - SIGNAL_HDMI_STATE, g_variant_new("(i)", status)); + dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_SYSNOTI, + DEVICED_INTERFACE_SYSNOTI, + SIGNAL_HDMI_STATE, + g_variant_new("(i)", status)); } static int hdmi_update(int status) @@ -79,8 +81,8 @@ static int display_changed(void *data) } GVariant *dbus_hdmi_handler(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { return g_variant_new("(i)", hdmi_extcon_ops.status); } diff --git a/src/ir/ir.c b/src/ir/ir.c index 979c6d3..3b43fd3 100644 --- a/src/ir/ir.c +++ b/src/ir/ir.c @@ -27,8 +27,8 @@ static struct ir_device *ir_dev; static GVariant *dbus_ir_is_available(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret = 0; bool val; @@ -52,8 +52,8 @@ exit: } static GVariant *dbus_ir_transmit(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret = 0; int size; @@ -91,8 +91,8 @@ exit: } static GVariant *dbus_set_ir_command(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret = -ENOTSUP; diff --git a/src/led/torch.c b/src/led/torch.c index 5e9470e..1982cdc 100644 --- a/src/led/torch.c +++ b/src/led/torch.c @@ -44,13 +44,15 @@ static struct led_state led_state = { static void flash_state_broadcast(int val) { - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_LED, DEVICED_INTERFACE_LED, - SIGNAL_FLASH_STATE, g_variant_new("(i)", val)); + dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_LED, + DEVICED_INTERFACE_LED, + SIGNAL_FLASH_STATE, + g_variant_new("(i)", val)); } static GVariant *dbus_get_brightness(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret, alpha; @@ -71,8 +73,8 @@ error: } static GVariant *dbus_get_max_brightness(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; @@ -82,8 +84,8 @@ static GVariant *dbus_get_max_brightness(GDBusConnection *conn, } static GVariant *dbus_set_brightness(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int val, enable, ret; struct led_state tmp = {0,}; diff --git a/src/libdeviced/dbus.c b/src/libdeviced/dbus.c index af1aa54..c760d70 100644 --- a/src/libdeviced/dbus.c +++ b/src/libdeviced/dbus.c @@ -35,19 +35,20 @@ typedef struct { GDBusConnection *conn; GBusType bus_type; gboolean priv; - GList *list_names; // dbus_name - GList *list_object; /* dbus_object_handle_s */ - pthread_mutex_t mutex;// = PTHREAD_MUTEX_INITIALIZER; + GList *list_names; /* dbus_name */ + GList *list_object; /* dbus_object_handle_s */ + pthread_mutex_t mutex; } dbus_handle_s; /* path + interfaces */ typedef struct { - dbus_handle_s *dh; /* dbus handle */ - const char *path; - GList *list_ifaces; /* dbus_interface_s */ + dbus_handle_s *dh; /* dbus handle */ + const char *path; /* object path */ + GList *list_ifaces; /* dbus_interface_s */ } dbus_object_handle_s; #define get_dh_from_oh(oh) ((dbus_object_handle_s*)oh)->dh +/* global shared bus : system, session */ static dbus_handle_s g_dh[2]; static dbus_handle_s *_dbus_handle_get_connection(GBusType bus_type); @@ -127,11 +128,11 @@ static GDBusConnection * _get_bus_private(GBusType bus_type) } conn = g_dbus_connection_new_for_address_sync(address, - (GDBusConnectionFlags) (G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | - G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION), - NULL, /* GDBusAuthObserver */ - NULL, - &err); + (GDBusConnectionFlags) (G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | + G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION), + NULL, /* GDBusAuthObserver */ + NULL, + &err); if (!conn || err) { _E("failed to get private bus\n"); g_error_free(err); @@ -211,9 +212,9 @@ static void _free_func_signal(gpointer data) } guint subscribe_dbus_signal(dbus_handle_h handle, const char *path, - const char *iface, const char *name, - GDBusSignalCallback cb, void *data, - destroy_notified free_func) + const char *iface, const char *name, + GDBusSignalCallback cb, void *data, + destroy_notified free_func) { dcl_dbus_handle(); @@ -290,7 +291,6 @@ GVariant *dbus_handle_make_simple_array(const char *sig, int *param) snprintf(format, sizeof(format) - 1, "(%s)", sig); var = g_variant_new(format, builder); g_variant_builder_unref(builder); - return var; } @@ -373,8 +373,8 @@ static GVariant* _append_variant(const char *signature, const char *param[]) } GVariant *dbus_method_sync_with_reply(const char *dest, const char *path, - const char *iface, const char *method, - const char *signature, const char *param[]) + const char *iface, const char *method, + const char *signature, const char *param[]) { GError *err = NULL; GVariant * var = NULL; @@ -396,8 +396,8 @@ GVariant *dbus_method_sync_with_reply(const char *dest, const char *path, var = _append_variant(signature, param); ret = g_dbus_connection_call_sync(dh->conn, - dest, path, iface, method, - var, NULL, G_DBUS_CALL_FLAGS_NONE, DBUS_REPLY_TIMEOUT, NULL, &err); + dest, path, iface, method, + var, NULL, G_DBUS_CALL_FLAGS_NONE, DBUS_REPLY_TIMEOUT, NULL, &err); if (!ret || err) { if (err) { _E("failed to g_dbus_connection_call_sync:%s", err->message); @@ -412,8 +412,11 @@ GVariant *dbus_method_sync_with_reply(const char *dest, const char *path, return ret; } -GVariant *dbus_method_sync_with_reply_var(const char *dest, const char *path, - const char *iface, const char *method, GVariant *var) +GVariant *dbus_method_sync_with_reply_var(const char *dest, + const char *path, + const char *iface, + const char *method, + GVariant *var) { GError *err = NULL; GVariant * ret = NULL; @@ -435,8 +438,8 @@ GVariant *dbus_method_sync_with_reply_var(const char *dest, const char *path, } ret = g_dbus_connection_call_sync(dh->conn, - dest, path, iface, method, - var, NULL, G_DBUS_CALL_FLAGS_NONE, DBUS_REPLY_TIMEOUT, NULL, &err); + dest, path, iface, method, + var, NULL, G_DBUS_CALL_FLAGS_NONE, DBUS_REPLY_TIMEOUT, NULL, &err); if (!ret || err) { if (err) { _E("failed to g_dbus_connection_call_sync:%s", err->message); @@ -450,11 +453,16 @@ GVariant *dbus_method_sync_with_reply_var(const char *dest, const char *path, return ret; } -GVariant *dbus_method_with_unix_fd_list_sync_with_reply(const char *dest, const char *path, - const char *iface, const char *method, - const char *signature, const char *param[], - int *in_fdlist, int in_size, - int **out_fdlist, int *out_size) +GVariant *dbus_method_with_unix_fd_list_sync_with_reply(const char *dest, + const char *path, + const char *iface, + const char *method, + const char *signature, + const char *param[], + int *in_fdlist, + int in_size, + int **out_fdlist, + int *out_size) { GError *err = NULL; GVariant * var = NULL; @@ -539,11 +547,15 @@ out: return ret; } -GVariant *dbus_method_with_unix_fd_list_sync_with_reply_var(const char *dest, const char *path, - const char *iface, const char *method, - GVariant *param, - int *in_fdlist, int in_size, - int **out_fdlist, int *out_size) +GVariant *dbus_method_with_unix_fd_list_sync_with_reply_var(const char *dest, + const char *path, + const char *iface, + const char *method, + GVariant *param, + int *in_fdlist, + int in_size, + int **out_fdlist, + int *out_size) { GError *err = NULL; GVariant * ret = NULL; @@ -623,9 +635,12 @@ out: return ret; } -int dbus_method_sync(const char *dest, const char *path, - const char *iface, const char *method, - const char *signature, const char *param[]) +int dbus_method_sync(const char *dest, + const char *path, + const char *iface, + const char *method, + const char *signature, + const char *param[]) { int result; gboolean result_bool; @@ -654,8 +669,11 @@ int dbus_method_sync(const char *dest, const char *path, return result; } -int dbus_method_sync_var(const char *dest, const char *path, - const char *iface, const char *method, GVariant *param) +int dbus_method_sync_var(const char *dest, + const char *path, + const char *iface, + const char *method, + GVariant *param) { int result; gboolean result_bool; @@ -684,9 +702,13 @@ int dbus_method_sync_var(const char *dest, const char *path, return result; } -int dbus_method_sync_timeout(const char *dest, const char *path, - const char *iface, const char *method, - const char *signature, const char *param[], int timeout) +int dbus_method_sync_timeout(const char *dest, + const char *path, + const char *iface, + const char *method, + const char *signature, + const char *param[], + int timeout) { dbus_handle_s *dh = NULL; GError *err = NULL; @@ -709,8 +731,8 @@ int dbus_method_sync_timeout(const char *dest, const char *path, var = _append_variant(signature, param); reply = g_dbus_connection_call_sync(dh->conn, - dest, path, iface, method, - var, NULL, G_DBUS_CALL_FLAGS_NONE, timeout, NULL, &err); + dest, path, iface, method, + var, NULL, G_DBUS_CALL_FLAGS_NONE, timeout, NULL, &err); if (!reply || err) { _E("failed to g_dbus_connection_call_sync:%s", err->message); g_error_free(err); @@ -727,9 +749,12 @@ int dbus_method_sync_timeout(const char *dest, const char *path, return result; } -int dbus_method_sync_pairs(const char *dest, const char *path, - const char *iface, const char *method, - int num, va_list args) +int dbus_method_sync_pairs(const char *dest, + const char *path, + const char *iface, + const char *method, + int num, + va_list args) { GError *err = NULL; GVariant * reply = NULL; @@ -780,9 +805,12 @@ int dbus_method_sync_pairs(const char *dest, const char *path, return ret; } -int dbus_method_async_pairs(const char *dest, const char *path, - const char *iface, const char *method, - int num, va_list args) +int dbus_method_async_pairs(const char *dest, + const char *path, + const char *iface, + const char *method, + int num, + va_list args) { char *key, *value; GVariant *var; @@ -814,16 +842,19 @@ int dbus_method_async_pairs(const char *dest, const char *path, g_variant_builder_unref(builder); g_dbus_connection_call(dh->conn, dest, path, iface, method, - var, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, - NULL, - NULL); + var, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, + NULL, + NULL); return 0; } -int dbus_method_async(const char *dest, const char *path, - const char *iface, const char *method, - const char *signature, const char *param[]) +int dbus_method_async(const char *dest, + const char *path, + const char *iface, + const char *method, + const char *signature, + const char *param[]) { GVariant * var = NULL; dbus_handle_s *dh = NULL; @@ -843,15 +874,18 @@ int dbus_method_async(const char *dest, const char *path, var = _append_variant(signature, param); g_dbus_connection_call(dh->conn, dest, path, iface, method, - var, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, - NULL, - NULL); + var, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, + NULL, + NULL); return 0; } -int dbus_method_async_var(const char *dest, const char *path, - const char *iface, const char *method, GVariant *param) +int dbus_method_async_var(const char *dest, + const char *path, + const char *iface, + const char *method, + GVariant *param) { dbus_handle_s *dh = NULL; @@ -867,17 +901,17 @@ int dbus_method_async_var(const char *dest, const char *path, } g_dbus_connection_call(dh->conn, dest, path, iface, method, - param, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, - NULL, - NULL); + param, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, + NULL, + NULL); return 0; } /* callback should free gvariant */ static void _cb_pending(GDBusConnection *conn, - GAsyncResult *res, - gpointer user_data) + GAsyncResult *res, + gpointer user_data) { GVariant *reply = NULL; GError *err = NULL; @@ -904,9 +938,15 @@ out: free(data); } -int dbus_method_async_with_reply(const char *dest, const char *path, - const char *iface, const char *method, - const char *signature, const char *param[], dbus_pending_cb cb, int timeout_msec, void *data) +int dbus_method_async_with_reply(const char *dest, + const char *path, + const char *iface, + const char *method, + const char *signature, + const char *param[], + dbus_pending_cb cb, + int timeout_msec, + void *data) { dbus_handle_s *dh = NULL; pending_call_data *pdata = NULL; @@ -943,9 +983,9 @@ int dbus_method_async_with_reply(const char *dest, const char *path, pdata->data = data; } g_dbus_connection_call(dh->conn, dest, path, iface, method, - var, NULL, G_DBUS_CALL_FLAGS_NONE, timeout_msec, NULL, - (GAsyncReadyCallback)_cb_pending, - pdata); + var, NULL, G_DBUS_CALL_FLAGS_NONE, timeout_msec, NULL, + (GAsyncReadyCallback)_cb_pending, + pdata); return ret; err: @@ -955,13 +995,13 @@ err: } int dbus_method_async_with_reply_var(const char *dest, - const char *path, - const char *iface, - const char *method, - GVariant *param, - dbus_pending_cb cb, - int timeout_msec, - void *data) + const char *path, + const char *iface, + const char *method, + GVariant *param, + dbus_pending_cb cb, + int timeout_msec, + void *data) { dbus_handle_s *dh = NULL; pending_call_data *pdata = NULL; @@ -994,9 +1034,9 @@ int dbus_method_async_with_reply_var(const char *dest, pdata->data = data; } g_dbus_connection_call(dh->conn, dest, path, iface, method, - param, NULL, G_DBUS_CALL_FLAGS_NONE, timeout_msec, NULL, - (GAsyncReadyCallback)_cb_pending, - pdata); + param, NULL, G_DBUS_CALL_FLAGS_NONE, timeout_msec, NULL, + (GAsyncReadyCallback)_cb_pending, + pdata); return ret; err: diff --git a/src/libdeviced/deviced-conf.c b/src/libdeviced/deviced-conf.c index 62ba5a6..face25f 100644 --- a/src/libdeviced/deviced-conf.c +++ b/src/libdeviced/deviced-conf.c @@ -57,8 +57,10 @@ int util_oomadj_set(int pid, int oomadj_val) snprintf(buf2, sizeof(buf2), "%d", oomadj_val); msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_PROCESS, DEVICED_INTERFACE_PROCESS, - OOMADJ_SET, g_variant_new("(siss)", OOMADJ_SET, 2, buf1, buf2)); + DEVICED_PATH_PROCESS, + DEVICED_INTERFACE_PROCESS, + OOMADJ_SET, + g_variant_new("(siss)", OOMADJ_SET, 2, buf1, buf2)); if (!msg) return -EBADMSG; @@ -91,8 +93,10 @@ static int util_process_group_set(char* name, int pid) _D("pid(%d) is inserted at vip", pid); msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_PROCESS, DEVICED_INTERFACE_PROCESS, - PROCESS_GROUP_SET, g_variant_new("(siss)", PROCESS_GROUP_SET, 2, buf, name)); + DEVICED_PATH_PROCESS, + DEVICED_INTERFACE_PROCESS, + PROCESS_GROUP_SET, + g_variant_new("(siss)", PROCESS_GROUP_SET, 2, buf, name)); if (!msg) return -EBADMSG; diff --git a/src/libdeviced/deviced-noti.c b/src/libdeviced/deviced-noti.c index bfddcf9..a92bf4a 100644 --- a/src/libdeviced/deviced-noti.c +++ b/src/libdeviced/deviced-noti.c @@ -190,8 +190,10 @@ static int dbus_proc_handler(char* type, char *buf) int val; msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_PROCESS, DEVICED_INTERFACE_PROCESS, - type, g_variant_new("(sis)", type, 1, buf)); + DEVICED_PATH_PROCESS, + DEVICED_INTERFACE_PROCESS, + type, + g_variant_new("(sis)", type, 1, buf)); if (!msg) return -EBADMSG; @@ -242,8 +244,10 @@ static int dbus_power_handler(char* type) int val; msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_REBOOT, DEVICED_INTERFACE_REBOOT, - type, g_variant_new("(si)", type, 0)); + DEVICED_PATH_REBOOT, + DEVICED_INTERFACE_REBOOT, + type, + g_variant_new("(si)", type, 0)); if (!msg) return -EBADMSG; @@ -284,8 +288,10 @@ static int dbus_time_handler(char* type, char* buf) snprintf(name, sizeof(name), "%d", pid); msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI, - type, g_variant_new("(sis)", type, 1, buf)); + DEVICED_PATH_SYSNOTI, + DEVICED_INTERFACE_SYSNOTI, + type, + g_variant_new("(sis)", type, 1, buf)); if (!msg) return -EBADMSG; @@ -315,7 +321,11 @@ static int alarm_set_time(time_t timet) snprintf(name, sizeof(name), "%d", pid); _SI("[%s]start %s %ld", name, ALARM_INTERFACE_NAME, timet); - msg = dbus_method_sync_with_reply_var(ALARM_BUS_NAME, ALARM_PATH_NAME, ALARM_INTERFACE_NAME, ALARM_SET_TIME_METHOD, g_variant_new("(i)", timet)); + msg = dbus_method_sync_with_reply_var(ALARM_BUS_NAME, + ALARM_PATH_NAME, + ALARM_INTERFACE_NAME, + ALARM_SET_TIME_METHOD, + g_variant_new("(i)", timet)); if (!msg) { _E("dbus_message_new_method_call(%s:%s-%s)", ALARM_PATH_NAME, ALARM_INTERFACE_NAME, ALARM_SET_TIME_METHOD); @@ -356,8 +366,10 @@ static int dbus_cpu_handler(char* type, char* buf_pid, char* buf_freq) int val; msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI, - type, g_variant_new("(siss)", type, 2, buf_pid, buf_freq)); + DEVICED_PATH_SYSNOTI, + DEVICED_INTERFACE_SYSNOTI, + type, + g_variant_new("(siss)", type, 2, buf_pid, buf_freq)); if (!msg) return -EBADMSG; diff --git a/src/libdeviced/display.c b/src/libdeviced/display.c index 7744e09..e4b0fe3 100644 --- a/src/libdeviced/display.c +++ b/src/libdeviced/display.c @@ -64,8 +64,10 @@ API int display_get_max_brightness(void) int ret; ret = dbus_method_sync(DEVICED_BUS_NAME, - DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, - METHOD_GET_MAX_BRIGHTNESS, NULL, NULL); + DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + METHOD_GET_MAX_BRIGHTNESS, + NULL, NULL); if (ret < 0) return DISPLAY_MAX_BRIGHTNESS; @@ -81,8 +83,10 @@ API int display_set_brightness_with_setting(int val) return -EINVAL; ret = dbus_method_async_var(DEVICED_BUS_NAME, - DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, - METHOD_SET_BRIGHTNESS, g_variant_new("(i)", val)); + DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + METHOD_SET_BRIGHTNESS, + g_variant_new("(i)", val)); if (ret < 0) _E("no message : failed to setting"); @@ -133,8 +137,13 @@ API int display_change_state(unsigned int s_bits) return -EINVAL; ret = dbus_method_async_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, - METHOD_CHANGE_STATE, g_variant_new("(s)", lcd_str), display_change_cb, -1, NULL); + DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + METHOD_CHANGE_STATE, + g_variant_new("(s)", lcd_str), + display_change_cb, + -1, + NULL); if (ret < 0) _E("no message : failed to change state"); @@ -186,8 +195,13 @@ API int display_lock_state(unsigned int s_bits, unsigned int flag, pa[2] = p; ret = dbus_method_async_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, - METHOD_LOCK_STATE, g_variant_new("(sssi)", pa[0], pa[1], pa[2], timeout), display_lock_cb, -1, NULL); + DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + METHOD_LOCK_STATE, + g_variant_new("(sssi)", pa[0], pa[1], pa[2], timeout), + display_lock_cb, + -1, + NULL); if (ret < 0) _E("no message : failed to lock state"); @@ -240,8 +254,13 @@ API int display_unlock_state(unsigned int s_bits, unsigned int flag) pa[1] = p; ret = dbus_method_async_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, - METHOD_UNLOCK_STATE, g_variant_new("(ss)", pa[0], pa[1]), display_unlock_cb, -1, NULL); + DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + METHOD_UNLOCK_STATE, + g_variant_new("(ss)", pa[0], pa[1]), + display_unlock_cb, + -1, + NULL); if (ret < 0) _E("no message : failed to unlock state"); diff --git a/src/libdeviced/haptic.c b/src/libdeviced/haptic.c index 2a1de0a..ca58402 100644 --- a/src/libdeviced/haptic.c +++ b/src/libdeviced/haptic.c @@ -170,8 +170,11 @@ API int haptic_get_count(int *device_number) /* request to deviced to get haptic count */ ret = dbus_method_sync(VIBRATOR_BUS_NAME, - VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC, - METHOD_GET_COUNT, NULL, NULL); + VIBRATOR_PATH_HAPTIC, + VIBRATOR_INTERFACE_HAPTIC, + METHOD_GET_COUNT, + NULL, + NULL); if (ret < 0) return HAPTIC_ERROR_OPERATION_FAILED; @@ -198,8 +201,10 @@ API int haptic_open(haptic_device_e device_index, haptic_device_h *device_handle /* request to deviced to open haptic device */ ret = dbus_method_sync_var(VIBRATOR_BUS_NAME, - VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC, - METHOD_OPEN_DEVICE, g_variant_new("(i)", device_index)); + VIBRATOR_PATH_HAPTIC, + VIBRATOR_INTERFACE_HAPTIC, + METHOD_OPEN_DEVICE, + g_variant_new("(i)", device_index)); if (ret < 0) return HAPTIC_ERROR_OPERATION_FAILED; @@ -219,8 +224,10 @@ API int haptic_close(haptic_device_h device_handle) /* request to deviced to open haptic device */ ret = dbus_method_sync_var(VIBRATOR_BUS_NAME, - VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC, - METHOD_CLOSE_DEVICE, g_variant_new("(u)", device_handle)); + VIBRATOR_PATH_HAPTIC, + VIBRATOR_INTERFACE_HAPTIC, + METHOD_CLOSE_DEVICE, + g_variant_new("(u)", device_handle)); if (ret < 0) return HAPTIC_ERROR_OPERATION_FAILED; @@ -230,17 +237,17 @@ API int haptic_close(haptic_device_h device_handle) API int haptic_vibrate_monotone(haptic_device_h device_handle, int duration, haptic_effect_h *effect_handle) { return haptic_vibrate_monotone_with_detail(device_handle, - duration, - HAPTIC_FEEDBACK_AUTO, - HAPTIC_PRIORITY_MIN, - effect_handle); + duration, + HAPTIC_FEEDBACK_AUTO, + HAPTIC_PRIORITY_MIN, + effect_handle); } API int haptic_vibrate_monotone_with_detail(haptic_device_h device_handle, - int duration, - haptic_feedback_e feedback, - haptic_priority_e priority, - haptic_effect_h *effect_handle) + int duration, + haptic_feedback_e feedback, + haptic_priority_e priority, + haptic_effect_h *effect_handle) { int ret; @@ -272,8 +279,10 @@ API int haptic_vibrate_monotone_with_detail(haptic_device_h device_handle, /* request to deviced to open haptic device */ ret = dbus_method_sync_var(VIBRATOR_BUS_NAME, - VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC, - METHOD_VIBRATE_MONOTONE, g_variant_new("(uiii)", device_handle, duration, feedback, priority)); + VIBRATOR_PATH_HAPTIC, + VIBRATOR_INTERFACE_HAPTIC, + METHOD_VIBRATE_MONOTONE, + g_variant_new("(uiii)", device_handle, duration, feedback, priority)); if (ret < 0) return HAPTIC_ERROR_OPERATION_FAILED; @@ -295,12 +304,12 @@ API int haptic_vibrate_file(haptic_device_h device_handle, const char *file_path } ret = haptic_vibrate_buffers_with_detail(device_handle, - (const unsigned char *)vibe_buffer, - size, - HAPTIC_ITERATION_ONCE, - HAPTIC_FEEDBACK_AUTO, - HAPTIC_PRIORITY_MIN, - effect_handle); + (const unsigned char *)vibe_buffer, + size, + HAPTIC_ITERATION_ONCE, + HAPTIC_FEEDBACK_AUTO, + HAPTIC_PRIORITY_MIN, + effect_handle); free(vibe_buffer); return ret; } @@ -322,12 +331,12 @@ API int haptic_vibrate_file_with_detail(haptic_device_h device_handle, } ret = haptic_vibrate_buffers_with_detail(device_handle, - (const unsigned char *)vibe_buffer, - size, - iteration, - feedback, - priority, - effect_handle); + (const unsigned char *)vibe_buffer, + size, + iteration, + feedback, + priority, + effect_handle); free(vibe_buffer); return ret; } @@ -335,12 +344,12 @@ API int haptic_vibrate_file_with_detail(haptic_device_h device_handle, API int haptic_vibrate_buffer(haptic_device_h device_handle, const unsigned char *vibe_buffer, haptic_effect_h *effect_handle) { return haptic_vibrate_buffers_with_detail(device_handle, - vibe_buffer, - TEMP_BUFFER_SIZE, - HAPTIC_ITERATION_ONCE, - HAPTIC_FEEDBACK_AUTO, - HAPTIC_PRIORITY_MIN, - effect_handle); + vibe_buffer, + TEMP_BUFFER_SIZE, + HAPTIC_ITERATION_ONCE, + HAPTIC_FEEDBACK_AUTO, + HAPTIC_PRIORITY_MIN, + effect_handle); } API int haptic_vibrate_buffer_with_detail(haptic_device_h device_handle, @@ -351,35 +360,35 @@ API int haptic_vibrate_buffer_with_detail(haptic_device_h device_handle, haptic_effect_h *effect_handle) { return haptic_vibrate_buffers_with_detail(device_handle, - vibe_buffer, - TEMP_BUFFER_SIZE, - iteration, - feedback, - priority, - effect_handle); + vibe_buffer, + TEMP_BUFFER_SIZE, + iteration, + feedback, + priority, + effect_handle); } API int haptic_vibrate_buffers(haptic_device_h device_handle, - const unsigned char *vibe_buffer, - int size, - haptic_effect_h *effect_handle) + const unsigned char *vibe_buffer, + int size, + haptic_effect_h *effect_handle) { return haptic_vibrate_buffers_with_detail(device_handle, - vibe_buffer, - size, - HAPTIC_ITERATION_ONCE, - HAPTIC_FEEDBACK_AUTO, - HAPTIC_PRIORITY_MIN, - effect_handle); + vibe_buffer, + size, + HAPTIC_ITERATION_ONCE, + HAPTIC_FEEDBACK_AUTO, + HAPTIC_PRIORITY_MIN, + effect_handle); } API int haptic_vibrate_buffers_with_detail(haptic_device_h device_handle, - const unsigned char *vibe_buffer, - int size, - haptic_iteration_e iteration, - haptic_feedback_e feedback, - haptic_priority_e priority, - haptic_effect_h *effect_handle) + const unsigned char *vibe_buffer, + int size, + haptic_iteration_e iteration, + haptic_feedback_e feedback, + haptic_priority_e priority, + haptic_effect_h *effect_handle) { GVariant *pvar = NULL; int ret; @@ -419,8 +428,10 @@ API int haptic_vibrate_buffers_with_detail(haptic_device_h device_handle, /* request to deviced to open haptic device */ pvar = g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, vibe_buffer, size, sizeof(char)); ret = dbus_method_sync_var(VIBRATOR_BUS_NAME, - VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC, - METHOD_VIBRATE_BUFFER, g_variant_new("(u@ayiii)", device_handle, pvar, iteration, feedback, priority)); + VIBRATOR_PATH_HAPTIC, + VIBRATOR_INTERFACE_HAPTIC, + METHOD_VIBRATE_BUFFER, + g_variant_new("(u@ayiii)", device_handle, pvar, iteration, feedback, priority)); if (ret < 0) return HAPTIC_ERROR_OPERATION_FAILED; @@ -447,8 +458,10 @@ API int haptic_stop_all_effects(haptic_device_h device_handle) /* request to deviced to open haptic device */ ret = dbus_method_sync_var(VIBRATOR_BUS_NAME, - VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC, - METHOD_STOP_DEVICE, g_variant_new("(u)", device_handle)); + VIBRATOR_PATH_HAPTIC, + VIBRATOR_INTERFACE_HAPTIC, + METHOD_STOP_DEVICE, + g_variant_new("(u)", device_handle)); if (ret < 0) return HAPTIC_ERROR_OPERATION_FAILED; @@ -473,8 +486,10 @@ API int haptic_get_effect_state(haptic_device_h device_handle, haptic_effect_h e /* request to deviced to open haptic device */ ret = dbus_method_sync_var(VIBRATOR_BUS_NAME, - VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC, - METHOD_GET_STATE, g_variant_new("(i)", HAPTIC_DEVICE_0)); + VIBRATOR_PATH_HAPTIC, + VIBRATOR_INTERFACE_HAPTIC, + METHOD_GET_STATE, + g_variant_new("(i)", HAPTIC_DEVICE_0)); if (ret < 0) return HAPTIC_ERROR_OPERATION_FAILED; @@ -524,9 +539,10 @@ API int haptic_create_effect(unsigned char *vibe_buffer, pvar = g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, elem_arr, sizeof(haptic_effect_element_s) * max_elemcnt, sizeof(char)); msg = dbus_method_sync_with_reply_var(VIBRATOR_BUS_NAME, - VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC, - METHOD_CREATE_EFFECT, - g_variant_new("(i@ayi)", max_bufsize, pvar, max_elemcnt)); + VIBRATOR_PATH_HAPTIC, + VIBRATOR_INTERFACE_HAPTIC, + METHOD_CREATE_EFFECT, + g_variant_new("(i@ayi)", max_bufsize, pvar, max_elemcnt)); if (!msg) return HAPTIC_ERROR_OPERATION_FAILED; @@ -606,9 +622,9 @@ API int haptic_get_file_duration(haptic_device_h device_handle, const char *file } ret = haptic_get_buffers_duration(device_handle, - (const unsigned char *)vibe_buffer, - size, - file_duration); + (const unsigned char *)vibe_buffer, + size, + file_duration); free(vibe_buffer); return ret; } @@ -616,9 +632,9 @@ API int haptic_get_file_duration(haptic_device_h device_handle, const char *file API int haptic_get_buffer_duration(haptic_device_h device_handle, const unsigned char *vibe_buffer, int *buffer_duration) { return haptic_get_buffers_duration(device_handle, - vibe_buffer, - TEMP_BUFFER_SIZE, - buffer_duration); + vibe_buffer, + TEMP_BUFFER_SIZE, + buffer_duration); } API int haptic_get_buffers_duration(haptic_device_h device_handle, const unsigned char *vibe_buffer, int size, int *buffer_duration) @@ -646,8 +662,10 @@ API int haptic_get_buffers_duration(haptic_device_h device_handle, const unsigne /* request to deviced to open haptic device */ pvar = g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, vibe_buffer, size, sizeof(char)); ret = dbus_method_sync_var(VIBRATOR_BUS_NAME, - VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC, - METHOD_GET_DURATION, g_variant_new("(u@ay)", device_handle, pvar)); + VIBRATOR_PATH_HAPTIC, + VIBRATOR_INTERFACE_HAPTIC, + METHOD_GET_DURATION, + g_variant_new("(u@ay)", device_handle, pvar)); if (ret < 0) return HAPTIC_ERROR_OPERATION_FAILED; @@ -686,8 +704,10 @@ API int haptic_save_led(const unsigned char *vibe_buffer, int max_bufsize, const /* request to deviced to open haptic device */ pvar = g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, vibe_buffer, max_bufsize, sizeof(char)); ret = dbus_method_sync_var(VIBRATOR_BUS_NAME, - VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC, - METHOD_SAVE_BINARY, g_variant_new("(@ays)", pvar, file_path)); + VIBRATOR_PATH_HAPTIC, + VIBRATOR_INTERFACE_HAPTIC, + METHOD_SAVE_BINARY, + g_variant_new("(@ays)", pvar, file_path)); if (ret < 0) return HAPTIC_ERROR_OPERATION_FAILED; diff --git a/src/libdeviced/led.c b/src/libdeviced/led.c index 6352251..1fb8cf6 100644 --- a/src/libdeviced/led.c +++ b/src/libdeviced/led.c @@ -36,8 +36,10 @@ API int led_get_brightness(void) int ret_val = 0; msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, - DEVICED_PATH_LED, DEVICED_INTERFACE_LED, - METHOD_GET_BRIGHTNESS, NULL, NULL); + DEVICED_PATH_LED, + DEVICED_INTERFACE_LED, + METHOD_GET_BRIGHTNESS, + NULL, NULL); if (!msg) return -EBADMSG; @@ -57,8 +59,10 @@ API int led_get_max_brightness(void) int ret_val; msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, - DEVICED_PATH_LED, DEVICED_INTERFACE_LED, - METHOD_GET_MAX_BRIGHTNESS, NULL, NULL); + DEVICED_PATH_LED, + DEVICED_INTERFACE_LED, + METHOD_GET_MAX_BRIGHTNESS, + NULL, NULL); if (!msg) return -EBADMSG; @@ -78,8 +82,10 @@ API int led_set_brightness_with_noti(int val, bool enable) int ret_val; msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_LED, DEVICED_INTERFACE_LED, - METHOD_SET_BRIGHTNESS, g_variant_new("(ii)", val, enable)); + DEVICED_PATH_LED, + DEVICED_INTERFACE_LED, + METHOD_SET_BRIGHTNESS, + g_variant_new("(ii)", val, enable)); if (!msg) return -EBADMSG; diff --git a/src/libdeviced/mmc.c b/src/libdeviced/mmc.c index 933423e..c7c6ae0 100644 --- a/src/libdeviced/mmc.c +++ b/src/libdeviced/mmc.c @@ -43,8 +43,11 @@ API int mmc_secure_mount(const char *mount_point) if (mount_point == NULL) return -EINVAL; - return dbus_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_MMC, - DEVICED_INTERFACE_MMC, METHOD_REQUEST_SECURE_MOUNT, g_variant_new("(s)", mount_point)); + return dbus_method_sync_var(DEVICED_BUS_NAME, + DEVICED_PATH_MMC, + DEVICED_INTERFACE_MMC, + METHOD_REQUEST_SECURE_MOUNT, + g_variant_new("(s)", mount_point)); } API int mmc_secure_unmount(const char *mount_point) @@ -52,8 +55,11 @@ API int mmc_secure_unmount(const char *mount_point) if (mount_point == NULL) return -EINVAL; - return dbus_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_MMC, - DEVICED_INTERFACE_MMC, METHOD_REQUEST_SECURE_UNMOUNT, g_variant_new("(s)", mount_point)); + return dbus_method_sync_var(DEVICED_BUS_NAME, + DEVICED_PATH_MMC, + DEVICED_INTERFACE_MMC, + METHOD_REQUEST_SECURE_UNMOUNT, + g_variant_new("(s)", mount_point)); } static int get_mmc_primary_id() @@ -66,11 +72,11 @@ static int get_mmc_primary_id() int ret; int id; - reply = dbus_method_sync_with_reply_var( - STORAGE_BUS_NAME, - DEVICED_PATH_BLOCK_MANAGER, - DEVICED_INTERFACE_BLOCK_MANAGER, - "GetDeviceList", g_variant_new("(s)", "mmc")); + reply = dbus_method_sync_with_reply_var(STORAGE_BUS_NAME, + DEVICED_PATH_BLOCK_MANAGER, + DEVICED_INTERFACE_BLOCK_MANAGER, + "GetDeviceList", + g_variant_new("(s)", "mmc")); if (!reply) { _E("Failed to get mmc storage list"); return -EPERM; @@ -170,9 +176,14 @@ API int deviced_request_mount_mmc(struct mmc_contents *mmc_data) if (id < 0) return id; - ret = dbus_method_async_with_reply_var(STORAGE_BUS_NAME, DEVICED_PATH_BLOCK_MANAGER, - DEVICED_INTERFACE_BLOCK_MANAGER, "Mount", g_variant_new("(is)", id, ""), - mount_cb, -1, data); + ret = dbus_method_async_with_reply_var(STORAGE_BUS_NAME, + DEVICED_PATH_BLOCK_MANAGER, + DEVICED_INTERFACE_BLOCK_MANAGER, + "Mount", + g_variant_new("(is)", id, ""), + mount_cb, + -1, + data); _I("Mount Request %s", ret == 0 ? "Success" : "Failed"); @@ -226,9 +237,14 @@ API int deviced_request_unmount_mmc(struct mmc_contents *mmc_data, int option) if (id < 0) return id; - ret = dbus_method_async_with_reply_var(STORAGE_BUS_NAME, DEVICED_PATH_BLOCK_MANAGER, - DEVICED_INTERFACE_BLOCK_MANAGER, "Unmount", g_variant_new("(ii)", id, option), - unmount_cb, -1, data); + ret = dbus_method_async_with_reply_var(STORAGE_BUS_NAME, + DEVICED_PATH_BLOCK_MANAGER, + DEVICED_INTERFACE_BLOCK_MANAGER, + "Unmount", + g_variant_new("(ii)", id, option), + unmount_cb, + -1, + data); _I("Unmount Request %s", ret == 0 ? "Success" : "Failed"); @@ -287,9 +303,14 @@ API int deviced_format_mmc(struct mmc_contents *mmc_data, int option) if (id < 0) return id; - ret = dbus_method_async_with_reply_var(STORAGE_BUS_NAME, DEVICED_PATH_BLOCK_MANAGER, - DEVICED_INTERFACE_BLOCK_MANAGER, "Format", g_variant_new("(ii)", id, option), - format_cb, FORMAT_TIMEOUT, data); + ret = dbus_method_async_with_reply_var(STORAGE_BUS_NAME, + DEVICED_PATH_BLOCK_MANAGER, + DEVICED_INTERFACE_BLOCK_MANAGER, + "Format", + g_variant_new("(ii)", id, option), + format_cb, + FORMAT_TIMEOUT, + data); _I("Format Request %s", ret == 0 ? "Success" : "Failed"); diff --git a/src/libdeviced/usbhost.c b/src/libdeviced/usbhost.c index ced3059..8bf7e1d 100644 --- a/src/libdeviced/usbhost.c +++ b/src/libdeviced/usbhost.c @@ -51,10 +51,8 @@ struct signal_handler { static dd_list *handlers; -static int register_signal_handler(const char *path, const char *iface, - const char *name, GDBusSignalCallback cb, - union action action, - void *data) +static int register_signal_handler(const char *path, const char *iface, const char *name, + GDBusSignalCallback cb, union action action, void *data) { int ret; struct signal_handler *handler = NULL; @@ -85,12 +83,12 @@ out: } static void storage_signal_handler(GDBusConnection *conn, - const gchar *sender, - const gchar *path, - const gchar *iface, - const gchar *name, - GVariant *param, - gpointer data) + const gchar *sender, + const gchar *path, + const gchar *iface, + const gchar *name, + GVariant *param, + gpointer data) { char *type, *syspath; int mount; @@ -111,12 +109,12 @@ static void storage_signal_handler(GDBusConnection *conn, } static void device_signal_handler(GDBusConnection *conn, - const gchar *sender, - const gchar *path, - const gchar *iface, - const gchar *name, - GVariant *param, - gpointer data) + const gchar *sender, + const gchar *path, + const gchar *iface, + const gchar *name, + GVariant *param, + gpointer data) { char *syspath; struct usbhost_device device; @@ -124,17 +122,16 @@ static void device_signal_handler(GDBusConnection *conn, struct signal_handler *handler; dd_list *element; - g_variant_get(param, "(isiiiiisss)", - &state, - &syspath, - &device.baseclass, - &device.subclass, - &device.protocol, - &device.vendorid, - &device.productid, - &device.manufacturer, - &device.product, - &device.serial); + g_variant_get(param, "(isiiiiisss)", &state, + &syspath, + &device.baseclass, + &device.subclass, + &device.protocol, + &device.vendorid, + &device.productid, + &device.manufacturer, + &device.product, + &device.serial); strncpy(device.devpath, syspath, PATH_MAX); @@ -181,8 +178,11 @@ API void deinit_usbhost_signal(void) API int request_usb_storage_info(void) { - return dbus_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_USBHOST, - DEVICED_INTERFACE_USBHOST, METHOD_REQUEST_STORAGE_INFO_ALL, NULL, NULL); + return dbus_method_sync(DEVICED_BUS_NAME, + DEVICED_PATH_USBHOST, + DEVICED_INTERFACE_USBHOST, + METHOD_REQUEST_STORAGE_INFO_ALL, + NULL, NULL); } API int register_usb_storage_change_handler( @@ -198,11 +198,11 @@ API int register_usb_storage_change_handler( action.storage = storage_changed; ret = register_signal_handler(DEVICED_PATH_USBHOST, - DEVICED_INTERFACE_USBHOST, - SIGNAL_NAME_USB_STORAGE_CHANGED, - storage_signal_handler, - action, - data); + DEVICED_INTERFACE_USBHOST, + SIGNAL_NAME_USB_STORAGE_CHANGED, + storage_signal_handler, + action, + data); if (ret < 0) return -1; @@ -221,11 +221,11 @@ API int register_usb_device_change_handler( action.device = device_changed; ret = register_signal_handler(DEVICED_PATH_USBHOST, - DEVICED_INTERFACE_USBHOST, - SIGNAL_NAME_USB_DEVICE_CHANGED, - device_signal_handler, - action, - data); + DEVICED_INTERFACE_USBHOST, + SIGNAL_NAME_USB_DEVICE_CHANGED, + device_signal_handler, + action, + data); if (ret < 0) return -1; @@ -278,8 +278,11 @@ API int mount_usb_storage(char *path) if (!path) return -1; - return dbus_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_USBHOST, - DEVICED_INTERFACE_USBHOST, METHOD_REQUEST_STORAGE_MOUNT, g_variant_new("(s)", path)); + return dbus_method_sync_var(DEVICED_BUS_NAME, + DEVICED_PATH_USBHOST, + DEVICED_INTERFACE_USBHOST, + METHOD_REQUEST_STORAGE_MOUNT, + g_variant_new("(s)", path)); } API int unmount_usb_storage(char *path) @@ -287,8 +290,11 @@ API int unmount_usb_storage(char *path) if (!path) return -1; - return dbus_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_USBHOST, - DEVICED_INTERFACE_USBHOST, METHOD_REQUEST_STORAGE_UNMOUNT, g_variant_new("(s)", path)); + return dbus_method_sync_var(DEVICED_BUS_NAME, + DEVICED_PATH_USBHOST, + DEVICED_INTERFACE_USBHOST, + METHOD_REQUEST_STORAGE_UNMOUNT, + g_variant_new("(s)", path)); } API int format_usb_storage(char *path) @@ -296,8 +302,11 @@ API int format_usb_storage(char *path) if (!path) return -1; - return dbus_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_USBHOST, - DEVICED_INTERFACE_USBHOST, METHOD_REQUEST_STORAGE_FORMAT, g_variant_new("(s)", path)); + return dbus_method_sync_var(DEVICED_BUS_NAME, + DEVICED_PATH_USBHOST, + DEVICED_INTERFACE_USBHOST, + METHOD_REQUEST_STORAGE_FORMAT, + g_variant_new("(s)", path)); } API int open_usb_device(char *path, int *out_fd) @@ -311,10 +320,14 @@ API int open_usb_device(char *path, int *out_fd) return -EINVAL; reply = dbus_method_with_unix_fd_list_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_USBHOST, - DEVICED_INTERFACE_USBHOST, - METHOD_OPEN_DEVICE, - g_variant_new("(s)", path), NULL, 0, &fdlist, &size); + DEVICED_PATH_USBHOST, + DEVICED_INTERFACE_USBHOST, + METHOD_OPEN_DEVICE, + g_variant_new("(s)", path), + NULL, + 0, + &fdlist, + &size); if (!reply) { _E("Unable to open USB device"); return -1; diff --git a/src/power/boot.c b/src/power/boot.c index 75a4089..1b6be5d 100644 --- a/src/power/boot.c +++ b/src/power/boot.c @@ -124,19 +124,23 @@ void add_booting_done_handler(void *data) { /* System Session is loaded completely */ /*ret = */ - sig_id[0] = subscribe_dbus_signal(NULL, SYSTEMD_DBUS_PATH, - SYSTEMD_DBUS_IFACE_MANAGER, - SYSTEMD_DBUS_SIGNAL_SYSTEM_STARTUP_FINISHED, - booting_done_received, NULL, NULL); + sig_id[0] = subscribe_dbus_signal(NULL, + SYSTEMD_DBUS_PATH, + SYSTEMD_DBUS_IFACE_MANAGER, + SYSTEMD_DBUS_SIGNAL_SYSTEM_STARTUP_FINISHED, + booting_done_received, + NULL, NULL); if (sig_id[0] <= 0) _E("fail to init dbus signal(%s)", SYSTEMD_DBUS_SIGNAL_SYSTEM_STARTUP_FINISHED); /* User Session is loaded completely */ - sig_id[1] = subscribe_dbus_signal(NULL, SYSTEMD_DBUS_PATH, - SYSTEMD_DBUS_IFACE_MANAGER, - SYSTEMD_DBUS_SIGNAL_USER_STARTUP_FINISHED, - booting_done_received, NULL, NULL); + sig_id[1] = subscribe_dbus_signal(NULL, + SYSTEMD_DBUS_PATH, + SYSTEMD_DBUS_IFACE_MANAGER, + SYSTEMD_DBUS_SIGNAL_USER_STARTUP_FINISHED, + booting_done_received, + NULL, NULL); if (sig_id[1] <= 0) _E("fail to init dbus signal(%s)", SYSTEMD_DBUS_SIGNAL_USER_STARTUP_FINISHED); diff --git a/src/power/low-power.c b/src/power/low-power.c index 0daf2f9..efe8344 100644 --- a/src/power/low-power.c +++ b/src/power/low-power.c @@ -102,8 +102,8 @@ out: } GVariant *dbus_low_power_start(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; pid_t pid; @@ -125,8 +125,8 @@ out: return g_variant_new("(i)", ret); } GVariant *dbus_low_power_stop(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; pid_t pid; @@ -149,8 +149,8 @@ out: } GVariant *dbus_low_power_get_state(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { return g_variant_new("(i)", (low_power_enabled ? 1 : 0)); } diff --git a/src/power/power-handler.c b/src/power/power-handler.c index 99ab810..0008fe8 100644 --- a/src/power/power-handler.c +++ b/src/power/power-handler.c @@ -204,10 +204,12 @@ static void stop_systemd_service(void) { _I("Request to stop systemd service to resourced"); dbus_method_sync_timeout(RESOURCED_BUS_NAME, - RESOURCED_PATH_PROCESS, - RESOURCED_INTERFACE_PROCESS, - "PrePoweroff", - NULL, NULL, POWEROFF_WAIT_RESOURCED); + RESOURCED_PATH_PROCESS, + RESOURCED_INTERFACE_PROCESS, + "PrePoweroff", + NULL, + NULL, + POWEROFF_WAIT_RESOURCED); } /* umount usr data partition */ @@ -382,8 +384,10 @@ static void poweroff_send_broadcast(int status) old = status; /* Need to notify to deviced-vibrator. deviced-vibrator receives ChangeState signal for POWER_OFF_DIRECT and POWER_OFF_RESTART */ - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_POWEROFF, DEVICED_INTERFACE_POWEROFF, - SIGNAL_POWEROFF_STATE, g_variant_new("(i)", status)); + dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_POWEROFF, + DEVICED_INTERFACE_POWEROFF, + SIGNAL_POWEROFF_STATE, + g_variant_new("(i)", status)); } int check_power_flag(void) @@ -552,8 +556,8 @@ static int power_execute(void *data) } GVariant *dbus_power_handler(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { pid_t pid; int ret; @@ -584,8 +588,8 @@ out: } GVariant *dbus_power_option_handler(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { pid_t pid; int ret; @@ -610,8 +614,8 @@ out: } GVariant *request_reboot(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { char *str; int ret; diff --git a/src/proc/cpu-info.c b/src/proc/cpu-info.c index 46677ca..216dee6 100644 --- a/src/proc/cpu-info.c +++ b/src/proc/cpu-info.c @@ -113,8 +113,8 @@ static int get_revision(char *rev, int len) } GVariant *dbus_revision_handler(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { char rev[FILE_BUFF_MAX]; char *ptr; diff --git a/src/proc/proc-handler.c b/src/proc/proc-handler.c index 132fa34..64d903d 100644 --- a/src/proc/proc-handler.c +++ b/src/proc/proc-handler.c @@ -104,8 +104,8 @@ int set_oom_score_adj_action(int argc, char **argv) } GVariant *dbus_oom_handler(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { pid_t pid; int ret; @@ -187,8 +187,12 @@ static void process_init(void *data) { int ret; - ret = subscribe_dbus_signal(NULL, RESOURCED_PATH_PROCESS, - RESOURCED_INTERFACE_PROCESS, SIGNAL_PROC_STATUS, proc_signal_handler, NULL, NULL); + ret = subscribe_dbus_signal(NULL, + RESOURCED_PATH_PROCESS, + RESOURCED_INTERFACE_PROCESS, + SIGNAL_PROC_STATUS, + proc_signal_handler, + NULL, NULL); if (ret <= 0) _E("fail to init dbus method(%d)", ret); diff --git a/src/shared/dbus.c b/src/shared/dbus.c index 61b56d1..be38b85 100644 --- a/src/shared/dbus.c +++ b/src/shared/dbus.c @@ -42,7 +42,8 @@ int check_systemd_active(void) msg = dbus_method_sync_with_reply_var("org.freedesktop.systemd1", "/org/freedesktop/systemd1/unit/default_2etarget", "org.freedesktop.DBus.Properties", - "Get", g_variant_new("(ss)", "org.freedesktop.systemd1.Unit", "ActiveState")); + "Get", + g_variant_new("(ss)", "org.freedesktop.systemd1.Unit", "ActiveState")); if (!msg) return -EBADMSG; @@ -104,28 +105,29 @@ typedef struct { GDBusConnection *conn; GBusType bus_type; gboolean priv; - GList *list_names; // dbus_name - GList *list_object; /* dbus_object_handle_s */ - pthread_mutex_t mutex;// = PTHREAD_MUTEX_INITIALIZER; + GList *list_names; /* dbus_name */ + GList *list_object; /* dbus_object_handle_s */ + pthread_mutex_t mutex; } dbus_handle_s; /* path + interfaces */ typedef struct { - dbus_handle_s *dh; /* dbus handle */ - const char *path; - GList *list_ifaces; /* dbus_interface_s */ + dbus_handle_s *dh; /* dbus handle */ + const char *path; /* object path */ + GList *list_ifaces; /* dbus_interface_s */ } dbus_object_handle_s; typedef struct { - dbus_object_handle_s *oh; - const char *name; - GList *list_methods; // const dbus_method_s; + dbus_object_handle_s *oh; /* object handle */ + const char *name; /* interface name */ + GList *list_methods; /* const dbus_method_s */ guint reg_id; int modified; } dbus_interface_s; #define get_dh_from_oh(oh) ((dbus_object_handle_s*)oh)->dh +/* global shared bus : system, session */ static dbus_handle_s g_dh[2]; static dbus_handle_s *_dbus_handle_get_connection(GBusType bus_type); @@ -402,6 +404,7 @@ out: extern void booting_done(void); +/* default handler */ static void _name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) { dbus_handle_s *dh = (dbus_handle_s *)user_data; @@ -417,6 +420,7 @@ static void _name_acquired(GDBusConnection *connection, const gchar *name, gpoin //dh->bus_name = name; } +/* default handler */ static void _name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data) { _E("%s:%d:%s\n", __func__, __LINE__, name); @@ -428,8 +432,10 @@ static void _name_lost(GDBusConnection *connection, const gchar *name, gpointer _dbus_handle_remove_bus_name(dh, name); } -int dbus_handle_request_bus_name(dbus_handle_h handle, const char *bus_name, - GBusNameAcquiredCallback acquired_handler, GBusNameLostCallback lost_handler) +int dbus_handle_request_bus_name(dbus_handle_h handle, + const char *bus_name, + GBusNameAcquiredCallback acquired_handler, + GBusNameLostCallback lost_handler) { dcl_dbus_handle(); int id = -1; @@ -463,9 +469,13 @@ int dbus_handle_request_bus_name(dbus_handle_h handle, const char *bus_name, goto out; } - id = g_bus_own_name_on_connection(dh->conn, bus_name, G_BUS_NAME_OWNER_FLAGS_NONE, - acquired_handler ? acquired_handler : _name_acquired, - lost_handler ? lost_handler : _name_lost, dh, NULL); + id = g_bus_own_name_on_connection(dh->conn, + bus_name, + G_BUS_NAME_OWNER_FLAGS_NONE, + acquired_handler ? acquired_handler : _name_acquired, + lost_handler ? lost_handler : _name_lost, + dh, + NULL); if (!id) { _E("failed to own name:%s\n", bus_name); goto out; @@ -478,6 +488,7 @@ out: return id; } +/* !! _name_lost handler callback is disabled by g_bus_unown_name : ubuntu */ int dbus_handle_release_bus_name(dbus_handle_h handle, const char *bus_name) { dcl_dbus_handle(); @@ -644,6 +655,7 @@ int dbus_handle_free_connection(dbus_handle_h handle) } \ } while (0); +/* cal index of end of brace */ static int _check_brace(const char * expr) { int len = 0; @@ -699,6 +711,10 @@ static int _check_brace(const char * expr) return -1; } +/* +in : interface_s +out : xml format +*/ static int _get_xml_from_interfaces(char **xml, const dbus_interface_s *interfaces) { int nwrite = 0; @@ -960,10 +976,60 @@ static int _dbus_handle_attach_object(dbus_handle_s *dh, const char *obj_path, d return 0; } -/* libgio verify path and interface */ +/* +_method_call_handler + +libgio verify path and interface of incoming message. +--> just check method name. + +# parameters - member of invocation struct +every parameters of this function are member of GDBusMethodInvocation *invocation. +There are no reason to using g_dbus_method_invocation_get_* apis to get inforamtion from message. +just use params - sender, path, iface, name and param. + + +# user defined handler # + +1. synchronous handling + 1) with return value + handler() { + return g_variant_new("(i)", ret); + } + + 2) without return value + handler() { + return dbus_handle_new_g_variant_tuple(); // g_variant_new_tuple(NULL, 0) + } + +2. asynchronous handling + handler MUST call 'g_dbus_method_invocation_return_value' itself. otherwise, LEAK !! + + handler() { + return NULL; + } + + # if handler return NULL, assume asynchronous handling. do nothing. + + thread() { + do something; + + 1) with return value + g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", ret)); + + 2) without return value + g_dbus_method_invocation_return_value(invocation, NULL); + } + + +*/ static void _method_call_handler(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, + const gchar *path, + const gchar *iface, + const gchar *name, + GVariant *param, + GDBusMethodInvocation *invocation, + gpointer user_data) { dbus_interface_s *iface_s = (dbus_interface_s *)user_data; const dbus_method_s *methods; @@ -984,18 +1050,6 @@ static void _method_call_handler(GDBusConnection *conn, } g_dbus_method_invocation_return_value(invocation, result); - //if (g_variant_is_of_type(result, G_VARIANT_TYPE_TUPLE)) { - // //_E("TUPLE %s", g_variant_get_type_string(result)); - // g_dbus_method_invocation_return_value(invocation, result); - //} - //else if (g_variant_is_container(result)) { - // /* todo: we don't have any plan to using variant type for reply */ - // _E("CONTAINER %s", g_variant_get_type_string(result)); - // g_dbus_method_invocation_return_value(invocation, result); - // //g_dbus_method_invocation_return_value(invocation, g_variant_new("(v)", result)); - //} else { - // _E("Type is not Container : %s", g_variant_get_type_string(result)); - //} } static GDBusInterfaceVTable path_vtable = {_method_call_handler}; @@ -1064,9 +1118,13 @@ static int _dbus_handle_register_dbus_object(dbus_handle_h handle, const char *o if interface is already registered, then failed. g_dbus_connection_register_object ref(ifaceinfo) now, unref if object is unregistered */ - ret = g_dbus_connection_register_object(dh->conn, obj_path, ifaceinfo/*ref 2*/, &path_vtable, (void*)iface, - _free_func_object, - &err); + ret = g_dbus_connection_register_object(dh->conn, + obj_path, + ifaceinfo/*ref 2*/, + &path_vtable, + (void*)iface, + _free_func_object, + &err); if (err) { _E("failed to register object:err:%s:\n", err->message); ret = -1; @@ -1223,7 +1281,7 @@ int dbus_handle_unregister_dbus_object(dbus_handle_h handle, const char *obj_pat /* add object temporarily. -dbus_handle_register_dbus_object_all will register every objects on connection. +dbus_handle_register_dbus_object_all register every objects on connection. return registered method count */ @@ -1404,9 +1462,9 @@ static void _free_func_signal(gpointer data) } guint subscribe_dbus_signal(dbus_handle_h handle, const char *path, - const char *iface, const char *name, - GDBusSignalCallback cb, void *data, - destroy_notified free_func) + const char *iface, const char *name, + GDBusSignalCallback cb, void *data, + destroy_notified free_func) { dcl_dbus_handle(); @@ -1432,13 +1490,13 @@ void unsubscribe_dbus_signal(dbus_handle_h handle, guint id) dh = _dbus_handle_get_default_connection(); if (!dh) { _E("failed to get default connection, bustype:%d", (int)dbus_handle_get_default_bus_type()); - return; + return ; } } if (!dh->conn) { _E("connection is null. check bus status"); - return; + return ; } g_dbus_connection_signal_unsubscribe(dh->conn, id); @@ -1565,8 +1623,10 @@ static GVariant* _append_variant(const char *signature, const char *param[]) } int dbus_handle_broadcast_dbus_signal(const char *path, - const char *iface, const char *name, - const char *signature, const char *param[]) + const char *iface, + const char *name, + const char *signature, + const char *param[]) { dbus_handle_s *dh = NULL; GError *err = NULL; @@ -1591,8 +1651,9 @@ int dbus_handle_broadcast_dbus_signal(const char *path, } int dbus_handle_broadcast_dbus_signal_var(const char *path, - const char *iface, const char *name, - GVariant *param) + const char *iface, + const char *name, + GVariant *param) { dbus_handle_s *dh = NULL; GError *err = NULL; @@ -1653,8 +1714,11 @@ GVariant *dbus_method_sync_with_reply(const char *dest, const char *path, return ret; } -GVariant *dbus_method_sync_with_reply_var(const char *dest, const char *path, - const char *iface, const char *method, GVariant *var) +GVariant *dbus_method_sync_with_reply_var(const char *dest, + const char *path, + const char *iface, + const char *method, + GVariant *var) { GError *err = NULL; GVariant * ret = NULL; @@ -1714,11 +1778,16 @@ gint* dbus_handle_get_unix_fd_list(GDBusMethodInvocation *invocation, int *size) return g_unix_fd_list_steal_fds(fd_list, NULL); } -GVariant *dbus_method_with_unix_fd_list_sync_with_reply(const char *dest, const char *path, - const char *iface, const char *method, - const char *signature, const char *param[], - int *in_fdlist, int in_size, - int **out_fdlist, int *out_size) +GVariant *dbus_method_with_unix_fd_list_sync_with_reply(const char *dest, + const char *path, + const char *iface, + const char *method, + const char *signature, + const char *param[], + int *in_fdlist, + int in_size, + int **out_fdlist, + int *out_size) { GError *err = NULL; GVariant * var = NULL; @@ -1803,11 +1872,15 @@ out: return ret; } -GVariant *dbus_method_with_unix_fd_list_sync_with_reply_var(const char *dest, const char *path, - const char *iface, const char *method, - GVariant *param, - int *in_fdlist, int in_size, - int **out_fdlist, int *out_size) +GVariant *dbus_method_with_unix_fd_list_sync_with_reply_var(const char *dest, + const char *path, + const char *iface, + const char *method, + GVariant *param, + int *in_fdlist, + int in_size, + int **out_fdlist, + int *out_size) { GError *err = NULL; GVariant * ret = NULL; @@ -1887,9 +1960,12 @@ out: return ret; } -int dbus_method_sync(const char *dest, const char *path, - const char *iface, const char *method, - const char *signature, const char *param[]) +int dbus_method_sync(const char *dest, + const char *path, + const char *iface, + const char *method, + const char *signature, + const char *param[]) { int result; gboolean result_bool; @@ -1918,8 +1994,11 @@ int dbus_method_sync(const char *dest, const char *path, return result; } -int dbus_method_sync_var(const char *dest, const char *path, - const char *iface, const char *method, GVariant *param) +int dbus_method_sync_var(const char *dest, + const char *path, + const char *iface, + const char *method, + GVariant *param) { int result; gboolean result_bool; @@ -1948,9 +2027,13 @@ int dbus_method_sync_var(const char *dest, const char *path, return result; } -int dbus_method_sync_timeout(const char *dest, const char *path, - const char *iface, const char *method, - const char *signature, const char *param[], int timeout) +int dbus_method_sync_timeout(const char *dest, + const char *path, + const char *iface, + const char *method, + const char *signature, + const char *param[], + int timeout) { dbus_handle_s *dh = NULL; GError *err = NULL; @@ -1991,9 +2074,12 @@ int dbus_method_sync_timeout(const char *dest, const char *path, return result; } -int dbus_method_sync_pairs(const char *dest, const char *path, - const char *iface, const char *method, - int num, va_list args) +int dbus_method_sync_pairs(const char *dest, + const char *path, + const char *iface, + const char *method, + int num, + va_list args) { GError *err = NULL; GVariant * reply = NULL; @@ -2044,9 +2130,12 @@ int dbus_method_sync_pairs(const char *dest, const char *path, return ret; } -int dbus_method_async_pairs(const char *dest, const char *path, - const char *iface, const char *method, - int num, va_list args) +int dbus_method_async_pairs(const char *dest, + const char *path, + const char *iface, + const char *method, + int num, + va_list args) { char *key, *value; GVariant *var; @@ -2085,9 +2174,12 @@ int dbus_method_async_pairs(const char *dest, const char *path, return 0; } -int dbus_method_async(const char *dest, const char *path, - const char *iface, const char *method, - const char *signature, const char *param[]) +int dbus_method_async(const char *dest, + const char *path, + const char *iface, + const char *method, + const char *signature, + const char *param[]) { GVariant * var = NULL; dbus_handle_s *dh = NULL; @@ -2114,8 +2206,11 @@ int dbus_method_async(const char *dest, const char *path, return 0; } -int dbus_method_async_var(const char *dest, const char *path, - const char *iface, const char *method, GVariant *param) +int dbus_method_async_var(const char *dest, + const char *path, + const char *iface, + const char *method, + GVariant *param) { dbus_handle_s *dh = NULL; @@ -2140,8 +2235,8 @@ int dbus_method_async_var(const char *dest, const char *path, /* callback should free gvariant */ static void _cb_pending(GDBusConnection *conn, - GAsyncResult *res, - gpointer user_data) + GAsyncResult *res, + gpointer user_data) { GVariant *reply = NULL; GError *err = NULL; @@ -2169,14 +2264,14 @@ out: } int dbus_method_async_with_reply(const char *dest, - const char *path, - const char *iface, - const char *method, - const char *signature, - const char *param[], - dbus_pending_cb cb, - int timeout_msec, - void *data) + const char *path, + const char *iface, + const char *method, + const char *signature, + const char *param[], + dbus_pending_cb cb, + int timeout_msec, + void *data) { dbus_handle_s *dh = NULL; pending_call_data *pdata = NULL; @@ -2225,13 +2320,13 @@ err: } int dbus_method_async_with_reply_var(const char *dest, - const char *path, - const char *iface, - const char *method, - GVariant *param, - dbus_pending_cb cb, - int timeout_msec, - void *data) + const char *path, + const char *iface, + const char *method, + GVariant *param, + dbus_pending_cb cb, + int timeout_msec, + void *data) { dbus_handle_s *dh = NULL; pending_call_data *pdata = NULL; @@ -2347,16 +2442,16 @@ int dbus_handle_get_sender_credentials(dbus_handle_h handle, const char *name, G } } vret = g_dbus_connection_call_sync(dh->conn, - DBUS_BUS_NAME, - DBUS_OBJECT_PATH, - DBUS_INTERFACE_NAME, - "GetConnectionCredentials", - g_variant_new("(s)", name), - NULL, - G_DBUS_CALL_FLAGS_NONE, - DBUS_REPLY_TIMEOUT, - NULL, - &err); + DBUS_BUS_NAME, + DBUS_OBJECT_PATH, + DBUS_INTERFACE_NAME, + "GetConnectionCredentials", + g_variant_new("(s)", name), + NULL, + G_DBUS_CALL_FLAGS_NONE, + DBUS_REPLY_TIMEOUT, + NULL, + &err); if (!vret || err) { _E("failed to g_dbus_connection_call_sync:%s", err->message); return -1; @@ -2367,13 +2462,13 @@ int dbus_handle_get_sender_credentials(dbus_handle_h handle, const char *name, G while (g_variant_iter_loop(iter, "{sv}", &item, &sub)) { if (!g_strcmp0(item, "UnixUserID")) { g_variant_get(sub, "u", &creds->uid); - _D("UnixUserID %u", creds->uid); + //_D("UnixUserID %u", creds->uid); } else if (!g_strcmp0(item, "ProcessID")) { g_variant_get(sub, "u", &creds->pid); - _D("ProcessID %u", creds->pid); + //_D("ProcessID %u", creds->pid); } else if (!g_strcmp0(item, "LinuxSecurityLabel")) { g_variant_get(sub, "^ay", &creds->sec_label); - _D("%s", creds->sec_label); + //_D("%s", creds->sec_label); } } @@ -2392,9 +2487,9 @@ void _destroy_notify_watch_name(gpointer data) } int dbus_handle_watch_name(const char *name, - GBusNameAppearedCallback name_appeared_handler, - GBusNameVanishedCallback name_vanished_handler, - void *user_data) + GBusNameAppearedCallback name_appeared_handler, + GBusNameVanishedCallback name_vanished_handler, + void *user_data) { guint id = 0; @@ -2408,12 +2503,12 @@ int dbus_handle_watch_name(const char *name, } id = g_bus_watch_name(dbus_handle_get_default_bus_type(), - name, - G_BUS_NAME_WATCHER_FLAGS_NONE, - name_appeared_handler, - name_vanished_handler, - user_data, - _destroy_notify_watch_name); + name, + G_BUS_NAME_WATCHER_FLAGS_NONE, + name_appeared_handler, + name_vanished_handler, + user_data, + _destroy_notify_watch_name); if (!id) { _E("failed to g_bus_watch_name"); return -1; @@ -2492,13 +2587,16 @@ char **dbus_handle_get_owner_list(dbus_handle_h handle, const char *bus_name) } vret = g_dbus_connection_call_sync(dh->conn, - "org.freedesktop.DBus", "/", "org.freedesktop.DBus", "ListQueuedOwners", - g_variant_new("(s)", bus_name), - NULL, - G_DBUS_CALL_FLAGS_NONE, - DBUS_REPLY_TIMEOUT, - NULL, - &err); + "org.freedesktop.DBus", + "/", + "org.freedesktop.DBus", + "ListQueuedOwners", + g_variant_new("(s)", bus_name), + NULL, + G_DBUS_CALL_FLAGS_NONE, + DBUS_REPLY_TIMEOUT, + NULL, + &err); if (!vret || err) { _E("failed to g_dbus_connection_call_sync:%s", err->message); g_error_free(err); @@ -2551,8 +2649,10 @@ void dbush_handle_check_owner_name(dbus_handle_h handle, const char *owner_name) g_strfreev(strv); } -dbus_handle_h dbus_handle_init(GBusType type, const char* bus_name, - GBusNameAcquiredCallback acquired_handler, GBusNameLostCallback lost_handler) +dbus_handle_h dbus_handle_init(GBusType type, + const char* bus_name, + GBusNameAcquiredCallback acquired_handler, + GBusNameLostCallback lost_handler) { dbus_handle_h handle = NULL; int i, ret = 0; diff --git a/src/shared/dbus.h b/src/shared/dbus.h index 44b83a5..c6ef88c 100644 --- a/src/shared/dbus.h +++ b/src/shared/dbus.h @@ -1,4 +1,3 @@ - /* * deviced * diff --git a/src/time/time-handler.c b/src/time/time-handler.c index 9c7a916..9278118 100644 --- a/src/time/time-handler.c +++ b/src/time/time-handler.c @@ -277,8 +277,8 @@ out: } GVariant *dbus_time_handler(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { pid_t pid; int ret = 0; diff --git a/src/usb-host-test/usb-host-test.c b/src/usb-host-test/usb-host-test.c index 68c1f64..fb375b4 100644 --- a/src/usb-host-test/usb-host-test.c +++ b/src/usb-host-test/usb-host-test.c @@ -481,8 +481,8 @@ out: } static GVariant *dbus_start(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; @@ -496,8 +496,8 @@ static GVariant *dbus_start(GDBusConnection *conn, } static GVariant *dbus_stop(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret; diff --git a/src/usb/usb-dbus.c b/src/usb/usb-dbus.c index d7beb8c..f3a64fe 100755 --- a/src/usb/usb-dbus.c +++ b/src/usb/usb-dbus.c @@ -173,8 +173,8 @@ out: /* dbus methods */ GVariant *get_usb_client_state(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { unsigned int state; @@ -184,8 +184,8 @@ GVariant *get_usb_client_state(GDBusConnection *conn, } GVariant *get_usb_client_mode(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { unsigned int mode; diff --git a/src/usbhost/usb-host.c b/src/usbhost/usb-host.c index 7b38cb0..06d08c2 100644 --- a/src/usbhost/usb-host.c +++ b/src/usbhost/usb-host.c @@ -428,8 +428,8 @@ static int usbhost_init_from_udev_enumerate(void) } static GVariant *print_device_list(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { dd_list *elem; struct usbhost_device *usbhost; @@ -444,8 +444,8 @@ static GVariant *print_device_list(GDBusConnection *conn, } #define nullstr(x) (x ? x : "") static GVariant *get_device_list(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { GVariant *gvar = NULL; dd_list *elem; @@ -488,8 +488,8 @@ out: } static GVariant *get_device_list_count(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { dd_list *elem; struct usbhost_device *usbhost; @@ -563,8 +563,8 @@ static inline int marshal_policy_entry(char *buf, int len, struct policy_entry * } static GVariant *print_policy(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { char line[ENTRY_LINE_SIZE]; dd_list *elem; @@ -1015,8 +1015,8 @@ static void remove_all_access_list(void) } static GVariant *open_device(GDBusConnection *conn, - const gchar *sender, const gchar *obj_path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) + const gchar *sender, const gchar *obj_path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret = 0; int policy; -- 2.7.4 From 72473144ad099f92c753bcd4c8fffaccfc72d149 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Mon, 12 Feb 2018 13:46:58 +0900 Subject: [PATCH 05/16] Fix a bug in dbus for method DeviceList Change-Id: Iaf9972473c3f6ac3a8bada31b0491cc8404889c5 Signed-off-by: lokilee73 --- src/core/devices.c | 1 + src/shared/dbus.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/devices.c b/src/core/devices.c index 1f5e2ba..e91c7ff 100644 --- a/src/core/devices.c +++ b/src/core/devices.c @@ -79,6 +79,7 @@ GVariant *dbus_device_list(GDBusConnection *conn, DD_LIST_FOREACH(dev_head, elem, dev) _I("%s", dev->name); + g_dbus_method_invocation_return_value(invocation, NULL); return NULL; } diff --git a/src/shared/dbus.c b/src/shared/dbus.c index be38b85..1ab3248 100644 --- a/src/shared/dbus.c +++ b/src/shared/dbus.c @@ -1042,7 +1042,6 @@ static void _method_call_handler(GDBusConnection *conn, /* async, maybe they will reply...maybe.. */ if (!result) { - _E("finish method handle : NULL"); return ; } } else { -- 2.7.4 From 7e8d94ef024c2e4a9f42be69a793a510953c73c3 Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Tue, 13 Feb 2018 13:08:04 +0900 Subject: [PATCH 06/16] Remove build warning Signed-off-by: INSUN PYO Change-Id: Ia4bc639138df378aa607121e8293a7c6f39392e9 --- src/battery/power-supply.c | 9 +++--- src/core/common.c | 65 ------------------------------------------- src/core/common.h | 1 - src/devicectl/devicectl.c | 2 +- src/led/rgb.c | 6 +--- src/libdeviced/deviced-conf.c | 37 ------------------------ 6 files changed, 7 insertions(+), 113 deletions(-) diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index f6c217b..48b9ab6 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -124,16 +124,17 @@ static guint abnormal_timer; static void abnormal_popup_timer_init(void) { - if (abnormal_timer == NULL) + if (abnormal_timer == 0) return; + g_source_remove(abnormal_timer); - abnormal_timer = NULL; + abnormal_timer = 0; _I("delete health timer"); } static void health_timer_reset(void) { - abnormal_timer = NULL; + abnormal_timer = 0; } static gboolean health_timer_cb(void *data) @@ -170,7 +171,7 @@ static void abnormal_popup_dbus_signal_handler(GDBusConnection *conn, _I("restart health timer"); abnormal_timer = g_timeout_add_seconds(ABNORMAL_CHECK_TIMER_INTERVAL, health_timer_cb, NULL); - if (abnormal_timer == NULL) + if (abnormal_timer == 0) _E("Fail to add abnormal check timer"); } #endif /* TIZEN_FEATURE_BATTERY_OVER_TEMPERATURE */ diff --git a/src/core/common.c b/src/core/common.c index 9f6cb7e..6e5a192 100644 --- a/src/core/common.c +++ b/src/core/common.c @@ -234,71 +234,6 @@ int is_vip(int pid) return 0; } -static int remove_dir_internal(int fd) -{ - DIR *dir; - struct dirent entry; - struct dirent *de; - int subfd, ret = 0; - - dir = fdopendir(fd); - if (!dir) - return -1; - while (1) { - ret = readdir_r(dir, &entry, &de); - if (ret != 0 || de == NULL) - break; - if (de->d_type == DT_DIR) { - if (!strncmp(de->d_name, ".", 2) || !strncmp(de->d_name, "..", 3)) - continue; - subfd = openat(fd, de->d_name, O_RDONLY | O_DIRECTORY); - if (subfd < 0) { - _SE("Couldn't openat %s: %d\n", de->d_name, errno); - ret = -1; - continue; - } - if (remove_dir_internal(subfd)) - ret = -1; - - close(subfd); - if (unlinkat(fd, de->d_name, AT_REMOVEDIR) < 0) { - _SE("Couldn't unlinkat %s: %d\n", de->d_name, errno); - ret = -1; - } - } else { - if (unlinkat(fd, de->d_name, 0) < 0) { - _SE("Couldn't unlinkat %s: %d\n", de->d_name, errno); - ret = -1; - } - } - } - closedir(dir); - return ret; -} - -int remove_dir(const char *path, int del_dir) -{ - int fd, ret = 0; - - if (!path) - return -1; - fd = open(path, O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW); - if (fd < 0) { - _SE("Couldn't opendir %s: %d\n", path, errno); - return -errno; - } - ret = remove_dir_internal(fd); - close(fd); - - if (del_dir) { - if (rmdir(path)) { - _SE("Couldn't rmdir %s: %d\n", path, errno); - ret = -1; - } - } - return ret; -} - /* * Helper function * - Read from sysfs entry diff --git a/src/core/common.h b/src/core/common.h index a8db707..372f73e 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -145,7 +145,6 @@ int get_exec_pid(const char *execpath); int get_cmdline_name(pid_t pid, char *cmdline, size_t cmdline_size); int is_vip(int pid); int run_child(int argc, const char *argv[]); -int remove_dir(const char *path, int del_dir); int sys_check_node(char *path); int sys_get_int(char *fname, int *val); int sys_set_int(char *fname, int val); diff --git a/src/devicectl/devicectl.c b/src/devicectl/devicectl.c index b6560b7..e5d1590 100644 --- a/src/devicectl/devicectl.c +++ b/src/devicectl/devicectl.c @@ -195,7 +195,7 @@ static int save_dbus_name(char **args) return -EINVAL; } - printf("%d connections\n", g_variant_iter_n_children(iter)); + printf("%" G_GSIZE_FORMAT " connections\n", g_variant_iter_n_children(iter)); while (g_variant_iter_loop(iter, "s", &str)) { pid = dbus_handle_get_sender_pid(NULL, str); diff --git a/src/led/rgb.c b/src/led/rgb.c index e8146d7..4732265 100644 --- a/src/led/rgb.c +++ b/src/led/rgb.c @@ -242,8 +242,6 @@ static GVariant *dbus_multi_playcustom(GDBusConnection *conn, int ret = 0; unsigned int *color; int num_of_leds; - struct led_state state; - pid_t pid; GVariantIter *iter; int i; @@ -258,10 +256,8 @@ static GVariant *dbus_multi_playcustom(GDBusConnection *conn, g_variant_iter_free(iter); - pid = dbus_connection_get_sender_pid(conn, sender); - /* To be implemented */ -out: + free(color); return g_variant_new("(i)", ret); diff --git a/src/libdeviced/deviced-conf.c b/src/libdeviced/deviced-conf.c index face25f..e4b2aad 100644 --- a/src/libdeviced/deviced-conf.c +++ b/src/libdeviced/deviced-conf.c @@ -77,43 +77,6 @@ out: return val; } -static int util_process_group_set(char* name, int pid) -{ - GVariant *msg; - char buf[SYSTEM_NOTI_MAXARG]; - int val; - - if (strncmp(PROCESS_VIP, name, strlen(name)) != 0 && - strncmp(PROCESS_PERMANENT, name, strlen(name)) != 0) { - _E("fail to insert at %s group", name); - return -1; - } - - snprintf(buf, sizeof(buf), "%d", pid); - _D("pid(%d) is inserted at vip", pid); - - msg = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_PROCESS, - DEVICED_INTERFACE_PROCESS, - PROCESS_GROUP_SET, - g_variant_new("(siss)", PROCESS_GROUP_SET, 2, buf, name)); - if (!msg) - return -EBADMSG; - - if (!dh_get_param_from_var(msg, "(i)", &val)) { - _E("fail (signature:%s): no message", g_variant_get_type_string(msg)); - val = -EBADMSG; - goto out; - } - - _D("%s-%s : %d", DEVICED_INTERFACE_PROCESS, PROCESS_GROUP_SET, val); - -out: - g_variant_unref(msg); - - return val; -} - API int deviced_conf_set_mempolicy_bypid(int pid, enum mem_policy mempol) { if (pid < 1) -- 2.7.4 From a8fcf7ea874b1df301369245d4cfb99273a7ebc3 Mon Sep 17 00:00:00 2001 From: "insun.pyo" Date: Mon, 12 Feb 2018 17:01:45 +0900 Subject: [PATCH 07/16] tzip: fix race condition between tzip_thread and tzip_mount_thread - Add synchronization code between tzip_thread and tzip_mount_thread. tzip_mount_thread must wait for tzip_thread to complete. - Initializes async_queue out of the tzip_mount_thread. It adds synchronization between main loop and tzip_mount_thread. - add atomic varial stop_or_error to handle error between threads. Signed-off-by: insun.pyo Change-Id: If94cf4d7d58feeb1ad6d24f0d5902277bb266e94 Signed-off-by: Hyotaek Shim --- src/tzip/tzip.c | 121 ++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 88 insertions(+), 33 deletions(-) diff --git a/src/tzip/tzip.c b/src/tzip/tzip.c index 1c3f8b8..b55de62 100644 --- a/src/tzip/tzip.c +++ b/src/tzip/tzip.c @@ -43,12 +43,21 @@ #include "core/common.h" #include "tzip-utility.h" +enum tzip_state_t { + TZIP_RUNNING_STATE = 0, + TZIP_STOP_STATE, + TZIP_ERROR_STATE, +}; + static pthread_t thread; static pthread_t mount_thread; static pthread_attr_t attr; static struct fuse *fuse_handle; static struct fuse_chan *channel; static GAsyncQueue *async_queue; +static gint stop_or_error = TZIP_RUNNING_STATE; +static pthread_cond_t thread_cond = PTHREAD_COND_INITIALIZER; +static pthread_mutex_t thread_cond_mutex = PTHREAD_MUTEX_INITIALIZER; static int tzip_is_mounted(const char *mount_point); static int tzip_unmount_zipfs(const char *mount_point); @@ -389,7 +398,7 @@ static void *tzip_thread(void *arg) ret = mkdir(TZIP_ROOT_PATH, 0755); if (ret < 0 && errno != EEXIST) { _E("fail to make dir %s", TZIP_ROOT_PATH); - return NULL; + goto out; } tzip_lock(); @@ -435,9 +444,15 @@ static void *tzip_thread(void *arg) } tzip_unlock(); + /* notify to tzip_mount_thread */ + pthread_mutex_lock(&thread_cond_mutex); + pthread_cond_signal(&thread_cond); + pthread_mutex_unlock(&thread_cond_mutex); + if (fuse_loop_mt(fuse_handle)) { _E("Failed at fuse_loop_mt"); - goto out; + g_atomic_int_set(&stop_or_error, TZIP_ERROR_STATE); + return NULL; /* already send pthread_cond_signal() */ } tzip_lock(); @@ -445,10 +460,20 @@ static void *tzip_thread(void *arg) fuse_destroy(fuse_handle); fuse_handle = NULL; } + tzip_unlock(); + + return NULL; out_unlock: tzip_unlock(); out: + g_atomic_int_set(&stop_or_error, TZIP_ERROR_STATE); + + /* notify to tzip_mount_thread */ + pthread_mutex_lock(&thread_cond_mutex); + pthread_cond_signal(&thread_cond); + pthread_mutex_unlock(&thread_cond_mutex); + return NULL; } @@ -473,9 +498,10 @@ static void *tzip_mount_thread(void *arg) struct tzip_msg_data *msgdata; int ret = 0; - /* if g_async_queue_new() fails, tzip mount/unmount requests can not be handled */ - async_queue = g_async_queue_new(); - assert(async_queue); + /* wait for tzip_thread to be ready*/ + pthread_mutex_lock(&thread_cond_mutex); + pthread_cond_wait(&thread_cond, &thread_cond_mutex); + pthread_mutex_unlock(&thread_cond_mutex); while (1) { /* g_async_queue_pop() is a blocking call, it should never return NULL */ @@ -499,14 +525,41 @@ static void *tzip_mount_thread(void *arg) static void tzip_server_init(void) { - if (pthread_attr_init(&attr) != 0) + static int once = 0; + + /* You do not need pthread_once because it runs only in the main loop. */ + if (once) + return; + once = 1; + + _D("tzip_server_init"); + + /* for tzip_mount_thread */ + async_queue = g_async_queue_new(); + if (!async_queue) { + _E("async_queue creation fail"); + goto error; + } + + if (pthread_attr_init(&attr) != 0) { _E("pthread_attr_init Failed"); + goto error; + } - if (pthread_create(&thread, &attr, &tzip_thread, NULL)) + if (pthread_create(&thread, &attr, &tzip_thread, NULL)) { _E("pthread_create Failed"); + goto error; + } - if (pthread_create(&mount_thread, &attr, &tzip_mount_thread, NULL)) + if (pthread_create(&mount_thread, &attr, &tzip_mount_thread, NULL)) { _E("pthread_create Failed"); + goto error; + } + + return; + +error: + g_atomic_int_set(&stop_or_error, TZIP_ERROR_STATE); } static void tzip_server_exit(void) @@ -696,6 +749,13 @@ static GVariant *dbus_request_mount_tzip(GDBusConnection *conn, char *mountpath; struct tzip_msg_data *msgdata = NULL; + tzip_server_init(); + if (g_atomic_int_get(&stop_or_error) != TZIP_RUNNING_STATE) { + _E("tzip is not running state"); + ret = -EOWNERDEAD; + goto out; + } + g_variant_get(param, "(&s&s&s)", &mountpath, &zippath, &smack); if (!mountpath || !zippath || !smack) { @@ -717,9 +777,6 @@ static GVariant *dbus_request_mount_tzip(GDBusConnection *conn, goto out; } - if (!fuse_handle) - tzip_server_init(); - msgdata = calloc(1, sizeof(struct tzip_msg_data)); if (!msgdata) { _E("Malloc failed"); @@ -737,14 +794,8 @@ static GVariant *dbus_request_mount_tzip(GDBusConnection *conn, goto out; } - if (async_queue) { - g_async_queue_push(async_queue, (gpointer)msgdata); - ret = 0; - } else { - _E("async_queue (tzip_mount_thread) is not ready"); - ret = -EAGAIN; - goto out; - } + g_async_queue_push(async_queue, (gpointer)msgdata); + ret = 0; out: if (ret < 0) @@ -762,6 +813,13 @@ static GVariant *dbus_request_unmount_tzip(GDBusConnection *conn, char *mountpath; struct tzip_msg_data *msgdata = NULL; + tzip_server_init(); + if (g_atomic_int_get(&stop_or_error) != TZIP_RUNNING_STATE) { + _E("tzip is not running state"); + ret = -EOWNERDEAD; + goto out; + } + g_variant_get(param, "(&s)", &mountpath); if (!mountpath) { @@ -783,9 +841,6 @@ static GVariant *dbus_request_unmount_tzip(GDBusConnection *conn, goto out; } - if (!fuse_handle) - tzip_server_init(); - msgdata = calloc(1, sizeof(struct tzip_msg_data)); if (!msgdata) { _E("Malloc failed"); @@ -801,14 +856,8 @@ static GVariant *dbus_request_unmount_tzip(GDBusConnection *conn, goto out; } - if (async_queue) { - g_async_queue_push(async_queue, (gpointer)msgdata); - ret = 0; - } else { - _E("async_queue (tzip_mount_thread) is not ready"); - ret = -EAGAIN; - goto out; - } + g_async_queue_push(async_queue, (gpointer)msgdata); + ret = 0; out: if (ret < 0) @@ -824,6 +873,13 @@ static GVariant *dbus_request_ismounted_tzip(GDBusConnection *conn, int ret; char *mountpath; + tzip_server_init(); + if (g_atomic_int_get(&stop_or_error) != TZIP_RUNNING_STATE) { + _E("tzip is not running state"); + ret = -EOWNERDEAD; + goto out; + } + g_variant_get(param, "(&s)", &mountpath); if (!mountpath) { @@ -860,9 +916,8 @@ static const dbus_interface_u dbus_interface = { static int booting_done(void *data) { - if (!fuse_handle) - tzip_server_init(); - + /* To reduce the latency of the first Tzip operation, you can apply this optimization. + tzip_server_init(); */ return 0; } -- 2.7.4 From 28aa5805513d1e2613a0e24b7362373595c67301 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Tue, 13 Feb 2018 14:11:52 +0900 Subject: [PATCH 08/16] Battery: remove PROFILE_MOBILE in low and critical notification Change-Id: I678fa8b6c941def34248787bf094209de64fcdf5 Signed-off-by: lokilee73 Signed-off-by: Hyotaek Shim --- CMakeLists.txt | 7 +-- src/battery/lowbat-handler.c | 113 ++++++++++++++++++++----------------------- 2 files changed, 53 insertions(+), 67 deletions(-) mode change 100644 => 100755 CMakeLists.txt mode change 100644 => 100755 src/battery/lowbat-handler.c diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index 2e8a434..0ff812b --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,12 +213,7 @@ ADD_DEFINITIONS("-DENABLE_PM_LOG") IF(ENGINEER_MODE STREQUAL on) ADD_DEFINITIONS("-DENGINEER_MODE") ENDIF(ENGINEER_MODE STREQUAL on) -IF(PROFILE STREQUAL mobile) - ADD_DEFINITIONS("-DPROFILE_MOBILE") -ENDIF() -IF(PROFILE STREQUAL tv) - ADD_DEFINITIONS("-DPROFILE_TV") -ENDIF() + IF(USE_ARM) ADD_DEFINITIONS("-DTARGET") ENDIF() diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c old mode 100644 new mode 100755 index 860d7ab..64e2dd6 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -92,7 +92,7 @@ static int cur_bat_state = BATTERY_UNKNOWN; static int cur_bat_capacity = BATTERY_UNKNOWN; static int custom_warning_level = BATTERY_UNKNOWN; static int default_battery_warning = BATTERY_WARNING; -static int event_noti_on = -1, active_noti_on = -1; +static int event_noti_num = -1, active_noti_num = -1; static struct battery_config_info battery_info = { .normal = BATTERY_NORMAL, @@ -263,52 +263,44 @@ void power_off_timer_stop(void) power_off_timer = 0; } -static int get_lowbat_noti_value(int low_battery_type, char **actvie_noti, char **event_noti) +static int get_lowbat_noti_value(int low_battery_type, char **active_noti, char **event_noti) { int len; int ret = 1; len = strlen(battery.power_source_s); if (!strncmp(battery.power_source_s, POWER_SOURCE_NONE, len)) { - if (low_battery_type == LOW_BATTERY) - *actvie_noti = "BatteryLowActNotiOn"; - else if (low_battery_type == CRITICAL_BATTERY) - *actvie_noti = "BatteryCriticalActNotiOn"; -#ifdef PROFILE_MOBILE - if (low_battery_type == LOW_BATTERY) + if (low_battery_type == LOW_BATTERY) { + *active_noti = "BatteryLowActNotiOn"; *event_noti = "BatteryLowNotiOn"; - else if (low_battery_type == CRITICAL_BATTERY) + } else if (low_battery_type == CRITICAL_BATTERY) { + *active_noti = "BatteryCriticalActNotiOn"; *event_noti = "BatteryCriticalNotiOn"; -#else - if (low_battery_type == LOW_BATTERY) - *event_noti = NULL; - else if (low_battery_type == CRITICAL_BATTERY) - *event_noti = NULL; -#endif + } ret = 0; } else if (!strncmp(battery.power_source_s, POWER_SOURCE_AC, len) || !strncmp(battery.power_source_s, POWER_SOURCE_WIRELESS, len)) { if (low_battery_type == LOW_BATTERY) { - *actvie_noti = "BatteryLowActNotiChgOn"; + *active_noti = "BatteryLowActNotiChgOn"; *event_noti = NULL; } else if (low_battery_type == CRITICAL_BATTERY) { - *actvie_noti = "BatteryCriticalActNotiChgOn"; + *active_noti = "BatteryCriticalActNotiChgOn"; *event_noti = NULL; } } else if (!strncmp(battery.power_source_s, POWER_SOURCE_USB, len)) { if (low_battery_type == LOW_BATTERY) { - *actvie_noti = "BatteryLowActNotiUsbOn"; + *active_noti = "BatteryLowActNotiUsbOn"; *event_noti = NULL; } else if (low_battery_type == CRITICAL_BATTERY) { - *actvie_noti = "BatteryCriticalActNotiUsbOn"; + *active_noti = "BatteryCriticalActNotiUsbOn"; *event_noti = NULL; } } else { _E("Invalid power resource type(%s)", battery.power_source_s); - *actvie_noti = NULL; + *active_noti = NULL; *event_noti = NULL; } - _D("actvie_noti=%s event_noti=%s", *actvie_noti, *event_noti); + _D("actvie_noti=%s event_noti=%s", *active_noti, *event_noti); return ret; } @@ -389,45 +381,43 @@ direct_launch: if (lowbat_popup_option == LOWBAT_OPT_CHECK || lowbat_popup_option == LOWBAT_OPT_WARNING) { - if (event_noti) { - if (event_noti_on > 0) { - ret = remove_notification("BatteryLowCriticalNotiOff", event_noti_on); - if (ret < 0) - _E("Failed to remove event_noti : %d", ret); - else - event_noti_on = -1; - } - - if (!power_source) { - ret = add_notification(event_noti, NULL, NULL); - if (ret < 0) - _E("Failed to launch event_noti : %d", ret); - else - event_noti_on = ret; - } + + if (power_source) { + _D("active_noti = %d, event_noti = %d", active_noti_num, event_noti_num); + return 0; } - if (active_noti) { - if (active_noti_on > 0) { - ret = remove_notification("BatteryLowCriticalNotiOff", active_noti_on); - if (ret < 0) - _E("Failed to launch remove active_noti : %d", ret); - else - active_noti_on = -1; - } - - if (!power_source) { - snprintf(temp, sizeof(temp), "%d", cur_bat_capacity); - ret = add_notification(active_noti, "s", temp); - } else - ret = add_notification(active_noti, NULL, NULL); + if (event_noti_num > 0) { + ret = remove_notification("BatteryLowCriticalNotiOff", event_noti_num); + if (ret < 0) + _E("Failed to remove event_noti : %d", ret); + else + event_noti_num = -1; + } + + ret = add_notification(event_noti, NULL, NULL); + if (ret < 0) + _E("Failed to launch event_noti : %d", ret); + else + event_noti_num = ret; + if (active_noti_num > 0) { + ret = remove_notification("BatteryLowCriticalNotiOff", active_noti_num); if (ret < 0) - _E("Failed to launch active noti : %d", ret); + _E("Failed to launch remove active_noti : %d", ret); else - active_noti_on = ret; - return ret; + active_noti_num = -1; } + + snprintf(temp, sizeof(temp), "%d", cur_bat_capacity); + ret = add_notification(active_noti, "s", temp); + if (ret < 0) + _E("Failed to launch active noti : %d", ret); + else + active_noti_num = ret; + + _D("active_noti = %d, event_noti = %d", active_noti_num, event_noti_num); + return 0; } else return launch_system_app(APP_DEFAULT, 2, APP_KEY_TYPE, value); @@ -541,19 +531,19 @@ void clear_noti_if_needed(const char *old_string, const char *new_string) if (old_string == new_string) return; - if (event_noti_on > 0) { - ret = remove_notification("BatteryLowCriticalNotiOff", event_noti_on); + if (event_noti_num > 0) { + ret = remove_notification("BatteryLowCriticalNotiOff", event_noti_num); if (ret < 0) _E("Failed to launch remove_event_noti : %d", ret); else - event_noti_on = -1; + event_noti_num = -1; } - if (active_noti_on > 0) { - ret = remove_notification("BatteryLowCriticalNotiOff", active_noti_on); + if (active_noti_num > 0) { + ret = remove_notification("BatteryLowCriticalNotiOff", active_noti_num); if (ret < 0) _E("Failed to launch remove_active_noti : %d", ret); - active_noti_on = -1; + active_noti_num = -1; } } @@ -574,7 +564,8 @@ static void battery_level_send_system_event(int bat_percent) else str = EVT_VAL_BATTERY_LEVEL_EMPTY; - clear_noti_if_needed(prev, str); + if (str == EVT_VAL_BATTERY_LEVEL_FULL || str == EVT_VAL_BATTERY_LEVEL_HIGH) + clear_noti_if_needed(prev, str); if (prev == str) return; -- 2.7.4 From 4b2194b09f4fc73faf6a059d58efbd14014e0cc7 Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Tue, 1 Aug 2017 15:55:25 +0900 Subject: [PATCH 09/16] dbus: clean up dbus policy Change-Id: I0f798e7f33eff857914a14691ba01c7cf9bd26fe Signed-off-by: sanghyeok.oh --- scripts/deviced.conf | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/scripts/deviced.conf b/scripts/deviced.conf index b7c7ff7..81086b6 100644 --- a/scripts/deviced.conf +++ b/scripts/deviced.conf @@ -1,25 +1,7 @@ - - - - - - - - - - - - - -- 2.7.4 From f532db9827f45b5209be1870a5ff253c69843f8e Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Wed, 14 Feb 2018 13:07:32 +0900 Subject: [PATCH 10/16] tzip: change dbus requests (Mount/Unmount/IsUmounted) to sync Signed-off-by: INSUN PYO Change-Id: I802b255d646e24752e5869d97a30e7f5c8a1cee8 --- src/tzip/tzip-utility.h | 2 ++ src/tzip/tzip.c | 79 +++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 68 insertions(+), 13 deletions(-) diff --git a/src/tzip/tzip-utility.h b/src/tzip/tzip-utility.h index 80f0159..89b986c 100644 --- a/src/tzip/tzip-utility.h +++ b/src/tzip/tzip-utility.h @@ -21,6 +21,7 @@ #include #include +#include #define TZIP_ROOT_PATH "/run/tzip" @@ -79,6 +80,7 @@ struct tzip_msg_data { char *zippath; char *mountpath; char *smack; + GDBusMethodInvocation *invocation; }; int get_path_prop(const char *path, struct stat *stbuf); diff --git a/src/tzip/tzip.c b/src/tzip/tzip.c index b55de62..ec2c226 100644 --- a/src/tzip/tzip.c +++ b/src/tzip/tzip.c @@ -493,6 +493,11 @@ static void free_tzip_msg_data(struct tzip_msg_data *msg) } } +#define TZIP_MSGTYPE_STR(type) \ + type == 'm' ? "Mount" : \ + type == 'u' ? "Unmount" : \ + type == 'i' ? "IsMount" : "Unknown Command" + static void *tzip_mount_thread(void *arg) { struct tzip_msg_data *msgdata; @@ -508,15 +513,35 @@ static void *tzip_mount_thread(void *arg) msgdata = (struct tzip_msg_data *)g_async_queue_pop(async_queue); assert(msgdata); - if (msgdata->type == 'm') + switch (msgdata->type) { + case 'm': ret = tzip_mount_zipfs(msgdata->zippath, msgdata->mountpath, msgdata->smack); - else if (msgdata->type == 'u') + break; + + case 'u': ret = tzip_unmount_zipfs(msgdata->mountpath); + break; - free_tzip_msg_data(msgdata); + case 'i': + ret = tzip_is_mounted(msgdata->mountpath); + break; + + default: + ret = -EINVAL; + break; + } - if (ret) - _E("Failed to process mount/unmount request"); + if (ret < 0) + _E("Failed %s operation: %s, %d", TZIP_MSGTYPE_STR(msgdata->type), msgdata->mountpath, ret); + else + _D("Successful %s operation: %s", TZIP_MSGTYPE_STR(msgdata->type), msgdata->mountpath); + + if (msgdata->invocation) { + /* g_object_unref(msgdata->invocation) is called within this function */ + g_dbus_method_invocation_return_value(msgdata->invocation, g_variant_new("(i)", ret)); + } + + free_tzip_msg_data(msgdata); } /* dead code, added just to satisfy compiler */ @@ -704,7 +729,7 @@ static int tzip_is_mounted(const char *mount_point) tzip_lock(); if (!get_hashmap()) { _E("tzip init is not done yet"); - ret = 0; + ret = -EOWNERDEAD; goto out_unlock; } @@ -788,6 +813,7 @@ static GVariant *dbus_request_mount_tzip(GDBusConnection *conn, msgdata->smack = strdup(smack); msgdata->zippath = strdup(zippath); msgdata->mountpath = strdup(mountpath); + msgdata->invocation = invocation; if (!msgdata->smack || !msgdata->zippath || !msgdata->mountpath) { _E("Malloc failed"); ret = -ENOMEM; @@ -798,10 +824,12 @@ static GVariant *dbus_request_mount_tzip(GDBusConnection *conn, ret = 0; out: - if (ret < 0) + if (ret < 0) { free_tzip_msg_data(msgdata); + return g_variant_new("(i)", ret); + } - return g_variant_new("(i)", ret); + return NULL; } static GVariant *dbus_request_unmount_tzip(GDBusConnection *conn, @@ -850,6 +878,7 @@ static GVariant *dbus_request_unmount_tzip(GDBusConnection *conn, msgdata->type = 'u'; msgdata->mountpath = strdup(mountpath); + msgdata->invocation = invocation; if (!msgdata->mountpath) { _E("Malloc failed"); ret = -ENOMEM; @@ -860,10 +889,12 @@ static GVariant *dbus_request_unmount_tzip(GDBusConnection *conn, ret = 0; out: - if (ret < 0) + if (ret < 0) { free_tzip_msg_data(msgdata); + return g_variant_new("(i)", ret); + } - return g_variant_new("(i)", ret); + return NULL; } static GVariant *dbus_request_ismounted_tzip(GDBusConnection *conn, @@ -872,6 +903,7 @@ static GVariant *dbus_request_ismounted_tzip(GDBusConnection *conn, { int ret; char *mountpath; + struct tzip_msg_data *msgdata = NULL; tzip_server_init(); if (g_atomic_int_get(&stop_or_error) != TZIP_RUNNING_STATE) { @@ -894,10 +926,31 @@ static GVariant *dbus_request_ismounted_tzip(GDBusConnection *conn, goto out; } - ret = tzip_is_mounted(mountpath); + msgdata = calloc(1, sizeof(struct tzip_msg_data)); + if (!msgdata) { + _E("Malloc failed"); + ret = -ENOMEM; + goto out; + } + + msgdata->type = 'i'; + msgdata->mountpath = strdup(mountpath); + msgdata->invocation = invocation; + if (!msgdata->mountpath) { + _E("Malloc failed"); + ret = -ENOMEM; + goto out; + } + g_async_queue_push(async_queue, (gpointer)msgdata); + ret = 0; out: - return g_variant_new("(i)", ret); + if (ret < 0) { + free_tzip_msg_data(msgdata); + return g_variant_new("(i)", ret); + } + + return NULL; } static const dbus_method_s dbus_methods[] = { @@ -916,7 +969,7 @@ static const dbus_interface_u dbus_interface = { static int booting_done(void *data) { - /* To reduce the latency of the first Tzip operation, you can apply this optimization. + /* To reduce the latency of the first Tzip operation, you can apply this optimization. tzip_server_init(); */ return 0; } -- 2.7.4 From e67cd4c58a210c7cd64ac97ab06810276cd11a5a Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Mon, 19 Feb 2018 15:09:23 +0900 Subject: [PATCH 11/16] tzip: fix memory leak g_hash_table_inter_init() returns an iterator that should not be modified. Links - https://developer.gnome.org/glib/stable/glib-Hash-Tables.html#g-hash-table-iter-init "Modifying the hash table after calling this function invalidates the returned iterator." - https://developer.gnome.org/glib/stable/glib-Hash-Tables.html#g-hash-table-iter-remove Change-Id: I606d3309119c6911f8b3a8a9877b6f2ac5af5784 Signed-off-by: INSUN PYO --- src/tzip/tzip-utility.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/tzip/tzip-utility.c b/src/tzip/tzip-utility.c index c50c149..45e2948 100644 --- a/src/tzip/tzip-utility.c +++ b/src/tzip/tzip-utility.c @@ -252,8 +252,9 @@ static int add_dir_info(struct tzip_mount_entry *entry, const char *parent_dir, return -ENOMEM; } snprintf(dinfo->name, len, "%s", parent_dir); - g_hash_table_insert(entry->dir_hash, dinfo->name, dinfo); + fileinfo_to_stat(NULL, &dinfo->stat, S_IFDIR); + g_hash_table_insert(entry->dir_hash, dinfo->name, dinfo); } finfo = (struct tzip_file_info *)g_hash_table_lookup( @@ -277,7 +278,6 @@ static int add_dir_info(struct tzip_mount_entry *entry, const char *parent_dir, strncpy(finfo->name, filename, len); fileinfo_to_stat(file_info, &finfo->stat, mode); - g_hash_table_insert(dinfo->file_hash, finfo->name, finfo); } @@ -393,7 +393,6 @@ int add_mount_entry(const char *zip_path, const char *mount_path) ret = -ENOMEM; goto out; } - strncpy(entry->zip_path, zip_path, len); g_hash_table_insert(hashmap, entry->path, entry); @@ -578,12 +577,12 @@ static void free_mount_node(struct tzip_mount_entry *entry) g_hash_table_iter_init(&f_iter, dinfo->file_hash); while (g_hash_table_iter_next(&f_iter, &fkey, &fval)) { finfo = (struct tzip_file_info *)fval; - g_hash_table_remove(dinfo->file_hash, fkey); + g_hash_table_iter_remove(&f_iter); free(finfo->name); free(finfo); } - g_hash_table_remove(entry->dir_hash, dkey); + g_hash_table_iter_remove(&d_iter); free(dinfo->name); if (dinfo->file_hash) g_hash_table_destroy(dinfo->file_hash); -- 2.7.4 From 812b6dcb8a8f9d23f7f8f321ec8ec8f23070376e Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Tue, 20 Feb 2018 10:02:04 +0900 Subject: [PATCH 12/16] tzip: fix pthread_cond_wait/pthread_cond_signal wrong usage bug between tzip_thread and tzip_mount_thread =============== tzip_mount_thread is blocked here ================================ Thread 5 (Thread 0xb33ed1f0 (LWP 6078)): 0 0xb69726f4 in __pthread_cond_wait (cond=cond@entry=0x7f67e0d0 , mutex=mutex@entry=0x7f67e0b8 ) at pthread_cond_wait.c:186 1 0x7f62f2ba in tzip_mount_thread (arg=) at /usr/src/debug/deviced-5.0.0/src/tzip/tzip.c:508 2 0xb696bf04 in start_thread (arg=0xb33ed1f0) at pthread_create.c:335 3 0xb68fa338 in ?? () at ../sysdeps/unix/sysv/linux/arm/clone.S:86 from /lib/libc.so.6 Backtrace stopped: previous frame identical to this frame (corrupt stack?) ================================================================================== Signed-off-by: INSUN PYO Change-Id: Ia4fb0c6de2c22084abef4ba84ee8bd1c77b10933 --- src/tzip/tzip.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tzip/tzip.c b/src/tzip/tzip.c index ec2c226..03af53d 100644 --- a/src/tzip/tzip.c +++ b/src/tzip/tzip.c @@ -56,6 +56,8 @@ static struct fuse *fuse_handle; static struct fuse_chan *channel; static GAsyncQueue *async_queue; static gint stop_or_error = TZIP_RUNNING_STATE; + +static int thread_ready; static pthread_cond_t thread_cond = PTHREAD_COND_INITIALIZER; static pthread_mutex_t thread_cond_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -446,6 +448,7 @@ static void *tzip_thread(void *arg) /* notify to tzip_mount_thread */ pthread_mutex_lock(&thread_cond_mutex); + thread_ready = 1; pthread_cond_signal(&thread_cond); pthread_mutex_unlock(&thread_cond_mutex); @@ -471,6 +474,7 @@ out: /* notify to tzip_mount_thread */ pthread_mutex_lock(&thread_cond_mutex); + thread_ready = 1; pthread_cond_signal(&thread_cond); pthread_mutex_unlock(&thread_cond_mutex); @@ -505,7 +509,9 @@ static void *tzip_mount_thread(void *arg) /* wait for tzip_thread to be ready*/ pthread_mutex_lock(&thread_cond_mutex); - pthread_cond_wait(&thread_cond, &thread_cond_mutex); + if (!thread_ready) + pthread_cond_wait(&thread_cond, &thread_cond_mutex); + assert(thread_ready); /* Never happend */ pthread_mutex_unlock(&thread_cond_mutex); while (1) { -- 2.7.4 From b8b1b6713e39bbb82b34e9262d2753e88b41bd3f Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Mon, 19 Feb 2018 17:50:47 +0900 Subject: [PATCH 13/16] tzip: Fixed the problem that mount node information is left in /run/.deviced when tzip umount is done. When deviced restarts, save the mount information in the /run/.deviced file to recover the existing mounts. However, there was a bug in umount that the node is not removed in /run/.deviced. Signed-off-by: INSUN PYO Change-Id: I2a78e3accf4146db1dedf3d711190de54b5f3664 --- src/tzip/tzip-utility.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ src/tzip/tzip-utility.h | 2 ++ src/tzip/tzip.c | 3 +++ 3 files changed, 70 insertions(+) diff --git a/src/tzip/tzip-utility.c b/src/tzip/tzip-utility.c index 45e2948..bfbd3b9 100644 --- a/src/tzip/tzip-utility.c +++ b/src/tzip/tzip-utility.c @@ -847,6 +847,71 @@ out: return ret; } +int tzip_clear_mount_info(void) +{ + int len; + int ret = 0; + FILE *fp; + char *file_entry = NULL; + gpointer key, value; + GHashTableIter iter; + struct tzip_mount_entry *entry; + + /* no mount entry */ + if (g_hash_table_size(hashmap) == 0) { + ret = unlink(TZIP_INFO_FILE); + if (ret < 0) + _E("unlink fail %s, %d", TZIP_INFO_FILE, errno); + + return ret; + } + + fp = fopen(TZIP_INFO_TMP_FILE, "w"); + if (fp == NULL) { + _E("fopen() Failed!!!"); + return -EIO; + } + + g_hash_table_iter_init(&iter, hashmap); + while (g_hash_table_iter_next(&iter, &key, &value)) { + entry = (struct tzip_mount_entry*)value; + + len = strlen(entry->zip_path) + strlen(entry->path) + 3; + file_entry = (char *)malloc(len); + if (!file_entry) { + _E("Malloc failed"); + ret = -ENOMEM; + goto out; + } + snprintf(file_entry, len, "%s:%s\n", entry->zip_path, entry->path); + + len = strlen(file_entry); + if (fwrite(file_entry, sizeof(char), len, fp) != len) { + _E(" fwrite Failed !!!! "); + free(file_entry); + ret = -EIO; + goto out; + } + + free(file_entry); + } + +out: + fclose(fp); + + if (ret == 0) { + ret = unlink(TZIP_INFO_FILE); + if (ret < 0) + _E("unlink fail %s, %d", TZIP_INFO_FILE, errno); + + ret = rename(TZIP_INFO_TMP_FILE, TZIP_INFO_FILE); + if (ret < 0) + _E("rename fail %s, %s, %d", TZIP_INFO_TMP_FILE, TZIP_INFO_FILE, errno); + } + + return ret; +} + int tzip_remount_zipfs(const char *src_file, const char *mount_point) { int ret = 0; diff --git a/src/tzip/tzip-utility.h b/src/tzip/tzip-utility.h index 89b986c..be8b3c5 100644 --- a/src/tzip/tzip-utility.h +++ b/src/tzip/tzip-utility.h @@ -32,6 +32,7 @@ #define DEFAULT_FILE_MODE 0755 #define TZIP_INFO_FILE "/run/.deviced" +#define TZIP_INFO_TMP_FILE "/run/.deviced.tmpfile" #define TZIP_MSGQ_NAME "/tzipmsgq" @@ -99,6 +100,7 @@ void tzip_unlock(void); GHashTable *hashmap_init(void); GHashTable *get_hashmap(void); +int tzip_clear_mount_info(void); int tzip_store_mount_info(const char* zip_path, const char* mount_path); int tzip_remount_zipfs(const char *src_file, const char *mount_point); diff --git a/src/tzip/tzip.c b/src/tzip/tzip.c index 03af53d..e090719 100644 --- a/src/tzip/tzip.c +++ b/src/tzip/tzip.c @@ -718,6 +718,9 @@ static int tzip_unmount_zipfs(const char *mount_point) _E("unlink failed"); } + if (tzip_clear_mount_info()) + _E("Failed to clear_mount_info %s", mount_point); + out_unlock: tzip_unlock(); free(tzip_path); -- 2.7.4 From 35b93ec4ec1a8b902086490ace1f979d361e2268 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Wed, 14 Feb 2018 16:31:04 +0900 Subject: [PATCH 14/16] Initial work to adopt plugin architecture /plugins directory has been added. Change-Id: Ie1550e2d76fb20fb204134c8c25a04584dd48355 Signed-off-by: Hyotaek Shim Signed-off-by: lokilee73 Signed-off-by: Hyotaek Shim --- CMakeLists.txt | 20 +++--- .../org.tizen.system.deviced.conf | 0 packaging/deviced.spec | 22 ++++++- plugins/CMakeLists.txt | 26 ++++++++ {src => plugins}/display/state-tv.c | 0 src/battery/lowbat-handler.c | 2 +- src/display/core.c | 17 ++++- src/shared/CMakeLists.txt | 3 +- src/shared/plugin.c | 75 ++++++++++++++++++++++ src/shared/plugin.h | 25 ++++++++ 10 files changed, 178 insertions(+), 12 deletions(-) rename scripts/deviced.conf => conf/org.tizen.system.deviced.conf (100%) create mode 100644 plugins/CMakeLists.txt rename {src => plugins}/display/state-tv.c (100%) create mode 100644 src/shared/plugin.c create mode 100755 src/shared/plugin.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ff812b..5603c4b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(deviced C) ######################################################## -# Build options: +# Build options # ######################################################## + SET(CMAKE_VERBOSE_MAKEFILE OFF) IF("${ARCH}" STREQUAL "arm") @@ -17,13 +18,13 @@ ELSEIF("${ARCH_BIT}" STREQUAL "64") ENDIF() ######################################################## -# Deviced Macros +# Macros # ######################################################## MACRO(ADD_SOURCE DIR OUT) FILE(GLOB ALL_SRCS "${DIR}/*.c") FOREACH(SRC ${ALL_SRCS}) - IF(NOT ${SRC} MATCHES "ivi|mobile|wearable|tv") + IF(NOT ${SRC} MATCHES "mobile|wearable|tv") SET(D_SRCS ${D_SRCS} ${SRC}) ENDIF() ENDFOREACH() @@ -50,8 +51,9 @@ MACRO(INSTALL_CONF DIR CONF) ENDMACRO() ######################################################## -# Deviced CMakeLists.txt +# CMakeLists.txt # ######################################################## + SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "${PREFIX}/bin") SET(INCLUDEDIR "${PREFIX}/include/${PROJECT_NAME}") @@ -199,9 +201,10 @@ FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -fPIE") +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIE -rdynamic") SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -lrt") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") SET(CMAKE_EXE_LINKER_FLAGS "-pie") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") @@ -225,7 +228,7 @@ ENDIF() ADD_DEFINITIONS("-DDEBUG") ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-ldl" "-lm" shared) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-lrt -ldl -lm" shared) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/deviced/ DESTINATION include/${PROJECT_NAME} @@ -262,7 +265,7 @@ IF(TIZEN_FEATURE_CPU_MODULE STREQUAL on) INSTALL_CONF(conf cpu) ENDIF() -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/deviced.conf DESTINATION /etc/dbus-1/system.d) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/conf/org.tizen.system.deviced.conf DESTINATION /etc/dbus-1/system.d) CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) @@ -288,3 +291,4 @@ IF(TIZEN_FEATURE_USBHOST_TEST STREQUAL on) ADD_SUBDIRECTORY(src/usb-host-ffs-test-daemon) ENDIF() ADD_SUBDIRECTORY(src/auto-test) +ADD_SUBDIRECTORY(plugins) diff --git a/scripts/deviced.conf b/conf/org.tizen.system.deviced.conf similarity index 100% rename from scripts/deviced.conf rename to conf/org.tizen.system.deviced.conf diff --git a/packaging/deviced.spec b/packaging/deviced.spec index 0630d54..5a11f03 100644 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -101,6 +101,14 @@ BuildArch: noarch %description config-enable-display-timer This package is used for enabling a display timer. +%package plugin-profile-tv +Summary: Plugin libraries for TV profile +Group: System/Management +Requires: %{name} = %{version}-%{release} + +%description plugin-profile-tv +Plugin libraries for TV profile + %prep %setup -q @@ -192,6 +200,12 @@ rm -rf %{_sysconfdir}/deviced/display-profile-wearable.conf cat %{_sysconfdir}/deviced/display-enable-timer.conf >> %{_sysconfdir}/deviced/display.conf rm -rf %{_sysconfdir}/deviced/display-enable-timer.conf +%post plugin-profile-tv +mkdir -p %{_libdir}/deviced +mv %{_libdir}/display-tv.so %{_libdir}/deviced/display.so + +%postun plugin-profile-tv + %files %manifest %{name}.manifest %license LICENSE.Apache-2.0 @@ -204,7 +218,7 @@ rm -rf %{_sysconfdir}/deviced/display-enable-timer.conf %{_unitdir}/sdb-prestart.service %{_unitdir}/basic.target.wants/sdb-prestart.service %endif -%config %{_sysconfdir}/dbus-1/system.d/deviced.conf +%config %{_sysconfdir}/dbus-1/system.d/org.tizen.system.deviced.conf %config %{_sysconfdir}/deviced/cpu.conf %config %{_sysconfdir}/deviced/power.conf %config %{_sysconfdir}/deviced/battery.conf @@ -254,3 +268,9 @@ rm -rf %{_sysconfdir}/deviced/display-enable-timer.conf %manifest deviced.manifest %license LICENSE.Apache-2.0 %config %{_sysconfdir}/deviced/display-enable-timer.conf + +%files plugin-profile-tv +%manifest deviced.manifest +%license LICENSE.Apache-2.0 +%defattr(-,root,root,-) +%{_libdir}/display-tv.so diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt new file mode 100644 index 0000000..90e5132 --- /dev/null +++ b/plugins/CMakeLists.txt @@ -0,0 +1,26 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(libplugin-tv C) + +SET(PLUGIN_TV_SRCS + display/state-tv.c +) + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/core ${CMAKE_SOURCE_DIR}/src/display) + +INCLUDE(FindPkgConfig) +pkg_check_modules(libpkgs REQUIRED + dlog + glib-2.0 + gio-2.0 + gio-unix-2.0) + +FOREACH(flag ${libpkgs_CFLAGS}) + SET(EXTRA_LIB_CFLAGS "${EXTRA_LIB_CFLAGS} ${flag}") +ENDFOREACH(flag) +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_LIB_CFLAGS}") + +ADD_LIBRARY(${PROJECT_NAME} SHARED ${PLUGIN_TV_SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${libpkgs_LDFLAGS}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "") +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME display-tv) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) diff --git a/src/display/state-tv.c b/plugins/display/state-tv.c similarity index 100% rename from src/display/state-tv.c rename to plugins/display/state-tv.c diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index 64e2dd6..be3beaf 100755 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -300,7 +300,7 @@ static int get_lowbat_noti_value(int low_battery_type, char **active_noti, char *active_noti = NULL; *event_noti = NULL; } - _D("actvie_noti=%s event_noti=%s", *active_noti, *event_noti); + _D("active_noti=%s event_noti=%s", *active_noti, *event_noti); return ret; } diff --git a/src/display/core.c b/src/display/core.c index 6f930c8..037a79f 100644 --- a/src/display/core.c +++ b/src/display/core.c @@ -51,6 +51,7 @@ #include "core/list.h" #include "core/common.h" #include "shared/dbus.h" +#include "shared/plugin.h" #include "core/config-parser.h" #include "core/launch.h" #include "extcon/extcon.h" @@ -101,8 +102,8 @@ static int lcd_paneloff_mode = false; static int stay_touchscreen_off = false; static dd_list *lcdon_ops; static bool lcdon_broadcast = true; - static bool touch_blocked = false; +static void *plugin_handle; /* default transition, action fuctions */ static int default_trans(int evt); @@ -2163,6 +2164,16 @@ static void add_timer_for_wm_ready(void) _E("Failed to add wm_ready timeout"); } +static int display_plugin_load() +{ + return load_plugin("display", &plugin_handle); +} + +static int display_plugin_unload() +{ + return unload_plugin(plugin_handle); +} + /** * Power manager Main * @@ -2174,6 +2185,8 @@ static int display_probe(void *data) * if there is no display shared library, * deviced does not provide any method and function of display. */ + display_plugin_load(); + return display_service_load(); } @@ -2290,6 +2303,8 @@ static void display_exit(void *data) { int i = INIT_END; + display_plugin_unload(); + status = DEVICE_OPS_STATUS_STOP; /* Set current state to S_NORMAL */ diff --git a/src/shared/CMakeLists.txt b/src/shared/CMakeLists.txt index 5963347..c274d9c 100644 --- a/src/shared/CMakeLists.txt +++ b/src/shared/CMakeLists.txt @@ -3,6 +3,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) SET(SHARED_SRCS dbus.c deviced-systemd.c + plugin.c ) INCLUDE(FindPkgConfig) @@ -17,5 +18,5 @@ FOREACH(flag ${libshared_CFLAGS}) ENDFOREACH(flag) ADD_LIBRARY(shared STATIC ${SHARED_SRCS}) -TARGET_LINK_LIBRARIES(shared ${libshared_LDFLAGS}) +TARGET_LINK_LIBRARIES(shared ${libshared_LDFLAGS} "-ldl") SET_TARGET_PROPERTIES(shared PROPERTIES COMPILE_FLAGS "-fPIC") diff --git a/src/shared/plugin.c b/src/shared/plugin.c new file mode 100644 index 0000000..b1ec85e --- /dev/null +++ b/src/shared/plugin.c @@ -0,0 +1,75 @@ +/* + * deviced + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include + +#include "common.h" +#include "core/log.h" + +#ifndef LIBPATH +#error LIBPATH is not defined. +#endif +#define MODULE_PATH LIBPATH"/deviced" + +int load_plugin(const char *id, void **h) +{ + char path[PATH_MAX]; + void *handle; + + if (!id || !h) + return -EINVAL; + + /* Find matched module path */ + snprintf(path, sizeof(path), "%s/%s.so", MODULE_PATH, id); + if (access(path, R_OK) != 0) { + _E("there is no %s device", id); + return -ENODEV; + } + + /* Load module */ + handle = dlopen(path, RTLD_LAZY|RTLD_GLOBAL); + //handle = dlopen(path, RTLD_NOW|RTLD_GLOBAL); + if (!handle) { + _E("fail to open module : %s", dlerror()); + goto error; + } + + *h = handle; + + return 0; + +error: + if (handle) + dlclose(handle); + + return -ENOENT; +} + + +int unload_plugin(void *h) +{ + return dlclose(h); +} diff --git a/src/shared/plugin.h b/src/shared/plugin.h new file mode 100755 index 0000000..fefaef4 --- /dev/null +++ b/src/shared/plugin.h @@ -0,0 +1,25 @@ +/* + * deviced + * + * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __DD_PLUGIN_H__ +#define __DD_PLUGIN_H__ + +int load_plugin(const char *id, void **h); +int unload_plugin(void *h); + +#endif /* __DD_PLUGIN_H__ */ -- 2.7.4 From 8dcf9414d639f322bb401f7bce7d8c827aa292e7 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Tue, 20 Feb 2018 15:47:47 +0900 Subject: [PATCH 15/16] Fix a warning Change-Id: I5408b2e98e874d8bf7951ffb69032ae9fa395af7 Signed-off-by: lokilee73 --- src/battery/lowbat-handler.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index be3beaf..4632339 100755 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -553,20 +553,19 @@ static void battery_level_send_system_event(int bat_percent) const char *str; static const char *prev; - if (bat_percent > battery_info.normal) + if (bat_percent > battery_info.normal) { str = EVT_VAL_BATTERY_LEVEL_FULL; - else if (bat_percent > battery_info.warning) + clear_noti_if_needed(prev, str); + } else if (bat_percent > battery_info.warning) { str = EVT_VAL_BATTERY_LEVEL_HIGH; - else if (bat_percent > battery_info.critical) + clear_noti_if_needed(prev, str); + } else if (bat_percent > battery_info.critical) str = EVT_VAL_BATTERY_LEVEL_LOW; else if (bat_percent > battery_info.poweroff) str = EVT_VAL_BATTERY_LEVEL_CRITICAL; else str = EVT_VAL_BATTERY_LEVEL_EMPTY; - if (str == EVT_VAL_BATTERY_LEVEL_FULL || str == EVT_VAL_BATTERY_LEVEL_HIGH) - clear_noti_if_needed(prev, str); - if (prev == str) return; -- 2.7.4 From bd008683e38276ec2c3724441ee9bbd02613be03 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Wed, 21 Feb 2018 17:36:57 +0900 Subject: [PATCH 16/16] Minor fix on CMakeLists.txt of plugins Change-Id: I5a2b1e08fcdddd3ef6d15ad4170fcf755a208729 Signed-off-by: Hyotaek Shim --- CMakeLists.txt | 2 +- plugins/{ => display}/CMakeLists.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename plugins/{ => display}/CMakeLists.txt (94%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5603c4b..007070e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -291,4 +291,4 @@ IF(TIZEN_FEATURE_USBHOST_TEST STREQUAL on) ADD_SUBDIRECTORY(src/usb-host-ffs-test-daemon) ENDIF() ADD_SUBDIRECTORY(src/auto-test) -ADD_SUBDIRECTORY(plugins) +ADD_SUBDIRECTORY(plugins/display) diff --git a/plugins/CMakeLists.txt b/plugins/display/CMakeLists.txt similarity index 94% rename from plugins/CMakeLists.txt rename to plugins/display/CMakeLists.txt index 90e5132..65e95ec 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/display/CMakeLists.txt @@ -1,8 +1,8 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(libplugin-tv C) +PROJECT(display-tv C) SET(PLUGIN_TV_SRCS - display/state-tv.c + state-tv.c ) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/core ${CMAKE_SOURCE_DIR}/src/display) -- 2.7.4