mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 22:21:36 -04:00
!8145 system_kit读取配置路径
Merge pull request !8145 from donglin/system_kit
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "accesstoken_kit.h"
|
||||
#include "config_policy_utils.h"
|
||||
#include "constants.h"
|
||||
#include "connect_server_manager.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
@@ -86,6 +87,7 @@ constexpr char MERGE_ABC_PATH[] = "/ets/modules.abc";
|
||||
constexpr char BUNDLE_INSTALL_PATH[] = "/data/storage/el1/bundle/";
|
||||
constexpr const char* PERMISSION_RUN_ANY_CODE = "ohos.permission.RUN_ANY_CODE";
|
||||
|
||||
const std::string CONFIG_PATH = "/etc/system_kits_config.json";
|
||||
const std::string SYSTEM_KITS_CONFIG_PATH = "/system/etc/system_kits_config.json";
|
||||
|
||||
const std::string SYSTEM_KITS = "systemkits";
|
||||
@@ -1496,18 +1498,29 @@ void JsRuntime::SetDeviceDisconnectCallback(const std::function<bool()> &cb)
|
||||
jsEnv_->SetDeviceDisconnectCallback(cb);
|
||||
}
|
||||
|
||||
std::string JsRuntime::GetSystemKitPath()
|
||||
{
|
||||
char buf[MAX_PATH_LEN] = { 0 };
|
||||
char *configPath = GetOneCfgFile(CONFIG_PATH.c_str(), buf, MAX_PATH_LEN);
|
||||
if (configPath == nullptr || configPath[0] == '\0' || strlen(configPath) > MAX_PATH_LEN) {
|
||||
return SYSTEM_KITS_CONFIG_PATH;
|
||||
}
|
||||
return configPath;
|
||||
}
|
||||
|
||||
std::vector<panda::HmsMap> JsRuntime::GetSystemKitsMap(uint32_t version)
|
||||
{
|
||||
std::vector<panda::HmsMap> systemKitsMap;
|
||||
nlohmann::json jsonBuf;
|
||||
if (access(SYSTEM_KITS_CONFIG_PATH.c_str(), F_OK) != 0) {
|
||||
std::string configPath = GetSystemKitPath();
|
||||
if (configPath == "") {
|
||||
return systemKitsMap;
|
||||
}
|
||||
|
||||
std::fstream in;
|
||||
char errBuf[256];
|
||||
errBuf[0] = '\0';
|
||||
in.open(SYSTEM_KITS_CONFIG_PATH, std::ios_base::in);
|
||||
in.open(configPath, std::ios_base::in);
|
||||
if (!in.is_open()) {
|
||||
strerror_r(errno, errBuf, sizeof(errBuf));
|
||||
return systemKitsMap;
|
||||
|
||||
@@ -103,6 +103,7 @@ ohos_shared_library("runtime") {
|
||||
"bundle_framework:bundle_napi_common",
|
||||
"bundle_framework:libappexecfwk_common",
|
||||
"c_utils:utils",
|
||||
"config_policy:configpolicy_util",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"ets_utils:console",
|
||||
"ets_utils:timer",
|
||||
|
||||
@@ -177,6 +177,7 @@ private:
|
||||
void LoadAotFile(const Options& options);
|
||||
void SetRequestAotCallback();
|
||||
|
||||
std::string GetSystemKitPath();
|
||||
std::vector<panda::HmsMap> GetSystemKitsMap(uint32_t version);
|
||||
|
||||
void GetPkgContextInfoListMap(const std::map<std::string, std::string> &contextInfoMap,
|
||||
|
||||
Reference in New Issue
Block a user