* @brief RUA record info structure
*/
struct rua_rec {
- int id; /**< primary key */
+ int id; /**< primary key */
char *pkg_name; /**< package name */
char *app_path; /**< application path */
char *arg; /**< application launching argument */
time_t launch_time; /**< application launching time */
+ char *instance_id; /**< Instance ID */
+ char *instance_name; /**< Instance Name */
+ char *icon; /**< Icon path */
+ char *uri; /**< URI */
};
/**
API int rua_is_latest_app_for_uid(const char *pkg_name, uid_t uid);
/**
+ * @brief Delete rua history with instance id
+ * @param[in] app_id The application ID
+ * @param[in] instance_id The instance ID
+ * @return 0 on success, otherwise a negative error value
+ */
+API int rua_delete_history_with_instance_id(const char *app_id,
+ const char *instance_id);
+
+/**
* @brief Initialize rua
* @return 0 on success, otherwise a nagative error value
* @retval 0 on successful
if (r != SQLITE_OK)
return -1;
- snprintf(query, QUERY_MAXLEN,
- "select pkg_name, app_path, arg, launch_time from %s order by launch_time desc;", RUA_HISTORY);
+ snprintf(query, sizeof(query),
+ "SELECT pkg_name, app_path, arg, launch_time, instance_id, "
+ "instance_name, icon, uri FROM %s ORDER BY launch_time DESC;",
+ RUA_HISTORY);
r = sqlite3_get_table(db, query, &db_result, nrows, ncols, &db_err);
if (tmp)
rec->launch_time = atoi(tmp);
+ tmp = db_result[RUA_COL_INSTANCE_ID];
+ if (tmp && tmp[0] != '\0')
+ rec->instance_id = tmp;
+ else
+ rec->instance_id = NULL;
+
+ tmp = db_result[RUA_COL_INSTANCE_NAME];
+ if (tmp && tmp[0] != '\0')
+ rec->instance_name = tmp;
+ else
+ rec->instance_name = NULL;
+
+ tmp = db_result[RUA_COL_ICON];
+ if (tmp && tmp[0] != '\0')
+ rec->icon = tmp;
+ else
+ rec->icon = NULL;
+
+ tmp = db_result[RUA_COL_URI];
+ if (tmp && tmp[0] != '\0')
+ rec->uri = tmp;
+ else
+ rec->uri = NULL;
+
return 0;
}
{
return 0;
}
+
+int rua_delete_history_with_instance_id(const char *app_id,
+ const char *instance_id)
+{
+ int ret;
+ bundle *b;
+
+ if (app_id == NULL) {
+ LOGE("Invalid parameter");
+ return -1;
+ }
+
+ b = bundle_create();
+ if (b == NULL) {
+ LOGE("Out of memory");
+ return -1;
+ }
+
+ bundle_add_str(b, AUL_K_RUA_PKGNAME, app_id);
+ if (instance_id)
+ bundle_add_str(b, AUL_K_RUA_INSTANCE_ID, instance_id);
+
+ ret = aul_delete_rua_history_for_uid(b, getuid());
+ bundle_free(b);
+ if (ret < 0) {
+ LOGE("Failed to delete rua history - result(%d)", ret);
+ return -1;
+ }
+
+ return 0;
+}
char query[QUERY_MAXLEN];
char *pkg_name = NULL;
char *app_path = NULL;
+ char *instance_id = NULL;
char *errmsg = NULL;
int result = 0;
if (b != NULL) {
bundle_get_str(b, AUL_K_RUA_PKGNAME, &pkg_name);
bundle_get_str(b, AUL_K_RUA_APPPATH, &app_path);
+ bundle_get_str(b, AUL_K_RUA_INSTANCE_ID, &instance_id);
}
- if (pkg_name != NULL)
- snprintf(query, QUERY_MAXLEN, "delete from rua_history where pkg_name = '%s';", pkg_name);
- else if (app_path != NULL)
- snprintf(query, QUERY_MAXLEN, "delete from rua_history where app_path = '%s';", app_path);
- else
- snprintf(query, QUERY_MAXLEN, "delete from rua_history;");
+ if (pkg_name) {
+ snprintf(query, sizeof(query),
+ "DELETE FROM rua_history WHERE pkg_name = '%s' "
+ "AND instance_id = '%s';",
+ pkg_name, instance_id ? instance_id : "");
+ } else if (app_path) {
+ snprintf(query, sizeof(query),
+ "DELETE FROM rua_history WHERE app_path = '%s' "
+ "AND instance_id = '%s';",
+ app_path, instance_id ? instance_id : "");
+ } else {
+ snprintf(query, sizeof(query), "DELETE FROM rua_history;");
+ }
LOGI("rua_delete_history_from_db : %s", query);
r = sqlite3_exec(db, query, NULL, NULL, &errmsg);
{
int r;
char query[QUERY_MAXLEN];
- sqlite3 *db = NULL;
+ sqlite3 *db;
+
+ if (rec == NULL || rec->pkg_name == NULL || rec->app_path == NULL) {
+ LOGE("Invalid parameter");
+ return -1;
+ }
db = __db_init(uid);
if (db == NULL) {
return -1;
}
- if (rec == NULL) {
- LOGE("Error rec null");
- db_util_close(db);
- return -1;
+ if (rec->instance_id &&
+ (rec->instance_name == NULL || rec->icon == NULL ||
+ rec->uri == NULL)) {
+ snprintf(query, sizeof(query),
+ "UPDATE %s SET launch_time = %d "
+ "WHERE pkg_name = %s AND instance_id = %s;",
+ RUA_HISTORY,
+ (int)rec->launch_time,
+ rec->pkg_name,
+ rec->instance_id);
+ } else {
+ snprintf(query, sizeof(query),
+ "INSERT OR REPLACE INTO %s "
+ "(pkg_name, app_path, arg, launch_time, "
+ "instance_id, instance_name, icon, uri) "
+ "VALUES (\"%s\", \"%s\", \"%s\", %d, "
+ "\"%s\", \"%s\", \"%s\", \"%s\");",
+ RUA_HISTORY,
+ rec->pkg_name,
+ rec->app_path,
+ rec->arg ? rec->arg : "",
+ (int)rec->launch_time,
+ rec->instance_id ? rec->instance_id : "",
+ rec->instance_name ? rec->instance_name : "",
+ rec->icon ? rec->icon : "",
+ rec->uri ? rec->uri : "");
}
- snprintf(query, QUERY_MAXLEN,
- "insert or replace into %s ( pkg_name, app_path, arg, launch_time) "
- " values ( \"%s\", \"%s\", \"%s\", %d) ",
- RUA_HISTORY,
- rec->pkg_name ? rec->pkg_name : "",
- rec->app_path ? rec->app_path : "",
- rec->arg ? rec->arg : "", (int)rec->launch_time);
-
r = __exec(db, query);
if (r == -1) {
LOGE("[RUA ADD HISTORY ERROR] %s\n", query);