Exclude battery critical-log in case of -DBATTERY_MODULE=off 99/217299/4
authorYoungjae Cho <y0.cho@samsung.com>
Fri, 8 Nov 2019 06:33:26 +0000 (15:33 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Mon, 11 Nov 2019 04:49:58 +0000 (04:49 +0000)
Change-Id: I9adfd7018964fb14b73f1453876ee0fc3d5b78ea
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
CMakeLists.txt
packaging/deviced.spec
src/critical-log/critical-log.c

index 10f7bb8..d47d10f 100644 (file)
@@ -223,7 +223,9 @@ ADD_DEFINITIONS("-DENABLE_PM_LOG")
 IF(ENGINEER_MODE STREQUAL on)
 ADD_DEFINITIONS("-DENGINEER_MODE")
 ENDIF(ENGINEER_MODE STREQUAL on)
-
+IF(BATTERY_MODULE STREQUAL on)
+ADD_DEFINITIONS("-DBATTERY_MODULE")
+ENDIF(ENGINEER_MODULE STREQUAL on)
 IF(USE_ARM)
        ADD_DEFINITIONS("-DTARGET")
 ENDIF()
index 7ebba2c..87b1f68 100644 (file)
@@ -139,6 +139,8 @@ Plugin libraries for IoT devices
 %define engineer_mode off
 %endif
 
+%define battery_module on
+
 %cmake \
        -DTZ_SYS_ETC=%TZ_SYS_ETC \
        -DCMAKE_INSTALL_PREFIX=%{_prefix} \
@@ -146,7 +148,7 @@ Plugin libraries for IoT devices
        -DARCH_BIT=%{ARCH_BIT} \
        -DDPMS=%{DPMS} \
        -DENGINEER_MODE=%{engineer_mode} \
-       -DBATTERY_MODULE=on \
+       -DBATTERY_MODULE=%{battery_module} \
        -DDISPLAY_MODULE=on \
        -DEXTCON_MODULE=on \
        -DIR_MODULE=on \
@@ -244,7 +246,9 @@ mv %{_libdir}/iot-display.so %{_libdir}/deviced/display.so
 %config %{_sysconfdir}/dbus-1/system.d/org.tizen.system.deviced.conf
 %config %{_sysconfdir}/deviced/cpu.conf
 %config %{_sysconfdir}/deviced/power.conf
+%if %{?battery_module} == on
 %config %{_sysconfdir}/deviced/battery.conf
+%endif
 # usbhost_test
 %{_sysconfdir}/deviced/usb-host-test/test_gadget.gs
 %{_bindir}/usb-host-ffs-test-daemon
index 154859a..d826833 100644 (file)
@@ -28,7 +28,9 @@
 #include "core/common.h"
 #include "core/config-parser.h"
 #include "core/device-notifier.h"
+#ifdef BATTERY_MODULE
 #include "battery/power-supply.h"
+#endif
 #include "power/power-handler.h"
 
 #define CLOG_SAVE_FILE  "/var/log/critical-log.log"
@@ -192,6 +194,7 @@ static int clog_execute(void *data)
        localtime_r((time_t *)&tspec.tv_sec, &tm_now);
        strftime(str_time, sizeof(str_time), CLOG_TIME_FORMAT, &tm_now);
        snprintf(str_msec, sizeof(str_msec), ":%03ld|", tspec.tv_nsec / 1000000);
+#ifdef BATTERY_MODULE
        snprintf(str_buff, sizeof(str_buff), "%s%s[%d]%s BAT(P:%s S:%s C:%d M:%d Chg_ON:%d)\n",
                str_time, str_msec, getpid(), input,
                battery.power_source_s,
@@ -199,6 +202,10 @@ static int clog_execute(void *data)
                battery.capacity,
                battery.misc,
                battery.charger_charging);
+#else
+       snprintf(str_buff, sizeof(str_buff), "%s%s[%d]%s\n",
+                       str_time, str_msec, getpid(), input);
+#endif
        _D("%s", str_buff);
        msg->log = strdup(str_buff);
        msg->type = tag->type;
@@ -231,6 +238,7 @@ out:
        return ret;
 }
 
+#ifdef BATTERY_MODULE
 static int clog_battery_health(void *data)
 {
        char clog[CLOG_MSG_MAX] = {0,};
@@ -272,6 +280,7 @@ static int clog_battery_present(void *data)
 
        return clog_execute((void *)clog);
 }
+#endif
 
 static void clog_save_log(void)
 {
@@ -447,8 +456,10 @@ out:
 static void clog_init(void *none)
 {
        register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, clog_booting_done);
+#ifdef BATTERY_MODULE
        register_notifier(DEVICE_NOTIFIER_BATTERY_HEALTH, clog_battery_health);
        register_notifier(DEVICE_NOTIFIER_BATTERY_PRESENT, clog_battery_present);
+#endif
        register_notifier(DEVICE_NOTIFIER_CRITICAL_LOG, clog_common_log);
        register_notifier(DEVICE_NOTIFIER_POWEROFF, clog_power_off);
        if (config_parse(CLOG_CONF_FILE, clog_load_config, NULL) < 0)
@@ -457,8 +468,10 @@ static void clog_init(void *none)
 
 static void clog_exit(void *data)
 {
+#ifdef BATTERY_MODULE
        unregister_notifier(DEVICE_NOTIFIER_BATTERY_HEALTH, clog_battery_health);
        unregister_notifier(DEVICE_NOTIFIER_BATTERY_PRESENT, clog_battery_present);
+#endif
        unregister_notifier(DEVICE_NOTIFIER_CRITICAL_LOG, clog_common_log);
        unregister_notifier(DEVICE_NOTIFIER_POWEROFF, clog_power_off);
        free_clog_data();