fix utils

Signed-off-by: kirby <zhangruiming4@huawei.com>
This commit is contained in:
kirby 2024-11-06 10:22:11 +08:00
parent 7e85b33a4f
commit b78a300c1d
3 changed files with 14 additions and 4 deletions

View File

@ -19,7 +19,6 @@
#include <string>
#include "configuration.h"
#include "cj_common_ffi.h"
namespace OHOS {
namespace AbilityRuntime {
@ -37,6 +36,11 @@ struct CConfiguration {
char* mnc;
};
struct CArrString {
char** head;
int64_t size;
};
struct CProcessInformation {
int32_t pid;
int32_t uid;
@ -52,12 +56,12 @@ struct CArrProcessInformation {
int64_t size;
};
CConfiguration CreateCConfiguration(const OHOS::AppExecFwk::Configuration &configuration);
}
}
// The return variable needs free in CJ.
char* CreateCStringFromString(const std::string& source);
char** VectorToCArrString(const std::vector<std::string>& vec);
OHOS::AbilityRuntime::CConfiguration CreateCConfiguration(const OHOS::AppExecFwk::Configuration &configuration);
#endif // OHOS_ABILITY_RUNTIME_CJ_UTILS_FFI_H

View File

@ -113,9 +113,12 @@ int32_t ConvertDisplayId(std::string displayId)
return std::stoi(displayId);
}
OHOS::AbilityRuntime::CConfiguration CreateCConfiguration(const OHOS::AppExecFwk::Configuration &configuration)
namespace OHOS {
namespace AbilityRuntime {
CConfiguration CreateCConfiguration(const OHOS::AppExecFwk::Configuration &configuration)
{
OHOS::AbilityRuntime::CConfiguration cfg;
CConfiguration cfg;
cfg.language = CreateCStringFromString(configuration.GetItem(
OHOS::AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE));
cfg.colorMode = ConvertColorMode(configuration.GetItem(OHOS::AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE));
@ -135,4 +138,6 @@ OHOS::AbilityRuntime::CConfiguration CreateCConfiguration(const OHOS::AppExecFwk
cfg.mcc = CreateCStringFromString(configuration.GetItem(OHOS::AAFwk::GlobalConfigurationKey::SYSTEM_MCC));
cfg.mnc = CreateCStringFromString(configuration.GetItem(OHOS::AAFwk::GlobalConfigurationKey::SYSTEM_MNC));
return cfg;
}
}
}

View File

@ -49,6 +49,7 @@ ohos_unittest("cj_application_context_test") {
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_innerkits_path}/ability_manager:ability_start_setting",
"${ability_runtime_innerkits_path}/ability_manager:mission_info",
"${ability_runtime_innerkits_path}/app_manager:app_manager",
"${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper",
"${ability_runtime_native_path}/ability:ability_context_native",
"${ability_runtime_native_path}/ability/native:ability_thread",