mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-23 15:20:34 +00:00
cherry pick 4d6f6e7
from https://gitee.com/zexin_c/ability_ability_runtime/pulls/11187
revert: changlian context Signed-off-by: chenzexin <chenzexin14@huawei.com>
This commit is contained in:
parent
ea1140e441
commit
8ad12346b7
@ -66,28 +66,14 @@ napi_value AttachUIExtensionContext(napi_env env, void *value, void *extValue)
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "invalid context");
|
||||
return nullptr;
|
||||
}
|
||||
auto screenModePtr = reinterpret_cast<std::weak_ptr<int32_t> *>(extValue)->lock();
|
||||
if (screenModePtr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "Invalid screenModePtr");
|
||||
napi_value object = JsUIExtensionContext::CreateJsUIExtensionContext(env, ptr);
|
||||
auto contextRef = JsRuntime::LoadSystemModuleByEngine(env, "application.UIExtensionContext",
|
||||
&object, 1);
|
||||
if (contextRef == nullptr) {
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "Failed to load module");
|
||||
return nullptr;
|
||||
}
|
||||
napi_value contextObj = nullptr;
|
||||
if (*screenModePtr == AAFwk::IDLE_SCREEN_MODE) {
|
||||
auto uiExtObject = JsUIExtensionContext::CreateJsUIExtensionContext(env, ptr);
|
||||
CHECK_POINTER_AND_RETURN(uiExtObject, nullptr);
|
||||
auto contextRef = JsRuntime::LoadSystemModuleByEngine(env, "application.UIExtensionContext",
|
||||
&uiExtObject, 1);
|
||||
CHECK_POINTER_AND_RETURN(contextRef, nullptr);
|
||||
contextObj = contextRef->GetNapiValue();
|
||||
} else {
|
||||
auto emUIObject = JsEmbeddableUIAbilityContext::CreateJsEmbeddableUIAbilityContext(env,
|
||||
nullptr, ptr, *screenModePtr);
|
||||
CHECK_POINTER_AND_RETURN(emUIObject, nullptr);
|
||||
auto contextRef = JsRuntime::LoadSystemModuleByEngine(env, "application.EmbeddableUIAbilityContext",
|
||||
&emUIObject, 1);
|
||||
CHECK_POINTER_AND_RETURN(contextRef, nullptr);
|
||||
contextObj = contextRef->GetNapiValue();
|
||||
}
|
||||
auto contextObj = contextRef->GetNapiValue();
|
||||
if (contextObj == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "load context error");
|
||||
return nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user