summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInkyun Kil <inkyun.kil@samsung.com>2019-08-30 10:58:57 +0900
committerInkyun Kil <inkyun.kil@samsung.com>2019-09-18 18:33:24 +0900
commit7b768f426b3becd204977db1da5a0ccc4d8dca88 (patch)
tree49b36ccee4ff1680adcc5514c5720d09f7614f75
parent03e01d0c8c2befbdf6312610ed3b23441a62de23 (diff)
downloadalarm-manager-7b768f426b3becd204977db1da5a0ccc4d8dca88.tar.gz
alarm-manager-7b768f426b3becd204977db1da5a0ccc4d8dca88.tar.bz2
alarm-manager-7b768f426b3becd204977db1da5a0ccc4d8dca88.zip
Improve logs
Change-Id: I17bc94488338ce9dfa8c45b284a477ce007c112f Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com> Signed-off-by: Jusung Son <jusung07.son@samsung.com>
-rwxr-xr-xalarmmgr_log_dump.sh2
-rw-r--r--include/alarm-internal.h4
-rw-r--r--packaging/alarm-manager.conf2
-rwxr-xr-xpackaging/alarm-manager.spec4
-rw-r--r--server/alarm-manager-dbus.c4
-rw-r--r--server/alarm-manager-util.c113
-rw-r--r--server/alarm-manager-util.h7
-rwxr-xr-x[-rw-r--r--]server/alarm-manager.c284
8 files changed, 202 insertions, 218 deletions
diff --git a/alarmmgr_log_dump.sh b/alarmmgr_log_dump.sh
index 985e5ac..1a8c788 100755
--- a/alarmmgr_log_dump.sh
+++ b/alarmmgr_log_dump.sh
@@ -3,7 +3,7 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin
ALARMMGR_DUMP=$1/alarmmgr
mkdir -p $ALARMMGR_DUMP
-cp -f /run/alarmmgr_log/alarmmgr.log $ALARMMGR_DUMP
+cp -f /var/log/appfw/alarmmgr_log/alarmmgr.log $ALARMMGR_DUMP
alarmmgr_get_all_info
mv -f /tmp/alarmmgr_* $ALARMMGR_DUMP
diff --git a/include/alarm-internal.h b/include/alarm-internal.h
index bc7b174..8744ce3 100644
--- a/include/alarm-internal.h
+++ b/include/alarm-internal.h
@@ -193,8 +193,8 @@ int alarm_manager_alarm_get_info(GVariant *parameters, uid_t uid, alarm_info_t *
int alarm_manager_alarm_get_next_duetime(GVariant *parameters, uid_t uid, time_t *duetime);
int alarm_manager_alarm_get_all_info(uid_t uid, char **db_path);
int alarm_manager_alarm_set_rtc_time(GVariant *parameters);
-int alarm_manager_alarm_set_time(GVariant* parameters);
-int alarm_manager_alarm_set_time_with_propagation_delay(GVariant* parameters);
+int alarm_manager_alarm_set_time(GVariant* parameters, pid_t pid);
+int alarm_manager_alarm_set_time_with_propagation_delay(GVariant* parameters, pid_t pid);
int alarm_manager_alarm_set_timezone(GVariant* parameters);
int alarm_manager_alarm_set_global(GVariant *parameters, uid_t uid);
int alarm_manager_alarm_get_global(GVariant *parameters, gboolean *global);
diff --git a/packaging/alarm-manager.conf b/packaging/alarm-manager.conf
index e4d6a58..5d387a9 100644
--- a/packaging/alarm-manager.conf
+++ b/packaging/alarm-manager.conf
@@ -1,2 +1,2 @@
d /run/alarm_agent 0777 root users -
-d /run/alarmmgr_log 0775 app_fw app_fw -
+d /var/log/appfw/alarmmgr_log 0775 app_fw app_fw -
diff --git a/packaging/alarm-manager.spec b/packaging/alarm-manager.spec
index 89784e9..beb1be2 100755
--- a/packaging/alarm-manager.spec
+++ b/packaging/alarm-manager.spec
@@ -51,6 +51,8 @@ BuildRequires: pkgconfig(gmock)
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
+%define logdir /var/log/appfw/alarmmgr_log
+
%description
Alarm Server and devel libraries
@@ -187,6 +189,7 @@ mkdir -p %{buildroot}%{_tmpfilesdir}
install -m 0644 %SOURCE4 %{buildroot}%{_tmpfilesdir}/alarm-manager.conf
mkdir -p %{buildroot}%{_libdir}/udev/rules.d
install -m 0644 %SOURCE5 %{buildroot}%{_libdir}/udev/rules.d
+mkdir -p %{buildroot}%{logdir}
%if 0%{?gcov:1}
mkdir -p %{buildroot}%{_datadir}/gcov/obj
@@ -240,6 +243,7 @@ fi
%license LICENSE
%if 0%{?appfw_feature_alarm_manager_module_log}
%attr(0755,root,root) %{TZ_SYS_ETC}/dump.d/module.d/alarmmgr_log_dump.sh
+%attr(0755,app_fw,app_fw) %{logdir}
%endif
%files -n libalarm
diff --git a/server/alarm-manager-dbus.c b/server/alarm-manager-dbus.c
index 8e0209d..0da088a 100644
--- a/server/alarm-manager-dbus.c
+++ b/server/alarm-manager-dbus.c
@@ -591,10 +591,10 @@ static void handle_method_call(GDBusConnection *connection,
ret = alarm_manager_alarm_set_rtc_time(parameters);
g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", ret));
} else if (g_strcmp0(method_name, "alarm_set_time") == 0) {
- ret = alarm_manager_alarm_set_time(parameters);
+ ret = alarm_manager_alarm_set_time(parameters, pid);
g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", ret));
} else if (g_strcmp0(method_name, "alarm_set_time_with_propagation_delay") == 0) {
- ret = alarm_manager_alarm_set_time_with_propagation_delay(parameters);
+ ret = alarm_manager_alarm_set_time_with_propagation_delay(parameters, pid);
g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", ret));
} else if (g_strcmp0(method_name, "alarm_set_timezone") == 0) {
ret = alarm_manager_alarm_set_timezone(parameters);
diff --git a/server/alarm-manager-util.c b/server/alarm-manager-util.c
index 03e6272..55a078a 100644
--- a/server/alarm-manager-util.c
+++ b/server/alarm-manager-util.c
@@ -15,9 +15,12 @@
*/
#define _GNU_SOURCE
+#include <fcntl.h>
#include <system_info.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/stat.h>
#include <aul.h>
#include <cert-svc/ccert.h>
@@ -29,6 +32,13 @@
#include "alarm-manager-util.h"
+#define ALARMMGR_LOG_BUFFER_SIZE 10000
+#define ALARMMGR_LOG_BUFFER_STRING_SIZE 400
+#define ALARMMGR_LOG_DIR_PATH "/var/log/appfw/alarmmgr_log/"
+#define ALARMMGR_LOG_FILE_PATH "/var/log/appfw/alarmmgr_log/alarmmgr.log"
+static int log_index = 0;
+static int log_fd = 0;
+
static int __bg_category_func(const char *name, void *user_data)
{
bg_category_cb_info_t *info = (bg_category_cb_info_t *)user_data;
@@ -420,3 +430,106 @@ out:
return _return;
}
+
+void _initialize_module_log(void)
+{
+#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
+ char buf[1024];
+
+ if (access(ALARMMGR_LOG_DIR_PATH, F_OK)) {
+ LOGE("Not exist(%s)", ALARMMGR_LOG_DIR_PATH);
+
+ if (mkdir(ALARMMGR_LOG_DIR_PATH, (S_IRUSR | S_IWUSR | S_IXUSR |
+ S_IRGRP | S_IWGRP | S_IXGRP))) {
+ LOGE("Failed to create directory(%s). errno(%d)",
+ ALARMMGR_LOG_DIR_PATH, errno);
+ return;
+ }
+ }
+
+ log_fd = open(ALARMMGR_LOG_FILE_PATH, O_CREAT | O_WRONLY, 0644);
+ if (log_fd == -1) {
+ LOGE("Opening the file for alarmmgr log is failed. err: %s", strerror_r(errno, buf, sizeof(buf)));
+ return;
+ }
+
+ int offset = lseek(log_fd, 0, SEEK_END);
+ if (offset != 0) {
+ log_index = (int)(offset / ALARMMGR_LOG_BUFFER_STRING_SIZE);
+ if (log_index >= ALARMMGR_LOG_BUFFER_SIZE) {
+ log_index = 0;
+ lseek(log_fd, 0, SEEK_SET);
+ }
+ }
+#endif /* _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG */
+ return;
+}
+
+void _save_module_log(const char *tag, const char *message)
+{
+#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
+ char buffer[ALARMMGR_LOG_BUFFER_STRING_SIZE] = {0,};
+ time_t now;
+ char buf[1024];
+ char *time_str;
+
+ if (log_fd == -1) {
+ LOGE("The file is not ready.");
+ return;
+ }
+
+ if (log_index != 0)
+ lseek(log_fd, 0, SEEK_CUR);
+ else
+ lseek(log_fd, 0, SEEK_SET);
+
+ time(&now);
+ time_str = ctime(&now);
+ if (time_str)
+ time_str[strlen(time_str) - 1] = '\0'; /* to avoid new line */
+
+ snprintf(buffer, ALARMMGR_LOG_BUFFER_STRING_SIZE, "[%-6d]%s\t%s\t : %ld %s\n", log_index, tag, message, now, time_str);
+
+ SECURE_LOGW("%s", buffer);
+ int ret = write(log_fd, buffer, strlen(buffer));
+ if (ret < 0) {
+ LOGE("Writing the alarmmgr log is failed. err: %s", strerror_r(errno, buf, sizeof(buf)));
+ return;
+ }
+
+ if (++log_index >= ALARMMGR_LOG_BUFFER_SIZE)
+ log_index = 0;
+#endif /* _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG */
+ return;
+}
+
+void _save_alarm_info_log(const char *tag, __alarm_info_t *info)
+{
+#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
+ char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
+ char *due_time_str = ctime(&(info->due_time));
+ if (due_time_str)
+ due_time_str[strlen(due_time_str) - 1] = '\0'; /* to avoid new line */
+
+ char *timebuf = strdup(ctime(&info->due_time));
+ if (timebuf)
+ timebuf[strlen(timebuf) - 1] = '\0'; /* to avoid new line */
+
+ snprintf(log_message, sizeof(log_message),
+ "alarmID: %d, uid: %d, caller : %s -> callee : %s, "
+ "dst_name %s, dst_mod %s, "
+ "type 0x%x, mode %d, "
+ "interval:%ld, duetime: %ld %s",
+ info->alarm_id, info->uid, info->app_unique_name, info->callee_pkgid,
+ info->dst_service_name, info->dst_service_name_mod,
+ info->alarm_info.alarm_type, info->alarm_info.mode.repeat,
+ info->alarm_info.mode.u_interval.interval, info->due_time, timebuf);
+
+ if (timebuf)
+ free(timebuf);
+
+ _save_module_log(tag, log_message);
+#endif /* _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG */
+ return;
+}
+
diff --git a/server/alarm-manager-util.h b/server/alarm-manager-util.h
index 5586a18..1ff1f8e 100644
--- a/server/alarm-manager-util.h
+++ b/server/alarm-manager-util.h
@@ -27,6 +27,9 @@ extern "C" {
#include "alarm-internal.h"
+#define ALARMMGR_LOG_TAG_SIZE 20
+#define ALARMMGR_LOG_MESSAGE_SIZE 330
+
profile_t _get_profile();
int _cynara_check(GDBusMethodInvocation *invocation, const char* privilege,
pid_t pid);
@@ -39,6 +42,10 @@ bool _permit_by_config(pkgmgrinfo_appinfo_h handle, uid_t uid);
bool _is_permitted(const char *app_id, int alarm_type, uid_t uid);
int _get_pid_from_appid(const char *app_id, uid_t uid);
+void _initialize_module_log(void);
+void _save_module_log(const char *tag, const char *messgae);
+void _save_alarm_info_log(const char *tag, __alarm_info_t *info);
+
#ifdef __cplusplus
}
#endif
diff --git a/server/alarm-manager.c b/server/alarm-manager.c
index 1f68d6c..9dd3baa 100644..100755
--- a/server/alarm-manager.c
+++ b/server/alarm-manager.c
@@ -63,15 +63,6 @@
#define _APPFW_FEATURE_WAKEUP_USING_RTC (_get_profile() != PROFILE_TV)
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
-#define ALARMMGR_LOG_BUFFER_SIZE 10000
-#define ALARMMGR_LOG_BUFFER_STRING_SIZE 200
-#define ALARMMGR_LOG_TAG_SIZE 20
-#define ALARMMGR_LOG_MESSAGE_SIZE 120
-#define ALARMMGR_LOG_FILE_PATH "/run/alarmmgr_log/alarmmgr.log"
-static int log_index = 0;
-static int log_fd = 0;
-#endif
static const char default_rtc[] = "/dev/rtc";
static int gfd = -1;
@@ -128,11 +119,6 @@ static void __initialize_noti();
void _release_alarm_info_t(__alarm_info_t *entry);
static notification_h __get_notification(guchar *data, int datalen);
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
-static void __initialize_module_log(void);
-static void __save_module_log(const char *tag, const char *messgae);
-#endif
-
static bool __get_caller_unique_name(int pid, char *unique_name, int size, bool *is_app, uid_t uid)
{
char caller_appid[MAX_APP_ID_LEN] = {0,};
@@ -259,9 +245,7 @@ void _rtc_set()
if (_APPFW_FEATURE_WAKEUP_USING_RTC) {
const char *rtc = default_rtc;
struct tm due_tm;
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
-#endif
#ifdef _SIMUL /* RTC does not work in simulator. */
LOGE("because it is simulator's mode, we don't set RTC.");
return;
@@ -278,13 +262,11 @@ void _rtc_set()
/* Read the RTC time/date */
int retval = 0;
char buf[1024];
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char *timebuf = ctime(&alarm_context.c_due_time);
if (timebuf) {
timebuf[strlen(timebuf) - 1] = '\0'; /* to avoid new line */
snprintf(log_message, sizeof(log_message), "wakeup time: %d, %s", (int)alarm_context.c_due_time, timebuf);
}
-#endif
LOGD("alarm_context.c_due_time is %d.", (int)alarm_context.c_due_time);
@@ -304,9 +286,7 @@ void _rtc_set()
LOGE("Alarm IRQs is not supported.");
LOGE("RTC_WKALM_SET disabled ioctl is failed. errno = %s", strerror_r(errno, buf, sizeof(buf)));
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- __save_module_log("FAIL: SET RTC", log_message);
-#endif
+ _save_module_log("FAIL: SET RTC", log_message);
return;
}
LOGD("[alarm-server]RTC_WKALM_SET disabled ioctl is successfully done.");
@@ -331,15 +311,11 @@ void _rtc_set()
LOGE("Alarm IRQs is not supported.");
LOGE("RTC ALARM_SET ioctl is failed. errno = %s", strerror_r(errno, buf, sizeof(buf)));
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- __save_module_log("FAIL: SET RTC", log_message);
-#endif
+ _save_module_log("FAIL: SET RTC", log_message);
return;
}
LOGD("[alarm-server]RTC ALARM_SET ioctl is successfully done.");
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- __save_module_log("SET RTC", log_message);
-#endif
+ _save_module_log("SET RTC", log_message);
} else {
LOGE("[alarm-server]alarm_context.c_due_time is"
"less than 10 sec. RTC alarm does not need to be set");
@@ -375,17 +351,15 @@ static bool __set_time(time_t _time)
const char *rtc0 = default_rtc;
struct rtc_time _rtc_time;
char buf[1024];
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
char *timebuf = ctime(&_time);
if (timebuf) {
timebuf[strlen(timebuf) - 1] = '\0'; /* to avoid new line */
- snprintf(log_message, sizeof(log_message), "RTC & OS =%d, %s", (int)_time, timebuf);
+ snprintf(log_message, sizeof(log_message), "RTC & OS =%ld, %s",
+ _time, timebuf);
}
-#endif
-
if (gfd < 0) {
gfd = open(rtc0, O_RDWR);
if (gfd < 0) {
@@ -408,16 +382,12 @@ static bool __set_time(time_t _time)
ret = ioctl(gfd, RTC_SET_TIME, &_rtc_time);
if (ret == -1) {
LOGE("ALARM_SET_RTC ioctl is failed. errno = %s", strerror_r(errno, buf, sizeof(buf)));
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
strncpy(log_tag, "FAIL: SET RTC", sizeof(log_tag) - 1);
- __save_module_log(log_tag, log_message);
-#endif
+ _save_module_log(log_tag, log_message);
} else {
LOGD("ALARM_SET_RTC ioctl is succeed. [%d]", (int)_time);
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- strncpy(log_tag, "SET RTC", sizeof(log_tag) - 1);
- __save_module_log(log_tag, log_message);
-#endif
+ strncpy(log_tag, "SET RTC START", sizeof(log_tag) - 1);
+ _save_module_log(log_tag, log_message);
return true;
}
} else {
@@ -888,6 +858,8 @@ static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id
_alarm_set_next_duetime(__alarm_info);
__alarm_add_to_list(__alarm_info);
+ _save_alarm_info_log("CREATE SVC", __alarm_info);
+
if (__alarm_info->due_time == 0) {
LOGE("[alarm-server]:Create a new alarm: "
"__alarm_info->due_time is 0, alarm(%d) \n", *alarm_id);
@@ -1002,6 +974,8 @@ static bool __alarm_create(alarm_info_t *alarm_info, alarm_id_t *alarm_id, uid_t
_alarm_set_next_duetime(__alarm_info);
__alarm_add_to_list(__alarm_info);
+ _save_alarm_info_log("CREATE", __alarm_info);
+
if (__alarm_info->due_time == 0) {
LOGE("[alarm-server]:Create a new alarm: due_time is 0, alarm(%d).", *alarm_id);
return true;
@@ -1157,6 +1131,8 @@ static bool __alarm_create_noti(alarm_info_t *alarm_info, alarm_id_t *alarm_id,
_alarm_set_next_duetime(__alarm_info);
__alarm_add_to_list(__alarm_info);
+ _save_alarm_info_log("CREATE NOTI", __alarm_info);
+
if (__alarm_info->due_time == 0) {
LOGE("[alarm-server]:Create a new alarm: due_time is 0, alarm(%d).", *alarm_id);
return true;
@@ -1220,6 +1196,8 @@ static bool __alarm_update(uid_t uid, alarm_id_t alarm_id,
_alarm_set_next_duetime(__alarm_info);
+ _save_alarm_info_log("UPDATE", __alarm_info);
+
result = _remove_from_scheduled_alarm_list(uid, alarm_id);
if (result == true && g_slist_length(g_scheduled_alarm_list) == 0) {
/*there is no scheduled alarm */
@@ -1469,9 +1447,6 @@ void _alarm_expired()
bundle *kb;
char *appid = NULL;
uid_t target_uid;
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
-#endif
LOGD("[alarm-server]: Enter");
@@ -1524,6 +1499,9 @@ void _alarm_expired()
LOGE("Failed to get value of VCONFKEY_ALARM_EXPIRE_MODE");
LOGD("Value of alarm_expire_mode [%d]", expire_mode);
+ SECURE_LOGW("alarm_expired : from [uid : %d, pid : %d, pkgid : %s, "
+ "unique_name : %s]", __alarm_info->uid, app_pid,
+ __alarm_info->caller_pkgid, __alarm_info->app_unique_name);
if (_compare_api_version(&result, app_pid, __alarm_info->uid) < 0) {
LOGE("Unable to check api version\n");
@@ -1677,15 +1655,14 @@ void _alarm_expired()
LOGD("alarm_id[%d] is expired.", alarm_id);
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- snprintf(log_message, sizeof(log_message), "alarmID: %d, duetime: %ld", alarm_id, __alarm_info->due_time);
- __save_module_log("EXPIRED", log_message);
-#endif
+ _save_alarm_info_log("EXPIRED", __alarm_info);
- if (__alarm_info->alarm_info.mode.repeat == ALARM_REPEAT_MODE_ONCE)
+ if (__alarm_info->alarm_info.mode.repeat == ALARM_REPEAT_MODE_ONCE) {
__alarm_remove_from_list(__alarm_info->uid, alarm_id, NULL);
- else
+ } else {
_alarm_set_next_duetime(__alarm_info);
+ _save_alarm_info_log("DUETIME", __alarm_info);
+ }
}
done:
@@ -1744,6 +1721,8 @@ static void __on_system_time_external_changed(keynode_t *node, void *data)
_alarm_schedule();
_rtc_set();
+ _save_module_log("SET RTC END", "requested by vconf");
+
return;
}
@@ -1874,59 +1853,6 @@ static int __on_app_uninstalled(uid_t target_uid, int req_id, const char *pkg_ty
return ALARMMGR_RESULT_SUCCESS;
}
-
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
-static void __initialize_module_log(void)
-{
- char buf[1024];
-
- log_fd = open(ALARMMGR_LOG_FILE_PATH, O_CREAT | O_WRONLY, 0644);
- if (log_fd == -1) {
- LOGE("Opening the file for alarmmgr log is failed. err: %s", strerror_r(errno, buf, sizeof(buf)));
- return;
- }
-
- int offset = lseek(log_fd, 0, SEEK_END);
- if (offset != 0) {
- log_index = (int)(offset / ALARMMGR_LOG_BUFFER_STRING_SIZE);
- if (log_index >= ALARMMGR_LOG_BUFFER_SIZE) {
- log_index = 0;
- lseek(log_fd, 0, SEEK_SET);
- }
- }
- return;
-}
-
-static void __save_module_log(const char *tag, const char *message)
-{
- char buffer[ALARMMGR_LOG_BUFFER_STRING_SIZE] = {0,};
- time_t now;
- char buf[1024];
-
- if (log_fd == -1) {
- LOGE("The file is not ready.");
- return;
- }
-
- if (log_index != 0)
- lseek(log_fd, 0, SEEK_CUR);
- else
- lseek(log_fd, 0, SEEK_SET);
-
- time(&now);
- snprintf(buffer, ALARMMGR_LOG_BUFFER_STRING_SIZE, "[%-6d] %-20s %-120s %d-%s", log_index, tag, message, (int)now, ctime(&now));
-
- int ret = write(log_fd, buffer, strlen(buffer));
- if (ret < 0) {
- LOGE("Writing the alarmmgr log is failed. err: %s", strerror_r(errno, buf, sizeof(buf)));
- return;
- }
-
- if (++log_index >= ALARMMGR_LOG_BUFFER_SIZE)
- log_index = 0;
-}
-#endif /* _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG */
-
static long __get_proper_interval(long interval, int alarm_type)
{
GSList *gs_iter = NULL;
@@ -1982,9 +1908,7 @@ gboolean __alarm_expired_directly(gpointer user_data)
void __reschedule_alarms_with_newtime(time_t cur_time, time_t new_time, double diff_time)
{
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
-#endif
vconf_set_int(VCONFKEY_SYSTEM_TIME_CHANGED, (int)diff_time);
bundle *b = NULL;
@@ -2000,14 +1924,13 @@ void __reschedule_alarms_with_newtime(time_t cur_time, time_t new_time, double d
_alarm_schedule();
_rtc_set();
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char *timebuf = ctime((const time_t *)&new_time);
if (timebuf) {
timebuf[strlen(timebuf) - 1] = '\0'; /* to avoid newline */
snprintf(log_message, sizeof(log_message), "Current: %ld, New: %ld, %s, diff: %f", cur_time, new_time, timebuf, diff_time);
}
- __save_module_log("CHANGE TIME", log_message);
-#endif
+
+ _save_module_log("CHANGE TIME", log_message);
g_idle_add(__alarm_expired_directly, (gpointer)(intptr_t)new_time); /* Expire alarms with duetime equal to newtime directly */
return;
@@ -2063,10 +1986,8 @@ int alarm_manager_alarm_set_rtc_time(GVariant *parameters)
struct rtc_wkalrm rtc_wkalarm;
int retval = 0;
struct tm tm, *alarm_tm = NULL;
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
-#endif
/*extract day of the week, day in the year & daylight saving time from system*/
time_t current_time;
char buf[1024];
@@ -2115,20 +2036,14 @@ int alarm_manager_alarm_set_rtc_time(GVariant *parameters)
LOGE("RTC ALARM_SET ioctl is failed. errno = %s", strerror_r(errno, buf, sizeof(buf)));
return_code = ERR_ALARM_SYSTEM_FAIL;
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
strncpy(log_tag, "FAIL: SET RTC", sizeof(log_tag) - 1);
-#endif
} else {
LOGD("[alarm-server]RTC alarm is setted");
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
strncpy(log_tag, "SET RTC", sizeof(log_tag) - 1);
-#endif
}
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- snprintf(log_message, sizeof(log_message), "wakeup rtc time: %ld, %s", rtc_time, ctime(&rtc_time));
- __save_module_log(log_tag, log_message);
-#endif
+ snprintf(log_message, sizeof(log_message), "wakeup rtc time: %ld, %s", rtc_time, ctime(&rtc_time));
+ _save_module_log(log_tag, log_message);
return return_code;
} else {
LOGW("[alarm-server] RTC does not work.");
@@ -2138,12 +2053,14 @@ int alarm_manager_alarm_set_rtc_time(GVariant *parameters)
static int accrue_msec = 0; /* To check a millisecond part of current time at changing the system time(sec) */
-int alarm_manager_alarm_set_time(GVariant* parameters)
+int alarm_manager_alarm_set_time(GVariant* parameters, pid_t pid)
{
double diff_time = 0.0;
struct timeval cur_time = {0,};
gint64 time_sec;
time_t new_time;
+ char sender_id[MAX_APP_ID_LEN];
+ char log_message[ALARMMGR_LOG_MESSAGE_SIZE];
g_variant_get(parameters, "(x)", &time_sec);
@@ -2174,10 +2091,15 @@ int alarm_manager_alarm_set_time(GVariant* parameters)
cur_time.tv_sec, new_time, ctime((const time_t *)&new_time), diff_time);
__reschedule_alarms_with_newtime(cur_time.tv_sec, new_time, diff_time);
+
+ __get_cached_unique_name(pid, sender_id, MAX_APP_ID_LEN, NULL, 5001);
+ snprintf(log_message, sizeof(log_message), "requested by %s (pid %d)", sender_id, pid);
+ _save_module_log("SET TIME END", log_message);
+
return ALARMMGR_RESULT_SUCCESS;;
}
-int alarm_manager_alarm_set_time_with_propagation_delay(GVariant* parameters)
+int alarm_manager_alarm_set_time_with_propagation_delay(GVariant* parameters, pid_t pid)
{
double diff_time = 0.0;
struct timespec cur_time = {0,};
@@ -2188,6 +2110,8 @@ int alarm_manager_alarm_set_time_with_propagation_delay(GVariant* parameters)
time_t new_sec, req_sec;
long new_nsec, req_nsec;
gint64 tmp_new_sec, tmp_req_sec, tmp_new_nsec, tmp_req_nsec;
+ char sender_id[MAX_APP_ID_LEN];
+ char log_message[ALARMMGR_LOG_MESSAGE_SIZE];
g_variant_get(parameters, "(xxxx)", &tmp_new_sec, &tmp_new_nsec, &tmp_req_sec, &tmp_req_nsec);
new_sec = (time_t)tmp_new_sec;
@@ -2239,6 +2163,11 @@ int alarm_manager_alarm_set_time_with_propagation_delay(GVariant* parameters)
cur_time.tv_sec, cur_time.tv_nsec, new_sec, new_nsec, real_newtime, diff_time);
LOGD("Requested(%ld.%09ld) Delay(%ld.%09ld) Sleep(%09ld)", req_sec, req_nsec, delay.tv_sec, delay.tv_nsec, sleep_time.tv_nsec);
__reschedule_alarms_with_newtime(cur_time.tv_sec, real_newtime, diff_time);
+
+ __get_cached_unique_name(pid, sender_id, MAX_APP_ID_LEN, NULL, 5001);
+ snprintf(log_message, sizeof(log_message), "requested by %s (pid %d)", sender_id, pid);
+ _save_module_log("SET TIME PROPAGATION END", log_message);
+
return ALARMMGR_RESULT_SUCCESS;
}
@@ -2248,10 +2177,8 @@ int alarm_manager_alarm_set_timezone(GVariant* parameters)
int return_code = ALARMMGR_RESULT_SUCCESS;
struct stat statbuf;
bundle *b = NULL;
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
-#endif
char *tzpath_str;
time_t cur_time;
@@ -2306,15 +2233,13 @@ int alarm_manager_alarm_set_timezone(GVariant* parameters)
bundle_free(b);
done:
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
if (return_code == ALARMMGR_RESULT_SUCCESS)
strncpy(log_tag, "SET TIMEZONE", sizeof(log_tag) - 1);
else
strncpy(log_tag, "FAIL: SET TIMEZONE", sizeof(log_tag) - 1);
snprintf(log_message, sizeof(log_message), "Set the timezone to %s.", tzpath_str);
- __save_module_log(log_tag, log_message);
-#endif
+ _save_module_log(log_tag, log_message);
return return_code;
}
@@ -2324,10 +2249,8 @@ int alarm_manager_alarm_create_appsvc(GVariant *parameters, uid_t uid, pid_t pid
alarm_info_t alarm_info;
int return_code = ALARMMGR_RESULT_SUCCESS;
int _alarm_id = 0;
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
-#endif
int result;
bundle *b;
const char *callee_appid;
@@ -2405,24 +2328,17 @@ int alarm_manager_alarm_create_appsvc(GVariant *parameters, uid_t uid, pid_t pid
if (!__alarm_create_appsvc(&alarm_info, &_alarm_id, mode_interval, uid, pid, bundle_data, &return_code)) {
LOGE("Unable to create alarm! return_code[%d]", return_code);
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- strncpy(log_tag, "FAIL: CREATE", sizeof(log_tag) - 1);
-#endif
+ strncpy(log_tag, "FAIL: CREATE SVC", sizeof(log_tag) - 1);
+ snprintf(log_message, sizeof(log_message),
+ "alarmID: %d, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
+ _alarm_id, uid, pid, start_year, start_month, start_day, start_hour, start_min, start_sec);
+ _save_module_log(log_tag, log_message);
return_code = ERR_ALARM_SYSTEM_FAIL;
} else {
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- strncpy(log_tag, "CREATE", sizeof(log_tag) - 1);
-#endif
*alarm_id = _alarm_id;
return_code = ALARMMGR_RESULT_SUCCESS;
}
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- snprintf(log_message, sizeof(log_message), "alarmID: %d, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
- *alarm_id, uid, pid, start_year, start_month, start_day, start_hour, start_min, start_sec);
- __save_module_log(log_tag, log_message);
-#endif
-
return return_code;
}
@@ -2432,10 +2348,8 @@ int alarm_manager_alarm_create_noti(GVariant *parameters, uid_t uid, pid_t pid,
alarm_info_t alarm_info;
int return_code = ALARMMGR_RESULT_SUCCESS;
int _alarm_id = 0;
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
-#endif
int start_year, start_month, start_day, start_hour, start_min, start_sec;
int end_year, end_month, end_day;
int mode_day_of_week, mode_repeat, alarm_type;
@@ -2482,24 +2396,16 @@ int alarm_manager_alarm_create_noti(GVariant *parameters, uid_t uid, pid_t pid,
if (!__alarm_create_noti(&alarm_info, &_alarm_id, mode_interval, uid, pid, noti_data, &return_code)) {
LOGE("Unable to create alarm! return_code[%d]", return_code);
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- strncpy(log_tag, "FAIL: CREATE", sizeof(log_tag) - 1);
-#endif
+ strncpy(log_tag, "FAIL: CREATE NOTI", sizeof(log_tag) - 1);
+ snprintf(log_message, sizeof(log_message), "alarmID: %d, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
+ _alarm_id, uid, pid, start_year, start_month, start_day, start_hour, start_min, start_sec);
+ _save_module_log(log_tag, log_message);
return_code = ERR_ALARM_SYSTEM_FAIL;
} else {
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- strncpy(log_tag, "CREATE", sizeof(log_tag) - 1);
-#endif
return_code = ALARMMGR_RESULT_SUCCESS;
*alarm_id = _alarm_id;
}
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- snprintf(log_message, sizeof(log_message), "alarmID: %d, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
- *alarm_id, uid, pid, start_year, start_month, start_day, start_hour, start_min, start_sec);
- __save_module_log(log_tag, log_message);
-#endif
-
return return_code;
}
@@ -2508,10 +2414,8 @@ int alarm_manager_alarm_create(GVariant *parameters, uid_t uid, pid_t pid, int *
alarm_info_t alarm_info;
int return_code = ALARMMGR_RESULT_SUCCESS;
int _alarm_id = 0;
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
-#endif
char *_reserved_service_name = NULL;
char *_reserved_service_name_mod = NULL;
@@ -2565,24 +2469,16 @@ int alarm_manager_alarm_create(GVariant *parameters, uid_t uid, pid_t pid, int *
if (!__alarm_create(&alarm_info, &_alarm_id, uid, pid, QUANTUMIZE, 0, 0, app_service_name, app_service_name_mod,
_reserved_service_name, _reserved_service_name_mod, &return_code)) {
LOGE("Unable to create alarm! return_code[%d]", return_code);
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
strncpy(log_tag, "FAIL: CREATE", sizeof(log_tag) - 1);
-#endif
+ snprintf(log_message, sizeof(log_message), "alarmID: %d, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
+ _alarm_id, uid, pid, start_year, start_month, start_day, start_hour, start_min, start_sec);
+ _save_module_log(log_tag, log_message);
return_code = ERR_ALARM_SYSTEM_FAIL;
} else {
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- strncpy(log_tag, "CREATE", sizeof(log_tag) - 1);
-#endif
return_code = ALARMMGR_RESULT_SUCCESS;
*alarm_id = _alarm_id;
}
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- snprintf(log_message, sizeof(log_message), "alarmID: %d, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
- *alarm_id, uid, pid, start_year, start_month, start_day, start_hour, start_min, start_sec);
- __save_module_log(log_tag, log_message);
-#endif
-
return return_code;
}
@@ -2602,10 +2498,8 @@ int alarm_manager_alarm_create_periodic(GVariant *parameters, uid_t uid,
alarm_info_t alarm_info;
int return_code = ALARMMGR_RESULT_SUCCESS;
int _alarm_id = 0;
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
-#endif
char *app_service_name = NULL;
char *app_service_name_mod = NULL;
int interval, is_ref, method;
@@ -2656,35 +2550,26 @@ int alarm_manager_alarm_create_periodic(GVariant *parameters, uid_t uid,
app_service_name, app_service_name_mod,
NULL, NULL, &return_code)) {
LOGE("Unable to create alarm! return_code[%d]", return_code);
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- strncpy(log_tag, "FAIL: CREATE", sizeof(log_tag) - 1);
-#endif
+ strncpy(log_tag, "FAIL: CREATE PERIODIC", sizeof(log_tag) - 1);
+ snprintf(log_message, sizeof(log_message), "alarmID: %d, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
+ _alarm_id, uid, pid, alarm_info.start.year, alarm_info.start.month,
+ alarm_info.start.day, alarm_info.start.hour,
+ alarm_info.start.min, alarm_info.start.sec);
+ _save_module_log(log_tag, log_message);
return_code = ERR_ALARM_SYSTEM_FAIL;
} else {
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- strncpy(log_tag, "CREATE", sizeof(log_tag) - 1);
-#endif
return_code = ALARMMGR_RESULT_SUCCESS;
*alarm_id = _alarm_id;
}
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- snprintf(log_message, sizeof(log_message), "alarmID: %d, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
- *alarm_id, uid, pid, alarm_info.start.year, alarm_info.start.month,
- alarm_info.start.day, alarm_info.start.hour,
- alarm_info.start.min, alarm_info.start.sec);
- __save_module_log(log_tag, log_message);
-#endif
return return_code;
}
int alarm_manager_alarm_delete(GVariant *parameters, uid_t uid, pid_t pid)
{
int return_code = ALARMMGR_RESULT_SUCCESS;
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
-#endif
int alarm_id;
if (uid < 0 || pid < 0)
@@ -2698,22 +2583,16 @@ int alarm_manager_alarm_delete(GVariant *parameters, uid_t uid, pid_t pid)
if (!__alarm_delete(uid, alarm_id, &return_code)) {
LOGE("Unable to delete the alarm! alarm_id[%d], return_code[%d]", alarm_id, return_code);
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
strncpy(log_tag, "FAIL: DELETE", sizeof(log_tag) - 1);
-#endif
return_code = ERR_ALARM_SYSTEM_FAIL;
} else {
LOGD("alarm_id[%d] is removed.", alarm_id);
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
strncpy(log_tag, "DELETE", sizeof(log_tag) - 1);
-#endif
return_code = ALARMMGR_RESULT_SUCCESS;
}
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
snprintf(log_message, sizeof(log_message), "alarmID: %d, uid: %d, pid: %d", alarm_id, uid, pid);
- __save_module_log(log_tag, log_message);
-#endif
+ _save_module_log(log_tag, log_message);
return return_code;
}
@@ -2725,18 +2604,14 @@ int alarm_manager_alarm_delete_all(GVariant *parameters, uid_t uid, pid_t pid)
alarm_info_t *alarm_info = NULL;
__alarm_info_t *entry = NULL;
bool is_deleted = false;
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
-#endif
if (uid < 0 || pid < 0)
return ERR_ALARM_SYSTEM_FAIL;
if (__get_cached_unique_name(pid, app_name, sizeof(app_name), NULL, uid) == false) {
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
snprintf(log_message, sizeof(log_message), "pid: %d. Can not get the unique_name.", pid);
- __save_module_log("FAIL: DELETE ALL", log_message);
-#endif
+ _save_module_log("FAIL: DELETE ALL", log_message);
return ERR_ALARM_SYSTEM_FAIL;
}
@@ -2774,10 +2649,8 @@ int alarm_manager_alarm_delete_all(GVariant *parameters, uid_t uid, pid_t pid)
_alarm_schedule();
}
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
snprintf(log_message, sizeof(log_message), "uid: %d, pid: %d, unique_name: %s", uid, pid, app_name);
- __save_module_log("DELETE ALL", log_message);
-#endif
+ _save_module_log("DELETE ALL", log_message);
_rtc_set();
return ALARMMGR_RESULT_SUCCESS;
@@ -2787,10 +2660,8 @@ int alarm_manager_alarm_update(GVariant *parameters, uid_t uid, pid_t pid)
{
int return_code = ALARMMGR_RESULT_SUCCESS;
alarm_info_t alarm_info;
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
-#endif
int alarm_id;
int start_year, start_month, start_day, start_hour, start_min, start_sec;
int end_year, end_month, end_day;
@@ -2834,21 +2705,12 @@ int alarm_manager_alarm_update(GVariant *parameters, uid_t uid, pid_t pid)
if (!__alarm_update(uid, alarm_id, &alarm_info,
update_flag, &return_code)) {
LOGE("Unable to update the alarm! alarm_id[%d], return_code[%d]", alarm_id, return_code);
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
strncpy(log_tag, "FAIL: UPDATE", sizeof(log_tag) - 1);
-#endif
- } else {
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- strncpy(log_tag, "UPDATE", sizeof(log_tag) - 1);
-#endif
+ snprintf(log_message, sizeof(log_message), "alarmID: %d, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
+ alarm_id, uid, pid, start_year, start_month, start_day, start_hour, start_min, start_sec);
+ _save_module_log(log_tag, log_message);
}
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- snprintf(log_message, sizeof(log_message), "alarmID: %d, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
- alarm_id, uid, pid, start_year, start_month, start_day, start_hour, start_min, start_sec);
- __save_module_log(log_tag, log_message);
-#endif
-
return return_code;
}
@@ -3234,9 +3096,7 @@ void _alarm_initialize()
exit(1);
}
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- __initialize_module_log(); /* for module log */
-#endif
+ _initialize_module_log(); /* for module log */
__initialize_scheduled_alarm_list();
if (_initialize_db() == false) {