diff options
author | Inkyun Kil <inkyun.kil@samsung.com> | 2017-11-21 18:20:36 +0900 |
---|---|---|
committer | Inkyun Kil <inkyun.kil@samsung.com> | 2017-11-22 14:07:44 +0900 |
commit | c8884ee8dd06ff024966f5dcb3c442e1c09e4359 (patch) | |
tree | 64c74fa8295fe19608f6d2e5f013d5ac932435b9 | |
parent | 25d9621d0c49e10146a878b595092802b0b378a0 (diff) | |
download | alarm-manager-c8884ee8dd06ff024966f5dcb3c442e1c09e4359.tar.gz alarm-manager-c8884ee8dd06ff024966f5dcb3c442e1c09e4359.tar.bz2 alarm-manager-c8884ee8dd06ff024966f5dcb3c442e1c09e4359.zip |
Add code for checking integrity
Change-Id: I48277013b5f1efe59e123efe909b926cface677d
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
-rw-r--r-- | alarm-manager.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/alarm-manager.c b/alarm-manager.c index b1b29ed..551a182 100644 --- a/alarm-manager.c +++ b/alarm-manager.c @@ -123,6 +123,7 @@ bool is_time_changed = false; /* for calculating next duetime */ #define BILLION 1000000000 /* for calculating nano seconds */ static time_t periodic_alarm_standard_time = 0; +static bool is_db_corrupted = false; static int __is_ui_app(const char *appid, uid_t uid); static long __get_proper_interval(long interval, int alarm_type); @@ -3995,6 +3996,19 @@ static int __db_busyhandler(void *pData, int count) } } +int check_callback(void *pid, int argc, char **argv, char **notUsed2) +{ + if (strcmp(argv[0], "ok") != 0) { + ALARM_MGR_EXCEPTION_PRINT("check integrity result : %s" , argv[0]); + is_db_corrupted = true; + return -1; + } else { + ALARM_MGR_LOG_PRINT("check integrity result : %s" , argv[0]); + } + + return 0; +} + static bool __initialize_db() { char *error_message = NULL; @@ -4033,6 +4047,13 @@ static bool __initialize_db() } } + /* Check integrity of DB */ + ret = sqlite3_exec(alarmmgr_db, "PRAGMA integrity_check", check_callback, NULL, 0); + if (ret != SQLITE_OK || is_db_corrupted) { + ALARM_MGR_EXCEPTION_PRINT("Loss alarm db's integrity"); + goto recover; + } + return true; recover: |