}
return PMINFO_R_OK;
+}
+
+extern "C" EXPORT_API int _appinfo_get_datacontrol_trusted_info(
+ const char *providerid, const char *type, uid_t uid,
+ char **appid, char **trusted) {
+ char *query = nullptr;
+ query = sqlite3_mprintf(
+ "SELECT app_id, trusted FROM package_app_data_control "
+ "WHERE providerid=%Q AND type=%Q", providerid, type);
+ if (query == NULL) {
+ LOGE("Out of memory");
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
+ new pkgmgr_common::parcel::QueryParcelable(uid, std::string(query)));
+
+ pkgmgr_client::PkgInfoClient client(parcelable, uid);
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
+ // TODO: deliver rawdata to reqhandler directly if server is not working
+
+ std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
+ std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
+ client.GetResultParcel()));
+ tizen_base::Parcel parcel;
+ parcel.ReadParcelable(return_parcel.get());
+ sqlite3_free(query);
+ // result_list is vector of string vector
+ auto result_list = return_parcel->GetResult();
+ if (result_list.size() == 0)
+ return PMINFO_R_ENOENT;
+ for (auto result : result_list) {
+ if (result.size() != 2)
+ return PMINFO_R_ERROR;
+ if (result.front().empty() || result.front().size() == 0 ||
+ result.back().empty() || result.back().size() == 0)
+ return PMINFO_R_ERROR;
+ *appid = strdup(result.front().c_str());
+ *trusted = strdup(result.back().c_str());
+ if (*appid == nullptr || *trusted == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return PMINFO_R_ERROR;
+ }
+ }
+
+ return PMINFO_R_OK;
}
\ No newline at end of file
int _appinfo_get_datacontrol_appid(const char *providerid, uid_t uid,
char **appid);
+int _appinfo_get_datacontrol_trusted_info(const char *providerid,
+ const char *type, uid_t uid, char **appid, char **trusted);
+
#ifdef __cplusplus
}
#endif
return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
}
-static int _pkgmgrinfo_appinfo_get_datacontrol_trusted_info(uid_t uid,
- const char *providerid, const char *type, char **appid,
- bool *is_trusted)
-{
- char *query = NULL;
-
- query = sqlite3_mprintf(
- "SELECT app_id, trusted FROM package_app_data_control "
- "WHERE providerid=%Q AND type=%Q", providerid, type);
- if (query == NULL)
- return -1;
-
- // TODO: need to use pkginfo-client APIs
- sqlite3_free(query);
- return 0;
-}
-
API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(
const char *providerid, const char *type, uid_t uid,
char **appid, bool *is_trusted)
{
int ret;
-
+ char *trusted = NULL;
if (providerid == NULL || type == NULL || appid == NULL ||
is_trusted == NULL) {
LOGE("invalid parameter");
return PMINFO_R_EINVAL;
}
- ret = _pkgmgrinfo_appinfo_get_datacontrol_trusted_info(GLOBAL_USER,
- providerid, type, appid, is_trusted);
- if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
- ret = _pkgmgrinfo_appinfo_get_datacontrol_trusted_info(uid,
- providerid, type, appid, is_trusted);
+ ret = _appinfo_get_datacontrol_trusted_info(providerid, type, uid,
+ appid, &trusted);
/* FIXME: It should return PMINFO_R_ENOENT but to keep previous
* implementation, return PMINFO_R_ERROR. This should be
LOGE("no datacontrol trusted info of %s", providerid);
ret = PMINFO_R_ERROR;
}
+ *is_trusted = _get_bool_value(trusted);
+ free(trusted);
return ret;
}