int\r
PrivacyChecker::check(const std::string privacyId, std::map < std::string, bool >& privacyMap)\r
{\r
- LOGI("enter, %d", privacyMap.size());\r
+ LOGI("enter");\r
\r
TryReturn(m_isInitialized, PRIV_MGR_ERROR_NOT_INITIALIZED, , "Not initialized");\r
\r
std::map < std::string, bool >::iterator iter;\r
\r
- for (iter = privacyMap.begin(); iter != privacyMap.end(); ++iter)\r
- {\r
- LOGD("data: %s, %d", iter->first.c_str(), iter->second);\r
- }\r
iter = privacyMap.find(privacyId);\r
if (iter == privacyMap.end() )\r
{\r
\r
if (iter->second.size() == 0)\r
{\r
- LOGD("NO PRIVACY contained");\r
+ LOGD("No privacy contained");\r
return PRIV_MGR_ERROR_USER_NOT_CONSENTED;\r
}\r
\r
std::string privacyId;\r
int res = PrivacyIdInfo::getPrivacyIdFromPrivilege(privilege, privacyId);\r
if (res == PRIV_MGR_ERROR_NO_DATA) {\r
- LOGD("NOT privacy privilege");\r
+ LOGD("%s is not privacy privilege", privilege.c_str());\r
return PRIV_MGR_ERROR_SUCCESS;\r
}\r
\r
\r
std::string privacyId;\r
int res = PrivacyIdInfo::getPrivacyIdFromPrivilege(privilege, privacyId);\r
- if (res == PRIV_MGR_ERROR_NO_DATA)\r
+ if (res == PRIV_MGR_ERROR_NO_DATA) {\r
+ LOGD("%s is not privacy privilege", privilege.c_str());\r
return PRIV_MGR_ERROR_SUCCESS;\r
+ }\r
+\r
TryReturn( res == PRIV_MGR_ERROR_SUCCESS, res, , "getPrivacyIdFromPrivilege : %d", res);\r
\r
LOGI("leave");\r
int res = PrivacyIdInfo::getPrivacyIdFromDeviceCap(deviceCap, privacyId);\r
if (res == PRIV_MGR_ERROR_NO_DATA)\r
return PRIV_MGR_ERROR_SUCCESS;\r
+\r
TryReturn( res == PRIV_MGR_ERROR_SUCCESS, res, , "getPrivacyIdFromPrivilege : %d", res);\r
\r
LOGI("leave");\r
int res = PrivacyIdInfo::getPrivacyIdFromDeviceCap(deviceCap, privacyId);\r
if (res == PRIV_MGR_ERROR_NO_DATA)\r
return PRIV_MGR_ERROR_SUCCESS;\r
+\r
TryReturn( res == PRIV_MGR_ERROR_SUCCESS, res, , "getPrivacyIdFromPrivilege : %d", res);\r
\r
LOGI("leave");\r
m_pHandlerGMainContext = NULL;\r
}\r
\r
-\r
m_isInitialized = false;\r
\r
return PRIV_MGR_ERROR_SUCCESS;\r
{\r
bool privacyEnabled = sqlite3_column_int(pPrivacyStmt.get(), 0) > 0 ? true : false;\r
\r
- LOGI("Set result : %s : %d", privacyId.c_str(), privacyEnabled );\r
+ LOGD("Set result : %s : %d", privacyId.c_str(), privacyEnabled );\r
pkgCacheMap.erase(privacyId);\r
pkgCacheMap.insert(std::map < std::string, bool >::value_type(privacyId, privacyEnabled));\r
}\r
pSocketClient->disconnect();\r
TryReturn(res == PRIV_MGR_ERROR_SUCCESS, res, , "disconnect : %d", res);\r
\r
- for (std::list < std::pair <std::string, bool > >::const_iterator iter = list.begin(); iter != list.end(); ++iter){\r
- LOGD(" %s : %d", iter->first.c_str(), iter->second);\r
- }\r
-\r
return result;\r
#endif \r
\r
#include "SocketClient.h"\r
#include <Utils.h>\r
\r
-\r
-/*int\r
-SocketClient::throwWithErrnoMessage(const std::string& specificInfo){\r
- LOGE("%s : %s", specificInfo.c_str(), strerror(errno));\r
- return -1;\r
-}*/\r
-\r
#define throwWithErrnoMessage(specificInfo) do {\\r
LOGE("%s : %s", specificInfo, strerror(errno)); \\r
return -1; \\r
\r
int privacy_manager_client_install_privacy(const char *package_id, const char** privacy_list)\r
{\r
- LOGI("enter");\r
-\r
PrivacyManagerClient* pInst = PrivacyManagerClient::getInstance();\r
std::list < std::string > privacyList;\r
\r
\r
int retval = pInst->addAppPackagePrivacyInfo(std::string(package_id), privacyList, false);\r
\r
- LOGI("leave");\r
-\r
return retval;\r
}\r
\r
\r
std::list < std::pair < std::string, bool > > packageList;\r
retval = pInst->getAppPackagesbyPrivacyId(std::string(privacy_id), packageList);\r
- for (std::list < std::pair < std::string, bool > >::iterator iter = packageList.begin(); iter != packageList.end(); ++iter)\r
- {\r
- LOGD("result : %s %d", iter->first.c_str(), iter->second);\r
- }\r
+\r
if (retval != PRIV_MGR_ERROR_SUCCESS)\r
return retval;\r
if (packageList.size() == 0)\r
int length = strlen(in);\r
int res = m_socketStream.writeStream(sizeof(length), &length);\r
TryReturn(res == PRIV_MGR_ERROR_SUCCESS, res, , "writeStream : %d", res);\r
- LOGD(" write char : %s %d", in, length);\r
res = m_socketStream.writeStream(length, in);\r
TryReturn(res == PRIV_MGR_ERROR_SUCCESS, res, , "writeStream : %d", res);\r
\r
return r; \
} else {;}
-auto StmtDeleter = [&](sqlite3_stmt* pPtr) { /*LOGI("sqlite3_finalize");*/ sqlite3_reset (pPtr); sqlite3_finalize(pPtr); };
-auto DbDeleter = [&](sqlite3* pPtr) { /*LOGI("sqlite3_close");*/ /*sqlite3_close(pPtr);*/ db_util_close(pPtr); };
+auto StmtDeleter = [&](sqlite3_stmt* pPtr) { sqlite3_reset (pPtr); sqlite3_finalize(pPtr); };
+auto DbDeleter = [&](sqlite3* pPtr) { /*sqlite3_close(pPtr);*/ db_util_close(pPtr); };
#define setStmtToUniquePtr(x, y) std::unique_ptr < sqlite3_stmt, decltype(StmtDeleter) > x (y, StmtDeleter);
#define setDbToUniquePtr(x, y) std::unique_ptr < sqlite3, decltype(DbDeleter) > x (y, DbDeleter);
int res = sqlite3_bind_text(pStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);
TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);
- LOGI("start");
-
while ( (res= sqlite3_step(pStmt.get())) == SQLITE_ROW )
{
const char* privacyId = reinterpret_cast < const char* > (sqlite3_column_text(pStmt.get(), 0));
isPrompted = true;
- if (isFilteredPackage(pkgId))\r
- {\r
- LOGD("%s is Filtered", pkgId.c_str());\r
- return 0;\r
- }\r
-\r
+ if (isFilteredPackage(pkgId))
+ {
+ LOGD("%s is Filtered", pkgId.c_str());
+ return 0;
+ }
+
openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READONLY);
prepareDb(pDbHandler, query.c_str(), pStmt);
}
else
{
- LOGE("The package[%s] doesnt access privacy", pkgId.c_str());
+ LOGE("The package[%s] can not access privacy", pkgId.c_str());
return PRIV_MGR_ERROR_SUCCESS;
}
int
PrivacyDb::setUserPrompted(const std::string pkgId, bool prompted)
{
- LOGI("enter :%s - %d", pkgId.c_str(), prompted);
+ LOGI("enter");
std::string query = std::string("UPDATE PackageInfo set IS_SET =? where PKG_ID=?");
res = sqlite3_step(pStmt.get());
TryReturn( res == SQLITE_DONE, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_step : %d", res);
+ LOGI("leave");
+
return 0;
}
const char* pPkgId = reinterpret_cast < const char* > (sqlite3_column_text(pStmt.get(), 0));
bool isEnabled = sqlite3_column_int(pStmt.get(), 1) > 0 ? true : false;
- LOGD("result : %s %d", pPkgId, isEnabled);
+ LOGD("result : %s - %d", pPkgId, isEnabled);
list.push_back( std::pair <std::string, bool >(std::string(pPkgId), isEnabled) );
}
- LOGI("leave %d", res);
+ LOGI("leave");
return PRIV_MGR_ERROR_SUCCESS;
}
const char* privilegeId = reinterpret_cast < const char* > (sqlite3_column_text(pStmtPrivilege.get(), 0));\r
const char* privacyId = reinterpret_cast < const char* > (sqlite3_column_text(pStmtPrivilege.get(), 1));\r
m_privilegeToPrivacyMap.insert(std::map < std::string, std::string >::value_type(std::string(privilegeId), std::string(privacyId)));\r
- LOGD(" %s : %s", privilegeId, privacyId);\r
}\r
\r
prepareDb(pDbHandler, sqlDeviceCap.c_str(), pStmtDeviceCap);\r
PrivacyIdInfo::getAllPrivacyId(std::list < std::string >& privacyIdList)\r
{\r
static const std::string sql("SELECT PRIVACY_ID from PrivacyInfo");\r
-\r
- LOGI("enter");\r
\r
openDb(PRIVACY_INFO_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READONLY);\r
prepareDb(pDbHandler, sql.c_str(), pStmt);\r
memcpy(ppPrivilegeList[i], iter->c_str(), strlen(iter->c_str()));\r
++iter;\r
}\r
- for (int i = 0; i < privilegeList.size(); ++i)\r
- LOGD(" values : %s", ppPrivilegeList[i]);\r
\r
ppPrivilegeList[privilegeList.size()] = (char*)calloc (2, sizeof(char));\r
memcpy(ppPrivilegeList[privilegeList.size()], "\0", 1);\r
std::unique_ptr < char[] > pRule(new char[MAX_LOCAL_BUF_SIZE]);\r
\r
snprintf(pRule.get(), MAX_LOCAL_BUF_SIZE, "path='%s',type='signal',interface='%s'", DBUS_PATH.c_str(), DBUS_SIGNAL_INTERFACE.c_str());\r
- LOGD("rule : %s" ,pRule.get());\r
+\r
dbus_bus_add_match(m_pDBusConnection, pRule.get(), &error);\r
TryReturn(!dbus_error_is_set(&error), PRIV_MGR_ERROR_SYSTEM_ERROR, dbus_error_free(&error), "dbus_bus_add_match : %s", error.message);\r
\r
\r
char* pPkgId = const_cast <char*> (pkgId.c_str());\r
char* pPrivacyId = const_cast <char*> (privacyId.c_str());\r
- LOGD("path: %s, inter: %s, name: %s", DBUS_PATH.c_str(), DBUS_SIGNAL_INTERFACE.c_str(), DBUS_SIGNAL_SETTING_CHANGED.c_str());\r
+\r
DBusMessage* pMessage = dbus_message_new_signal(DBUS_PATH.c_str(), DBUS_SIGNAL_INTERFACE.c_str(), DBUS_SIGNAL_SETTING_CHANGED.c_str());\r
TryReturn(pMessage != NULL, PRIV_MGR_ERROR_IPC_ERROR, , "dbus_message_new_signal");\r
\r
return PRIV_MGR_ERROR_INVALID_STATE;\r
\r
char* pPkgId = const_cast <char*> (pkgId.c_str());\r
- LOGD("path: %s, inter: %s, name: %s", DBUS_PATH.c_str(), DBUS_SIGNAL_INTERFACE.c_str(), DBUS_SIGNAL_PKG_REMOVED.c_str());\r
+\r
DBusMessage* pMessage = dbus_message_new_signal(DBUS_PATH.c_str(), DBUS_SIGNAL_INTERFACE.c_str(), DBUS_SIGNAL_PKG_REMOVED.c_str());\r
TryReturn(pMessage != NULL, PRIV_MGR_ERROR_IPC_ERROR, , "dbus_message_new_signal");\r
\r
int\r
PrivacyManagerServer::setPrivacySetting(const std::string pkgId, const std::string privacyId, bool enabled)\r
{\r
- LOGD("Set Privacy: %s, %s, %d", pkgId.c_str(), privacyId.c_str(), enabled);\r
-\r
int res = PrivacyDb::getInstance()->setPrivacySetting(pkgId, privacyId, enabled);\r
TryReturn( res == PRIV_MGR_ERROR_SUCCESS, res, , "privacyDb::setPrivacySetting : %d", res);\r
\r