#include "pkgmgr-info.h"
#include "pkgmgrinfo_debug.h"
+#include <vector>
+
#ifdef LOG_TAG
#undef LOG_TAG
#endif
constexpr uid_t REGULAR_USER = 5000;
+uid_t GetGlobalUID() {
+ return tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+}
+
uid_t ConvertUID(uid_t uid) {
if (uid < REGULAR_USER)
return tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
DBHandleProvider::DBHandleProvider(uid_t uid) : uid_(uid),
parser_memory_db_handle_(nullptr, sqlite3_close_v2),
cert_memory_db_handle_(nullptr, sqlite3_close_v2) {
- char* tmp_path = getUserPkgParserDBPathUID(uid_);
+ char *tmp_path = getUserPkgParserDBPathUID(GetGlobalUID());
+ global_parser_file_db_path_ = tmp_path;
+ free(tmp_path);
+
+ tmp_path = getUserPkgParserDBPathUID(uid_);
parser_file_db_path_ = tmp_path;
free(tmp_path);
cert_file_db_path_ = tmp_path;
free(tmp_path);
+ global_parser_memory_db_path_ = "file:parserdb?mode=memory&cache=shared";
parser_memory_db_path_ = "file:parserdb" +
std::to_string(static_cast<int>(uid_)) + "?mode=memory&cache=shared";
cert_memory_db_path_ = "file:certdb" +
return *prov;
}
-std::string DBHandleProvider::GetParserDBPath() {
+std::vector<std::string> DBHandleProvider::GetParserDBPath() {
std::unique_lock<std::mutex> u(lock_);
- if (is_memory_)
- return parser_memory_db_path_;
- else
- return parser_file_db_path_;
+ std::vector<std::string> db_path_list;
+ if (is_memory_) {
+ db_path_list.emplace_back(parser_memory_db_path_);
+ db_path_list.emplace_back(global_parser_memory_db_path_);
+ } else {
+ db_path_list.emplace_back(parser_file_db_path_);
+ db_path_list.emplace_back(global_parser_file_db_path_);
+ }
+ return db_path_list;
}
std::string DBHandleProvider::GetCertDBPath() {
#include <memory>
#include <mutex>
#include <unordered_map>
+#include <vector>
#include "shared_object.hh"
public:
~DBHandleProvider() = default;
static DBHandleProvider& GetInst(uid_t uid);
- std::string GetParserDBPath();
+ std::vector<std::string> GetParserDBPath();
std::string GetCertDBPath();
void SetMemoryMode(bool flag);
std::unique_ptr<sqlite3, decltype(sqlite3_close_v2)*> parser_memory_db_handle_;
std::unique_ptr<sqlite3, decltype(sqlite3_close_v2)*> cert_memory_db_handle_;
std::string parser_memory_db_path_;
+ std::string global_parser_memory_db_path_;
std::string parser_file_db_path_;
+ std::string global_parser_file_db_path_;
std::string cert_memory_db_path_;
std::string cert_file_db_path_;
static bool is_memory_;