#include "CynaraService.h"
#include "PrivacyGuardDb.h"
#include "PrivacyIdInfo.h"
+#include "security-manager.h"
#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
// DB update
const char *user = NULL, *client = NULL, *privilege = NULL;
+#if 0
char *package_id = NULL, *package_id_dup = NULL;
const timespec *timestamp = NULL;
uid_t userId;
packageId = package_id_dup;
pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo);
}
+#else
+ const timespec *timestamp = NULL;
+ uid_t userId;
+ std::string appId, privacyId, packageId;
+ time_t date;
+ int res = -1;
+ pkgmgrinfo_pkginfo_h pkg_handle;
+ bool is_global = false;
+ char *pkg_name = NULL, *app_name = NULL;
+
+ while (*entryIter != nullptr) {
+ privilege = cynara_monitor_entry_get_privilege(*entryIter);
+ TryReturn(privilege != NULL, PRIV_GUARD_ERROR_SYSTEM_ERROR, , "Privilege Id in the entry is NULL");
+
+ // change from privilege to privacy
+ res = PrivacyIdInfo::getPrivacyIdFromPrivilege(privilege, privacyId);
+ if (res != PRIV_GUARD_ERROR_NO_DATA) {
+ // User ID - string
+ user = cynara_monitor_entry_get_user(*entryIter);
+ TryReturn(user != NULL, PRIV_GUARD_ERROR_SYSTEM_ERROR, , "User Id in the entry is NULL");
+
+ // App ID - string
+ client = cynara_monitor_entry_get_client(*entryIter);
+ TryReturn(client != NULL, PRIV_GUARD_ERROR_SYSTEM_ERROR, , "App Id in the entry is NULL");
+
+ // timestamp
+ timestamp = cynara_monitor_entry_get_timestamp(*entryIter);
+ TryReturn(timestamp != NULL, PRIV_GUARD_ERROR_SYSTEM_ERROR, , "timestamp in the entry is NULL");
+
+ // convert string to integer
+ userId = atoi(user);
+
+ res = security_manager_identify_app_from_cynara_client(client, &pkg_name, &app_name);
+ if (res != PRIV_GUARD_ERROR_NO_DATA) {
+ PG_LOGE("Failed to security_manager_identify_app_from_cynara_client()");
+ }
+ // check pkg ID
+ std::string tempPkgId = pkg_name;
+ if (tempPkgId.substr(0, USER_PKG_PREFIX_LEN).compare(USER_PKG_PREFIX) == 0) {
+ packageId = tempPkgId.substr(USER_PKG_PREFIX_LEN, tempPkgId.length() - USER_PKG_PREFIX_LEN);
+ PG_LOGD("Pkg ID: [%s]", packageId.c_str());
+ } else {
+ packageId = pkg_name;
+ PG_LOGD("Pkg ID: [%s]", pkg_name);
+ }
+#endif
// check this package is global app
if (userId == GLOBAL_USER) {
res = pkgmgrinfo_pkginfo_get_pkginfo(packageId.c_str(), &pkg_handle);