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
}
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;