diff options
author | hyunho <hhstark.kang@samsung.com> | 2020-09-14 16:52:27 +0900 |
---|---|---|
committer | hyunho <hhstark.kang@samsung.com> | 2020-09-14 16:52:27 +0900 |
commit | 8e8d0b450a7f32a60a6e837ad5e1c8fcedffc721 (patch) | |
tree | f48f41132749b780f4f721e4a4145472226d845c /src | |
parent | 2a709dfaf0ad53d7d6f77756d3240b9aefe92567 (diff) | |
download | librua-8e8d0b450a7f32a60a6e837ad5e1c8fcedffc721.tar.gz librua-8e8d0b450a7f32a60a6e837ad5e1c8fcedffc721.tar.bz2 librua-8e8d0b450a7f32a60a6e837ad5e1c8fcedffc721.zip |
Add rua history update APIs
Change-Id: If0ce1c2c7d5a28d93bce413dc5d732552f7769fa
Signed-off-by: hyunho <hhstark.kang@samsung.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/rua_internal.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/rua_internal.c b/src/rua_internal.c index 0bb4305..287b7fa 100644 --- a/src/rua_internal.c +++ b/src/rua_internal.c @@ -286,6 +286,54 @@ static int __update_history(sqlite3 *db, struct rua_rec *rec) return 0; } +API int rua_usr_db_update_history(const char *pkg_name, + const char *comp_id, int launch_time, uid_t uid) +{ + static const char query[] = + "UPDATE rua_history SET launch_time=? " + "WHERE pkg_name=? AND comp_id=?"; + int r; + sqlite3_stmt *stmt; + int idx = 1; + sqlite3 *db; + + db = __db_init(uid); + if (db == NULL) { + LOGE("Error db null"); + return -1; + } + + r = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL); + if (r != SQLITE_OK) { + LOGE("prepare failed: %s", sqlite3_errmsg(db)); + sqlite3_close_v2(db); + return -1; + } + + __BIND_INT(db, stmt, idx++, launch_time); + __BIND_TEXT(db, stmt, idx++, pkg_name); + __BIND_TEXT(db, stmt, idx++, comp_id ? comp_id : ""); + + r = sqlite3_step(stmt); + if (r != SQLITE_DONE) { + LOGE("step failed: %s", sqlite3_errmsg(db)); + sqlite3_finalize(stmt); + sqlite3_close_v2(db); + return -1; + } + + sqlite3_finalize(stmt); + sqlite3_close_v2(db); + return r; +} + +API int rua_db_update_history(const char *pkg_name, + const char *comp_id, int launch_time) +{ + return rua_usr_db_update_history( + pkg_name, comp_id, launch_time, getuid()); +} + API int rua_usr_db_add_history(struct rua_rec *rec, uid_t uid) { int r; |