summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhyunho <hhstark.kang@samsung.com>2020-09-14 16:52:27 +0900
committerhyunho <hhstark.kang@samsung.com>2020-09-14 16:52:27 +0900
commit8e8d0b450a7f32a60a6e837ad5e1c8fcedffc721 (patch)
treef48f41132749b780f4f721e4a4145472226d845c
parent2a709dfaf0ad53d7d6f77756d3240b9aefe92567 (diff)
downloadlibrua-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>
-rw-r--r--include/rua_internal.h4
-rw-r--r--src/rua_internal.c48
2 files changed, 52 insertions, 0 deletions
diff --git a/include/rua_internal.h b/include/rua_internal.h
index a9c7c22..e1cf72c 100644
--- a/include/rua_internal.h
+++ b/include/rua_internal.h
@@ -65,6 +65,10 @@ int rua_db_update_image(const char *pkg_name, const char *comp_id,
const char *instance_id, const char *image);
int rua_usr_db_update_image(const char *pkg_name, const char *comp_id,
const char *instance_id, const char *image, uid_t uid);
+int rua_usr_db_update_history(const char *pkg_name,
+ const char *comp_id, int launch_time, uid_t uid);
+int rua_db_update_history(const char *pkg_name,
+ const char *comp_id, int launch_time);
#ifdef __cplusplus
}
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;