int PgAddMonitorPolicyOffline(const int userId, const std::string packageId, const std::list < std::string > privacyList, bool monitorPolicy);
- int PgAddPrivacyAccessLog(const int userId, const std::string packageId, const std::string privacyId);
-
- int PgAddPrivacyAccessLogTest(const int userId, const std::string packageId, const std::string privacyId);
-
int PgAddPrivacyAccessLogBeforeTerminate(void);
int PgAddMonitorPolicy(const int userId, const std::string pkgId, const std::list < std::string >& list, int monitorPolicy);
return PRIV_GUARD_ERROR_SUCCESS;
}
-
-int
-PrivacyGuardClient::PgAddPrivacyAccessLog(const int userId, const std::string packageId, const std::string privacyId)
-{
- int result = PRIV_GUARD_ERROR_SUCCESS;
- m_logInfoList.push_back(std::pair <std::string, std::string> (packageId, privacyId));
- PG_LOGD("PrivacyGuardClient userId : %d, PgAddPrivacyAccessLog m_logInfoList.size() : %d", userId, m_logInfoList.size());
-
- if(m_logInfoList.size() >= COUNT) {
- int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
-
- res = m_pSocketClient->call("PgAddPrivacyAccessLog", userId, m_logInfoList, &result);
- TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
-
- res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "disconnect : %d", res);
- m_logInfoList.clear();
- }
-
- return result;
-}
-
-int
-PrivacyGuardClient::PgAddPrivacyAccessLogTest(const int userId, const std::string packageId, const std::string privacyId)
-{
- int result = PRIV_GUARD_ERROR_SUCCESS;
-
- int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
-
- res = m_pSocketClient->call("PgAddPrivacyAccessLogTest", userId, packageId, privacyId, &result);
- TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
-
- res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "disconnect : %d", res);
-
- return result;
-}
-
int
PrivacyGuardClient::PgAddPrivacyAccessLogBeforeTerminate(void)
{
#include <string.h>
#include <string>
#include <memory>
+#include <pkgmgr-info.h>
#include "PrivacyChecker.h"
#include "PrivacyGuardClient.h"
#include "privacy_guard_client.h"
#define TIZEN_PATH_MAX 1024
#endif
-int privacy_guard_client_add_privacy_access_log(const int user_id, const char *package_id, const char *privilege_id)
-{
- if (user_id < 0 || package_id == NULL || privilege_id == NULL) {
- PG_LOGE("Invalid parameters.");
- return PRIV_GUARD_ERROR_INVALID_PARAMETER;
- }
-
- int monitor_policy = 0;
- std::string privacy_id;
-
- PG_LOGD("user_id : %d, package_id : %s, privilege_id : %s", user_id, package_id, privilege_id);
-
- int retval = PrivacyChecker::checkMonitorPolicyWithPrivilege(user_id, std::string(package_id), std::string(privilege_id), privacy_id, monitor_policy);
- if (retval != PRIV_GUARD_ERROR_SUCCESS) {
- PG_LOGE("Failed to do PrivacyChecker::checkMonitorPolicyWithPrivilege() [%d]", retval);
- return retval;
- }
-
- if (monitor_policy == MONITOR_POLICY_ON) {
- PrivacyGuardClient *pInst = PrivacyGuardClient::getInstance();
- retval = pInst->PgAddPrivacyAccessLog(user_id, std::string(package_id), std::string(privacy_id));
- if (retval != PRIV_GUARD_ERROR_SUCCESS) {
- PG_LOGE("Failed to do PrivacyChecker::checkMonitorPolicyWithPrivilege() [%d]", retval);
- return retval;
- }
- }
-
- return PRIV_GUARD_ERROR_SUCCESS;
-}
-
int privacy_guard_client_delete_all_logs_and_monitor_policy(void)
{
PrivacyGuardClient *pInst = PrivacyGuardClient::getInstance();
int retval = pInst->PgAddMonitorPolicy(user_id, std::string(package_id), privilegeList, monitor_policy);
if (retval != PRIV_GUARD_ERROR_SUCCESS) {
- PG_LOGE("Failed to do PrivacyGuardClient::PgAddMonitorPolicy() [%d]", retval);
+ PG_LOGE("Failed to do PrivacyGuardClient::PgAddMonitorPolicy() [%d]", retval);
return retval;
}
return PRIV_GUARD_ERROR_INVALID_PARAMETER;
}
- PrivacyGuardClient *pInst = PrivacyGuardClient::getInstance();
+ PrivacyGuardClient *pInst = PrivacyGuardClient::getInstance();
+
+ pkgmgrinfo_pkginfo_h pkg_handle;
+ bool is_global = false;
+ int fixed_user_id = -1;
+
+ int retval = pkgmgrinfo_pkginfo_get_pkginfo(package_id, &pkg_handle);
+ if (retval != PMINFO_R_OK) {
+ PG_LOGE("Failed to do pkgmgrinfo_pkginfo_get_pkginfo [%d]", retval);
+ return retval;
+ }
+
+ retval = pkgmgrinfo_pkginfo_is_global(pkg_handle, &is_global);
+ if (retval != PMINFO_R_OK) {
+ PG_LOGE("Failed to do pkgmgrinfo_pkginfo_is_global [%d]", retval);
+ return retval;
+ }
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle);
+
+ if (is_global == true) {
+ PG_LOGD("[%s] is global app.", package_id);
+ fixed_user_id = 0;
+ } else {
+ fixed_user_id = user_id;
+ }
- int retval = pInst->PgUpdateMonitorPolicy(user_id, std::string(package_id), std::string(privacy_id), monitor_policy);
+ retval = pInst->PgUpdateMonitorPolicy(fixed_user_id, std::string(package_id), std::string(privacy_id), monitor_policy);
if (retval != PRIV_GUARD_ERROR_SUCCESS) {
- PG_LOGE("Failed to do PrivacyGuardClient::PgUpdateMonitorPolicy() [%d]", retval);
+ PG_LOGE("Failed to do PrivacyGuardClient::PgUpdateMonitorPolicy() [%d]", retval);
return retval;
}
#define CYNARA_BUFFER_SIZE 100
#define USER_APP_PREFIX "User::App::"
#define USER_APP_PREFIX_LEN 11
-#define ROOT_USER_ID 0
+#define GLOBAL_APP_USER_ID 0
typedef struct _privacy_data_s {
char *privacy_id;
public:
static void registerCallbacks(SocketService* pSocketService)
{
- pSocketService->registerServiceCallback(getInterfaceName(), std::string("PgAddPrivacyAccessLog"), PgAddPrivacyAccessLog);
- pSocketService->registerServiceCallback(getInterfaceName(), std::string("PgAddPrivacyAccessLogTest"), PgAddPrivacyAccessLogTest);
pSocketService->registerServiceCallback(getInterfaceName(), std::string("PgAddMonitorPolicy"), PgAddMonitorPolicy);
pSocketService->registerServiceCallback(getInterfaceName(), std::string("PgDeleteAllLogsAndMonitorPolicy"), PgDeleteAllLogsAndMonitorPolicy);
pSocketService->registerServiceCallback(getInterfaceName(), std::string("PgDeleteLogsByPackageId"), PgDeleteLogsByPackageId);
pSocketService->registerServiceCallback(getInterfaceName(), std::string("PgDeleteMainMonitorPolicyByUserId"), PgDeleteMainMonitorPolicyByUserId);
}
- static void PgAddPrivacyAccessLog(SocketConnection* pConnector);
- static void PgAddPrivacyAccessLogTest(SocketConnection* pConnector);
static void PgAddMonitorPolicy(SocketConnection* pConnector);
static void PgDeleteAllLogsAndMonitorPolicy(SocketConnection* pConnector);
static void PgDeleteLogsByPackageId(SocketConnection* pConnector);
#include <memory>
#include <thread>
#include <cynara-monitor.h>
+#include <pkgmgr-info.h>
#include "PrivacyGuardTypes.h"
#include "Utils.h"
#include "CynaraService.h"
time_t date;
int res = -1;
+ pkgmgrinfo_pkginfo_h pkg_handle;
+ bool is_global = false;
+
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");
PG_LOGD("Fixed Package ID: [%s]", client);
}
+ // check this package is global app
+ res = pkgmgrinfo_pkginfo_get_pkginfo(packageId.c_str(), &pkg_handle);
+ if (res != PMINFO_R_OK) {
+ PG_LOGE("Failed to do pkgmgrinfo_pkginfo_get_pkginfo [%d]", res);
+ } else {
+ res = pkgmgrinfo_pkginfo_is_global(pkg_handle, &is_global);
+ if (res != PMINFO_R_OK) {
+ PG_LOGE("Failed to do pkgmgrinfo_pkginfo_is_global [%d]", res);
+ } else {
+ if (is_global == true) {
+ PG_LOGD("[%s] is a global app. So set the user_id to 0.", packageId.c_str());
+ userId = GLOBAL_APP_USER_ID;
+ }
+ }
+ pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle);
+ }
+
// datetime
date = timestamp->tv_sec;
PrivacyGuardDb::PgForeachPackageInfoByPrivacyId(const int userId, const std::string privacyId, std::list < package_data_s > &packageInfoList)
{
int res = -1;
- static const std::string query = std::string("SELECT DISTINCT PKG_ID, MONITOR_POLICY FROM MonitorPolicy WHERE USER_ID=? AND PRIVACY_ID=?");
- static const std::string PKGINFO_SELECT = std::string("SELECT COUNT(*) FROM StatisticsMonitorInfo WHERE USER_ID=? AND PKG_ID=? AND PRIVACY_ID=? AND USE_DATE>=? AND USE_DATE<=?");
+ static const std::string query = std::string("SELECT DISTINCT PKG_ID, MONITOR_POLICY FROM MonitorPolicy WHERE (USER_ID=? OR USER_ID=0) AND PRIVACY_ID=?");
+ static const std::string PKGINFO_SELECT = std::string("SELECT COUNT(*) FROM StatisticsMonitorInfo WHERE (USER_ID=? OR USER_ID=0) AND PKG_ID=? AND PRIVACY_ID=? AND USE_DATE>=? AND USE_DATE<=?");
sqlite3_stmt* infoStmt;
time_t start_date, today_midnight, end_date;
struct tm date;
#include "Utils.h"
void
-PrivacyInfoService::PgAddPrivacyAccessLog(SocketConnection* pConnector)
-{
- int userId = 0;
- std::list <std::pair<std::string, std::string>> logInfoList;
-
- pConnector->read(&userId, &logInfoList);
-
- int result = PrivacyGuardDb::getInstance()->PgAddPrivacyAccessLog(userId, logInfoList);
-
- pConnector->write(result);
-}
-
-void
-PrivacyInfoService::PgAddPrivacyAccessLogTest(SocketConnection* pConnector)
-{
- int userId = 0;
- std::string packageId;
- std::string privacyId;
-
- pConnector->read(&userId, &packageId, &privacyId);
-
- int result = PrivacyGuardDb::getInstance()->PgAddPrivacyAccessLogTest(userId, packageId, privacyId);
-
- pConnector->write(result);
-}
-
-void
PrivacyInfoService::PgAddMonitorPolicy(SocketConnection* pConnector)
{
int userId = 0;