!9470 appkit hilog

Merge pull request !9470 from zhuhan/0717_hilog
This commit is contained in:
openharmony_ci 2024-07-26 15:07:21 +00:00 committed by Gitee
commit c95db6fa6d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
32 changed files with 490 additions and 579 deletions

View File

@ -2344,7 +2344,7 @@ napi_value JsAbilityContext::OnRequestModalUIExtension(napi_env env, NapiCallbac
if (*innerErrCode == ERR_OK) {
task.Resolve(env, CreateJsUndefined(env));
} else {
TAG_LOGE(AAFwkTag::APPKIT, "OnRequestModalUIExtension is failed %{public}d", *innerErrCode);
TAG_LOGE(AAFwkTag::APPKIT, "OnRequestModalUIExtension failed %{public}d", *innerErrCode);
task.Reject(env, CreateJsErrorByNativeErr(env, *innerErrCode));
}
};

View File

@ -1086,7 +1086,7 @@ private:
if (*innerErrCode == ERR_OK) {
task.Resolve(env, CreateJsUndefined(env));
} else {
TAG_LOGE(AAFwkTag::APPKIT, "OnRequestModalUIExtension is failed %{public}d", *innerErrCode);
TAG_LOGE(AAFwkTag::APPKIT, "OnRequestModalUIExtension failed %{public}d", *innerErrCode);
task.Reject(env, CreateJsErrorByNativeErr(env, *innerErrCode));
}
};

View File

@ -47,14 +47,10 @@ std::shared_ptr<AbilityStage> AbilityStage::Create(
}
void AbilityStage::OnCreate(const AAFwk::Want &want) const
{
TAG_LOGD(AAFwkTag::APPKIT, "AbilityStage OnCreate come.");
}
{}
void AbilityStage::OnDestroy() const
{
TAG_LOGD(AAFwkTag::APPKIT, "AbilityStage::OnDestroy come");
}
{}
std::shared_ptr<Context> AbilityStage::GetContext() const
{
@ -72,12 +68,12 @@ void AbilityStage::AddAbility(const sptr<IRemoteObject> &token,
const std::shared_ptr<AppExecFwk::AbilityLocalRecord> &abilityRecord)
{
if (token == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "AbilityStage::AddAbility failed, token is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "token is nullptr");
return;
}
if (abilityRecord == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "AbilityStage::AddAbility failed, abilityRecord is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "abilityRecord is nullptr");
return;
}
@ -87,7 +83,7 @@ void AbilityStage::AddAbility(const sptr<IRemoteObject> &token,
void AbilityStage::RemoveAbility(const sptr<IRemoteObject> &token)
{
if (token == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "AbilityStage::RemoveAbility failed, token is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "token is nullptr");
return;
}
abilityRecords_.erase(token);
@ -100,30 +96,23 @@ bool AbilityStage::ContainsAbility() const
std::string AbilityStage::OnAcceptWant(const AAFwk::Want &want)
{
TAG_LOGD(AAFwkTag::APPKIT, "AbilityStage::OnAcceptWant come");
return "";
}
std::string AbilityStage::OnNewProcessRequest(const AAFwk::Want &want)
{
TAG_LOGD(AAFwkTag::APPKIT, "AbilityStage::OnNewProcessRequest come");
return "";
}
void AbilityStage::OnConfigurationUpdated(const AppExecFwk::Configuration& configuration)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
}
{}
void AbilityStage::OnMemoryLevel(int level)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
}
{}
int32_t AbilityStage::RunAutoStartupTask(const std::function<void()> &callback, bool &isAsyncCallback,
const std::shared_ptr<Context> &stageContext)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
isAsyncCallback = false;
return ERR_OK;
}

View File

@ -54,23 +54,23 @@ napi_value AttachAbilityStageContext(napi_env env, void *value, void *)
{
TAG_LOGD(AAFwkTag::APPKIT, "AttachAbilityStageContext");
if (env == nullptr || value == nullptr) {
TAG_LOGW(AAFwkTag::APPKIT, "invalid parameter, env or value is nullptr.");
TAG_LOGW(AAFwkTag::APPKIT, "invalid parameter, env or value is nullptr");
return nullptr;
}
auto ptr = reinterpret_cast<std::weak_ptr<AbilityContext> *>(value)->lock();
if (ptr == nullptr) {
TAG_LOGW(AAFwkTag::APPKIT, "invalid context.");
TAG_LOGW(AAFwkTag::APPKIT, "invalid context");
return nullptr;
}
napi_value object = CreateJsAbilityStageContext(env, ptr);
auto systemModule = JsRuntime::LoadSystemModuleByEngine(env, "application.AbilityStageContext", &object, 1);
if (systemModule == nullptr) {
TAG_LOGW(AAFwkTag::APPKIT, "invalid systemModule.");
TAG_LOGW(AAFwkTag::APPKIT, "invalid systemModule");
return nullptr;
}
auto contextObj = systemModule->GetNapiValue();
if (!CheckTypeForNapiValue(env, contextObj, napi_object)) {
TAG_LOGW(AAFwkTag::APPKIT, "LoadSystemModuleByEngine or ConvertNativeValueTo failed.");
TAG_LOGW(AAFwkTag::APPKIT, "LoadSystemModuleByEngine or ConvertNativeValueTo failed");
return nullptr;
}
napi_coerce_to_native_binding_object(
@ -78,7 +78,7 @@ napi_value AttachAbilityStageContext(napi_env env, void *value, void *)
auto workContext = new (std::nothrow) std::weak_ptr<AbilityRuntime::Context>(ptr);
napi_wrap(env, contextObj, workContext,
[](napi_env, void *data, void *) {
TAG_LOGD(AAFwkTag::APPKIT, "Finalizer for weak_ptr ability stage context is called");
TAG_LOGD(AAFwkTag::APPKIT, "Finalizer context is called");
delete static_cast<std::weak_ptr<AbilityRuntime::Context> *>(data);
},
nullptr, nullptr);
@ -103,7 +103,7 @@ std::shared_ptr<AbilityStage> JsAbilityStage::Create(
const std::unique_ptr<Runtime>& runtime, const AppExecFwk::HapModuleInfo& hapModuleInfo)
{
if (runtime == nullptr) {
TAG_LOGW(AAFwkTag::APPKIT, "invalid parameter, runtime is nullptr.");
TAG_LOGW(AAFwkTag::APPKIT, "runtime is nullptr");
return nullptr;
}
auto& jsRuntime = static_cast<JsRuntime&>(*runtime);
@ -144,7 +144,6 @@ JsAbilityStage::JsAbilityStage(JsRuntime& jsRuntime, std::unique_ptr<NativeRefer
JsAbilityStage::~JsAbilityStage()
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
auto context = GetContext();
if (context) {
context->Unbind();
@ -174,7 +173,6 @@ void JsAbilityStage::Init(const std::shared_ptr<Context> &context,
void JsAbilityStage::OnCreate(const AAFwk::Want &want) const
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
AbilityStage::OnCreate(want);
if (!jsAbilityStageObj_) {
@ -201,7 +199,6 @@ void JsAbilityStage::OnCreate(const AAFwk::Want &want) const
auto delegator = AppExecFwk::AbilityDelegatorRegistry::GetAbilityDelegator();
if (delegator) {
TAG_LOGD(AAFwkTag::APPKIT, "Call PostPerformStageStart");
delegator->PostPerformStageStart(CreateStageProperty());
}
}
@ -303,20 +300,19 @@ std::string JsAbilityStage::OnNewProcessRequest(const AAFwk::Want &want)
void JsAbilityStage::OnConfigurationUpdated(const AppExecFwk::Configuration& configuration)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
AbilityStage::OnConfigurationUpdated(configuration);
HandleScope handleScope(jsRuntime_);
auto env = jsRuntime_.GetNapiEnv();
auto application = application_.lock();
if (application == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "application is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "application is nullptr");
return;
}
// Notify Ability stage context
auto fullConfig = application->GetConfiguration();
if (!fullConfig) {
TAG_LOGE(AAFwkTag::APPKIT, "configuration is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "configuration is nullptr");
return;
}
JsAbilityStageContext::ConfigurationUpdated(env, shellContextRef_, fullConfig);
@ -358,16 +354,16 @@ int32_t JsAbilityStage::RunAutoStartupTask(const std::function<void()> &callback
isAsyncCallback = false;
auto context = GetContext();
if (!context) {
TAG_LOGE(AAFwkTag::APPKIT, "context invalid.");
TAG_LOGE(AAFwkTag::APPKIT, "context invalid");
return ERR_INVALID_VALUE;
}
auto hapModuleInfo = context->GetHapModuleInfo();
if (!hapModuleInfo) {
TAG_LOGE(AAFwkTag::APPKIT, "hapModuleInfo invalid.");
TAG_LOGE(AAFwkTag::APPKIT, "hapModuleInfo invalid");
return ERR_INVALID_VALUE;
}
if (hapModuleInfo->moduleType != AppExecFwk::ModuleType::ENTRY || hapModuleInfo->appStartup.empty()) {
TAG_LOGD(AAFwkTag::APPKIT, "not entry module or appStartup not exist.");
TAG_LOGD(AAFwkTag::APPKIT, "not entry module or appStartup not exist");
return ERR_INVALID_VALUE;
}
if (!shellContextRef_) {
@ -380,7 +376,7 @@ int32_t JsAbilityStage::RunAutoStartupTask(const std::function<void()> &callback
}
std::shared_ptr<StartupManager> startupManager = DelayedSingleton<StartupManager>::GetInstance();
if (startupManager == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "failed to get startupManager.");
TAG_LOGE(AAFwkTag::APPKIT, "failed to get startupManager");
return ERR_INVALID_VALUE;
}
std::shared_ptr<StartupTaskManager> startupTaskManager = nullptr;
@ -411,12 +407,12 @@ int32_t JsAbilityStage::RegisterStartupTaskFromProfile(std::vector<JsStartupTask
TAG_LOGD(AAFwkTag::APPKIT, "called");
std::vector<std::string> profileInfo;
if (!GetProfileInfoFromResourceManager(profileInfo)) {
TAG_LOGE(AAFwkTag::APPKIT, "appStartup config not exist.");
TAG_LOGE(AAFwkTag::APPKIT, "appStartup config not exist");
return ERR_INVALID_VALUE;
}
if (!AnalyzeProfileInfoAndRegisterStartupTask(profileInfo)) {
TAG_LOGE(AAFwkTag::APPKIT, "appStartup config not exist.");
TAG_LOGE(AAFwkTag::APPKIT, "appStartup config not exist");
return ERR_INVALID_VALUE;
}
@ -428,19 +424,19 @@ bool JsAbilityStage::GetProfileInfoFromResourceManager(std::vector<std::string>
TAG_LOGD(AAFwkTag::APPKIT, "called");
auto context = GetContext();
if (!context) {
TAG_LOGE(AAFwkTag::APPKIT, "context is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "context is nullptr");
return false;
}
auto resMgr = context->GetResourceManager();
if (!resMgr) {
TAG_LOGE(AAFwkTag::APPKIT, "resMgr is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "resMgr is nullptr");
return false;
}
auto hapModuleInfo = context->GetHapModuleInfo();
if (!hapModuleInfo) {
TAG_LOGE(AAFwkTag::APPKIT, "hapModuleInfo is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "hapModuleInfo is nullptr");
return false;
}
@ -448,13 +444,13 @@ bool JsAbilityStage::GetProfileInfoFromResourceManager(std::vector<std::string>
bool isCompressed = !hapModuleInfo->hapPath.empty();
std::string appStartup = hapModuleInfo->appStartup;
if (appStartup.empty()) {
TAG_LOGE(AAFwkTag::APPKIT, "appStartup invalid.");
TAG_LOGE(AAFwkTag::APPKIT, "appStartup invalid");
return false;
}
GetResFromResMgr(appStartup, resMgr, isCompressed, profileInfo);
if (profileInfo.empty()) {
TAG_LOGE(AAFwkTag::APPKIT, "appStartup config not exist.");
TAG_LOGE(AAFwkTag::APPKIT, "appStartup config not exist");
return false;
}
return true;
@ -462,19 +458,19 @@ bool JsAbilityStage::GetProfileInfoFromResourceManager(std::vector<std::string>
std::unique_ptr<NativeReference> JsAbilityStage::LoadJsSrcEntry(const std::string &srcEntry)
{
TAG_LOGD(AAFwkTag::APPKIT, "call.");
TAG_LOGD(AAFwkTag::APPKIT, "call");
if (srcEntry.empty()) {
TAG_LOGE(AAFwkTag::APPKIT, "srcEntry invalid.");
TAG_LOGE(AAFwkTag::APPKIT, "srcEntry invalid");
return nullptr;
}
auto context = GetContext();
if (!context) {
TAG_LOGE(AAFwkTag::APPKIT, "context is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "context is nullptr");
return nullptr;
}
auto hapModuleInfo = context->GetHapModuleInfo();
if (!hapModuleInfo) {
TAG_LOGE(AAFwkTag::APPKIT, "hapModuleInfo is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "hapModuleInfo is nullptr");
return nullptr;
}
@ -499,13 +495,13 @@ bool JsAbilityStage::LoadJsStartupConfig(const std::string &srcEntry)
{
std::unique_ptr<NativeReference> startupConfigEntry = LoadJsSrcEntry(srcEntry);
if (startupConfigEntry == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "fail to load config src entry.");
TAG_LOGE(AAFwkTag::APPKIT, "fail to load config src entry");
return false;
}
auto env = jsRuntime_.GetNapiEnv();
std::shared_ptr<JsStartupConfig> startupConfig = std::make_shared<JsStartupConfig>(env);
if (startupConfig == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "startupConfig is null.");
TAG_LOGE(AAFwkTag::APPKIT, "startupConfig is null");
return false;
}
if (startupConfig->Init(startupConfigEntry) != ERR_OK) {

View File

@ -29,13 +29,13 @@ void JsAbilityStageContext::ConfigurationUpdated(napi_env env, std::shared_ptr<N
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
if (!jsContext || !config) {
TAG_LOGE(AAFwkTag::APPKIT, "jsContext or config is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "jsContext or config is nullptr");
return;
}
napi_value object = jsContext->GetNapiValue();
if (!CheckTypeForNapiValue(env, object, napi_object)) {
TAG_LOGE(AAFwkTag::APPKIT, "object is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "object is nullptr");
return;
}

View File

@ -45,20 +45,20 @@ void JsAbilityLifecycleCallback::CallJsMethodInnerCommon(const std::string &meth
for (auto &callback : callbacks) {
if (!callback.second) {
TAG_LOGE(AAFwkTag::APPKIT, "CallJsMethodInnerCommon, Invalid jsCallback");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid jsCallback");
return;
}
auto obj = callback.second->GetNapiValue();
if (!CheckTypeForNapiValue(env_, obj, napi_object)) {
TAG_LOGE(AAFwkTag::APPKIT, "CallJsMethodInnerCommon, Failed to get object");
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get object");
return;
}
napi_value method = nullptr;
napi_get_named_property(env_, obj, methodName.data(), &method);
if (method == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "CallJsMethodInnerCommon, Failed to get %{public}s from object",
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get %{public}s from object",
methodName.data());
return;
}
@ -76,7 +76,7 @@ void JsAbilityLifecycleCallback::CallJsMethodInnerCommon(const std::string &meth
void JsAbilityLifecycleCallback::CallJsMethod(
const std::string &methodName, const std::shared_ptr<NativeReference> &ability)
{
TAG_LOGD(AAFwkTag::APPKIT, "CallJsMethod methodName = %{public}s", methodName.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "methodName = %{public}s", methodName.c_str());
if (!ability) {
TAG_LOGE(AAFwkTag::APPKIT, "ability is nullptr");
return;
@ -89,7 +89,7 @@ void JsAbilityLifecycleCallback::CallJsMethod(
void JsAbilityLifecycleCallback::CallWindowStageJsMethod(const std::string &methodName,
const std::shared_ptr<NativeReference> &ability, const std::shared_ptr<NativeReference> &windowStage)
{
TAG_LOGD(AAFwkTag::APPKIT, "CallWindowStageJsMethod methodName = %{public}s", methodName.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "methodName = %{public}s", methodName.c_str());
if (!ability || !windowStage) {
TAG_LOGE(AAFwkTag::APPKIT, "ability or windowStage is nullptr");
return;
@ -199,18 +199,18 @@ int32_t JsAbilityLifecycleCallback::Register(napi_value jsCallback, bool isSync)
bool JsAbilityLifecycleCallback::UnRegister(int32_t callbackId, bool isSync)
{
TAG_LOGI(AAFwkTag::APPKIT, "UnRegister called, callbackId : %{public}d", callbackId);
TAG_LOGI(AAFwkTag::APPKIT, "callbackId : %{public}d", callbackId);
if (isSync) {
auto it = callbacksSync_.find(callbackId);
if (it == callbacksSync_.end()) {
TAG_LOGE(AAFwkTag::APPKIT, "UnRegister callbackId: %{public}d is not in callbacksSync_", callbackId);
TAG_LOGE(AAFwkTag::APPKIT, "callbackId: %{public}d is not in callbacksSync_", callbackId);
return false;
}
return callbacksSync_.erase(callbackId) == 1;
}
auto it = callbacks_.find(callbackId);
if (it == callbacks_.end()) {
TAG_LOGE(AAFwkTag::APPKIT, "UnRegister callbackId: %{public}d is not in callbacks_", callbackId);
TAG_LOGE(AAFwkTag::APPKIT, "callbackId: %{public}d is not in callbacks_", callbackId);
return false;
}
return callbacks_.erase(callbackId) == 1;

View File

@ -25,14 +25,13 @@ const size_t AbilityStageContext::CONTEXT_TYPE_ID(std::hash<const char*> {} ("Ab
AbilityStageContext::AbilityStageContext()
{
TAG_LOGD(AAFwkTag::APPKIT, "Constructor.");
contextImpl_ = std::make_shared<ContextImpl>();
}
void AbilityStageContext::SetParentContext(const std::shared_ptr<Context> &context)
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return;
}
@ -42,7 +41,7 @@ void AbilityStageContext::SetParentContext(const std::shared_ptr<Context> &conte
void AbilityStageContext::InitHapModuleInfo(const std::shared_ptr<AppExecFwk::AbilityInfo> &abilityInfo)
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return;
}
@ -52,7 +51,7 @@ void AbilityStageContext::InitHapModuleInfo(const std::shared_ptr<AppExecFwk::Ab
void AbilityStageContext::InitHapModuleInfo(const AppExecFwk::HapModuleInfo &hapModuleInfo)
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return;
}
@ -62,7 +61,7 @@ void AbilityStageContext::InitHapModuleInfo(const AppExecFwk::HapModuleInfo &hap
std::shared_ptr<AppExecFwk::HapModuleInfo> AbilityStageContext::GetHapModuleInfo() const
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return nullptr;
}
@ -72,7 +71,7 @@ std::shared_ptr<AppExecFwk::HapModuleInfo> AbilityStageContext::GetHapModuleInfo
void AbilityStageContext::SetConfiguration(const std::shared_ptr<AppExecFwk::Configuration> &config)
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return;
}
@ -82,7 +81,7 @@ void AbilityStageContext::SetConfiguration(const std::shared_ptr<AppExecFwk::Con
std::shared_ptr<AppExecFwk::Configuration> AbilityStageContext::GetConfiguration() const
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return nullptr;
}
@ -92,7 +91,7 @@ std::shared_ptr<AppExecFwk::Configuration> AbilityStageContext::GetConfiguration
void AbilityStageContext::SetResourceManager(const std::shared_ptr<Global::Resource::ResourceManager> &resourceManager)
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return;
}
@ -102,7 +101,7 @@ void AbilityStageContext::SetResourceManager(const std::shared_ptr<Global::Resou
std::shared_ptr<Global::Resource::ResourceManager> AbilityStageContext::GetResourceManager() const
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return nullptr;
}
@ -112,7 +111,7 @@ std::shared_ptr<Global::Resource::ResourceManager> AbilityStageContext::GetResou
std::string AbilityStageContext::GetBundleName() const
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return {};
}
@ -122,7 +121,7 @@ std::string AbilityStageContext::GetBundleName() const
std::shared_ptr<AppExecFwk::ApplicationInfo> AbilityStageContext::GetApplicationInfo() const
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return nullptr;
}
@ -132,7 +131,7 @@ std::shared_ptr<AppExecFwk::ApplicationInfo> AbilityStageContext::GetApplication
std::shared_ptr<Context> AbilityStageContext::CreateBundleContext(const std::string &bundleName)
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return nullptr;
}
@ -142,7 +141,7 @@ std::shared_ptr<Context> AbilityStageContext::CreateBundleContext(const std::str
std::shared_ptr<Context> AbilityStageContext::CreateModuleContext(const std::string &moduleName)
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return nullptr;
}
@ -153,7 +152,7 @@ std::shared_ptr<Context> AbilityStageContext::CreateModuleContext(const std::str
const std::string &moduleName)
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return nullptr;
}
@ -164,7 +163,7 @@ std::shared_ptr<Global::Resource::ResourceManager> AbilityStageContext::CreateMo
const std::string &bundleName, const std::string &moduleName)
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return nullptr;
}
@ -175,7 +174,7 @@ int32_t AbilityStageContext::CreateSystemHspModuleResourceManager(const std::str
const std::string &moduleName, std::shared_ptr<Global::Resource::ResourceManager> &resourceManager)
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return ERR_INVALID_VALUE;
}
@ -185,7 +184,7 @@ int32_t AbilityStageContext::CreateSystemHspModuleResourceManager(const std::str
std::string AbilityStageContext::GetBundleCodePath() const
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return {};
}
@ -195,7 +194,7 @@ std::string AbilityStageContext::GetBundleCodePath() const
std::string AbilityStageContext::GetBundleCodeDir()
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return {};
}
@ -205,7 +204,7 @@ std::string AbilityStageContext::GetBundleCodeDir()
std::string AbilityStageContext::GetCacheDir()
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return {};
}
@ -215,7 +214,7 @@ std::string AbilityStageContext::GetCacheDir()
std::string AbilityStageContext::GetTempDir()
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return {};
}
@ -225,7 +224,7 @@ std::string AbilityStageContext::GetTempDir()
std::string AbilityStageContext::GetFilesDir()
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return {};
}
@ -235,7 +234,7 @@ std::string AbilityStageContext::GetFilesDir()
std::string AbilityStageContext::GetResourceDir()
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return {};
}
@ -245,7 +244,7 @@ std::string AbilityStageContext::GetResourceDir()
std::string AbilityStageContext::GetDatabaseDir()
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return {};
}
@ -255,7 +254,7 @@ std::string AbilityStageContext::GetDatabaseDir()
std::string AbilityStageContext::GetPreferencesDir()
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return {};
}
@ -265,7 +264,7 @@ std::string AbilityStageContext::GetPreferencesDir()
std::string AbilityStageContext::GetGroupDir(std::string groupId)
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return {};
}
@ -275,7 +274,7 @@ std::string AbilityStageContext::GetGroupDir(std::string groupId)
int32_t AbilityStageContext::GetSystemDatabaseDir(const std::string &groupId, bool checkExist, std::string &databaseDir)
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return ERR_INVALID_VALUE;
}
@ -286,7 +285,7 @@ int32_t AbilityStageContext::GetSystemPreferencesDir(const std::string &groupId,
std::string &preferencesDir)
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return ERR_INVALID_VALUE;
}
@ -296,7 +295,7 @@ int32_t AbilityStageContext::GetSystemPreferencesDir(const std::string &groupId,
std::string AbilityStageContext::GetDistributedFilesDir()
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return {};
}
@ -306,7 +305,7 @@ std::string AbilityStageContext::GetDistributedFilesDir()
std::string AbilityStageContext::GetCloudFileDir()
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return {};
}
@ -316,7 +315,7 @@ std::string AbilityStageContext::GetCloudFileDir()
std::string AbilityStageContext::GetBaseDir() const
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return {};
}
@ -326,7 +325,7 @@ std::string AbilityStageContext::GetBaseDir() const
bool AbilityStageContext::IsUpdatingConfigurations()
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return false;
}
@ -336,7 +335,7 @@ bool AbilityStageContext::IsUpdatingConfigurations()
bool AbilityStageContext::PrintDrawnCompleted()
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return false;
}
@ -346,7 +345,7 @@ bool AbilityStageContext::PrintDrawnCompleted()
sptr<IRemoteObject> AbilityStageContext::GetToken()
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return nullptr;
}
@ -356,7 +355,7 @@ sptr<IRemoteObject> AbilityStageContext::GetToken()
void AbilityStageContext::SetToken(const sptr<IRemoteObject> &token)
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return;
}
@ -366,7 +365,7 @@ void AbilityStageContext::SetToken(const sptr<IRemoteObject> &token)
void AbilityStageContext::SwitchArea(int mode)
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return;
}
@ -376,7 +375,7 @@ void AbilityStageContext::SwitchArea(int mode)
int AbilityStageContext::GetArea()
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return ContextImpl::EL_DEFAULT;
}
@ -386,7 +385,7 @@ int AbilityStageContext::GetArea()
Global::Resource::DeviceType AbilityStageContext::GetDeviceType() const
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid contextImpl");
return Global::Resource::DeviceType::DEVICE_PHONE;
}

View File

@ -237,9 +237,9 @@ void ApplicationContext::DispatchOnAbilityContinue(const std::shared_ptr<NativeR
void ApplicationContext::DispatchOnAbilityWillContinue(const std::shared_ptr<NativeReference> &ability)
{
TAG_LOGD(AAFwkTag::APPKIT, "Dispatch onAbilityWillContinue.");
TAG_LOGD(AAFwkTag::APPKIT, "Dispatch onAbilityWillContinue");
if (ability == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Parameters invalid, ability is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "ability is nullptr");
return;
}
@ -254,9 +254,9 @@ void ApplicationContext::DispatchOnAbilityWillContinue(const std::shared_ptr<Nat
void ApplicationContext::DispatchOnWindowStageWillRestore(const std::shared_ptr<NativeReference> &ability,
const std::shared_ptr<NativeReference> &windowStage)
{
TAG_LOGD(AAFwkTag::APPKIT, "Dispatch onWindowStageWillRestore.");
TAG_LOGD(AAFwkTag::APPKIT, "Dispatch onWindowStageWillRestore");
if (ability == nullptr || windowStage == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Parameters invalid, ability or windowStage is null.");
TAG_LOGE(AAFwkTag::APPKIT, "ability or windowStage is null");
return;
}
@ -271,9 +271,9 @@ void ApplicationContext::DispatchOnWindowStageWillRestore(const std::shared_ptr<
void ApplicationContext::DispatchOnWindowStageRestore(const std::shared_ptr<NativeReference> &ability,
const std::shared_ptr<NativeReference> &windowStage)
{
TAG_LOGD(AAFwkTag::APPKIT, "Dispatch onWindowStageRestore.");
TAG_LOGD(AAFwkTag::APPKIT, "Dispatch onWindowStageRestore");
if (ability == nullptr || windowStage == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Parameters invalid, ability or windowStage is null.");
TAG_LOGE(AAFwkTag::APPKIT, "ability or windowStage is null");
return;
}
@ -287,9 +287,9 @@ void ApplicationContext::DispatchOnWindowStageRestore(const std::shared_ptr<Nati
void ApplicationContext::DispatchOnAbilityWillSaveState(const std::shared_ptr<NativeReference> &ability)
{
TAG_LOGD(AAFwkTag::APPKIT, "Dispatch onAbilityWillSaveState.");
TAG_LOGD(AAFwkTag::APPKIT, "Dispatch onAbilityWillSaveState");
if (ability == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Parameters invalid, ability is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "ability is nullptr");
return;
}
@ -305,7 +305,7 @@ void ApplicationContext::DispatchOnAbilitySaveState(const std::shared_ptr<Native
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
if (ability == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Parameters invalid, ability is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "ability is nullptr");
return;
}
@ -639,7 +639,7 @@ int32_t ApplicationContext::RestartApp(const AAFwk::Want& want)
{
std::string abilityName = want.GetElement().GetAbilityName();
if (abilityName == "") {
TAG_LOGE(AAFwkTag::APPKIT, "abilityName is empty.");
TAG_LOGE(AAFwkTag::APPKIT, "abilityName is empty");
return ERR_INVALID_VALUE;
}
std::string bundleName = GetBundleName();
@ -678,9 +678,9 @@ void ApplicationContext::SwitchArea(int mode)
void ApplicationContext::SetColorMode(int32_t colorMode)
{
TAG_LOGD(AAFwkTag::APPKIT, "colorMode:%{public}d.", colorMode);
TAG_LOGD(AAFwkTag::APPKIT, "colorMode:%{public}d", colorMode);
if (colorMode < -1 || colorMode > 1) {
TAG_LOGE(AAFwkTag::APPKIT, "colorMode is invalid.");
TAG_LOGE(AAFwkTag::APPKIT, "colorMode is invalid");
return;
}
AppExecFwk::Configuration config;
@ -694,7 +694,7 @@ void ApplicationContext::SetColorMode(int32_t colorMode)
void ApplicationContext::SetLanguage(const std::string &language)
{
TAG_LOGD(AAFwkTag::APPKIT, "language:%{public}s.", language.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "language:%{public}s", language.c_str());
AppExecFwk::Configuration config;
config.AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE, language);
config.AddItem(AAFwk::GlobalConfigurationKey::LANGUAGE_IS_SET_BY_APP,
@ -706,7 +706,7 @@ void ApplicationContext::SetLanguage(const std::string &language)
void ApplicationContext::SetFont(const std::string &font)
{
TAG_LOGD(AAFwkTag::APPKIT, "font:%{public}s.", font.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "font:%{public}s", font.c_str());
#ifdef SUPPORT_GRAPHICS
// Notify Window
AppExecFwk::Configuration config;
@ -741,7 +741,7 @@ void ApplicationContext::ClearUpApplicationData()
int ApplicationContext::GetArea()
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "AbilityContext::contextImpl is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "contextImpl is nullptr");
return ContextImpl::EL_DEFAULT;
}
return contextImpl_->GetArea();
@ -774,26 +774,26 @@ void ApplicationContext::RegisterAppFontObserver(AppConfigUpdateCallback appFont
std::string ApplicationContext::GetAppRunningUniqueId() const
{
TAG_LOGD(AAFwkTag::APPKIT, "GetAppRunningUniqueId is %{public}s.", appRunningUniqueId_.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "GetAppRunningUniqueId is %{public}s", appRunningUniqueId_.c_str());
return appRunningUniqueId_;
}
int32_t ApplicationContext::GetCurrentAppCloneIndex()
{
TAG_LOGD(AAFwkTag::APPKIT, "getCurrentAppCloneIndex is %{public}d.", appIndex_);
TAG_LOGD(AAFwkTag::APPKIT, "getCurrentAppCloneIndex is %{public}d", appIndex_);
return appIndex_;
}
int32_t ApplicationContext::GetCurrentAppMode()
{
TAG_LOGD(AAFwkTag::APPKIT, "getCurrentMode is %{public}d.", appMode_);
TAG_LOGD(AAFwkTag::APPKIT, "getCurrentMode is %{public}d", appMode_);
return appMode_;
}
void ApplicationContext::SetAppRunningUniqueId(const std::string &appRunningUniqueId)
{
TAG_LOGD(AAFwkTag::APPKIT, "SetAppRunningUniqueId is %{public}s.", appRunningUniqueId.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "SetAppRunningUniqueId is %{public}s", appRunningUniqueId.c_str());
appRunningUniqueId_ = appRunningUniqueId;
}
@ -802,19 +802,19 @@ int32_t ApplicationContext::SetSupportedProcessCacheSelf(bool isSupport)
if (contextImpl_ != nullptr) {
return contextImpl_->SetSupportedProcessCacheSelf(isSupport);
}
TAG_LOGE(AAFwkTag::APPKIT, "contextImpl_ is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "contextImpl_ is nullptr");
return ERR_INVALID_VALUE;
}
void ApplicationContext::SetCurrentAppCloneIndex(int32_t appIndex)
{
TAG_LOGD(AAFwkTag::APPKIT, "setCurrentAppCloneIndex is %{public}d.", appIndex);
TAG_LOGD(AAFwkTag::APPKIT, "setCurrentAppCloneIndex is %{public}d", appIndex);
appIndex_ = appIndex;
}
void ApplicationContext::SetCurrentAppMode(int32_t appMode)
{
TAG_LOGD(AAFwkTag::APPKIT, "setCurrentAppMode is %{public}d.", appMode);
TAG_LOGD(AAFwkTag::APPKIT, "setCurrentAppMode is %{public}d", appMode);
appMode_ = appMode;
}
} // namespace AbilityRuntime

View File

@ -94,7 +94,7 @@ void JsApplicationStateChangeCallback::Register(napi_value jsCallback)
bool JsApplicationStateChangeCallback::UnRegister(napi_value jsCallback)
{
if (jsCallback == nullptr) {
TAG_LOGI(AAFwkTag::APPKIT, "jsCallback is nullptr, delete all callback.");
TAG_LOGI(AAFwkTag::APPKIT, "jsCallback is nullptr, delete all callback");
callbacks_.clear();
return true;
}

View File

@ -237,7 +237,7 @@ int32_t ContextImpl::GetGroupDirWithCheck(const std::string &groupId, bool check
}
int errCode = GetBundleManager();
if (errCode != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "failed, errCode: %{public}d.", errCode);
TAG_LOGE(AAFwkTag::APPKIT, "failed, errCode: %{public}d", errCode);
return errCode;
}
std::string groupDirGet;
@ -352,18 +352,18 @@ std::string ContextImpl::GetCloudFileDir()
void ContextImpl::SwitchArea(int mode)
{
TAG_LOGD(AAFwkTag::APPKIT, "mode:%{public}d.", mode);
TAG_LOGD(AAFwkTag::APPKIT, "mode:%{public}d", mode);
if (mode < 0 || mode >= (int)(sizeof(CONTEXT_ELS) / sizeof(CONTEXT_ELS[0]))) {
TAG_LOGE(AAFwkTag::APPKIT, "ContextImpl::SwitchArea, mode is invalid.");
return;
}
currArea_ = CONTEXT_ELS[mode];
TAG_LOGD(AAFwkTag::APPKIT, "currArea:%{public}s.", currArea_.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "currArea:%{public}s", currArea_.c_str());
}
void ContextImpl::SetMcc(std::string mcc)
{
TAG_LOGD(AAFwkTag::APPKIT, "mcc:%{public}s.", mcc.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "mcc:%{public}s", mcc.c_str());
if (config_) {
config_->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_MCC, mcc);
}
@ -371,7 +371,7 @@ void ContextImpl::SetMcc(std::string mcc)
void ContextImpl::SetMnc(std::string mnc)
{
TAG_LOGD(AAFwkTag::APPKIT, "mnc:%{public}s.", mnc.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "mnc:%{public}s", mnc.c_str());
if (config_) {
config_->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_MNC, mnc);
}
@ -385,7 +385,7 @@ std::shared_ptr<Context> ContextImpl::CreateModuleContext(const std::string &mod
std::shared_ptr<Context> ContextImpl::CreateModuleContext(const std::string &bundleName, const std::string &moduleName)
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::APPKIT, "begin.");
TAG_LOGD(AAFwkTag::APPKIT, "begin");
if (bundleName.empty() || moduleName.empty()) {
return nullptr;
}
@ -418,7 +418,7 @@ std::shared_ptr<Context> ContextImpl::CreateModuleContext(const std::string &bun
return hapModuleInfo.moduleName == moduleName;
});
if (info == bundleInfo.hapModuleInfos.end()) {
TAG_LOGE(AAFwkTag::APPKIT, "moduleName is error.");
TAG_LOGE(AAFwkTag::APPKIT, "moduleName is error");
return nullptr;
}
appContext->InitHapModuleInfo(*info);
@ -531,7 +531,7 @@ int32_t ContextImpl::GetBundleInfo(const std::string &bundleName, AppExecFwk::Bu
int errCode = GetBundleManager();
if (errCode != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "errCode: %{public}d.", errCode);
TAG_LOGE(AAFwkTag::APPKIT, "errCode: %{public}d", errCode);
return errCode;
}
@ -570,7 +570,7 @@ void ContextImpl::GetBundleInfo(const std::string &bundleName, AppExecFwk::Bundl
if (bundleMgr_ == nullptr) {
int errCode = GetBundleManager();
if (errCode != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "failed, errCode: %{public}d.", errCode);
TAG_LOGE(AAFwkTag::APPKIT, "failed, errCode: %{public}d", errCode);
return;
}
}
@ -600,7 +600,7 @@ int ContextImpl::GetArea()
}
}
if (mode == -1) {
TAG_LOGE(AAFwkTag::APPKIT, "not find mode.");
TAG_LOGE(AAFwkTag::APPKIT, "not find mode");
return EL_DEFAULT;
}
TAG_LOGD(AAFwkTag::APPKIT, "end");
@ -631,7 +631,7 @@ int ContextImpl::GetCurrentAccountId() const
int userId = 0;
auto instance = DelayedSingleton<AppExecFwk::OsAccountManagerWrapper>::GetInstance();
if (instance == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get OsAccountManager instance.");
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get OsAccountManager instance");
return userId;
}
instance->GetOsAccountLocalIdFromProcess(userId);
@ -644,22 +644,22 @@ int ContextImpl::GetCurrentActiveAccountId() const
std::vector<int> accountIds;
auto instance = DelayedSingleton<AppExecFwk::OsAccountManagerWrapper>::GetInstance();
if (instance == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get OsAccountManager instance.");
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get OsAccountManager instance");
return 0;
}
ErrCode ret = instance->QueryActiveOsAccountIds(accountIds);
if (ret != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "ContextImpl::GetCurrentActiveAccountId error.");
TAG_LOGE(AAFwkTag::APPKIT, "ContextImpl::GetCurrentActiveAccountId error");
return 0;
}
if (accountIds.size() == 0) {
TAG_LOGE(AAFwkTag::APPKIT, "no accounts.");
TAG_LOGE(AAFwkTag::APPKIT, "no accounts");
return 0;
}
if (accountIds.size() > 1) {
TAG_LOGE(AAFwkTag::APPKIT, "no current now.");
TAG_LOGE(AAFwkTag::APPKIT, "no current now");
return 0;
}
@ -669,7 +669,7 @@ int ContextImpl::GetCurrentActiveAccountId() const
std::shared_ptr<Context> ContextImpl::CreateBundleContext(const std::string &bundleName)
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::APPKIT, "begin.");
TAG_LOGD(AAFwkTag::APPKIT, "begin");
if (parentContext_ != nullptr) {
return parentContext_->CreateBundleContext(bundleName);
}
@ -681,7 +681,7 @@ std::shared_ptr<Context> ContextImpl::CreateBundleContext(const std::string &bun
int errCode = GetBundleManager();
if (errCode != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "failed, errCode: %{public}d.", errCode);
TAG_LOGE(AAFwkTag::APPKIT, "failed, errCode: %{public}d", errCode);
return nullptr;
}
@ -798,12 +798,12 @@ std::shared_ptr<Global::Resource::ResourceManager> ContextImpl::InitResourceMana
} else if (bundleInfo.applicationInfo.bundleType == AppExecFwk::BundleType::SHARED) {
loadPath = std::regex_replace(loadPath, hsp_pattern, hsp_sandbox);
} else if (bundleInfo.applicationInfo.bundleType == AppExecFwk::BundleType::APP_SERVICE_FWK) {
TAG_LOGD(AAFwkTag::APPKIT, "System hsp path, not need translate.");
TAG_LOGD(AAFwkTag::APPKIT, "System hsp path, not need translate");
} else {
loadPath = std::regex_replace(loadPath, outer_pattern, LOCAL_BUNDLES);
}
TAG_LOGD(AAFwkTag::APPKIT, "loadPath: %{public}s", loadPath.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "loadPath: %{private}s", loadPath.c_str());
GetOverlayPath(resourceManager, bundleInfo.name, hapModuleInfo.moduleName, loadPath, currentBundle);
AddPatchResource(resourceManager, loadPath, hapModuleInfo.hqfInfo.hqfFilePath,
bundleInfo.applicationInfo.debug);
@ -838,7 +838,7 @@ void ContextImpl::GetOverlayPath(std::shared_ptr<Global::Resource::ResourceManag
}
if (overlayModuleInfos.size() == 0) {
if (!resourceManager->AddResource(loadPath.c_str())) {
TAG_LOGE(AAFwkTag::APPKIT, "AddResource fail, moduleResPath: %{public}s", loadPath.c_str());
TAG_LOGE(AAFwkTag::APPKIT, "AddResource fail, moduleResPath: %{private}s", loadPath.c_str());
}
} else {
std::vector<std::string> overlayPaths;
@ -850,7 +850,7 @@ void ContextImpl::GetOverlayPath(std::shared_ptr<Global::Resource::ResourceManag
it.hapPath = std::regex_replace(it.hapPath, std::regex(ABS_CODE_PATH), LOCAL_BUNDLES);
}
if (it.state == AppExecFwk::OverlayState::OVERLAY_ENABLE) {
TAG_LOGD(AAFwkTag::APPKIT, "hapPath: %{public}s", it.hapPath.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "hapPath: %{private}s", it.hapPath.c_str());
overlayPaths.emplace_back(it.hapPath);
}
}
@ -902,7 +902,7 @@ void ContextImpl::UpdateResConfig(std::shared_ptr<Global::Resource::ResourceMana
if (load && GetApplicationInfo()->apiTargetVersion % API_VERSION_MOD >= API11) {
std::shared_ptr<Global::Resource::ResourceManager> currentResMgr = GetResourceManager();
if (currentResMgr != nullptr) {
TAG_LOGD(AAFwkTag::APPKIT, "apiVersion: %{public}d, load parent config.",
TAG_LOGD(AAFwkTag::APPKIT, "apiVersion: %{public}d, load parent config",
GetApplicationInfo()->apiTargetVersion);
currentResMgr->GetResConfig(*resConfig);
}
@ -918,7 +918,7 @@ void ContextImpl::UpdateResConfig(std::shared_ptr<Global::Resource::ResourceMana
resConfig->GetLocaleInfo()->getLanguage(), resConfig->GetLocaleInfo()->getScript(),
resConfig->GetLocaleInfo()->getCountry());
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextImpl::InitResourceManager language: GetLocaleInfo is null.");
TAG_LOGE(AAFwkTag::APPKIT, "LocaleInfo is null");
}
#endif
resConfig->SetDeviceType(GetDeviceType());
@ -928,7 +928,7 @@ void ContextImpl::UpdateResConfig(std::shared_ptr<Global::Resource::ResourceMana
resConfig->SetMcc(static_cast<uint32_t>(std::stoi(mcc)));
resConfig->SetMnc(static_cast<uint32_t>(std::stoi(mnc)));
} catch (...) {
TAG_LOGW(AAFwkTag::APPKIT, "Set mcc,mnc failed mcc:%{public}s mnc:%{public}s.", mcc.c_str(), mnc.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "Set mcc,mnc failed mcc:%{public}s mnc:%{public}s", mcc.c_str(), mnc.c_str());
}
resourceManager->UpdateResConfig(*resConfig);
}
@ -943,11 +943,11 @@ ErrCode ContextImpl::GetBundleManager()
bundleMgr_ = DelayedSingleton<AppExecFwk::BundleMgrHelper>::GetInstance();
if (bundleMgr_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "The bundleMgr_ is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "The bundleMgr_ is nullptr");
return ERR_NULL_OBJECT;
}
TAG_LOGD(AAFwkTag::APPKIT, "Success.");
TAG_LOGD(AAFwkTag::APPKIT, "Success");
return ERR_OK;
}
@ -962,9 +962,7 @@ void ContextImpl::SetApplicationInfo(const std::shared_ptr<AppExecFwk::Applicati
void ContextImpl::SetResourceManager(const std::shared_ptr<Global::Resource::ResourceManager> &resourceManager)
{
TAG_LOGD(AAFwkTag::APPKIT, "Start.");
resourceManager_ = resourceManager;
TAG_LOGD(AAFwkTag::APPKIT, "End.");
}
std::shared_ptr<Global::Resource::ResourceManager> ContextImpl::GetResourceManager() const
@ -1005,7 +1003,7 @@ void ContextImpl::InitHapModuleInfo(const std::shared_ptr<AppExecFwk::AbilityInf
}
int errCode = GetBundleManager();
if (errCode != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "failed, errCode: %{public}d.", errCode);
TAG_LOGE(AAFwkTag::APPKIT, "failed, errCode: %{public}d", errCode);
return ;
}
@ -1070,7 +1068,7 @@ void ContextImpl::CreateDirIfNotExist(const std::string& dirPath, const mode_t&
TAG_LOGD(AAFwkTag::APPKIT, "ForceCreateDirectory, dir: %{public}s", dirPath.c_str());
bool createDir = OHOS::ForceCreateDirectory(dirPath);
if (!createDir) {
TAG_LOGE(AAFwkTag::APPKIT, "create dir %{public}s failed, errno is %{public}d.", dirPath.c_str(), errno);
TAG_LOGE(AAFwkTag::APPKIT, "create dir %{public}s failed, errno is %{public}d", dirPath.c_str(), errno);
return;
}
if (mode != 0) {
@ -1086,7 +1084,7 @@ void ContextImpl::SetConfiguration(const std::shared_ptr<AppExecFwk::Configurati
void ContextImpl::KillProcessBySelf(const bool clearPageStack)
{
TAG_LOGD(AAFwkTag::APPKIT, "killProcessBySelf called clearPageStack is %{public}d.", clearPageStack);
TAG_LOGD(AAFwkTag::APPKIT, "killProcessBySelf called clearPageStack is %{public}d", clearPageStack);
auto appMgrClient = DelayedSingleton<AppExecFwk::AppMgrClient>::GetInstance();
appMgrClient->KillApplicationSelf(clearPageStack);
}
@ -1095,14 +1093,14 @@ int32_t ContextImpl::GetProcessRunningInformation(AppExecFwk::RunningProcessInfo
{
auto appMgrClient = DelayedSingleton<AppExecFwk::AppMgrClient>::GetInstance();
auto result = appMgrClient->GetProcessRunningInformation(info);
TAG_LOGD(AAFwkTag::APPKIT, "result is %{public}d.", result);
TAG_LOGD(AAFwkTag::APPKIT, "result is %{public}d", result);
return result;
}
int32_t ContextImpl::RestartApp(const AAFwk::Want& want)
{
auto result = OHOS::AAFwk::AbilityManagerClient::GetInstance()->RestartApp(want);
TAG_LOGD(AAFwkTag::APPKIT, "result is %{public}d.", result);
TAG_LOGD(AAFwkTag::APPKIT, "result is %{public}d", result);
return result;
}
@ -1120,14 +1118,14 @@ Global::Resource::DeviceType ContextImpl::GetDeviceType() const
auto config = GetConfiguration();
if (config != nullptr) {
auto deviceType = config->GetItem(AAFwk::GlobalConfigurationKey::DEVICE_TYPE);
TAG_LOGD(AAFwkTag::APPKIT, "deviceType is %{public}s.", deviceType.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "deviceType is %{public}s", deviceType.c_str());
deviceType_ = AppExecFwk::ConvertDeviceType(deviceType);
}
if (deviceType_ == Global::Resource::DeviceType::DEVICE_NOT_SET) {
deviceType_ = Global::Resource::DeviceType::DEVICE_PHONE;
}
TAG_LOGD(AAFwkTag::APPKIT, "deviceType is %{public}d.", deviceType_);
TAG_LOGD(AAFwkTag::APPKIT, "deviceType is %{public}d", deviceType_);
return deviceType_;
}
@ -1136,7 +1134,7 @@ ErrCode ContextImpl::GetOverlayMgrProxy()
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
int errCode = GetBundleManager();
if (errCode != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "failed, errCode: %{public}d.", errCode);
TAG_LOGE(AAFwkTag::APPKIT, "failed, errCode: %{public}d", errCode);
return errCode;
}
@ -1147,7 +1145,7 @@ ErrCode ContextImpl::GetOverlayMgrProxy()
overlayMgrProxy_ = bundleMgr_->GetOverlayManagerProxy();
if (overlayMgrProxy_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "GetOverlayManagerProxy failed.");
TAG_LOGE(AAFwkTag::APPKIT, "GetOverlayManagerProxy failed");
return ERR_NULL_OBJECT;
}
@ -1161,14 +1159,14 @@ int ContextImpl::GetOverlayModuleInfos(const std::string &bundleName, const std:
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
int errCode = GetOverlayMgrProxy();
if (errCode != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "failed, errCode: %{public}d.", errCode);
TAG_LOGE(AAFwkTag::APPKIT, "failed, errCode: %{public}d", errCode);
return errCode;
}
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "overlayMgrProxy_->GetTargetOverlayModuleInfo");
auto ret = overlayMgrProxy_->GetTargetOverlayModuleInfo(moduleName, overlayModuleInfos);
if (ret != ERR_OK) {
TAG_LOGD(AAFwkTag::APPKIT, "GetOverlayModuleInfo form bms failed.");
TAG_LOGD(AAFwkTag::APPKIT, "GetOverlayModuleInfo form bms failed");
return ret;
}
}
@ -1193,7 +1191,7 @@ std::vector<std::string> ContextImpl::GetAddOverlayPaths(
if ((iter != overlayModuleInfos_.end()) && (it.state == AppExecFwk::OverlayState::OVERLAY_ENABLE)) {
iter->state = it.state;
ChangeToLocalPath(iter->bundleName, iter->hapPath, iter->hapPath);
TAG_LOGD(AAFwkTag::APPKIT, "add path:%{public}s", iter->hapPath.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "add path:%{private}s", iter->hapPath.c_str());
addPaths.emplace_back(iter->hapPath);
}
}
@ -1214,7 +1212,7 @@ std::vector<std::string> ContextImpl::GetRemoveOverlayPaths(
if ((iter != overlayModuleInfos_.end()) && (it.state != AppExecFwk::OverlayState::OVERLAY_ENABLE)) {
iter->state = it.state;
ChangeToLocalPath(iter->bundleName, iter->hapPath, iter->hapPath);
TAG_LOGD(AAFwkTag::APPKIT, "remove path:%{public}s", iter->hapPath.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "remove path:%{private}s", iter->hapPath.c_str());
removePaths.emplace_back(iter->hapPath);
}
}
@ -1227,25 +1225,25 @@ void ContextImpl::OnOverlayChanged(const EventFwk::CommonEventData &data,
const std::string &moduleName, const std::string &loadPath)
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::APPKIT, "begin.");
TAG_LOGD(AAFwkTag::APPKIT, "begin");
auto want = data.GetWant();
std::string action = want.GetAction();
if (action != OVERLAY_STATE_CHANGED) {
TAG_LOGD(AAFwkTag::APPKIT, "Not this subscribe, action: %{public}s.", action.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "Not this subscribe, action: %{public}s", action.c_str());
return;
}
if (GetBundleName() != bundleName) {
TAG_LOGD(AAFwkTag::APPKIT, "Not this app, bundleName: %{public}s.", bundleName.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "Not this app, bundleName: %{public}s", bundleName.c_str());
return;
}
bool isEnable = data.GetWant().GetBoolParam(AppExecFwk::Constants::OVERLAY_STATE, false);
// 1.get overlay hapPath
if (resourceManager == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "resourceManager is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "resourceManager is nullptr");
return;
}
if (overlayModuleInfos_.size() == 0) {
TAG_LOGE(AAFwkTag::APPKIT, "overlayModuleInfos is empty.");
TAG_LOGE(AAFwkTag::APPKIT, "overlayModuleInfos is empty");
return;
}
std::vector<AppExecFwk::OverlayModuleInfo> overlayModuleInfos;
@ -1256,7 +1254,7 @@ void ContextImpl::OnOverlayChanged(const EventFwk::CommonEventData &data,
// 2.add/remove overlay hapPath
if (loadPath.empty() || overlayModuleInfos.size() == 0) {
TAG_LOGW(AAFwkTag::APPKIT, "There is not any hapPath in overlayModuleInfo.");
TAG_LOGW(AAFwkTag::APPKIT, "There is not any hapPath in overlayModuleInfo");
} else {
if (isEnable) {
std::vector<std::string> overlayPaths = GetAddOverlayPaths(overlayModuleInfos);

View File

@ -32,23 +32,23 @@ int32_t JsEnvironmentCallback::serialNumber_ = 0;
void JsEnvironmentCallback::CallConfigurationUpdatedInner(const std::string &methodName,
const AppExecFwk::Configuration &config, const std::map<int32_t, std::shared_ptr<NativeReference>> &callbacks)
{
TAG_LOGD(AAFwkTag::APPKIT, "CallConfigurationUpdatedInner methodName = %{public}s", methodName.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "methodName = %{public}s", methodName.c_str());
for (auto &callback : callbacks) {
if (!callback.second) {
TAG_LOGE(AAFwkTag::APPKIT, "CallConfigurationUpdatedInner, Invalid jsCallback");
TAG_LOGE(AAFwkTag::APPKIT, " Invalid jsCallback");
return;
}
auto obj = callback.second->GetNapiValue();
if (!CheckTypeForNapiValue(env_, obj, napi_object)) {
TAG_LOGE(AAFwkTag::APPKIT, "CallConfigurationUpdatedInner, Failed to get object");
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get object");
return;
}
napi_value method = nullptr;
napi_get_named_property(env_, obj, methodName.data(), &method);
if (method == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "CallConfigurationUpdatedInner, Failed to get %{public}s from object",
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get %{public}s from object",
methodName.data());
return;
}
@ -80,23 +80,23 @@ void JsEnvironmentCallback::OnConfigurationUpdated(const AppExecFwk::Configurati
void JsEnvironmentCallback::CallMemoryLevelInner(const std::string &methodName, const int level,
const std::map<int32_t, std::shared_ptr<NativeReference>> &callbacks)
{
TAG_LOGD(AAFwkTag::APPKIT, "CallMemoryLevelInner methodName = %{public}s", methodName.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "methodName = %{public}s", methodName.c_str());
for (auto &callback : callbacks) {
if (!callback.second) {
TAG_LOGE(AAFwkTag::APPKIT, "CallMemoryLevelInner, Invalid jsCallback");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid jsCallback");
return;
}
auto obj = callback.second->GetNapiValue();
if (!CheckTypeForNapiValue(env_, obj, napi_object)) {
TAG_LOGE(AAFwkTag::APPKIT, "CallMemoryLevelInner, Failed to get object");
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get object");
return;
}
napi_value method = nullptr;
napi_get_named_property(env_, obj, methodName.data(), &method);
if (method == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "CallMemoryLevelInner, Failed to get %{public}s from object", methodName.data());
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get %{public}s from object", methodName.data());
return;
}
@ -126,7 +126,6 @@ void JsEnvironmentCallback::OnMemoryLevel(const int level)
int32_t JsEnvironmentCallback::Register(napi_value jsCallback, bool isSync)
{
TAG_LOGD(AAFwkTag::APPKIT, "start");
if (env_ == nullptr) {
return -1;
}
@ -143,17 +142,16 @@ int32_t JsEnvironmentCallback::Register(napi_value jsCallback, bool isSync)
} else {
callbacks_.emplace(callbackId, std::shared_ptr<NativeReference>(reinterpret_cast<NativeReference*>(ref)));
}
TAG_LOGD(AAFwkTag::APPKIT, "end");
return callbackId;
}
bool JsEnvironmentCallback::UnRegister(int32_t callbackId, bool isSync)
{
TAG_LOGD(AAFwkTag::APPKIT, "UnRegister called, env callbackId : %{public}d", callbackId);
TAG_LOGD(AAFwkTag::APPKIT, "callbackId : %{public}d", callbackId);
if (isSync) {
auto it = callbacksSync_.find(callbackId);
if (it == callbacksSync_.end()) {
TAG_LOGE(AAFwkTag::APPKIT, "UnRegister env callbackId: %{public}d is not in callbacksSync_", callbackId);
TAG_LOGE(AAFwkTag::APPKIT, "callbackId: %{public}d is not in callbacksSync_", callbackId);
return false;
}
TAG_LOGD(AAFwkTag::APPKIT, "callbacksSync_.callbackId : %{public}d", it->first);
@ -161,7 +159,7 @@ bool JsEnvironmentCallback::UnRegister(int32_t callbackId, bool isSync)
}
auto it = callbacks_.find(callbackId);
if (it == callbacks_.end()) {
TAG_LOGE(AAFwkTag::APPKIT, "UnRegister env callbackId: %{public}d is not in callbacks_", callbackId);
TAG_LOGE(AAFwkTag::APPKIT, "callbackId: %{public}d is not in callbacks_", callbackId);
return false;
}
TAG_LOGD(AAFwkTag::APPKIT, "callbacks_.callbackId : %{public}d", it->first);

View File

@ -733,12 +733,12 @@ napi_value JsApplicationContextUtils::OnPreloadUIExtensionAbility(napi_env env,
NapiAsyncTask::ExecuteCallback execute = [applicationContext = applicationContext_, want, innerErrCode]() {
auto context = applicationContext.lock();
if (!context) {
TAG_LOGE(AAFwkTag::APPKIT, "context is released");
TAG_LOGE(AAFwkTag::APPKIT, "applicationContext is released");
*innerErrCode = static_cast<int>(AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT);
return;
}
auto hostBundleName = context->GetBundleName();
TAG_LOGD(AAFwkTag::APPKIT, "HostBundleName is %{public}s.", hostBundleName.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "HostBundleName is %{public}s", hostBundleName.c_str());
*innerErrCode = AAFwk::AbilityManagerClient::GetInstance()->PreloadUIExtensionAbility(want, hostBundleName);
};
NapiAsyncTask::CompleteCallback complete = [innerErrCode](napi_env env, NapiAsyncTask& task, int32_t status) {
@ -894,23 +894,22 @@ napi_value JsApplicationContextUtils::OnRegisterAbilityLifecycleCallback(
TAG_LOGD(AAFwkTag::APPKIT, "called");
// only support one params
if (info.argc != ARGC_ONE) {
TAG_LOGE(AAFwkTag::APPKIT, "Not enough params.");
TAG_LOGE(AAFwkTag::APPKIT, "Not enough params");
return CreateJsUndefined(env);
}
auto applicationContext = applicationContext_.lock();
if (applicationContext == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr");
return CreateJsUndefined(env);
}
if (callback_ != nullptr) {
TAG_LOGD(AAFwkTag::APPKIT, "callback_ is not nullptr.");
TAG_LOGD(AAFwkTag::APPKIT, "callback_ is not nullptr");
return CreateJsValue(env, callback_->Register(info.argv[0]));
}
callback_ = std::make_shared<JsAbilityLifecycleCallback>(env);
int32_t callbackId = callback_->Register(info.argv[INDEX_ZERO]);
applicationContext->RegisterAbilityLifecycleCallback(callback_);
TAG_LOGI(AAFwkTag::APPKIT, "end");
return CreateJsValue(env, callbackId);
}
@ -921,7 +920,7 @@ napi_value JsApplicationContextUtils::OnUnregisterAbilityLifecycleCallback(
int32_t errCode = 0;
auto applicationContext = applicationContext_.lock();
if (applicationContext == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr");
errCode = ERROR_CODE_ONE;
}
int32_t callbackId = -1;
@ -981,34 +980,32 @@ napi_value JsApplicationContextUtils::OnRegisterEnvironmentCallback(
TAG_LOGD(AAFwkTag::APPKIT, "called");
// only support one params
if (info.argc != ARGC_ONE) {
TAG_LOGE(AAFwkTag::APPKIT, "Not enough params.");
TAG_LOGE(AAFwkTag::APPKIT, "Not enough params");
return CreateJsUndefined(env);
}
auto applicationContext = applicationContext_.lock();
if (applicationContext == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr");
return CreateJsUndefined(env);
}
if (envCallback_ != nullptr) {
TAG_LOGD(AAFwkTag::APPKIT, "envCallback_ is not nullptr.");
TAG_LOGD(AAFwkTag::APPKIT, "envCallback_ is not nullptr");
return CreateJsValue(env, envCallback_->Register(info.argv[0]));
}
envCallback_ = std::make_shared<JsEnvironmentCallback>(env);
int32_t callbackId = envCallback_->Register(info.argv[INDEX_ZERO]);
applicationContext->RegisterEnvironmentCallback(envCallback_);
TAG_LOGD(AAFwkTag::APPKIT, "end");
return CreateJsValue(env, callbackId);
}
napi_value JsApplicationContextUtils::OnUnregisterEnvironmentCallback(
napi_env env, NapiCallbackInfo& info)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
int32_t errCode = 0;
auto applicationContext = applicationContext_.lock();
if (applicationContext == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr");
errCode = ERROR_CODE_ONE;
}
int32_t callbackId = -1;
@ -1017,7 +1014,7 @@ napi_value JsApplicationContextUtils::OnUnregisterEnvironmentCallback(
errCode = ERROR_CODE_ONE;
} else {
napi_get_value_int32(env, info.argv[INDEX_ZERO], &callbackId);
TAG_LOGD(AAFwkTag::APPKIT, "callbackId is %{public}d.", callbackId);
TAG_LOGD(AAFwkTag::APPKIT, "callbackId is %{public}d", callbackId);
}
std::weak_ptr<JsEnvironmentCallback> envCallbackWeak(envCallback_);
NapiAsyncTask::CompleteCallback complete = [envCallbackWeak, callbackId, errCode](
@ -1033,9 +1030,8 @@ napi_value JsApplicationContextUtils::OnUnregisterEnvironmentCallback(
return;
}
TAG_LOGD(AAFwkTag::APPKIT, "begin");
if (!env_callback->UnRegister(callbackId)) {
TAG_LOGE(AAFwkTag::APPKIT, "call UnRegister failed!");
TAG_LOGE(AAFwkTag::APPKIT, "call UnRegister failed");
task.Reject(env, CreateJsError(env, ERROR_CODE_ONE, "call UnRegister failed!"));
return;
}
@ -1064,7 +1060,7 @@ napi_value JsApplicationContextUtils::OnOn(napi_env env, NapiCallbackInfo& info)
TAG_LOGD(AAFwkTag::APPKIT, "called");
if (info.argc != ARGC_TWO) {
TAG_LOGE(AAFwkTag::APPKIT, "Not enough params.");
TAG_LOGE(AAFwkTag::APPKIT, "Not enough params");
ThrowInvalidParamError(env, "Not enough params.");
return CreateJsUndefined(env);
}
@ -1076,7 +1072,7 @@ napi_value JsApplicationContextUtils::OnOn(napi_env env, NapiCallbackInfo& info)
}
std::string type;
if (!ConvertFromJsValue(env, info.argv[0], type)) {
TAG_LOGE(AAFwkTag::APPKIT, "convert type failed!");
TAG_LOGE(AAFwkTag::APPKIT, "convert type failed");
ThrowInvalidParamError(env,
"Parse param type failed, type must be string.");
return CreateJsUndefined(env);
@ -1097,7 +1093,7 @@ napi_value JsApplicationContextUtils::OnOn(napi_env env, NapiCallbackInfo& info)
if (type == "applicationStateChange") {
return OnOnApplicationStateChange(env, info);
}
TAG_LOGE(AAFwkTag::APPKIT, "on function type not match.");
TAG_LOGE(AAFwkTag::APPKIT, "on function type not match");
ThrowInvalidParamError(env, "Parse param callback failed, callback must be function.");
return CreateJsUndefined(env);
}
@ -1118,7 +1114,7 @@ napi_value JsApplicationContextUtils::OnOff(napi_env env, NapiCallbackInfo& info
}
std::string type;
if (!ConvertFromJsValue(env, info.argv[0], type)) {
TAG_LOGE(AAFwkTag::APPKIT, "convert type failed!");
TAG_LOGE(AAFwkTag::APPKIT, "convert type failed");
ThrowInvalidParamError(env,
"Parse param type failed, type must be string.");
return CreateJsUndefined(env);
@ -1160,34 +1156,29 @@ napi_value JsApplicationContextUtils::OnOff(napi_env env, NapiCallbackInfo& info
napi_value JsApplicationContextUtils::OnOnAbilityLifecycle(
napi_env env, NapiCallbackInfo& info, bool isSync)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
auto applicationContext = applicationContext_.lock();
if (applicationContext == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
}
if (callback_ != nullptr) {
TAG_LOGD(AAFwkTag::APPKIT, "callback_ is not nullptr.");
TAG_LOGD(AAFwkTag::APPKIT, "callback_ is not nullptr");
return CreateJsValue(env, callback_->Register(info.argv[1], isSync));
}
callback_ = std::make_shared<JsAbilityLifecycleCallback>(env);
int32_t callbackId = callback_->Register(info.argv[1], isSync);
applicationContext->RegisterAbilityLifecycleCallback(callback_);
TAG_LOGI(AAFwkTag::APPKIT, "end");
return CreateJsValue(env, callbackId);
}
napi_value JsApplicationContextUtils::OnOffAbilityLifecycle(
napi_env env, NapiCallbackInfo& info, int32_t callbackId)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
auto applicationContext = applicationContext_.lock();
if (applicationContext == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
}
@ -1203,9 +1194,8 @@ napi_value JsApplicationContextUtils::OnOffAbilityLifecycle(
return;
}
TAG_LOGD(AAFwkTag::APPKIT, "OnOffAbilityLifecycle begin");
if (!callback->UnRegister(callbackId, false)) {
TAG_LOGE(AAFwkTag::APPKIT, "call UnRegister failed!");
TAG_LOGE(AAFwkTag::APPKIT, "call UnRegister failed");
task.Reject(env, CreateJsError(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER,
"call UnRegister failed!"));
return;
@ -1227,7 +1217,7 @@ napi_value JsApplicationContextUtils::OnOffAbilityLifecycleEventSync(
auto applicationContext = applicationContext_.lock();
if (applicationContext == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INTERNAL_ERROR);
return CreateJsUndefined(env);
}
@ -1274,7 +1264,7 @@ napi_value JsApplicationContextUtils::OnOffEnvironment(
auto applicationContext = applicationContext_.lock();
if (applicationContext == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
}
@ -1293,7 +1283,7 @@ napi_value JsApplicationContextUtils::OnOffEnvironment(
TAG_LOGD(AAFwkTag::APPKIT, "OnOffEnvironment begin");
if (!env_callback->UnRegister(callbackId, false)) {
TAG_LOGE(AAFwkTag::APPKIT, "call UnRegister failed!");
TAG_LOGE(AAFwkTag::APPKIT, "call UnRegister failed");
task.Reject(env, CreateJsError(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER,
"call UnRegister failed!"));
return;
@ -1315,7 +1305,7 @@ napi_value JsApplicationContextUtils::OnOffEnvironmentEventSync(
auto applicationContext = applicationContext_.lock();
if (applicationContext == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INTERNAL_ERROR);
return CreateJsUndefined(env);
}
@ -1325,7 +1315,7 @@ napi_value JsApplicationContextUtils::OnOffEnvironmentEventSync(
return CreateJsUndefined(env);
}
if (!envCallback_->UnRegister(callbackId, true)) {
TAG_LOGE(AAFwkTag::APPKIT, "call UnRegister failed!");
TAG_LOGE(AAFwkTag::APPKIT, "call UnRegister failed");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INTERNAL_ERROR);
return CreateJsUndefined(env);
}
@ -1338,7 +1328,7 @@ napi_value JsApplicationContextUtils::OnOnApplicationStateChange(
TAG_LOGD(AAFwkTag::APPKIT, "called");
auto applicationContext = applicationContext_.lock();
if (applicationContext == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
}
@ -1361,14 +1351,14 @@ napi_value JsApplicationContextUtils::OnOffApplicationStateChange(
TAG_LOGD(AAFwkTag::APPKIT, "called");
auto applicationContext = applicationContext_.lock();
if (applicationContext == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationContext is nullptr");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
}
std::lock_guard<std::mutex> lock(applicationStateCallbackLock_);
if (applicationStateCallback_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationStateCallback_ is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationStateCallback_ is nullptr");
ThrowInvalidParamError(env,
"Parse applicationStateCallback failed, applicationStateCallback must be function.");
return CreateJsUndefined(env);
@ -1377,7 +1367,7 @@ napi_value JsApplicationContextUtils::OnOffApplicationStateChange(
if (info.argc == ARGC_ONE || !CheckTypeForNapiValue(env, info.argv[INDEX_ONE], napi_object)) {
applicationStateCallback_->UnRegister();
} else if (!applicationStateCallback_->UnRegister(info.argv[INDEX_ONE])) {
TAG_LOGE(AAFwkTag::APPKIT, "call UnRegister failed!");
TAG_LOGE(AAFwkTag::APPKIT, "call UnRegister failed");
ThrowInvalidParamError(env, "Parse param call UnRegister failed, call UnRegister must be function.");
return CreateJsUndefined(env);
}

View File

@ -107,7 +107,6 @@ napi_value JsBaseContext::GetApplicationContext(napi_env env, napi_callback_info
napi_value JsBaseContext::SwitchArea(napi_env env, napi_callback_info info)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnSwitchArea, BASE_CONTEXT_NAME);
}
@ -151,7 +150,6 @@ napi_value JsBaseContext::OnSwitchArea(napi_env env, NapiCallbackInfo& info)
napi_value JsBaseContext::CreateModuleContext(napi_env env, napi_callback_info info)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnCreateModuleContext, BASE_CONTEXT_NAME);
}
@ -168,7 +166,7 @@ napi_value JsBaseContext::OnCreateModuleContext(napi_env env, NapiCallbackInfo&
std::string moduleName;
if (!ConvertFromJsValue(env, info.argv[1], moduleName)) {
TAG_LOGD(AAFwkTag::APPKIT, "Parse inner module name.");
TAG_LOGD(AAFwkTag::APPKIT, "Parse inner module name");
if (!ConvertFromJsValue(env, info.argv[0], moduleName)) {
TAG_LOGE(AAFwkTag::APPKIT, "Parse moduleName failed");
ThrowInvalidParamError(env, "Parse param moduleName failed, moduleName must be string.");
@ -187,12 +185,12 @@ napi_value JsBaseContext::OnCreateModuleContext(napi_env env, NapiCallbackInfo&
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_NOT_SYSTEM_APP);
return CreateJsUndefined(env);
}
TAG_LOGD(AAFwkTag::APPKIT, "Parse outer module name.");
TAG_LOGD(AAFwkTag::APPKIT, "Parse outer module name");
moduleContext = context->CreateModuleContext(bundleName, moduleName);
}
if (!moduleContext) {
TAG_LOGE(AAFwkTag::APPKIT, "failed to create module context.");
TAG_LOGE(AAFwkTag::APPKIT, "failed to create module context");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
}
@ -204,7 +202,7 @@ napi_value JsBaseContext::CreateJsModuleContext(napi_env env, const std::shared_
napi_value value = CreateJsBaseContext(env, moduleContext, true);
auto systemModule = JsRuntime::LoadSystemModuleByEngine(env, "application.Context", &value, 1);
if (systemModule == nullptr) {
TAG_LOGW(AAFwkTag::APPKIT, "invalid systemModule.");
TAG_LOGW(AAFwkTag::APPKIT, "invalid systemModule");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
}
@ -227,7 +225,6 @@ napi_value JsBaseContext::CreateJsModuleContext(napi_env env, const std::shared_
napi_value JsBaseContext::CreateSystemHspModuleResourceManager(napi_env env, napi_callback_info info)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext,
OnCreateSystemHspModuleResourceManager, BASE_CONTEXT_NAME);
}
@ -272,7 +269,6 @@ napi_value JsBaseContext::OnCreateSystemHspModuleResourceManager(napi_env env, N
napi_value JsBaseContext::CreateModuleResourceManager(napi_env env, napi_callback_info info)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnCreateModuleResourceManager, BASE_CONTEXT_NAME);
}
@ -314,7 +310,6 @@ napi_value JsBaseContext::OnCreateModuleResourceManager(napi_env env, NapiCallba
napi_value JsBaseContext::GetArea(napi_env env, napi_callback_info info)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnGetArea, BASE_CONTEXT_NAME);
}
@ -331,7 +326,6 @@ napi_value JsBaseContext::OnGetArea(napi_env env, NapiCallbackInfo& info)
napi_value JsBaseContext::GetCacheDir(napi_env env, napi_callback_info info)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnGetCacheDir, BASE_CONTEXT_NAME);
}
@ -348,7 +342,6 @@ napi_value JsBaseContext::OnGetCacheDir(napi_env env, NapiCallbackInfo& info)
napi_value JsBaseContext::GetTempDir(napi_env env, napi_callback_info info)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnGetTempDir, BASE_CONTEXT_NAME);
}
@ -365,7 +358,6 @@ napi_value JsBaseContext::OnGetTempDir(napi_env env, NapiCallbackInfo& info)
napi_value JsBaseContext::GetResourceDir(napi_env env, napi_callback_info info)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnGetResourceDir, BASE_CONTEXT_NAME);
}
@ -382,7 +374,6 @@ napi_value JsBaseContext::OnGetResourceDir(napi_env env, NapiCallbackInfo& info)
napi_value JsBaseContext::GetFilesDir(napi_env env, napi_callback_info info)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnGetFilesDir, BASE_CONTEXT_NAME);
}
@ -399,7 +390,6 @@ napi_value JsBaseContext::OnGetFilesDir(napi_env env, NapiCallbackInfo& info)
napi_value JsBaseContext::GetDistributedFilesDir(napi_env env, napi_callback_info info)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnGetDistributedFilesDir, BASE_CONTEXT_NAME);
}
@ -416,7 +406,6 @@ napi_value JsBaseContext::OnGetDistributedFilesDir(napi_env env, NapiCallbackInf
napi_value JsBaseContext::GetDatabaseDir(napi_env env, napi_callback_info info)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnGetDatabaseDir, BASE_CONTEXT_NAME);
}
@ -433,7 +422,6 @@ napi_value JsBaseContext::OnGetDatabaseDir(napi_env env, NapiCallbackInfo& info)
napi_value JsBaseContext::GetPreferencesDir(napi_env env, napi_callback_info info)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnGetPreferencesDir, BASE_CONTEXT_NAME);
}
@ -450,7 +438,6 @@ napi_value JsBaseContext::OnGetPreferencesDir(napi_env env, NapiCallbackInfo& in
napi_value JsBaseContext::GetGroupDir(napi_env env, napi_callback_info info)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnGetGroupDir, BASE_CONTEXT_NAME);
}
@ -469,7 +456,6 @@ napi_value JsBaseContext::OnGetGroupDir(napi_env env, NapiCallbackInfo& info)
return CreateJsUndefined(env);
}
TAG_LOGD(AAFwkTag::APPKIT, "Get Group Dir");
auto complete = [context = context_, groupId]
(napi_env env, NapiAsyncTask& task, int32_t status) {
auto completeContext = context.lock();
@ -491,7 +477,6 @@ napi_value JsBaseContext::OnGetGroupDir(napi_env env, NapiCallbackInfo& info)
napi_value JsBaseContext::GetBundleCodeDir(napi_env env, napi_callback_info info)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnGetBundleCodeDir, BASE_CONTEXT_NAME);
}
@ -564,7 +549,7 @@ napi_value JsBaseContext::CreateJsBundleContext(napi_env env, const std::shared_
napi_value value = CreateJsBaseContext(env, bundleContext, true);
auto systemModule = JsRuntime::LoadSystemModuleByEngine(env, "application.Context", &value, 1);
if (systemModule == nullptr) {
TAG_LOGW(AAFwkTag::APPKIT, "OnCreateBundleContext, invalid systemModule.");
TAG_LOGW(AAFwkTag::APPKIT, "OnCreateBundleContext, invalid systemModule");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
}
@ -587,7 +572,6 @@ napi_value JsBaseContext::CreateJsBundleContext(napi_env env, const std::shared_
napi_value JsBaseContext::OnGetApplicationContext(napi_env env, NapiCallbackInfo& info)
{
TAG_LOGD(AAFwkTag::APPKIT, "start");
auto context = context_.lock();
if (!context) {
TAG_LOGW(AAFwkTag::APPKIT, "context is already released");
@ -619,7 +603,7 @@ napi_value JsBaseContext::CreateJSApplicationContext(napi_env env,
napi_value value = JsApplicationContextUtils::CreateJsApplicationContext(env);
auto systemModule = JsRuntime::LoadSystemModuleByEngine(env, "application.ApplicationContext", &value, 1);
if (systemModule == nullptr) {
TAG_LOGW(AAFwkTag::APPKIT, "OnGetApplicationContext, invalid systemModule.");
TAG_LOGW(AAFwkTag::APPKIT, "OnGetApplicationContext, invalid systemModule");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
}
@ -661,18 +645,18 @@ napi_value AttachBaseContext(napi_env env, void* value, void* hint)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
if (value == nullptr || env == nullptr) {
TAG_LOGW(AAFwkTag::APPKIT, "invalid parameter.");
TAG_LOGW(AAFwkTag::APPKIT, "invalid parameter");
return nullptr;
}
auto ptr = reinterpret_cast<std::weak_ptr<Context>*>(value)->lock();
if (ptr == nullptr) {
TAG_LOGW(AAFwkTag::APPKIT, "invalid context.");
TAG_LOGW(AAFwkTag::APPKIT, "invalid context");
return nullptr;
}
napi_value object = CreateJsBaseContext(env, ptr, true);
auto systemModule = JsRuntime::LoadSystemModuleByEngine(env, "application.Context", &object, 1);
if (systemModule == nullptr) {
TAG_LOGW(AAFwkTag::APPKIT, "AttachBaseContext, invalid systemModule.");
TAG_LOGW(AAFwkTag::APPKIT, "AttachBaseContext, invalid systemModule");
return nullptr;
}
@ -696,18 +680,18 @@ napi_value AttachApplicationContext(napi_env env, void* value, void* hint)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
if (value == nullptr || env == nullptr) {
TAG_LOGW(AAFwkTag::APPKIT, "invalid parameter.");
TAG_LOGW(AAFwkTag::APPKIT, "invalid parameter");
return nullptr;
}
auto ptr = reinterpret_cast<std::weak_ptr<ApplicationContext>*>(value)->lock();
if (ptr == nullptr) {
TAG_LOGW(AAFwkTag::APPKIT, "invalid context.");
TAG_LOGW(AAFwkTag::APPKIT, "invalid context");
return nullptr;
}
napi_value object = JsApplicationContextUtils::CreateJsApplicationContext(env);
auto systemModule = JsRuntime::LoadSystemModuleByEngine(env, "application.ApplicationContext", &object, 1);
if (systemModule == nullptr) {
TAG_LOGW(AAFwkTag::APPKIT, "invalid systemModule.");
TAG_LOGW(AAFwkTag::APPKIT, "invalid systemModule");
return nullptr;
}
auto contextObj = systemModule->GetNapiValue();
@ -733,7 +717,7 @@ napi_value CreateJsBaseContext(napi_env env, std::shared_ptr<Context> context, b
napi_value object = nullptr;
napi_create_object(env, &object);
if (object == nullptr) {
TAG_LOGW(AAFwkTag::APPKIT, "invalid object.");
TAG_LOGW(AAFwkTag::APPKIT, "invalid object");
return nullptr;
}
auto jsContext = std::make_unique<JsBaseContext>(context);

View File

@ -24,7 +24,7 @@ const size_t ExtensionContext::CONTEXT_TYPE_ID(std::hash<const char*> {} ("Exten
void ExtensionContext::SetAbilityInfo(const std::shared_ptr<OHOS::AppExecFwk::AbilityInfo> &abilityInfo)
{
if (abilityInfo == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ExtensionContext::SetAbilityInfo Info == nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "abilityInfo == nullptr");
return;
}
abilityInfo_ = abilityInfo;

View File

@ -31,13 +31,13 @@ int FormExtensionContext::UpdateForm(const int64_t formId, const AppExecFwk::For
{
TAG_LOGD(AAFwkTag::APPKIT, "Update form, formId: %{public}" PRId64 ".", formId);
if (formId <= 0) {
TAG_LOGE(AAFwkTag::APPKIT, "FormId can't be negative or zero.");
TAG_LOGE(AAFwkTag::APPKIT, "FormId can't be negative or zero");
return ERR_APPEXECFWK_FORM_INVALID_PARAM;
}
// check fms recover status
if (AppExecFwk::FormMgr::GetRecoverStatus() == AppExecFwk::Constants::IN_RECOVERING) {
TAG_LOGE(AAFwkTag::APPKIT, "Update failed, form is in recover status, can't do action on it.");
TAG_LOGE(AAFwkTag::APPKIT, "Update failed, form is in recover status, can't do action on it");
return ERR_APPEXECFWK_FORM_IN_RECOVER;
}
@ -54,11 +54,11 @@ int FormExtensionContext::UpdateForm(const int64_t formId, const AppExecFwk::For
ErrCode FormExtensionContext::StartAbility(const AAFwk::Want &want) const
{
TAG_LOGD(AAFwkTag::APPKIT, "Start ability.");
TAG_LOGD(AAFwkTag::APPKIT, "Start ability");
// route to FMS
ErrCode err = AppExecFwk::FormMgr::GetInstance().StartAbility(want, token_);
if (err != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "Start ability failed with %{public}d.", err);
TAG_LOGE(AAFwkTag::APPKIT, "Start ability failed with %{public}d", err);
}
return err;
}

View File

@ -30,10 +30,10 @@ int32_t ServiceExtensionContext::ILLEGAL_REQUEST_CODE(-1);
ErrCode ServiceExtensionContext::StartAbility(const AAFwk::Want &want) const
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::APPKIT, "Start ability begin, ability:%{public}s.", want.GetElement().GetAbilityName().c_str());
TAG_LOGD(AAFwkTag::APPKIT, "ability:%{public}s", want.GetElement().GetAbilityName().c_str());
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, token_, ILLEGAL_REQUEST_CODE);
if (err != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "ServiceContext::StartAbility is failed %{public}d", err);
TAG_LOGE(AAFwkTag::APPKIT, "StartAbility is failed %{public}d", err);
}
return err;
}
@ -41,11 +41,11 @@ ErrCode ServiceExtensionContext::StartAbility(const AAFwk::Want &want) const
ErrCode ServiceExtensionContext::StartAbility(const AAFwk::Want &want, const AAFwk::StartOptions &startOptions) const
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::APPKIT, "Start ability begin, ability:%{public}s.", want.GetElement().GetAbilityName().c_str());
TAG_LOGD(AAFwkTag::APPKIT, "ability:%{public}s", want.GetElement().GetAbilityName().c_str());
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, startOptions, token_,
ILLEGAL_REQUEST_CODE);
if (err != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "ServiceContext::StartAbility is failed %{public}d", err);
TAG_LOGE(AAFwkTag::APPKIT, "StartAbility is failed %{public}d", err);
}
return err;
}
@ -53,12 +53,12 @@ ErrCode ServiceExtensionContext::StartAbility(const AAFwk::Want &want, const AAF
ErrCode ServiceExtensionContext::StartAbilityAsCaller(const AAFwk::Want &want) const
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::APPKIT, "Start ability as caller begin, ability:%{public}s.",
TAG_LOGD(AAFwkTag::APPKIT, "ability:%{public}s",
want.GetElement().GetAbilityName().c_str());
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->
StartAbilityAsCaller(want, token_, nullptr, ILLEGAL_REQUEST_CODE);
if (err != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "ServiceContext::StartAbilityAsCaller is failed %{public}d", err);
TAG_LOGE(AAFwkTag::APPKIT, "StartAbilityAsCaller is failed %{public}d", err);
}
return err;
}
@ -67,12 +67,12 @@ ErrCode ServiceExtensionContext::StartAbilityAsCaller(const AAFwk::Want &want,
const AAFwk::StartOptions &startOptions) const
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::APPKIT, "Start ability as caller begin, ability:%{public}s.",
TAG_LOGD(AAFwkTag::APPKIT, "ability:%{public}s.",
want.GetElement().GetAbilityName().c_str());
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbilityAsCaller(want, startOptions, token_, nullptr,
ILLEGAL_REQUEST_CODE);
if (err != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "ServiceContext::StartAbilityAsCaller is failed %{public}d", err);
TAG_LOGE(AAFwkTag::APPKIT, "StartAbilityAsCaller is failed %{public}d", err);
}
return err;
}
@ -80,11 +80,11 @@ ErrCode ServiceExtensionContext::StartAbilityAsCaller(const AAFwk::Want &want,
ErrCode ServiceExtensionContext::StartAbilityByCall(
const AAFwk::Want& want, const std::shared_ptr<CallerCallBack> &callback, int32_t accountId)
{
TAG_LOGD(AAFwkTag::APPKIT, "%{public}s begin.", __func__);
TAG_LOGD(AAFwkTag::APPKIT, "begin");
if (localCallContainer_ == nullptr) {
localCallContainer_ = std::make_shared<LocalCallContainer>();
if (localCallContainer_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "%{public}s failed, localCallContainer_ is nullptr.", __func__);
TAG_LOGE(AAFwkTag::APPKIT, "localCallContainer_ == nullptr");
return ERR_INVALID_VALUE;
}
}
@ -93,9 +93,9 @@ ErrCode ServiceExtensionContext::StartAbilityByCall(
ErrCode ServiceExtensionContext::ReleaseCall(const std::shared_ptr<CallerCallBack> &callback) const
{
TAG_LOGD(AAFwkTag::APPKIT, "%{public}s begin.", __func__);
TAG_LOGD(AAFwkTag::APPKIT, "begin");
if (localCallContainer_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "%{public}s failed, localCallContainer_ is nullptr.", __func__);
TAG_LOGE(AAFwkTag::APPKIT, "localCallContainer_ == nullptr");
return ERR_INVALID_VALUE;
}
return localCallContainer_->ReleaseCall(callback);
@ -103,9 +103,9 @@ ErrCode ServiceExtensionContext::ReleaseCall(const std::shared_ptr<CallerCallBac
void ServiceExtensionContext::ClearFailedCallConnection(const std::shared_ptr<CallerCallBack> &callback) const
{
TAG_LOGD(AAFwkTag::APPKIT, "%{public}s begin.", __func__);
TAG_LOGD(AAFwkTag::APPKIT, "begin");
if (localCallContainer_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "%{public}s failed, localCallContainer_ is nullptr.", __func__);
TAG_LOGE(AAFwkTag::APPKIT, "localCallContainer_ == nullptr");
return;
}
localCallContainer_->ClearFailedCallConnection(callback);
@ -114,11 +114,11 @@ void ServiceExtensionContext::ClearFailedCallConnection(const std::shared_ptr<Ca
ErrCode ServiceExtensionContext::ConnectAbility(
const AAFwk::Want &want, const sptr<AbilityConnectCallback> &connectCallback) const
{
TAG_LOGD(AAFwkTag::APPKIT, "Connect ability begin, ability:%{public}s.",
TAG_LOGD(AAFwkTag::APPKIT, "ability:%{public}s.",
want.GetElement().GetAbilityName().c_str());
ErrCode ret =
ConnectionManager::GetInstance().ConnectAbility(token_, want, connectCallback);
TAG_LOGD(AAFwkTag::APPKIT, "ServiceExtensionContext::ConnectAbility ErrorCode = %{public}d", ret);
TAG_LOGD(AAFwkTag::APPKIT, "ConnectAbility ErrorCode = %{public}d", ret);
return ret;
}
@ -136,9 +136,9 @@ ErrCode ServiceExtensionContext::StartAbilityWithAccount(const AAFwk::Want &want
}
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(
want, token_, ILLEGAL_REQUEST_CODE, accountId);
TAG_LOGD(AAFwkTag::APPKIT, "%{public}s. End calling StartAbilityWithAccount. ret=%{public}d", __func__, err);
TAG_LOGD(AAFwkTag::APPKIT, "ret=%{public}d", err);
if (err != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "ServiceContext::StartAbilityWithAccount is failed %{public}d", err);
TAG_LOGE(AAFwkTag::APPKIT, "StartAbilityWithAccount is failed %{public}d", err);
}
return err;
}
@ -146,46 +146,46 @@ ErrCode ServiceExtensionContext::StartAbilityWithAccount(const AAFwk::Want &want
ErrCode ServiceExtensionContext::StartAbilityWithAccount(
const AAFwk::Want &want, int32_t accountId, const AAFwk::StartOptions &startOptions) const
{
TAG_LOGD(AAFwkTag::APPKIT, "%{public}s begin.", __func__);
TAG_LOGD(AAFwkTag::APPKIT, "begin");
(const_cast<Want &>(want)).SetParam(START_ABILITY_TYPE, true);
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, startOptions, token_,
ILLEGAL_REQUEST_CODE, accountId);
TAG_LOGD(AAFwkTag::APPKIT, "%{public}s. End calling StartAbilityWithAccount. ret=%{public}d", __func__, err);
TAG_LOGD(AAFwkTag::APPKIT, "End calling StartAbilityWithAccount. ret=%{public}d", err);
if (err != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "ServiceContext::StartAbilityWithAccount is failed %{public}d", err);
TAG_LOGE(AAFwkTag::APPKIT, "StartAbilityWithAccount is failed %{public}d", err);
}
return err;
}
ErrCode ServiceExtensionContext::StartServiceExtensionAbility(const AAFwk::Want &want, int32_t accountId) const
{
TAG_LOGD(AAFwkTag::APPKIT, "%{public}s begin.", __func__);
TAG_LOGD(AAFwkTag::APPKIT, "begin");
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartExtensionAbility(
want, token_, accountId, AppExecFwk::ExtensionAbilityType::SERVICE);
if (err != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "ServiceContext::StartServiceExtensionAbility is failed %{public}d", err);
TAG_LOGE(AAFwkTag::APPKIT, "StartServiceExtensionAbility is failed %{public}d", err);
}
return err;
}
ErrCode ServiceExtensionContext::StartUIServiceExtensionAbility(const AAFwk::Want &want, int32_t accountId) const
{
TAG_LOGD(AAFwkTag::APPKIT, "begin.");
TAG_LOGD(AAFwkTag::APPKIT, "begin");
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartExtensionAbility(
want, token_, accountId, AppExecFwk::ExtensionAbilityType::UI_SERVICE);
if (err != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "ServiceContext::StartServiceExtensionAbility is failed %{public}d", err);
TAG_LOGE(AAFwkTag::APPKIT, "StartServiceExtensionAbility is failed %{public}d", err);
}
return err;
}
ErrCode ServiceExtensionContext::StopServiceExtensionAbility(const AAFwk::Want& want, int32_t accountId) const
{
TAG_LOGD(AAFwkTag::APPKIT, "%{public}s begin.", __func__);
TAG_LOGD(AAFwkTag::APPKIT, "begin");
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StopExtensionAbility(
want, token_, accountId, AppExecFwk::ExtensionAbilityType::SERVICE);
if (err != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "ServiceContext::StopServiceExtensionAbility is failed %{public}d", err);
TAG_LOGE(AAFwkTag::APPKIT, "StopServiceExtensionAbility is failed %{public}d", err);
}
return err;
}
@ -193,45 +193,42 @@ ErrCode ServiceExtensionContext::StopServiceExtensionAbility(const AAFwk::Want&
ErrCode ServiceExtensionContext::ConnectAbilityWithAccount(
const AAFwk::Want &want, int32_t accountId, const sptr<AbilityConnectCallback> &connectCallback) const
{
TAG_LOGI(AAFwkTag::APPKIT, "%{public}s begin.", __func__);
TAG_LOGI(AAFwkTag::APPKIT, "begin");
ErrCode ret =
ConnectionManager::GetInstance().ConnectAbilityWithAccount(token_, want, accountId, connectCallback);
TAG_LOGI(AAFwkTag::APPKIT, "ServiceExtensionContext::ConnectAbilityWithAccount ErrorCode = %{public}d", ret);
TAG_LOGI(AAFwkTag::APPKIT, "ConnectAbilityWithAccount ErrorCode = %{public}d", ret);
return ret;
}
ErrCode ServiceExtensionContext::DisconnectAbility(const AAFwk::Want &want,
const sptr<AbilityConnectCallback> &connectCallback, int32_t accountId) const
{
TAG_LOGD(AAFwkTag::APPKIT, "begin.");
TAG_LOGD(AAFwkTag::APPKIT, "begin");
ErrCode ret =
ConnectionManager::GetInstance().DisconnectAbility(token_, want, connectCallback, accountId);
if (ret != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "%{public}s end DisconnectAbility error, ret=%{public}d", __func__, ret);
TAG_LOGE(AAFwkTag::APPKIT, "DisconnectAbility error, ret=%{public}d", ret);
}
TAG_LOGI(AAFwkTag::APPKIT, "end");
return ret;
}
ErrCode ServiceExtensionContext::TerminateAbility()
{
TAG_LOGI(AAFwkTag::APPKIT, "%{public}s begin.", __func__);
TAG_LOGI(AAFwkTag::APPKIT, "begin");
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->TerminateAbility(token_, -1, nullptr);
if (err != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "ServiceExtensionContext::TerminateAbility is failed %{public}d", err);
TAG_LOGE(AAFwkTag::APPKIT, "TerminateAbility is failed %{public}d", err);
}
TAG_LOGI(AAFwkTag::APPKIT, "%{public}s end.", __func__);
return err;
}
ErrCode ServiceExtensionContext::RequestModalUIExtension(const Want &want)
{
TAG_LOGI(AAFwkTag::APPKIT, "%{public}s begin.", __func__);
TAG_LOGI(AAFwkTag::APPKIT, "begin");
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->RequestModalUIExtension(want);
if (err != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "ServiceExtensionContext::RequestModalUIExtension is failed %{public}d", err);
TAG_LOGE(AAFwkTag::APPKIT, "RequestModalUIExtension is failed %{public}d", err);
}
TAG_LOGI(AAFwkTag::APPKIT, "%{public}s end.", __func__);
return err;
}
@ -239,7 +236,7 @@ AppExecFwk::AbilityType ServiceExtensionContext::GetAbilityInfoType() const
{
std::shared_ptr<AppExecFwk::AbilityInfo> info = GetAbilityInfo();
if (info == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ServiceContext::GetAbilityInfoType info == nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "info == nullptr");
return AppExecFwk::AbilityType::UNKNOWN;
}
@ -258,13 +255,11 @@ ErrCode ServiceExtensionContext::AddFreeInstallObserver(const sptr<AbilityRuntim
ErrCode ServiceExtensionContext::PreStartMission(const std::string& bundleName, const std::string& moduleName,
const std::string& abilityName, const std::string& startTime)
{
TAG_LOGI(AAFwkTag::APPKIT, "called");
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->PreStartMission(
bundleName, moduleName, abilityName, startTime);
if (err != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "ServiceExtensionContext::PreStartMission is failed %{public}d", err);
TAG_LOGE(AAFwkTag::APPKIT, "PreStartMission is failed %{public}d", err);
}
TAG_LOGI(AAFwkTag::APPKIT, "End.");
return err;
}
} // namespace AbilityRuntime

View File

@ -36,23 +36,21 @@ int32_t UIServiceExtensionContext::ILLEGAL_REQUEST_CODE(-1);
ErrCode UIServiceExtensionContext::StartAbility(const AAFwk::Want &want, const AAFwk::StartOptions &startOptions) const
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::APPKIT, "Start ability begin, ability:%{public}s.", want.GetElement().GetAbilityName().c_str());
TAG_LOGD(AAFwkTag::APPKIT, "ability:%{public}s", want.GetElement().GetAbilityName().c_str());
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, startOptions, token_,
ILLEGAL_REQUEST_CODE);
if (err != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "UIServiceExtensionContext::StartAbility is failed %{public}d", err);
TAG_LOGE(AAFwkTag::APPKIT, "StartAbility is failed %{public}d", err);
}
return err;
}
ErrCode UIServiceExtensionContext::TerminateSelf()
{
TAG_LOGI(AAFwkTag::APPKIT, "begin.");
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->TerminateAbility(token_, -1, nullptr);
if (err != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "UIServiceExtensionContext::TerminateAbility is failed %{public}d", err);
TAG_LOGE(AAFwkTag::APPKIT, "TerminateAbility is failed %{public}d", err);
}
TAG_LOGI(AAFwkTag::APPKIT, "%{public}s end.", __func__);
return err;
}
@ -68,7 +66,7 @@ sptr<Rosen::Window> UIServiceExtensionContext::GetWindow()
Ace::UIContent* UIServiceExtensionContext::GetUIContent()
{
TAG_LOGI(AAFwkTag::UI_EXT, "called");
TAG_LOGD(AAFwkTag::UI_EXT, "called");
if (window_ == nullptr) {
TAG_LOGD(AAFwkTag::APPKIT, "window_ is nullptr");
return nullptr;
@ -81,12 +79,12 @@ ErrCode UIServiceExtensionContext::StartAbilityByType(const std::string &type,
{
TAG_LOGD(AAFwkTag::APPKIT, "StartAbilityByType begin.");
if (uiExtensionCallbacks == nullptr) {
TAG_LOGD(AAFwkTag::APPKIT, "uiExtensionCallbacks is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "uiExtensionCallbacks is nullptr");
return ERR_INVALID_VALUE;
}
auto uiContent = GetUIContent();
if (uiContent == nullptr) {
TAG_LOGD(AAFwkTag::APPKIT, "uiContent is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "uiContent is nullptr");
return ERR_INVALID_VALUE;
}
wantParam.SetParam(UIEXTENSION_TARGET_TYPE_KEY, AAFwk::String::Box(type));
@ -112,7 +110,7 @@ ErrCode UIServiceExtensionContext::StartAbilityByType(const std::string &type,
int32_t sessionId = uiContent->CreateModalUIExtension(want, callback, config);
if (sessionId == 0) {
TAG_LOGD(AAFwkTag::APPKIT, "CreateModalUIExtension is failed");
TAG_LOGE(AAFwkTag::APPKIT, "CreateModalUIExtension is failed");
return ERR_INVALID_VALUE;
}
uiExtensionCallbacks->SetUIContent(uiContent);

View File

@ -48,13 +48,13 @@ static const int RESULT_ERR = -1;
void ApplicationCleaner::RenameTempData()
{
if (context_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Context is null.");
TAG_LOGE(AAFwkTag::APPKIT, "Context is null");
return;
}
std::vector<std::string> tempdir{};
context_->GetAllTempDir(tempdir);
if (tempdir.empty()) {
TAG_LOGE(AAFwkTag::APPKIT, "Get app temp path list is empty.");
TAG_LOGE(AAFwkTag::APPKIT, "Get app temp path list is empty");
return;
}
int64_t now =
@ -83,12 +83,12 @@ void ApplicationCleaner::ClearTempData()
std::vector<std::string> temps;
if (self->GetRootPath(rootDir) != RESULT_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "Get root dir error.");
TAG_LOGE(AAFwkTag::APPKIT, "Get root dir error");
return;
}
if (self->GetObsoleteBundleTempPath(rootDir, temps) != RESULT_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "Get bundle temp file list is false.");
TAG_LOGE(AAFwkTag::APPKIT, "Get bundle temp file list is false");
return;
}
@ -110,7 +110,7 @@ int ApplicationCleaner::GetRootPath(std::vector<std::string> &rootPath)
auto instance = DelayedSingleton<AppExecFwk::OsAccountManagerWrapper>::GetInstance();
if (instance == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get OsAccountManager instance.");
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get OsAccountManager instance");
return RESULT_ERR;
}

View File

@ -32,13 +32,11 @@ ApplicationDataManager &ApplicationDataManager::GetInstance()
void ApplicationDataManager::AddErrorObserver(const std::shared_ptr<IErrorObserver> &observer)
{
TAG_LOGD(AAFwkTag::APPKIT, "Add error observer come.");
errorObserver_ = observer;
}
bool ApplicationDataManager::NotifyUnhandledException(const std::string &errMsg)
{
TAG_LOGD(AAFwkTag::APPKIT, "Notify error observer come.");
if (errorObserver_) {
errorObserver_->OnUnhandledException(errMsg);
return true;
@ -51,7 +49,6 @@ bool ApplicationDataManager::NotifyUnhandledException(const std::string &errMsg)
bool ApplicationDataManager::NotifyCJUnhandledException(const std::string &errMsg)
{
TAG_LOGD(AAFwkTag::APPKIT, "Notify error observer come.");
if (errorObserver_) {
errorObserver_->OnUnhandledException(errMsg);
return true;
@ -64,13 +61,11 @@ bool ApplicationDataManager::NotifyCJUnhandledException(const std::string &errMs
void ApplicationDataManager::RemoveErrorObserver()
{
TAG_LOGD(AAFwkTag::APPKIT, "Remove error observer come.");
errorObserver_ = nullptr;
}
bool ApplicationDataManager::NotifyExceptionObject(const AppExecFwk::ErrorObject &errorObj)
{
TAG_LOGD(AAFwkTag::APPKIT, "Notify Exception error observer come.");
if (errorObserver_) {
errorObserver_->OnExceptionObject(errorObj);
return true;
@ -83,7 +78,7 @@ bool ApplicationDataManager::NotifyExceptionObject(const AppExecFwk::ErrorObject
bool ApplicationDataManager::NotifyCJExceptionObject(const AppExecFwk::ErrorObject &errorObj)
{
TAG_LOGD(AAFwkTag::APPKIT, "Notify Exception error observer come.");
TAG_LOGD(AAFwkTag::APPKIT, "Notify Exception error observer come");
if (errorObserver_) {
errorObserver_->OnExceptionObject(errorObj);
return true;

View File

@ -117,7 +117,6 @@ bool ApplicationImpl::PerformTerminate(bool isLastProcess)
curState_ = APP_STATE_TERMINATED;
return true;
}
TAG_LOGE(AAFwkTag::APPKIT, "curState is %{public}d", curState_);
return false;
}

View File

@ -30,7 +30,7 @@ int32_t AssertFaultCallback::OnRemoteRequest(
std::u16string descriptor = AssertFaultCallback::GetDescriptor();
std::u16string remoteDescriptor = data.ReadInterfaceToken();
if (descriptor != remoteDescriptor) {
TAG_LOGE(AAFwkTag::APPKIT, "Local descriptor is not equal to remote.");
TAG_LOGE(AAFwkTag::APPKIT, "Local descriptor is not equal to remote");
return ERR_INVALID_STATE;
}
@ -40,17 +40,17 @@ int32_t AssertFaultCallback::OnRemoteRequest(
return NO_ERROR;
}
TAG_LOGW(AAFwkTag::APPKIT, "Unexpected event ID, for default handling.");
TAG_LOGW(AAFwkTag::APPKIT, "Unexpected event ID, for default handling");
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
}
void AssertFaultCallback::NotifyDebugAssertResult(AAFwk::UserStatus status)
{
TAG_LOGD(AAFwkTag::APPKIT, "Notify user action result to assert fault thread.");
TAG_LOGD(AAFwkTag::APPKIT, "Notify user action result to assert fault thread");
status_ = status;
auto assertThread = assertFaultThread_.lock();
if (assertThread == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Failed to obtain assert fault thread.");
TAG_LOGE(AAFwkTag::APPKIT, "Failed to obtain assert fault thread");
return;
}
assertThread->NotifyReleaseLongWaiting();

View File

@ -41,7 +41,7 @@ constexpr char ASSERT_FAULT_PROMPT[] = "\n\n(Press Retry to debug the applicatio
AAFwk::UserStatus AssertFaultTaskThread::RequestAssertResult(const std::string &exprStr)
{
if (assertHandler_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Assert handler is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "Assert handler is nullptr");
return ASSERT_FAULT_DEFAULT_VALUE;
}
@ -51,7 +51,7 @@ AAFwk::UserStatus AssertFaultTaskThread::RequestAssertResult(const std::string &
TAG_LOGD(AAFwkTag::APPKIT, "called");
auto assertFaultTask = weak.lock();
if (assertFaultTask == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Assert fault task instance is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "Assert fault task instance is nullptr");
return;
}
assertResult = assertFaultTask->HandleAssertCallback(exprStr);
@ -63,7 +63,7 @@ Assert_Status ConvertAssertResult(AAFwk::UserStatus status)
{
auto result = assertResultMap.find(status);
if (result == assertResultMap.end()) {
TAG_LOGE(AAFwkTag::APPKIT, "Find %{public}d failed, convert assert reuslt error.", status);
TAG_LOGE(AAFwkTag::APPKIT, "Find %{public}d failed, convert assert reuslt error", status);
return Assert_Status::ASSERT_ABORT;
}
return result->second;
@ -74,7 +74,7 @@ static Assert_Status AssertCallback(AssertFailureInfo assertFail)
TAG_LOGD(AAFwkTag::APPKIT, "called");
auto instance = DelayedSingleton<AbilityRuntime::AssertFaultTaskThread>::GetInstance();
if (instance == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid Instance.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid Instance");
return Assert_Status::ASSERT_ABORT;
}
@ -88,7 +88,7 @@ static Assert_Status AssertCallback(AssertFailureInfo assertFail)
std::string textDetail = textFile + textFunc + textLine + textExpression + ASSERT_FAULT_PROMPT;
auto ret = ConvertAssertResult(instance->RequestAssertResult(textDetail));
TAG_LOGD(AAFwkTag::APPKIT, "Return sync task result is %{public}d.", static_cast<int32_t>(ret));
TAG_LOGD(AAFwkTag::APPKIT, "Return sync task result is %{public}d", static_cast<int32_t>(ret));
return ret;
}
@ -96,13 +96,13 @@ void AssertFaultTaskThread::InitAssertFaultTask(const wptr<AppExecFwk::MainThrea
{
auto runner = AppExecFwk::EventRunner::Create(ASSERT_FAULT_THREAD);
if (runner == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Runner is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "Runner is nullptr");
return;
}
auto assertHandler = std::make_shared<AppExecFwk::EventHandler>(runner);
if (assertHandler == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Handler is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "Handler is nullptr");
runner->Stop();
return;
}
@ -117,7 +117,7 @@ void AssertFaultTaskThread::InitAssertFaultTask(const wptr<AppExecFwk::MainThrea
void AssertFaultTaskThread::Stop()
{
if (assertRunner_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Assert runner is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "Assert runner is nullptr");
return;
}
assertRunner_->Stop();
@ -128,7 +128,7 @@ AAFwk::UserStatus AssertFaultTaskThread::HandleAssertCallback(const std::string
{
auto mainThread = mainThread_.promote();
if (mainThread == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid thread object.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid thread object");
return ASSERT_FAULT_DEFAULT_VALUE;
}
@ -140,13 +140,13 @@ AAFwk::UserStatus AssertFaultTaskThread::HandleAssertCallback(const std::string
sptr<AssertFaultCallback> assertFaultCallback =
new (std::nothrow) AssertFaultCallback(shared_from_this());
if (assertFaultCallback == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid assert fault callback object.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid assert fault callback object");
break;
}
auto amsClient = AAFwk::AbilityManagerClient::GetInstance();
if (amsClient == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Invalid client object.");
TAG_LOGE(AAFwkTag::APPKIT, "Invalid client object");
break;
}
@ -155,12 +155,11 @@ AAFwk::UserStatus AssertFaultTaskThread::HandleAssertCallback(const std::string
wantParams.SetParam(ASSERT_FAULT_DETAIL, AAFwk::String::Box(exprStr));
auto err = amsClient->RequestAssertFaultDialog(assertFaultCallback->AsObject(), wantParams);
if (err != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "Request assert fault dialog failed.");
TAG_LOGE(AAFwkTag::APPKIT, "Request assert fault dialog failed");
break;
}
assertResultCV_.wait(lockAssertResult);
TAG_LOGD(AAFwkTag::APPKIT, "Wait assert result over.");
assertResult = assertFaultCallback->GetAssertResult();
} while (false);
@ -174,7 +173,6 @@ void AssertFaultTaskThread::NotifyReleaseLongWaiting()
{
std::unique_lock<std::mutex> lockAssertResult(assertResultMutex_);
assertResultCV_.notify_one();
TAG_LOGD(AAFwkTag::APPKIT, "Notify assert result done.");
}
} // namespace AbilityRuntime
} // namespace OHOS

View File

@ -30,7 +30,6 @@ using OHOS::AbilityRuntime::ChildProcessManager;
ChildMainThread::ChildMainThread()
{
processArgs_ = std::make_shared<ChildProcessArgs>();
TAG_LOGD(AAFwkTag::APPKIT, "ChildMainThread constructor called");
}
ChildMainThread::~ChildMainThread()
@ -40,31 +39,31 @@ ChildMainThread::~ChildMainThread()
void ChildMainThread::Start(const std::map<std::string, int32_t> &fds)
{
TAG_LOGI(AAFwkTag::APPKIT, "ChildMainThread start.");
TAG_LOGI(AAFwkTag::APPKIT, "ChildMainThread start");
ChildProcessInfo processInfo;
auto ret = GetChildProcessInfo(processInfo);
if (ret != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "GetChildProcessInfo failed, ret:%{public}d.", ret);
TAG_LOGE(AAFwkTag::APPKIT, "GetChildProcessInfo failed, ret:%{public}d", ret);
return;
}
sptr<ChildMainThread> thread = sptr<ChildMainThread>(new (std::nothrow) ChildMainThread());
if (thread == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "New ChildMainThread failed.");
TAG_LOGE(AAFwkTag::APPKIT, "New ChildMainThread failed");
return;
}
thread->SetFds(fds);
std::shared_ptr<EventRunner> runner = EventRunner::GetMainEventRunner();
if (runner == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "runner is null.");
TAG_LOGE(AAFwkTag::APPKIT, "runner is null");
return;
}
if (!thread->Init(runner, processInfo)) {
TAG_LOGE(AAFwkTag::APPKIT, "ChildMainThread Init failed.");
TAG_LOGE(AAFwkTag::APPKIT, "ChildMainThread Init failed");
return;
}
if (!thread->Attach()) {
TAG_LOGE(AAFwkTag::APPKIT, "ChildMainThread Attach failed.");
TAG_LOGE(AAFwkTag::APPKIT, "ChildMainThread Attach failed");
return;
}
@ -73,7 +72,7 @@ void ChildMainThread::Start(const std::map<std::string, int32_t> &fds)
TAG_LOGE(AAFwkTag::APPKIT, "ChildMainThread runner->Run failed ret = %{public}d", ret);
}
TAG_LOGD(AAFwkTag::APPKIT, "ChildMainThread end.");
TAG_LOGD(AAFwkTag::APPKIT, "ChildMainThread end");
}
int32_t ChildMainThread::GetChildProcessInfo(ChildProcessInfo &info)
@ -95,7 +94,7 @@ int32_t ChildMainThread::GetChildProcessInfo(ChildProcessInfo &info)
void ChildMainThread::SetFds(const std::map<std::string, int32_t> &fds)
{
if (!processArgs_) {
TAG_LOGE(AAFwkTag::APPKIT, "processArgs_ is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "processArgs_ is nullptr");
return;
}
processArgs_->fds = fds;
@ -105,7 +104,7 @@ bool ChildMainThread::Init(const std::shared_ptr<EventRunner> &runner, const Chi
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
if (runner == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "runner is null.");
TAG_LOGE(AAFwkTag::APPKIT, "runner is null");
return false;
}
processInfo_ = std::make_shared<ChildProcessInfo>(processInfo);
@ -125,12 +124,12 @@ bool ChildMainThread::Attach()
TAG_LOGD(AAFwkTag::APPKIT, "called");
auto sysMrgClient = DelayedSingleton<AppExecFwk::SysMrgClient>::GetInstance();
if (sysMrgClient == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get SysMrgClient.");
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get SysMrgClient");
return false;
}
auto object = sysMrgClient->GetSystemAbility(APP_MGR_SERVICE_ID);
if (object == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "GetAppMgr failed.");
TAG_LOGE(AAFwkTag::APPKIT, "GetAppMgr failed");
return false;
}
appMgr_ = iface_cast<IAppMgr>(object);
@ -150,7 +149,7 @@ bool ChildMainThread::ScheduleLoadJs()
return false;
}
if (!processInfo_) {
TAG_LOGE(AAFwkTag::APPKIT, "processInfo is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "processInfo is nullptr");
return false;
}
auto childProcessType = processInfo_->childProcessType;
@ -158,7 +157,7 @@ bool ChildMainThread::ScheduleLoadJs()
auto task = [weak, childProcessType]() {
auto childMainThread = weak.promote();
if (childMainThread == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "childMainThread is nullptr, ScheduleLoadJs failed.");
TAG_LOGE(AAFwkTag::APPKIT, "childMainThread is nullptr, ScheduleLoadJs failed");
return;
}
if (childProcessType == CHILD_PROCESS_TYPE_ARK) {
@ -168,7 +167,7 @@ bool ChildMainThread::ScheduleLoadJs()
}
};
if (!mainHandler_->PostTask(task, "ChildMainThread::HandleLoadJs")) {
TAG_LOGE(AAFwkTag::APPKIT, "ChildMainThread::ScheduleLoadJs PostTask task failed.");
TAG_LOGE(AAFwkTag::APPKIT, "PostTask task failed");
return false;
}
return true;
@ -178,14 +177,14 @@ void ChildMainThread::HandleLoadJs()
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
if (!processInfo_ || !bundleInfo_) {
TAG_LOGE(AAFwkTag::APPKIT, "processInfo or bundleInfo_ is null.");
TAG_LOGE(AAFwkTag::APPKIT, "processInfo or bundleInfo_ is null");
return;
}
ChildProcessManager &childProcessManager = ChildProcessManager::GetInstance();
HapModuleInfo hapModuleInfo;
BundleInfo bundleInfoCopy = *bundleInfo_;
if (!childProcessManager.GetEntryHapModuleInfo(bundleInfoCopy, hapModuleInfo)) {
TAG_LOGE(AAFwkTag::APPKIT, "GetEntryHapModuleInfo failed.");
TAG_LOGE(AAFwkTag::APPKIT, "GetEntryHapModuleInfo failed");
return;
}
@ -197,13 +196,12 @@ void ChildMainThread::HandleLoadJs()
AbilityRuntime::Runtime::DebugOption debugOption;
childProcessManager.SetAppSpawnForkDebugOption(debugOption, processInfo_);
TAG_LOGD(AAFwkTag::APPKIT, "StartDebugMode, isStartWithDebug is %{public}d, processName is %{public}s, "
"isDebugApp is %{public}d, isStartWithNative is %{public}d.", processInfo_->isStartWithDebug,
"isDebugApp is %{public}d, isStartWithNative is %{public}d", processInfo_->isStartWithDebug,
processInfo_->processName.c_str(), processInfo_->isDebugApp, processInfo_->isStartWithNative);
runtime_->StartDebugMode(debugOption);
std::string srcPath;
srcPath.append(hapModuleInfo.moduleName).append("/").append(processInfo_->srcEntry);
childProcessManager.LoadJsFile(srcPath, hapModuleInfo, runtime_);
TAG_LOGD(AAFwkTag::APPKIT, "ChildMainThread::HandleLoadJs end.");
ExitProcessSafely();
}
@ -211,23 +209,23 @@ void ChildMainThread::HandleLoadArkTs()
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
if (!processInfo_ || !bundleInfo_) {
TAG_LOGE(AAFwkTag::APPKIT, "processInfo or bundleInfo_ is null.");
TAG_LOGE(AAFwkTag::APPKIT, "processInfo or bundleInfo_ is null");
return;
}
if (!processArgs_) {
TAG_LOGE(AAFwkTag::APPKIT, "processArgs_ is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "processArgs_ is nullptr");
return;
}
auto &srcEntry = processInfo_->srcEntry;
ChildProcessManager &childProcessManager = ChildProcessManager::GetInstance();
std::string moduleName = childProcessManager.GetModuleNameFromSrcEntry(srcEntry);
if (moduleName.empty()) {
TAG_LOGE(AAFwkTag::APPKIT, "Can't find module name from srcEntry, srcEntry is %{private}s.", srcEntry.c_str());
TAG_LOGE(AAFwkTag::APPKIT, "Can't find module name from srcEntry, srcEntry is %{private}s", srcEntry.c_str());
return;
}
HapModuleInfo hapModuleInfo;
if (!childProcessManager.GetHapModuleInfo(*bundleInfo_, moduleName, hapModuleInfo)) {
TAG_LOGE(AAFwkTag::APPKIT, "GetHapModuleInfo failed, can't find module:%{public}s.", moduleName.c_str());
TAG_LOGE(AAFwkTag::APPKIT, "GetHapModuleInfo failed, can't find module:%{public}s", moduleName.c_str());
return;
}
@ -239,13 +237,12 @@ void ChildMainThread::HandleLoadArkTs()
AbilityRuntime::Runtime::DebugOption debugOption;
childProcessManager.SetAppSpawnForkDebugOption(debugOption, processInfo_);
TAG_LOGD(AAFwkTag::APPKIT, "StartDebugMode, isStartWithDebug is %{public}d, processName is %{public}s, "
"isDebugApp is %{public}d, isStartWithNative is %{public}d.", processInfo_->isStartWithDebug,
"isDebugApp is %{public}d, isStartWithNative is %{public}d", processInfo_->isStartWithDebug,
processInfo_->processName.c_str(), processInfo_->isDebugApp, processInfo_->isStartWithNative);
runtime_->StartDebugMode(debugOption);
processArgs_->entryParams = processInfo_->entryParams;
childProcessManager.LoadJsFile(srcEntry, hapModuleInfo, runtime_, processArgs_);
TAG_LOGD(AAFwkTag::APPKIT, "HandleLoadArkTs end.");
}
void ChildMainThread::InitNativeLib(const BundleInfo &bundleInfo)
@ -265,7 +262,7 @@ void ChildMainThread::InitNativeLib(const BundleInfo &bundleInfo)
void ChildMainThread::ExitProcessSafely()
{
if (appMgr_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "appMgr_ is null, use exit(0) instead.");
TAG_LOGE(AAFwkTag::APPKIT, "appMgr_ is null, use exit(0) instead");
exit(0);
return;
}
@ -283,13 +280,13 @@ bool ChildMainThread::ScheduleExitProcessSafely()
auto task = [weak]() {
auto childMainThread = weak.promote();
if (childMainThread == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "childMainThread is nullptr, ScheduleExitProcessSafely failed.");
TAG_LOGE(AAFwkTag::APPKIT, "childMainThread is nullptr, ScheduleExitProcessSafely failed");
return;
}
childMainThread->HandleExitProcessSafely();
};
if (!mainHandler_->PostTask(task, "ChildMainThread::HandleExitProcessSafely")) {
TAG_LOGE(AAFwkTag::APPKIT, "ScheduleExitProcessSafely PostTask task failed.");
TAG_LOGE(AAFwkTag::APPKIT, "ScheduleExitProcessSafely PostTask task failed");
return false;
}
return true;
@ -300,7 +297,7 @@ void ChildMainThread::HandleExitProcessSafely()
TAG_LOGD(AAFwkTag::APPKIT, "called");
std::shared_ptr<EventRunner> runner = mainHandler_->GetEventRunner();
if (runner == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "HandleExitProcessSafely get runner error.");
TAG_LOGE(AAFwkTag::APPKIT, "HandleExitProcessSafely get runner error");
return;
}
int ret = runner->Stop();
@ -325,13 +322,13 @@ bool ChildMainThread::ScheduleRunNativeProc(const sptr<IRemoteObject> &mainProce
auto task = [weak = wptr<ChildMainThread>(this), callback = sptr<IRemoteObject>(mainProcessCb)]() {
auto childMainThread = weak.promote();
if (childMainThread == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "childMainThread is nullptr, ScheduleRunNativeProc failed.");
TAG_LOGE(AAFwkTag::APPKIT, "childMainThread is nullptr, ScheduleRunNativeProc failed");
return;
}
childMainThread->HandleRunNativeProc(callback);
};
if (!mainHandler_->PostTask(task, "ChildMainThread::HandleRunNativeProc")) {
TAG_LOGE(AAFwkTag::APPKIT, "HandleRunNativeProc PostTask task failed.");
TAG_LOGE(AAFwkTag::APPKIT, "HandleRunNativeProc PostTask task failed");
return false;
}
return true;
@ -341,13 +338,12 @@ void ChildMainThread::HandleRunNativeProc(const sptr<IRemoteObject> &mainProcess
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
if (!processInfo_) {
TAG_LOGE(AAFwkTag::APPKIT, "processInfo is null.");
TAG_LOGE(AAFwkTag::APPKIT, "processInfo is null");
return;
}
ChildProcessManager &childProcessMgr = ChildProcessManager::GetInstance();
childProcessMgr.LoadNativeLib(nativeLibModuleName_, processInfo_->srcEntry, mainProcessCb);
TAG_LOGD(AAFwkTag::APPKIT, "HandleRunNativeProc end.");
ExitProcessSafely();
}
@ -397,7 +393,7 @@ void ChildMainThread::GetNativeLibPath(const BundleInfo &bundleInfo, AppLibPathM
for (auto &hapInfo : bundleInfo.hapModuleInfos) {
TAG_LOGD(AAFwkTag::APPKIT,
"moduleName: %{public}s, isLibIsolated: %{public}d, compressNativeLibs: %{public}d.",
"moduleName: %{public}s, isLibIsolated: %{public}d, compressNativeLibs: %{public}d",
hapInfo.moduleName.c_str(), hapInfo.isLibIsolated, hapInfo.compressNativeLibs);
GetHapSoPath(hapInfo, appLibPaths, hapInfo.hapPath.find(ABS_CODE_PATH));
}
@ -406,7 +402,7 @@ void ChildMainThread::GetNativeLibPath(const BundleInfo &bundleInfo, AppLibPathM
void ChildMainThread::GetHapSoPath(const HapModuleInfo &hapInfo, AppLibPathMap &appLibPaths, bool isPreInstallApp)
{
if (hapInfo.nativeLibraryPath.empty()) {
TAG_LOGD(AAFwkTag::APPKIT, "Lib path of %{public}s is empty, lib isn't isolated or compressed.",
TAG_LOGD(AAFwkTag::APPKIT, "Lib path of %{public}s is empty, lib isn't isolated or compressed",
hapInfo.moduleName.c_str());
return;
}
@ -414,7 +410,7 @@ void ChildMainThread::GetHapSoPath(const HapModuleInfo &hapInfo, AppLibPathMap &
std::string appLibPathKey = hapInfo.bundleName + "/" + hapInfo.moduleName;
std::string libPath = LOCAL_CODE_PATH;
if (!hapInfo.compressNativeLibs) {
TAG_LOGD(AAFwkTag::APPKIT, "Lib of %{public}s will not be extracted from hap.", hapInfo.moduleName.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "Lib of %{public}s will not be extracted from hap", hapInfo.moduleName.c_str());
libPath = GetLibPath(hapInfo.hapPath, isPreInstallApp);
}

View File

@ -35,7 +35,7 @@ const int32_t TYPE_OTHERS = 2;
void ContextContainer::AttachBaseContext(const std::shared_ptr<ContextDeal> &base)
{
if (base == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ContextDeal::AttachBaseContext failed, base is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "base is nullptr");
return;
}
baseContext_ = base;
@ -57,7 +57,7 @@ std::shared_ptr<ProcessInfo> ContextContainer::GetProcessInfo() const
void ContextContainer::SetProcessInfo(const std::shared_ptr<ProcessInfo> &info)
{
if (info == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "SetProcessInfo failed, info is empty");
TAG_LOGE(AAFwkTag::APPKIT, "info is empty");
return;
}
processInfo_ = info;
@ -68,7 +68,7 @@ std::shared_ptr<ApplicationInfo> ContextContainer::GetApplicationInfo() const
if (baseContext_ != nullptr) {
return baseContext_->GetApplicationInfo();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetApplicationInfo baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return nullptr;
}
}
@ -78,7 +78,7 @@ std::shared_ptr<Context> ContextContainer::GetApplicationContext() const
if (baseContext_ != nullptr) {
return baseContext_->GetApplicationContext();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetApplicationContext baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return nullptr;
}
}
@ -88,7 +88,7 @@ std::string ContextContainer::GetBundleCodePath()
if (baseContext_ != nullptr) {
return baseContext_->GetBundleCodePath();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetBundleCodePath baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return "";
}
}
@ -98,7 +98,7 @@ const std::shared_ptr<AbilityInfo> ContextContainer::GetAbilityInfo()
if (baseContext_ != nullptr) {
return baseContext_->GetAbilityInfo();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetAbilityInfo baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return nullptr;
}
}
@ -108,7 +108,7 @@ std::shared_ptr<Context> ContextContainer::GetContext()
if (baseContext_ != nullptr) {
return baseContext_->GetContext();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetContext baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return nullptr;
}
}
@ -118,7 +118,7 @@ std::shared_ptr<BundleMgrHelper> ContextContainer::GetBundleManager() const
if (baseContext_ != nullptr) {
return baseContext_->GetBundleManager();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "The baseContext_ is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return nullptr;
}
}
@ -128,7 +128,7 @@ std::shared_ptr<Global::Resource::ResourceManager> ContextContainer::GetResource
if (baseContext_ != nullptr) {
return baseContext_->GetResourceManager();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetResourceManager baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return nullptr;
}
}
@ -138,7 +138,7 @@ std::string ContextContainer::GetDatabaseDir()
if (baseContext_ != nullptr) {
return baseContext_->GetDatabaseDir();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetDatabaseDir baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return "";
}
}
@ -148,7 +148,7 @@ std::string ContextContainer::GetDataDir()
if (baseContext_ != nullptr) {
return baseContext_->GetDataDir();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetDataDir baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return "";
}
}
@ -158,7 +158,7 @@ std::string ContextContainer::GetDir(const std::string &name, int mode)
if (baseContext_ != nullptr) {
return baseContext_->GetDir(name, mode);
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetDir baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return "";
}
}
@ -168,7 +168,7 @@ std::string ContextContainer::GetFilesDir()
if (baseContext_ != nullptr) {
return baseContext_->GetFilesDir();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetFilesDir baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return "";
}
}
@ -178,7 +178,7 @@ std::string ContextContainer::GetBundleName() const
if (baseContext_ != nullptr) {
return baseContext_->GetBundleName();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetBundleName baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return "";
}
}
@ -188,7 +188,7 @@ std::string ContextContainer::GetBundleResourcePath()
if (baseContext_ != nullptr) {
return baseContext_->GetBundleResourcePath();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetBundleResourcePath baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return "";
}
}
@ -198,7 +198,7 @@ sptr<AAFwk::IAbilityManager> ContextContainer::GetAbilityManager()
if (baseContext_ != nullptr) {
return baseContext_->GetAbilityManager();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetAbilityManager baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return nullptr;
}
}
@ -208,7 +208,7 @@ std::string ContextContainer::GetAppType()
if (baseContext_ != nullptr) {
return baseContext_->GetAppType();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetAppType baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return "";
}
}
@ -218,7 +218,7 @@ void ContextContainer::SetPattern(int patternId)
if (baseContext_ != nullptr) {
baseContext_->SetPattern(patternId);
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::SetPattern baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
}
}
@ -227,7 +227,7 @@ std::shared_ptr<HapModuleInfo> ContextContainer::GetHapModuleInfo()
if (baseContext_ != nullptr) {
return baseContext_->GetHapModuleInfo();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetHapModuleInfo baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return nullptr;
}
}
@ -240,7 +240,7 @@ std::string ContextContainer::GetProcessName()
std::shared_ptr<Context> ContextContainer::CreateBundleContext(std::string bundleName, int flag, int accountId)
{
if (bundleName.empty()) {
TAG_LOGE(AAFwkTag::APPKIT, "The bundleName is empty.");
TAG_LOGE(AAFwkTag::APPKIT, "The bundleName is empty");
return nullptr;
}
@ -250,12 +250,12 @@ std::shared_ptr<Context> ContextContainer::CreateBundleContext(std::string bundl
std::shared_ptr<BundleMgrHelper> bundleMgr = GetBundleManager();
if (bundleMgr == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "The bundleMgr is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "The bundleMgr is nullptr");
return nullptr;
}
BundleInfo bundleInfo;
TAG_LOGI(AAFwkTag::APPKIT, "Length: %{public}zu, bundleName: %{public}s, accountId is %{public}d.",
TAG_LOGI(AAFwkTag::APPKIT, "Length: %{public}zu, bundleName: %{public}s, accountId is %{public}d",
bundleName.length(),
bundleName.c_str(),
accountId);
@ -266,7 +266,7 @@ std::shared_ptr<Context> ContextContainer::CreateBundleContext(std::string bundl
bundleMgr->GetBundleInfo(bundleName, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, realAccountId);
if (bundleInfo.name.empty() || bundleInfo.applicationInfo.name.empty()) {
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get Bundle Info.");
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get Bundle Info");
return nullptr;
}
@ -306,7 +306,7 @@ void ContextContainer::InitResourceManager(BundleInfo &bundleInfo, std::shared_p
std::shared_ptr<Global::Resource::ResourceManager> resourceManager(Global::Resource::CreateResourceManager(
bundleInfo.name, moduleName, hapPath, overlayPaths, *resConfig, appType));
if (resourceManager == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ContextImpl::InitResourceManager failed to create resourceManager");
TAG_LOGE(AAFwkTag::APPKIT, "failed to create resourceManager");
return;
}
deal->initResourceManager(resourceManager);
@ -316,7 +316,7 @@ void ContextContainer::InitResourceManager(BundleInfo &bundleInfo, std::shared_p
std::shared_ptr<Global::Resource::ResourceManager> resourceManager(Global::Resource::CreateResourceManager(
bundleInfo.name, moduleName, hapPath, overlayPaths, *resConfig, appType));
if (resourceManager == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::InitResourceManager create resourceManager failed");
TAG_LOGE(AAFwkTag::APPKIT, "create resourceManager failed");
return;
}
LoadResources(bundleInfo, resourceManager, resConfig, deal);
@ -326,7 +326,7 @@ void ContextContainer::LoadResources(BundleInfo &bundleInfo,
std::shared_ptr<Global::Resource::ResourceManager> &resourceManager,
std::unique_ptr<Global::Resource::ResConfig> &resConfig, std::shared_ptr<ContextDeal> &deal)
{
TAG_LOGD(AAFwkTag::APPKIT, "ContextContainer::InitResourceManager hapModuleInfos count: %{public}zu",
TAG_LOGD(AAFwkTag::APPKIT, "hapModuleInfos count: %{public}zu",
bundleInfo.hapModuleInfos.size());
std::regex pattern(AbilityBase::Constants::ABS_CODE_PATH);
for (auto hapModuleInfo : bundleInfo.hapModuleInfos) {
@ -340,7 +340,7 @@ void ContextContainer::LoadResources(BundleInfo &bundleInfo,
continue;
}
loadPath = std::regex_replace(loadPath, pattern, AbilityBase::Constants::LOCAL_BUNDLES);
TAG_LOGD(AAFwkTag::APPKIT, "ContextContainer::InitResourceManager loadPath: %{public}s", loadPath.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "loadPath: %{private}s", loadPath.c_str());
if (!resourceManager->AddResource(loadPath.c_str())) {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::InitResourceManager AddResource failed");
}
@ -350,12 +350,12 @@ void ContextContainer::LoadResources(BundleInfo &bundleInfo,
#ifdef SUPPORT_GRAPHICS
if (resConfig->GetLocaleInfo() != nullptr) {
TAG_LOGI(AAFwkTag::APPKIT,
"ContextContainer::InitResourceManager language: %{public}s, script: %{public}s, region: %{public}s,",
"language: %{public}s, script: %{public}s, region: %{public}s,",
resConfig->GetLocaleInfo()->getLanguage(),
resConfig->GetLocaleInfo()->getScript(),
resConfig->GetLocaleInfo()->getCountry());
} else {
TAG_LOGI(AAFwkTag::APPKIT, "ContextContainer::InitResourceManager language: GetLocaleInfo is null.");
TAG_LOGI(AAFwkTag::APPKIT, "language: GetLocaleInfo is null.");
}
#endif
resourceManager->UpdateResConfig(*resConfig);
@ -379,7 +379,7 @@ std::string ContextContainer::GetString(int resId)
std::string ret = baseContext_->GetString(resId);
return ret;
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetString baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "GetString baseContext_ is nullptr");
return "";
}
}
@ -389,7 +389,7 @@ std::vector<std::string> ContextContainer::GetStringArray(int resId)
if (baseContext_ != nullptr) {
return baseContext_->GetStringArray(resId);
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetStringArray baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return std::vector<std::string>();
}
}
@ -399,7 +399,7 @@ std::vector<int> ContextContainer::GetIntArray(int resId)
if (baseContext_ != nullptr) {
return baseContext_->GetIntArray(resId);
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetIntArray baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return std::vector<int>();
}
}
@ -409,7 +409,7 @@ std::map<std::string, std::string> ContextContainer::GetTheme()
if (baseContext_ != nullptr) {
return baseContext_->GetTheme();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetTheme baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return std::map<std::string, std::string>();
}
}
@ -419,7 +419,7 @@ void ContextContainer::SetTheme(int themeId)
if (baseContext_ != nullptr) {
baseContext_->SetTheme(themeId);
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::SetTheme baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
}
}
@ -428,7 +428,7 @@ std::map<std::string, std::string> ContextContainer::GetPattern()
if (baseContext_ != nullptr) {
return baseContext_->GetPattern();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetPattern baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return std::map<std::string, std::string>();
}
}
@ -438,7 +438,7 @@ int ContextContainer::GetColor(int resId)
if (baseContext_ != nullptr) {
return baseContext_->GetColor(resId);
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetColor baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return INVALID_RESOURCE_VALUE;
}
}
@ -448,7 +448,7 @@ int ContextContainer::GetThemeId()
if (baseContext_ != nullptr) {
return baseContext_->GetThemeId();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetThemeId baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return -1;
}
}
@ -458,7 +458,7 @@ int ContextContainer::GetDisplayOrientation()
if (baseContext_ != nullptr) {
return baseContext_->GetDisplayOrientation();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetDisplayOrientation baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return static_cast<int>(DisplayOrientation::UNSPECIFIED);
}
}
@ -468,7 +468,7 @@ std::string ContextContainer::GetPreferencesDir()
if (baseContext_ != nullptr) {
return baseContext_->GetPreferencesDir();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetPreferencesDir baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return "";
}
}
@ -476,7 +476,7 @@ std::string ContextContainer::GetPreferencesDir()
void ContextContainer::SetColorMode(int mode)
{
if (baseContext_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::SetColorMode baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return;
}
@ -486,7 +486,7 @@ void ContextContainer::SetColorMode(int mode)
int ContextContainer::GetColorMode()
{
if (baseContext_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ContextContainer::GetColorMode baseContext_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "baseContext_ is nullptr");
return -1;
}

View File

@ -56,7 +56,7 @@ std::shared_ptr<ApplicationInfo> ContextDeal::GetApplicationInfo() const
void ContextDeal::SetApplicationInfo(const std::shared_ptr<ApplicationInfo> &info)
{
if (info == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "SetApplicationInfo failed, info is empty");
TAG_LOGE(AAFwkTag::APPKIT, "info is empty");
return;
}
applicationInfo_ = info;
@ -70,7 +70,7 @@ std::shared_ptr<Context> ContextDeal::GetApplicationContext() const
void ContextDeal::SetApplicationContext(const std::shared_ptr<Context> &context)
{
if (context == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "SetApplicationContext failed, context is empty");
TAG_LOGE(AAFwkTag::APPKIT, "context is empty");
return;
}
appContext_ = context;
@ -105,7 +105,7 @@ const std::shared_ptr<AbilityInfo> ContextDeal::GetAbilityInfo()
void ContextDeal::SetAbilityInfo(const std::shared_ptr<AbilityInfo> &info)
{
if (info == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "SetAbilityInfo failed, info is empty");
TAG_LOGE(AAFwkTag::APPKIT, "info is empty");
return;
}
abilityInfo_ = info;
@ -119,7 +119,7 @@ std::shared_ptr<Context> ContextDeal::GetContext()
void ContextDeal::SetContext(const std::shared_ptr<Context> &context)
{
if (context == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "The context is empty.");
TAG_LOGE(AAFwkTag::APPKIT, "context is empty.");
return;
}
abilityContext_ = context;
@ -165,7 +165,7 @@ std::string ContextDeal::GetDataDir()
std::string ContextDeal::GetDir(const std::string &name, int mode)
{
if (applicationInfo_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "GetDir failed, applicationInfo_ == nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "applicationInfo_ == nullptr");
return "";
}
std::string dir = applicationInfo_->dataDir + CONTEXT_DEAL_FILE_SEPARATOR + name;
@ -305,7 +305,7 @@ std::string ContextDeal::GetString(int resId)
std::vector<std::string> ContextDeal::GetStringArray(int resId)
{
if (resourceManager_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "GetStringArray resourceManager_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "resourceManager_ is nullptr");
return std::vector<std::string>();
}
@ -314,7 +314,7 @@ std::vector<std::string> ContextDeal::GetStringArray(int resId)
if (errval == OHOS::Global::Resource::RState::SUCCESS) {
return retv;
} else {
TAG_LOGE(AAFwkTag::APPKIT, "GetStringArray GetStringArrayById(resId:%d) retval is %u", resId, errval);
TAG_LOGE(AAFwkTag::APPKIT, "GetStringArrayById(resId:%d) retval is %u", resId, errval);
return std::vector<std::string>();
}
}
@ -347,13 +347,13 @@ std::map<std::string, std::string> ContextDeal::GetTheme()
void ContextDeal::SetTheme(int themeId)
{
if (resourceManager_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "SetTheme resourceManager_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "resourceManager_ is nullptr");
return;
}
auto hapModInfo = GetHapModuleInfo();
if (hapModInfo == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "SetTheme hapModInfo is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "hapModInfo is nullptr");
return;
}
@ -407,10 +407,9 @@ int ContextDeal::GetThemeId()
int ContextDeal::GetDisplayOrientation()
{
if (abilityInfo_ != nullptr) {
TAG_LOGD(AAFwkTag::APPKIT, "GetDisplayOrientation end");
return static_cast<int>(abilityInfo_->orientation);
} else {
TAG_LOGE(AAFwkTag::APPKIT, "GetDisplayOrientation abilityInfo_ is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "abilityInfo_ is nullptr");
return static_cast<int>(DisplayOrientation::UNSPECIFIED);
}
}

View File

@ -30,18 +30,18 @@ DumpRuntimeHelper::DumpRuntimeHelper(const std::shared_ptr<OHOSApplication> &app
void DumpRuntimeHelper::SetAppFreezeFilterCallback()
{
if (application_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "SetAppFreezeFilterCallback OHOSApplication is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "OHOSApplication is nullptr");
return;
}
auto& runtime = application_->GetRuntime();
if (runtime == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "SetAppFreezeFilterCallback GetRuntime is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "Runtime is nullptr");
return;
}
auto appfreezeFilterCallback = [] (const int32_t pid) -> bool {
auto client = DelayedSingleton<AppExecFwk::AppMgrClient>::GetInstance();
if (client == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "SetAppFreezeFilterCallback client is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "client is nullptr");
return false;
}
return client->SetAppFreezeFilter(pid);

View File

@ -117,7 +117,7 @@ bool ExtensionPluginInfo::ScanExtensions(std::vector<std::string>& files)
std::string dirPath = EXTENSION_LIB;
DIR *dirp = opendir(dirPath.c_str());
if (dirp == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ExtensionPluginInfo::ScanDir open dir:%{public}s fail", dirPath.c_str());
TAG_LOGE(AAFwkTag::APPKIT, "ScanDir open dir:%{public}s fail", dirPath.c_str());
return false;
}
@ -146,7 +146,7 @@ bool ExtensionPluginInfo::ScanExtensions(std::vector<std::string>& files)
bool ExtensionPluginInfo::CheckFileType(const std::string& fileName, const std::string& extensionName)
{
TAG_LOGD(AAFwkTag::APPKIT, "ExtensionPluginInfo::CheckFileType path is %{public}s, support suffix is %{public}s",
TAG_LOGD(AAFwkTag::APPKIT, "CheckFileType path is %{public}s, support suffix is %{public}s",
fileName.c_str(),
extensionName.c_str());

View File

@ -48,7 +48,7 @@ void IdleTime::InitVSyncReceiver()
auto& rsClient = Rosen::RSInterfaces::GetInstance();
receiver_ = rsClient.CreateVSyncReceiver("ABILITY", eventHandler_);
if (receiver_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Create VSync receiver failed.");
TAG_LOGE(AAFwkTag::APPKIT, "Create VSync receiver failed");
return;
}
receiver_->Init();
@ -59,12 +59,12 @@ void IdleTime::InitVSyncReceiver()
void IdleTime::EventTask()
{
if (receiver_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "no VSyncReceiver.");
TAG_LOGE(AAFwkTag::APPKIT, "no VSyncReceiver");
return;
}
if (callback_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "no callback_.");
TAG_LOGE(AAFwkTag::APPKIT, "no callback_");
return;
}
@ -99,14 +99,14 @@ void IdleTime::PostTask()
}
if (eventHandler_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "eventHandler_ is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "eventHandler_ is nullptr");
return;
}
std::weak_ptr<IdleTime> weak(shared_from_this());
auto task = [weak]() {
auto idleTime = weak.lock();
if (idleTime == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "idleTime is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "idleTime is nullptr");
return;
}
idleTime->EventTask();

View File

@ -178,7 +178,7 @@ std::string GetLibPath(const std::string &hapPath, bool isPreInstallApp)
void GetHapSoPath(const HapModuleInfo &hapInfo, AppLibPathMap &appLibPaths, bool isPreInstallApp)
{
if (hapInfo.nativeLibraryPath.empty()) {
TAG_LOGD(AAFwkTag::APPKIT, "Lib path of %{public}s is empty, lib isn't isolated or compressed.",
TAG_LOGD(AAFwkTag::APPKIT, "Lib path of %{public}s is empty, lib isn't isolated or compressed",
hapInfo.moduleName.c_str());
return;
}
@ -186,7 +186,7 @@ void GetHapSoPath(const HapModuleInfo &hapInfo, AppLibPathMap &appLibPaths, bool
std::string appLibPathKey = hapInfo.bundleName + "/" + hapInfo.moduleName;
std::string libPath = LOCAL_CODE_PATH;
if (!hapInfo.compressNativeLibs) {
TAG_LOGD(AAFwkTag::APPKIT, "Lib of %{public}s will not be extracted from hap.", hapInfo.moduleName.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "Lib of %{public}s will not be extracted from hap", hapInfo.moduleName.c_str());
libPath = GetLibPath(hapInfo.hapPath, isPreInstallApp);
}
@ -230,12 +230,12 @@ void GetPatchNativeLibPath(const HapModuleInfo &hapInfo, std::string &patchNativ
}
if (patchNativeLibraryPath.empty()) {
TAG_LOGD(AAFwkTag::APPKIT, "Patch lib path of %{public}s is empty.", hapInfo.moduleName.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "Patch lib path of %{public}s is empty", hapInfo.moduleName.c_str());
return;
}
if (hapInfo.compressNativeLibs && !hapInfo.isLibIsolated) {
TAG_LOGD(AAFwkTag::APPKIT, "Lib of %{public}s has compressed and isn't isolated, no need to set.",
TAG_LOGD(AAFwkTag::APPKIT, "Lib of %{public}s has compressed and isn't isolated, no need to set",
hapInfo.moduleName.c_str());
return;
}
@ -294,12 +294,11 @@ void MainThread::GetNativeLibPath(const BundleInfo &bundleInfo, const HspList &h
*/
void AppMgrDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
{
TAG_LOGE(AAFwkTag::APPKIT, "MainThread::AppMgrDeathRecipient remote died receive");
TAG_LOGE(AAFwkTag::APPKIT, "remote died receive");
}
MainThread::MainThread()
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
#ifdef ABILITY_LIBRARY_LOADER
fileEntries_.clear();
nativeFileEntries_.clear();
@ -642,12 +641,12 @@ void MainThread::ScheduleJsHeapMemory(OHOS::AppExecFwk::JsHeapDumpInfo &info)
info.pid, info.tid, info.needGc, info.needSnapshot);
auto app = applicationForDump_.lock();
if (app == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ScheduleJsHeapMemory app nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "app nullptr");
return;
}
auto &runtime = app->GetRuntime();
if (runtime == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ScheduleJsHeapMemory runtime nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "runtime nullptr");
return;
}
if (info.needSnapshot == true) {
@ -666,7 +665,6 @@ void MainThread::ScheduleJsHeapMemory(OHOS::AppExecFwk::JsHeapDumpInfo &info)
*/
void MainThread::ScheduleProcessSecurityExit()
{
TAG_LOGD(AAFwkTag::APPKIT, "ScheduleProcessSecurityExit called");
wptr<MainThread> weak = this;
auto task = [weak]() {
auto appThread = weak.promote();
@ -705,9 +703,7 @@ void MainThread::ScheduleClearPageStack()
*
*/
void MainThread::ScheduleLowMemory()
{
TAG_LOGD(AAFwkTag::APPKIT, "MainThread::scheduleLowMemory called");
}
{}
/**
*
@ -1075,27 +1071,27 @@ bool MainThread::InitResourceManager(std::shared_ptr<Global::Resource::ResourceM
}
#endif
std::string colormode = config.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE);
TAG_LOGD(AAFwkTag::APPKIT, "Colormode is %{public}s.", colormode.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "Colormode is %{public}s", colormode.c_str());
resConfig->SetColorMode(ConvertColorMode(colormode));
std::string hasPointerDevice = config.GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
TAG_LOGD(AAFwkTag::APPKIT, "HasPointerDevice is %{public}s.", hasPointerDevice.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "HasPointerDevice is %{public}s", hasPointerDevice.c_str());
resConfig->SetInputDevice(ConvertHasPointerDevice(hasPointerDevice));
std::string deviceType = config.GetItem(AAFwk::GlobalConfigurationKey::DEVICE_TYPE);
TAG_LOGD(AAFwkTag::APPKIT, "deviceType is %{public}s <----> %{public}d.", deviceType.c_str(),
TAG_LOGD(AAFwkTag::APPKIT, "deviceType is %{public}s <----> %{public}d", deviceType.c_str(),
ConvertDeviceType(deviceType));
resConfig->SetDeviceType(ConvertDeviceType(deviceType));
std::string mcc = config.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MCC);
TAG_LOGD(AAFwkTag::APPKIT, "mcc is %{public}s.", mcc.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "mcc is %{public}s", mcc.c_str());
uint32_t mccNum = 0;
if (AbilityRuntime::ResourceConfigHelper::ConvertStringToUint32(mcc, mccNum)) {
resConfig->SetMcc(mccNum);
}
std::string mnc = config.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MNC);
TAG_LOGD(AAFwkTag::APPKIT, "mnc is %{public}s.", mnc.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "mnc is %{public}s", mnc.c_str());
uint32_t mncNum = 0;
if (AbilityRuntime::ResourceConfigHelper::ConvertStringToUint32(mnc, mncNum)) {
resConfig->SetMnc(mncNum);
@ -1118,7 +1114,7 @@ void MainThread::OnStartAbility(const std::string &bundleName,
// getOverlayPath
auto res = GetOverlayModuleInfos(bundleName, entryHapModuleInfo.moduleName, overlayModuleInfos_);
if (res != ERR_OK) {
TAG_LOGW(AAFwkTag::APPKIT, "getOverlayPath failed.");
TAG_LOGW(AAFwkTag::APPKIT, "getOverlayPath failed");
}
if (overlayModuleInfos_.size() == 0) {
if (!resourceManager->AddResource(loadPath.c_str())) {
@ -1126,7 +1122,7 @@ void MainThread::OnStartAbility(const std::string &bundleName,
}
} else {
std::vector<std::string> overlayPaths = GetOverlayPaths(bundleName, overlayModuleInfos_);
TAG_LOGD(AAFwkTag::APPKIT, "OverlayPaths size:%{public}zu.", overlayPaths.size());
TAG_LOGD(AAFwkTag::APPKIT, "OverlayPaths size:%{public}zu", overlayPaths.size());
if (!resourceManager->AddResource(loadPath, overlayPaths)) {
TAG_LOGE(AAFwkTag::APPKIT, "AddResource failed");
}
@ -1175,10 +1171,10 @@ void MainThread::SubscribeOverlayChange(const std::string &bundleName, const std
wptr<MainThread> weak = this;
auto callback = [weak, resourceManager, bundleName, moduleName = entryHapModuleInfo.moduleName,
loadPath](const EventFwk::CommonEventData &data) {
TAG_LOGD(AAFwkTag::APPKIT, "On overlay changed.");
TAG_LOGD(AAFwkTag::APPKIT, "On overlay changed");
auto appThread = weak.promote();
if (appThread == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "abilityThread is nullptr, SetRunnerStarted failed.");
TAG_LOGE(AAFwkTag::APPKIT, "abilityThread is nullptr, SetRunnerStarted failed");
return;
}
appThread->OnOverlayChanged(data, resourceManager, bundleName, moduleName, loadPath);
@ -1192,9 +1188,8 @@ void MainThread::OnOverlayChanged(const EventFwk::CommonEventData &data,
const std::shared_ptr<Global::Resource::ResourceManager> &resourceManager, const std::string &bundleName,
const std::string &moduleName, const std::string &loadPath)
{
TAG_LOGD(AAFwkTag::APPKIT, "begin.");
if (mainHandler_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "mainHandler is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "mainHandler is nullptr");
return;
}
wptr<MainThread> weak = this;
@ -1215,11 +1210,11 @@ void MainThread::HandleOnOverlayChanged(const EventFwk::CommonEventData &data,
const std::shared_ptr<Global::Resource::ResourceManager> &resourceManager, const std::string &bundleName,
const std::string &moduleName, const std::string &loadPath)
{
TAG_LOGD(AAFwkTag::APPKIT, "begin.");
TAG_LOGD(AAFwkTag::APPKIT, "begin");
auto want = data.GetWant();
std::string action = want.GetAction();
if (action != OVERLAY_STATE_CHANGED) {
TAG_LOGD(AAFwkTag::APPKIT, "Not this subscribe, action: %{public}s.", action.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "Not this subscribe, action: %{public}s", action.c_str());
return;
}
bool isEnable = data.GetWant().GetBoolParam(Constants::OVERLAY_STATE, false);
@ -1276,11 +1271,11 @@ bool GetBundleForLaunchApplication(std::shared_ptr<BundleMgrHelper> bundleMgrHel
{
bool queryResult;
if (appIndex > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) {
TAG_LOGD(AAFwkTag::APPKIT, "The bundleName = %{public}s.", bundleName.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "The bundleName = %{public}s", bundleName.c_str());
queryResult = (bundleMgrHelper->GetSandboxBundleInfo(bundleName,
appIndex, UNSPECIFIED_USERID, bundleInfo) == 0);
} else {
TAG_LOGD(AAFwkTag::APPKIT, "The bundleName = %{public}s.", bundleName.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "The bundleName = %{public}s", bundleName.c_str());
queryResult = (bundleMgrHelper->GetBundleInfoForSelf(
(static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY) +
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) +
@ -1306,7 +1301,7 @@ CJUncaughtExceptionInfo MainThread::CreateCjExceptionInfo(const std::string &bun
(std::string summary, const CJErrorObject errorObj) {
auto appThread = weak_this.promote();
if (appThread == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "appThread is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "appThread is nullptr");
return;
}
time_t timet;
@ -1359,9 +1354,8 @@ CJUncaughtExceptionInfo MainThread::CreateCjExceptionInfo(const std::string &bun
void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, const Configuration &config)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
TAG_LOGI(AAFwkTag::APPKIT, "called");
if (!CheckForHandleLaunchApplication(appLaunchData)) {
TAG_LOGE(AAFwkTag::APPKIT, "CheckForHandleLaunchApplication failed.");
TAG_LOGE(AAFwkTag::APPKIT, "CheckForHandleLaunchApplication failed");
return;
}
@ -1373,15 +1367,15 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
auto appInfo = appLaunchData.GetApplicationInfo();
ProcessInfo processInfo = appLaunchData.GetProcessInfo();
TAG_LOGD(AAFwkTag::APPKIT, "InitCreate Start.");
TAG_LOGD(AAFwkTag::APPKIT, "InitCreate Start");
std::shared_ptr<ContextDeal> contextDeal;
if (!InitCreate(contextDeal, appInfo, processInfo)) {
TAG_LOGE(AAFwkTag::APPKIT, "InitCreate failed.");
TAG_LOGE(AAFwkTag::APPKIT, "InitCreate failed");
return;
}
auto bundleMgrHelper = contextDeal->GetBundleManager();
if (bundleMgrHelper == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "The bundleMgrHelper is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "The bundleMgrHelper is nullptr");
return;
}
@ -1393,7 +1387,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
}
BundleInfo bundleInfo;
if (!GetBundleForLaunchApplication(bundleMgrHelper, bundleName, appLaunchData.GetAppIndex(), bundleInfo)) {
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get bundle info.");
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get bundle info");
return;
}
@ -1413,7 +1407,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
}
}
if (!findEntryHapModuleInfo) {
TAG_LOGW(AAFwkTag::APPKIT, "HandleLaunchApplication find entry hap module info failed!");
TAG_LOGW(AAFwkTag::APPKIT, "HandleLaunchApplication find entry hap module info failed");
entryHapModuleInfo = bundleInfo.hapModuleInfos.back();
}
#ifdef CJ_FRONTEND
@ -1482,8 +1476,6 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
application_->SetApplicationContext(applicationContext);
#ifdef SUPPORT_SCREEN
TAG_LOGI(
AAFwkTag::APPKIT, "HandleLaunchApplication cacheDir: %{public}s", applicationContext->GetCacheDir().c_str());
OHOS::EglSetCacheDir(applicationContext->GetCacheDir());
#endif
@ -1491,7 +1483,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
ErrCode ret = bundleMgrHelper->GetBaseSharedBundleInfos(appInfo.bundleName, hspList,
AppExecFwk::GetDependentBundleInfoFlag::GET_ALL_DEPENDENT_BUNDLE_INFO);
if (ret != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "Get base shared bundle infos failed: %{public}d.", ret);
TAG_LOGE(AAFwkTag::APPKIT, "Get base shared bundle infos failed: %{public}d", ret);
}
std::map<std::string, std::string> pkgContextInfoJsonStringMap;
@ -1622,7 +1614,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
pid, processName] (std::string summary, const JsEnv::ErrorObject errorObj) {
auto appThread = weak.promote();
if (appThread == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "appThread is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "appThread is nullptr");
return;
}
time_t timet;
@ -1682,7 +1674,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
if (app != nullptr) {
return AbilityRuntime::UIAbility::Create(app->GetRuntime());
}
TAG_LOGE(AAFwkTag::APPKIT, "failed.");
TAG_LOGE(AAFwkTag::APPKIT, "failed");
return nullptr;
});
#ifdef CJ_FRONTEND
@ -1696,12 +1688,12 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
IdleTimeCallback callback = [wpApplication](int32_t idleTime) {
auto app = wpApplication.lock();
if (app == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "app is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "app is nullptr");
return;
}
auto &runtime = app->GetRuntime();
if (runtime == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "runtime is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "runtime is nullptr");
return;
}
auto& nativeEngine = (static_cast<AbilityRuntime::JsRuntime&>(*runtime)).GetNativeEngine();
@ -1729,7 +1721,6 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
}
// init resourceManager.
TAG_LOGD(AAFwkTag::APPKIT, "CreateResourceManager Start.");
auto moduleName = entryHapModuleInfo.moduleName;
std::string loadPath =
@ -1839,18 +1830,18 @@ void MainThread::CalcNativeLiabraryEntries(const BundleInfo &bundleInfo, std::st
libPath.push_back('/');
}
for (const auto &entryName : item.nativeLibraryFileNames) {
TAG_LOGD(AAFwkTag::APPKIT, "add entry: %{public}s.", entryName.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "add entry: %{public}s", entryName.c_str());
nativeFileEntries.emplace_back(libPath + entryName);
}
} else {
TAG_LOGD(AAFwkTag::APPKIT, "compressNativeLibs flag true for: %{public}s.", item.moduleName.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "compressNativeLibs flag true for: %{public}s", item.moduleName.c_str());
loadSoFromDir = true;
}
}
if (loadSoFromDir) {
if (nativeLibraryPath.empty()) {
TAG_LOGW(AAFwkTag::APPKIT, "Native library path is empty.");
TAG_LOGW(AAFwkTag::APPKIT, "Native library path is empty");
return;
}
@ -1971,7 +1962,7 @@ void MainThread::HandleAbilityStage(const HapModuleInfo &abilityStage)
void MainThread::LoadAllExtensions(NativeEngine &nativeEngine)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::APPKIT, "LoadAllExtensions.");
TAG_LOGD(AAFwkTag::APPKIT, "LoadAllExtensions");
if (!extensionConfigMgr_) {
TAG_LOGE(AAFwkTag::APPKIT, "ExtensionConfigMgr is invalid");
return;
@ -1979,7 +1970,7 @@ void MainThread::LoadAllExtensions(NativeEngine &nativeEngine)
auto extensionPlugins = AbilityRuntime::ExtensionPluginInfo::GetInstance().GetExtensionPlugins();
if (extensionPlugins.empty()) {
TAG_LOGE(AAFwkTag::APPKIT, "no extension type map.");
TAG_LOGE(AAFwkTag::APPKIT, "no extension type map");
return;
}
@ -2013,14 +2004,14 @@ bool MainThread::PrepareAbilityDelegator(const std::shared_ptr<UserTestRecord> &
}
auto args = std::make_shared<AbilityDelegatorArgs>(record->want);
if (isStageBased) { // Stage model
TAG_LOGD(AAFwkTag::APPKIT, "Stage model.");
TAG_LOGD(AAFwkTag::APPKIT, "Stage model");
auto testRunner = TestRunner::Create(application_->GetRuntime(), args, false);
auto delegator = std::make_shared<AbilityDelegator>(
application_->GetAppContext(), std::move(testRunner), record->observer);
AbilityDelegatorRegistry::RegisterInstance(delegator, args);
delegator->Prepare();
} else { // FA model
TAG_LOGD(AAFwkTag::APPKIT, "FA model.");
TAG_LOGD(AAFwkTag::APPKIT, "FA model");
AbilityRuntime::Runtime::Options options;
options.codePath = LOCAL_CODE_PATH;
options.eventRunner = mainHandler_->GetEventRunner();
@ -2070,7 +2061,7 @@ void MainThread::HandleLaunchAbility(const std::shared_ptr<AbilityLocalRecord> &
if (abilityRecord->GetWant() != nullptr) {
traceName += abilityRecord->GetWant()->GetElement().GetBundleName();
} else {
TAG_LOGE(AAFwkTag::APPKIT, "Want is nullptr, cant not get abilityName.");
TAG_LOGE(AAFwkTag::APPKIT, "Want is nullptr, cant not get abilityName");
}
HITRACE_METER_NAME(HITRACE_TAG_APP, traceName);
CHECK_POINTER_LOG(applicationImpl_, "applicationImpl_ is null");
@ -2143,7 +2134,7 @@ void MainThread::HandleLaunchAbility(const std::shared_ptr<AbilityLocalRecord> &
*/
void MainThread::HandleCleanAbilityLocal(const sptr<IRemoteObject> &token)
{
TAG_LOGD(AAFwkTag::APPKIT, "start.");
TAG_LOGD(AAFwkTag::APPKIT, "start");
if (!IsApplicationReady()) {
TAG_LOGE(AAFwkTag::APPKIT, "should launch application first");
return;
@ -2256,7 +2247,7 @@ void MainThread::HandleForegroundApplication()
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
TAG_LOGI(AAFwkTag::APPKIT, "called");
if ((application_ == nullptr) || (appMgr_ == nullptr)) {
TAG_LOGE(AAFwkTag::APPKIT, "MainThread::handleForegroundApplication error!");
TAG_LOGE(AAFwkTag::APPKIT, "handleForegroundApplication error!");
return;
}
@ -2281,10 +2272,10 @@ void MainThread::HandleForegroundApplication()
void MainThread::HandleBackgroundApplication()
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
TAG_LOGI(AAFwkTag::APPKIT, "start.");
TAG_LOGI(AAFwkTag::APPKIT, "start");
if ((application_ == nullptr) || (appMgr_ == nullptr)) {
TAG_LOGE(AAFwkTag::APPKIT, "error!");
TAG_LOGE(AAFwkTag::APPKIT, "error");
return;
}
@ -2309,14 +2300,14 @@ void MainThread::HandleBackgroundApplication()
void MainThread::HandleTerminateApplication(bool isLastProcess)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::APPKIT, "start.");
TAG_LOGD(AAFwkTag::APPKIT, "start");
if ((application_ == nullptr) || (appMgr_ == nullptr)) {
TAG_LOGE(AAFwkTag::APPKIT, "error!");
TAG_LOGE(AAFwkTag::APPKIT, "error");
return;
}
if (!applicationImpl_->PerformTerminate(isLastProcess)) {
TAG_LOGD(AAFwkTag::APPKIT, "PerformTerminate() failed.");
TAG_LOGD(AAFwkTag::APPKIT, "PerformTerminate() failed");
}
std::shared_ptr<EventRunner> runner = mainHandler_->GetEventRunner();
@ -2348,7 +2339,6 @@ void MainThread::HandleTerminateApplication(bool isLastProcess)
void MainThread::HandleShrinkMemory(const int level)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::APPKIT, "start.");
if (applicationImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "applicationImpl_ is null");
@ -2368,7 +2358,7 @@ void MainThread::HandleShrinkMemory(const int level)
void MainThread::HandleMemoryLevel(int level)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::APPKIT, "start.");
TAG_LOGD(AAFwkTag::APPKIT, "start");
if (application_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "application_ is null");
@ -2388,8 +2378,6 @@ void MainThread::HandleMemoryLevel(int level)
void MainThread::HandleConfigurationUpdated(const Configuration &config)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::APPKIT, "start.");
if (applicationImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "applicationImpl_ is null");
return;
@ -2401,7 +2389,7 @@ void MainThread::HandleConfigurationUpdated(const Configuration &config)
void MainThread::TaskTimeoutDetected(const std::shared_ptr<EventRunner> &runner)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::APPKIT, "start.");
TAG_LOGD(AAFwkTag::APPKIT, "start");
auto deliveryTimeoutCallback = []() {
TAG_LOGD(AAFwkTag::APPKIT, "delivery timeout");
@ -2498,19 +2486,19 @@ void MainThread::HandleSignal(int signal, [[maybe_unused]] siginfo_t *siginfo, v
void MainThread::HandleDumpHeapPrepare()
{
TAG_LOGD(AAFwkTag::APPKIT, "HandleDumpHeapPrepare start.");
TAG_LOGD(AAFwkTag::APPKIT, "start");
if (mainHandler_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "HandleDumpHeapPrepare failed, mainHandler is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "mainHandler is nullptr");
return;
}
auto app = applicationForDump_.lock();
if (app == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "HandleDumpHeapPrepare app is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "app is nullptr");
return;
}
auto &runtime = app->GetRuntime();
if (runtime == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "HandleDumpHeapPrepare runtime is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "runtime is nullptr");
return;
}
runtime->GetHeapPrepare();
@ -2518,23 +2506,23 @@ void MainThread::HandleDumpHeapPrepare()
void MainThread::HandleDumpHeap(bool isPrivate)
{
TAG_LOGD(AAFwkTag::APPKIT, "HandleDump Heap start.");
TAG_LOGD(AAFwkTag::APPKIT, "start");
if (mainHandler_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "HandleDumpHeap failed, mainHandler is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "mainHandler is nullptr");
return;
}
auto app = applicationForDump_.lock();
if (app == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "HandleDumpHeap app is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "app is nullptr");
return;
}
auto &runtime = app->GetRuntime();
if (runtime == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "HandleDumpHeap runtime is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "runtime is nullptr");
return;
}
auto taskFork = [&runtime, &isPrivate] {
TAG_LOGD(AAFwkTag::APPKIT, "HandleDump Heap taskFork start.");
TAG_LOGD(AAFwkTag::APPKIT, "HandleDump Heap taskFork start");
time_t startTime = time(nullptr);
int pid = -1;
if ((pid = fork()) < 0) {
@ -2582,7 +2570,7 @@ void MainThread::DestroyHeapProfiler()
auto task = [] {
auto app = applicationForDump_.lock();
if (app == nullptr || app->GetRuntime() == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "runtime is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "runtime is nullptr");
return;
}
app->GetRuntime()->DestroyHeapProfiler();
@ -2592,7 +2580,7 @@ void MainThread::DestroyHeapProfiler()
void MainThread::ForceFullGC()
{
TAG_LOGD(AAFwkTag::APPKIT, "Force fullGC.");
TAG_LOGD(AAFwkTag::APPKIT, "Force fullGC");
if (mainHandler_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "mainHandler is nullptr");
return;
@ -2601,7 +2589,7 @@ void MainThread::ForceFullGC()
auto task = [] {
auto app = applicationForDump_.lock();
if (app == nullptr || app->GetRuntime() == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "runtime is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "runtime is nullptr");
return;
}
app->GetRuntime()->ForceFullGC();
@ -2612,7 +2600,7 @@ void MainThread::ForceFullGC()
void MainThread::Start()
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
TAG_LOGI(AAFwkTag::APPKIT, "App main thread create, pid:%{public}d.", getprocpid());
TAG_LOGI(AAFwkTag::APPKIT, "App main thread create, pid:%{public}d", getprocpid());
std::shared_ptr<EventRunner> runner = EventRunner::GetMainEventRunner();
if (runner == nullptr) {
@ -2647,7 +2635,6 @@ void MainThread::StartChild(const std::map<std::string, int32_t> &fds)
{
TAG_LOGI(AAFwkTag::APPKIT, "MainThread StartChild, fds size:%{public}zu", fds.size());
ChildMainThread::Start(fds);
TAG_LOGD(AAFwkTag::APPKIT, "MainThread::ChildMainThread end.");
}
void MainThread::PreloadExtensionPlugin()
@ -2707,7 +2694,7 @@ void MainThread::LoadAbilityLibrary(const std::vector<std::string> &libraryPaths
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
#ifdef ABILITY_LIBRARY_LOADER
TAG_LOGD(AAFwkTag::APPKIT, "start.");
TAG_LOGD(AAFwkTag::APPKIT, "start");
#ifdef SUPPORT_SCREEN
LoadAceAbilityLibrary();
#endif
@ -2725,7 +2712,7 @@ void MainThread::LoadAbilityLibrary(const std::vector<std::string> &libraryPaths
}
if (fileEntries_.empty()) {
TAG_LOGW(AAFwkTag::APPKIT, "No ability library");
TAG_LOGD(AAFwkTag::APPKIT, "No ability library");
return;
}
@ -2979,18 +2966,18 @@ int32_t MainThread::ScheduleNotifyLoadRepairPatch(const std::string &bundleName,
std::vector<std::pair<std::string, std::string>> hqfFilePair;
if (appThread->GetHqfFileAndHapPath(bundleName, hqfFilePair)) {
for (auto it = hqfFilePair.begin(); it != hqfFilePair.end(); it++) {
TAG_LOGI(AAFwkTag::APPKIT, "hqfFile: %{private}s, hapPath: %{private}s.",
TAG_LOGI(AAFwkTag::APPKIT, "hqfFile: %{private}s, hapPath: %{private}s",
it->first.c_str(), it->second.c_str());
ret = appThread->application_->NotifyLoadRepairPatch(it->first, it->second);
}
} else {
TAG_LOGD(AAFwkTag::APPKIT, "ScheduleNotifyLoadRepairPatch, There's no hqfFile need to load.");
TAG_LOGD(AAFwkTag::APPKIT, "ScheduleNotifyLoadRepairPatch, There's no hqfFile need to load");
}
callback->OnLoadPatchDone(ret ? NO_ERROR : ERR_INVALID_OPERATION, recordId);
};
if (mainHandler_ == nullptr || !mainHandler_->PostTask(task, "MainThread:NotifyLoadRepairPatch")) {
TAG_LOGE(AAFwkTag::APPKIT, "ScheduleNotifyLoadRepairPatch, Post task failed.");
TAG_LOGE(AAFwkTag::APPKIT, "ScheduleNotifyLoadRepairPatch, Post task failed");
return ERR_INVALID_VALUE;
}
@ -3005,14 +2992,14 @@ int32_t MainThread::ScheduleNotifyHotReloadPage(const sptr<IQuickFixCallback> &c
auto task = [weak, callback, recordId]() {
auto appThread = weak.promote();
if (appThread == nullptr || appThread->application_ == nullptr || callback == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "parameter is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "parameter is nullptr");
return;
}
auto ret = appThread->application_->NotifyHotReloadPage();
callback->OnReloadPageDone(ret ? NO_ERROR : ERR_INVALID_OPERATION, recordId);
};
if (mainHandler_ == nullptr || !mainHandler_->PostTask(task, "MainThread:NotifyHotReloadPage")) {
TAG_LOGE(AAFwkTag::APPKIT, "Post task failed.");
TAG_LOGE(AAFwkTag::APPKIT, "Post task failed");
return ERR_INVALID_VALUE;
}
@ -3025,7 +3012,7 @@ bool MainThread::GetHqfFileAndHapPath(const std::string &bundleName,
TAG_LOGD(AAFwkTag::APPKIT, "called");
auto bundleMgrHelper = DelayedSingleton<BundleMgrHelper>::GetInstance();
if (bundleMgrHelper == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "The bundleMgrHelper is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "The bundleMgrHelper is nullptr");
return false;
}
@ -3038,7 +3025,7 @@ bool MainThread::GetHqfFileAndHapPath(const std::string &bundleName,
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) +
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY) +
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_METADATA)), bundleInfo) != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "Get bundle info of %{public}s failed.", bundleName.c_str());
TAG_LOGE(AAFwkTag::APPKIT, "Get bundle info of %{public}s failed", bundleName.c_str());
return false;
}
@ -3048,7 +3035,7 @@ bool MainThread::GetHqfFileAndHapPath(const std::string &bundleName,
std::string resolvedHapPath(AbilityBase::GetLoadPath(hapInfo.hapPath));
std::string resolvedHqfFile(AbilityBase::GetLoadPath(hapInfo.hqfInfo.hqfFilePath));
TAG_LOGD(AAFwkTag::APPKIT, "bundleName: %{public}s, moduleName: %{public}s, processName: %{private}s, "
"hqf file: %{private}s, hap path: %{private}s.", bundleName.c_str(), hapInfo.moduleName.c_str(),
"hqf file: %{private}s, hap path: %{private}s", bundleName.c_str(), hapInfo.moduleName.c_str(),
hapInfo.process.c_str(), resolvedHqfFile.c_str(), resolvedHapPath.c_str());
fileMap.push_back(std::pair<std::string, std::string>(resolvedHqfFile, resolvedHapPath));
}
@ -3066,7 +3053,7 @@ int32_t MainThread::ScheduleNotifyUnLoadRepairPatch(const std::string &bundleNam
auto task = [weak, bundleName, callback, recordId]() {
auto appThread = weak.promote();
if (appThread == nullptr || appThread->application_ == nullptr || callback == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, " parameter is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, " parameter is nullptr");
return;
}
@ -3074,17 +3061,17 @@ int32_t MainThread::ScheduleNotifyUnLoadRepairPatch(const std::string &bundleNam
std::vector<std::pair<std::string, std::string>> hqfFilePair;
if (appThread->GetHqfFileAndHapPath(bundleName, hqfFilePair)) {
for (auto it = hqfFilePair.begin(); it != hqfFilePair.end(); it++) {
TAG_LOGI(AAFwkTag::APPKIT, "hqfFile: %{private}s.", it->first.c_str());
TAG_LOGI(AAFwkTag::APPKIT, "hqfFile: %{private}s", it->first.c_str());
ret = appThread->application_->NotifyUnLoadRepairPatch(it->first);
}
} else {
TAG_LOGD(AAFwkTag::APPKIT, "ScheduleNotifyUnLoadRepairPatch, There's no hqfFile need to unload.");
TAG_LOGD(AAFwkTag::APPKIT, "ScheduleNotifyUnLoadRepairPatch, There's no hqfFile need to unload");
}
callback->OnUnloadPatchDone(ret ? NO_ERROR : ERR_INVALID_OPERATION, recordId);
};
if (mainHandler_ == nullptr || !mainHandler_->PostTask(task, "MainThread:NotifyUnLoadRepairPatch")) {
TAG_LOGE(AAFwkTag::APPKIT, "ScheduleNotifyUnLoadRepairPatch, Post task failed.");
TAG_LOGE(AAFwkTag::APPKIT, "ScheduleNotifyUnLoadRepairPatch, Post task failed");
return ERR_INVALID_VALUE;
}
@ -3106,7 +3093,7 @@ int32_t MainThread::ScheduleNotifyAppFault(const FaultData &faultData)
auto task = [weak, faultData] {
auto appThread = weak.promote();
if (appThread == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "appThread is nullptr, NotifyAppFault failed.");
TAG_LOGE(AAFwkTag::APPKIT, "appThread is nullptr, NotifyAppFault failed");
return;
}
appThread->NotifyAppFault(faultData);
@ -3170,26 +3157,26 @@ int MainThread::GetOverlayModuleInfos(const std::string &bundleName, const std::
{
auto bundleMgrHelper = DelayedSingleton<BundleMgrHelper>::GetInstance();
if (bundleMgrHelper == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "The bundleMgrHelper is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "The bundleMgrHelper is nullptr");
return ERR_INVALID_VALUE;
}
auto overlayMgrProxy = bundleMgrHelper->GetOverlayManagerProxy();
if (overlayMgrProxy == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "The overlayMgrProxy is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "The overlayMgrProxy is nullptr");
return ERR_INVALID_VALUE;
}
auto ret = overlayMgrProxy->GetTargetOverlayModuleInfo(moduleName, overlayModuleInfos);
if (ret != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "failed.");
TAG_LOGE(AAFwkTag::APPKIT, "failed");
return ret;
}
std::sort(overlayModuleInfos.begin(), overlayModuleInfos.end(),
[](const OverlayModuleInfo& lhs, const OverlayModuleInfo& rhs) -> bool {
return lhs.priority > rhs.priority;
});
TAG_LOGD(AAFwkTag::APPKIT, "the size of overlay is: %{public}zu.", overlayModuleInfos.size());
TAG_LOGD(AAFwkTag::APPKIT, "the size of overlay is: %{public}zu", overlayModuleInfos.size());
return ERR_OK;
}
@ -3204,7 +3191,7 @@ std::vector<std::string> MainThread::GetAddOverlayPaths(const std::vector<Overla
if ((iter != overlayModuleInfos_.end()) && (it.state == AppExecFwk::OverlayState::OVERLAY_ENABLE)) {
iter->state = it.state;
ChangeToLocalPath(iter->bundleName, iter->hapPath, iter->hapPath);
TAG_LOGD(AAFwkTag::APPKIT, "add path:%{public}s.", iter->hapPath.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "add path:%{public}s", iter->hapPath.c_str());
addPaths.emplace_back(iter->hapPath);
}
}
@ -3222,7 +3209,7 @@ std::vector<std::string> MainThread::GetRemoveOverlayPaths(const std::vector<Ove
if ((iter != overlayModuleInfos_.end()) && (it.state != AppExecFwk::OverlayState::OVERLAY_ENABLE)) {
iter->state = it.state;
ChangeToLocalPath(iter->bundleName, iter->hapPath, iter->hapPath);
TAG_LOGD(AAFwkTag::APPKIT, "remove path:%{public}s.", iter->hapPath.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "remove path:%{public}s", iter->hapPath.c_str());
removePaths.emplace_back(iter->hapPath);
}
}
@ -3232,7 +3219,7 @@ std::vector<std::string> MainThread::GetRemoveOverlayPaths(const std::vector<Ove
int32_t MainThread::ScheduleChangeAppGcState(int32_t state)
{
TAG_LOGD(AAFwkTag::APPKIT, "called, state is %{public}d.", state);
TAG_LOGD(AAFwkTag::APPKIT, "called, state is %{public}d", state);
if (mainHandler_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "mainHandler is nullptr");
return ERR_INVALID_VALUE;
@ -3260,12 +3247,12 @@ int32_t MainThread::ChangeAppGcState(int32_t state)
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
if (application_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "application_ is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "application_ is nullptr");
return ERR_INVALID_VALUE;
}
auto &runtime = application_->GetRuntime();
if (runtime == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "runtime is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "runtime is nullptr");
return ERR_INVALID_VALUE;
}
if (runtime->GetLanguage() == AbilityRuntime::Runtime::Language::CJ) {
@ -3301,7 +3288,7 @@ void MainThread::AssertFaultPauseMainThreadDetection()
TAG_LOGD(AAFwkTag::APPKIT, "called");
SetAppDebug(AbilityRuntime::AppFreezeState::AppFreezeFlag::ASSERT_DEBUG_MODE, true);
if (appMgr_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "appMgr is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "appMgr is nullptr");
return;
}
appMgr_->SetAppAssertionPauseState(true);
@ -3312,7 +3299,7 @@ void MainThread::AssertFaultResumeMainThreadDetection()
TAG_LOGD(AAFwkTag::APPKIT, "called");
SetAppDebug(AbilityRuntime::AppFreezeState::AppFreezeFlag::ASSERT_DEBUG_MODE, false);
if (appMgr_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "appMgr is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "appMgr is nullptr");
return;
}
appMgr_->SetAppAssertionPauseState(false);
@ -3321,20 +3308,20 @@ void MainThread::AssertFaultResumeMainThreadDetection()
void MainThread::HandleInitAssertFaultTask(bool isDebugModule, bool isDebugApp)
{
if (!system::GetBoolParameter(PRODUCT_ASSERT_FAULT_DIALOG_ENABLED, false)) {
TAG_LOGE(AAFwkTag::APPKIT, "Unsupport assert fault dialog.");
TAG_LOGD(AAFwkTag::APPKIT, "Unsupport assert fault dialog");
return;
}
if (!system::GetBoolParameter(DEVELOPER_MODE_STATE, false)) {
TAG_LOGE(AAFwkTag::APPKIT, "Developer Mode is false.");
TAG_LOGE(AAFwkTag::APPKIT, "Developer Mode is false");
return;
}
if (!isDebugApp) {
TAG_LOGE(AAFwkTag::APPKIT, "Non-debug version application.");
TAG_LOGE(AAFwkTag::APPKIT, "Non-debug version application");
return;
}
auto assertThread = DelayedSingleton<AbilityRuntime::AssertFaultTaskThread>::GetInstance();
if (assertThread == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Get assert thread instance is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "Get assert thread instance is nullptr");
return;
}
assertThread->InitAssertFaultTask(this, isDebugModule);
@ -3346,17 +3333,17 @@ void MainThread::SetAppDebug(uint32_t modeFlag, bool isDebug)
TAG_LOGD(AAFwkTag::APPKIT, "called");
auto state = DelayedSingleton<AbilityRuntime::AppFreezeState>::GetInstance();
if (state == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Get app freeze state instance is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "Get app freeze state instance is nullptr");
return;
}
if (!isDebug) {
TAG_LOGD(AAFwkTag::APPKIT, "Call Cancel modeFlag is %{public}u.", modeFlag);
TAG_LOGD(AAFwkTag::APPKIT, "Call Cancel modeFlag is %{public}u", modeFlag);
state->CancelAppFreezeState(modeFlag);
return;
}
TAG_LOGD(AAFwkTag::APPKIT, "Call Set modeFlag is %{public}u.", modeFlag);
TAG_LOGD(AAFwkTag::APPKIT, "Call Set modeFlag is %{public}u", modeFlag);
state->SetAppFreezeState(modeFlag);
}
@ -3364,7 +3351,7 @@ void MainThread::HandleCancelAssertFaultTask()
{
auto assertThread = assertThread_.lock();
if (assertThread == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Get assert thread instance is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "Get assert thread instance is nullptr");
return;
}
assertThread->Stop();
@ -3379,21 +3366,21 @@ int32_t MainThread::ScheduleDumpIpcStart(std::string& result)
int32_t MainThread::ScheduleDumpIpcStop(std::string& result)
{
TAG_LOGD(AAFwkTag::APPKIT, "MainThread::ScheduleDumpIpcStop::pid:%{public}d", getprocpid());
TAG_LOGD(AAFwkTag::APPKIT, "pid:%{public}d", getprocpid());
DumpIpcHelper::DumpIpcStop(result);
return ERR_OK;
}
int32_t MainThread::ScheduleDumpIpcStat(std::string& result)
{
TAG_LOGD(AAFwkTag::APPKIT, "MainThread::ScheduleDumpIpcStat::pid:%{public}d", getprocpid());
TAG_LOGD(AAFwkTag::APPKIT, "pid:%{public}d", getprocpid());
DumpIpcHelper::DumpIpcStat(result);
return ERR_OK;
}
int32_t MainThread::ScheduleDumpFfrt(std::string& result)
{
TAG_LOGD(AAFwkTag::APPKIT, "MainThread::ScheduleDumpFfrt::pid:%{public}d", getprocpid());
TAG_LOGD(AAFwkTag::APPKIT, "pid:%{public}d", getprocpid());
return DumpFfrtHelper::DumpFfrt(result);
}
@ -3468,7 +3455,7 @@ void MainThread::ParseAppConfigurationParams(const std::string configuration, Co
void MainThread::HandleCacheProcess()
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::APPKIT, "start.");
TAG_LOGD(AAFwkTag::APPKIT, "start");
// force gc
if (application_ != nullptr) {

View File

@ -113,11 +113,10 @@ void OHOSApplication::OnBackground()
}
if (runtime_ == nullptr) {
TAG_LOGD(AAFwkTag::APPKIT, "NotifyApplicationState, runtime_ is nullptr");
TAG_LOGD(AAFwkTag::APPKIT, "runtime_ is nullptr");
return;
}
runtime_->NotifyApplicationState(true);
TAG_LOGD(AAFwkTag::APPKIT, "NotifyApplicationState::OnBackground end");
}
void OHOSApplication::DumpApplication()
@ -155,7 +154,6 @@ void OHOSApplication::DumpApplication()
}
// create and initialize applicationInfo
TAG_LOGD(AAFwkTag::APPKIT, "==============applicationInfo==============");
std::shared_ptr<ApplicationInfo> applicationInfoPtr = GetApplicationInfo();
if (applicationInfoPtr != nullptr) {
TAG_LOGD(AAFwkTag::APPKIT, "applicationInfo: name: %{public}s", applicationInfoPtr->name.c_str());
@ -174,11 +172,10 @@ void OHOSApplication::SetRuntime(std::unique_ptr<AbilityRuntime::Runtime>&& runt
{
TAG_LOGD(AAFwkTag::APPKIT, "begin");
if (runtime == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "OHOSApplication::SetRuntime failed, runtime is empty");
TAG_LOGE(AAFwkTag::APPKIT, "runtime is empty");
return;
}
runtime_ = std::move(runtime);
TAG_LOGD(AAFwkTag::APPKIT, "end");
}
/**
@ -191,7 +188,7 @@ void OHOSApplication::SetApplicationContext(
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
if (abilityRuntimeContext == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "OHOSApplication::SetApplicationContext failed, context is empty");
TAG_LOGE(AAFwkTag::APPKIT, "context is empty");
return;
}
abilityRuntimeContext_ = abilityRuntimeContext;
@ -225,7 +222,7 @@ void OHOSApplication::SetAbilityRecordMgr(const std::shared_ptr<AbilityRecordMgr
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
if (abilityRecordMgr == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "ContextDeal::SetAbilityRecordMgr failed, abilityRecordMgr is nullptr");
TAG_LOGE(AAFwkTag::APPKIT, "abilityRecordMgr is nullptr");
return;
}
abilityRecordMgr_ = abilityRecordMgr;
@ -438,7 +435,6 @@ void OHOSApplication::UnregisterElementsCallbacks(const std::shared_ptr<Elements
void OHOSApplication::OnConfigurationUpdated(Configuration config)
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::APPKIT, "called");
if (!abilityRecordMgr_ || !configuration_) {
TAG_LOGD(AAFwkTag::APPKIT, "abilityRecordMgr_ or configuration_ is null");
return;
@ -569,7 +565,6 @@ void OHOSApplication::OnFontUpdated(Configuration config)
{
#ifdef SUPPORT_GRAPHICS
// Notify Window
TAG_LOGD(AAFwkTag::APPKIT, "Update configuration for all window.");
auto diffConfiguration = std::make_shared<AppExecFwk::Configuration>(config);
Rosen::Window::UpdateConfigurationForAll(diffConfiguration);
#endif
@ -622,18 +617,14 @@ void OHOSApplication::OnMemoryLevel(int level)
*
*/
void OHOSApplication::OnStart()
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
}
{}
/**
*
* @brief Will be called the application ends
*/
void OHOSApplication::OnTerminate()
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
}
{}
/**
*
@ -650,16 +641,15 @@ void OHOSApplication::OnAbilitySaveState(const PacMap &outState)
void OHOSApplication::SetAppEnv(const std::vector<AppEnvironment>& appEnvironments)
{
if (!appEnvironments.size()) {
TAG_LOGI(AAFwkTag::APPKIT, "appEnvironments empty.");
return;
}
for (const auto &appEnvironment : appEnvironments) {
if (setenv(appEnvironment.name.c_str(), appEnvironment.value.c_str(), APP_ENVIRONMENT_OVERWRITE)) {
TAG_LOGE(AAFwkTag::APPKIT, "appEnvironment: %{public}s set failed.", appEnvironment.name.c_str());
TAG_LOGE(AAFwkTag::APPKIT, "appEnvironment: %{public}s set failed", appEnvironment.name.c_str());
return;
}
TAG_LOGI(AAFwkTag::APPKIT, "appEnvironment set successfully: %{public}s = %{public}s.",
TAG_LOGI(AAFwkTag::APPKIT, "appEnvironment set successfully: %{public}s = %{public}s",
appEnvironment.name.c_str(), appEnvironment.value.c_str());
}
return;
@ -777,7 +767,7 @@ void OHOSApplication::UpdateApplicationInfoInstalled(const AppExecFwk::Applicati
TAG_LOGD(AAFwkTag::APPKIT, "called");
if (abilityRuntimeContext_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "abilityRuntimeContext_ is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "abilityRuntimeContext_ is nullptr");
return;
}
@ -788,12 +778,12 @@ bool OHOSApplication::AddAbilityStage(const AppExecFwk::HapModuleInfo &hapModule
{
TAG_LOGD(AAFwkTag::APPKIT, "called");
if (abilityRuntimeContext_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "abilityRuntimeContext_ is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "abilityRuntimeContext_ is nullptr");
return false;
}
if (runtime_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "runtime_ is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "runtime_ is nullptr");
return false;
}
@ -854,7 +844,7 @@ void OHOSApplication::CleanAbilityStage(const sptr<IRemoteObject> &token,
void OHOSApplication::DoCleanWorkAfterStageCleaned(const AbilityInfo &abilityInfo)
{
TAG_LOGD(AAFwkTag::APPKIT, "language: %{public}s.", abilityInfo.srcLanguage.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "language: %{public}s", abilityInfo.srcLanguage.c_str());
if (runtime_) {
runtime_->DoCleanWorkAfterStageCleaned();
}
@ -892,9 +882,9 @@ void OHOSApplication::ScheduleAcceptWant(const AAFwk::Want &want, const std::str
void OHOSApplication::ScheduleNewProcessRequest(const AAFwk::Want &want, const std::string &moduleName,
std::string &flag)
{
TAG_LOGD(AAFwkTag::APPKIT, "call.");
TAG_LOGD(AAFwkTag::APPKIT, "call");
if (abilityStages_.empty()) {
TAG_LOGE(AAFwkTag::APPKIT, "abilityStages_ is empty.");
TAG_LOGE(AAFwkTag::APPKIT, "abilityStages_ is empty");
return;
}
auto iter = abilityStages_.find(moduleName);
@ -921,7 +911,7 @@ void OHOSApplication::SetExtensionTypeMap(std::map<int32_t, std::string> map)
bool OHOSApplication::NotifyLoadRepairPatch(const std::string &hqfFile, const std::string &hapPath)
{
if (runtime_ == nullptr) {
TAG_LOGD(AAFwkTag::APPKIT, "runtime is nullptr.");
TAG_LOGD(AAFwkTag::APPKIT, "runtime is nullptr");
return true;
}
@ -931,7 +921,7 @@ bool OHOSApplication::NotifyLoadRepairPatch(const std::string &hqfFile, const st
bool OHOSApplication::NotifyHotReloadPage()
{
if (runtime_ == nullptr) {
TAG_LOGD(AAFwkTag::APPKIT, "runtime is nullptr.");
TAG_LOGD(AAFwkTag::APPKIT, "runtime is nullptr");
return true;
}
@ -941,7 +931,7 @@ bool OHOSApplication::NotifyHotReloadPage()
bool OHOSApplication::NotifyUnLoadRepairPatch(const std::string &hqfFile)
{
if (runtime_ == nullptr) {
TAG_LOGD(AAFwkTag::APPKIT, "runtime is nullptr.");
TAG_LOGD(AAFwkTag::APPKIT, "runtime is nullptr");
return true;
}
@ -955,7 +945,7 @@ void OHOSApplication::CleanAppTempData(bool isLastProcess)
return;
}
if (abilityRuntimeContext_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Context is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "Context is nullptr");
return;
}
@ -969,7 +959,7 @@ void OHOSApplication::CleanAppTempData(bool isLastProcess)
void OHOSApplication::CleanUselessTempData()
{
if (abilityRuntimeContext_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Context is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "Context is nullptr");
return;
}
@ -984,7 +974,7 @@ void OHOSApplication::UpdateAppContextResMgr(const Configuration &config)
{
auto context = GetAppContext();
if (context == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "Application context is nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "Application context is nullptr");
return;
}
@ -1010,7 +1000,7 @@ void OHOSApplication::CleanEmptyAbilityStage()
}
}
if (containsNonEmpty) {
TAG_LOGI(AAFwkTag::APPKIT, "Application contains none empty abilityStage.");
TAG_LOGI(AAFwkTag::APPKIT, "Application contains none empty abilityStage");
}
}
} // namespace AppExecFwk

View File

@ -28,7 +28,7 @@ OverlayEventSubscriber::OverlayEventSubscriber(const EventFwk::CommonEventSubscr
void OverlayEventSubscriber::OnReceiveEvent(const EventFwk::CommonEventData &data)
{
TAG_LOGD(AAFwkTag::APPKIT, "OnReceiveEvent begin.");
TAG_LOGD(AAFwkTag::APPKIT, "OnReceiveEvent begin");
if (callback_ != nullptr) {
callback_(data);
}

View File

@ -43,7 +43,7 @@ sptr<IRemoteObject> SysMrgClient::GetSystemAbility(const int32_t systemAbilityId
if (abilityManager_ == nullptr) {
abilityManager_ = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (abilityManager_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "fail to GetSystemAbility abilityManager_ == nullptr.");
TAG_LOGE(AAFwkTag::APPKIT, "abilityManager_ == nullptr.");
return nullptr;
}
}