mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-23 07:10:19 +00:00
!7262 getuiextensionwindow需求开发
Merge pull request !7262 from wangkailong/uiextension
This commit is contained in:
commit
67502561cd
@ -929,6 +929,8 @@ config("ui_extension_public_config") {
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native/ability_runtime",
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native/insight_intent_executor",
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native/ui_extension_ability",
|
||||
"${windowmanager_path}/interfaces/kits/napi/extension_window",
|
||||
"${windowmanager_path}/wm/include",
|
||||
]
|
||||
}
|
||||
|
||||
@ -969,6 +971,7 @@ ohos_shared_library("ui_extension") {
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
"window_manager:extensionwindow_napi",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "hitrace_meter.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "js_error_utils.h"
|
||||
#include "js_extension_window.h"
|
||||
#include "js_runtime_utils.h"
|
||||
#include "js_ui_extension_context.h"
|
||||
#include "string_wrapper.h"
|
||||
@ -132,6 +133,11 @@ napi_value JsUIExtensionContentSession::StartAbilityAsCaller(napi_env env, napi_
|
||||
GET_NAPI_INFO_AND_CALL(env, info, JsUIExtensionContentSession, OnStartAbilityAsCaller);
|
||||
}
|
||||
|
||||
napi_value JsUIExtensionContentSession::GetUIExtensionHostWindowProxy(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_NAPI_INFO_AND_CALL(env, info, JsUIExtensionContentSession, OnGetUIExtensionHostWindowProxy);
|
||||
}
|
||||
|
||||
napi_value JsUIExtensionContentSession::StartAbilityForResult(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_NAPI_INFO_AND_CALL(env, info, JsUIExtensionContentSession, OnStartAbilityForResult);
|
||||
@ -231,6 +237,20 @@ napi_value JsUIExtensionContentSession::OnStartAbility(napi_env env, NapiCallbac
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value JsUIExtensionContentSession::OnGetUIExtensionHostWindowProxy(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
HILOG_DEBUG("OnGetUIExtensionHostWindowProxy is called");
|
||||
CHECK_IS_SYSTEM_APP;
|
||||
napi_value jsExtensionWindow = Rosen::JsExtensionWindow::CreateJsExtensionWindow(env, uiWindow_);
|
||||
if (jsExtensionWindow == nullptr) {
|
||||
HILOG_ERROR("Failed to create jsExtensionWindow object.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
auto value = JsRuntime::LoadSystemModuleByEngine(env, "application.extensionWindow", &jsExtensionWindow, 1);
|
||||
return value->GetNapiValue();
|
||||
}
|
||||
|
||||
napi_value JsUIExtensionContentSession::OnStartAbilityAsCaller(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
@ -793,6 +813,7 @@ napi_value JsUIExtensionContentSession::CreateJsUIExtensionContentSession(napi_e
|
||||
BindNativeFunction(env, object, "startAbilityForResult", moduleName, StartAbilityForResult);
|
||||
BindNativeFunction(env, object, "startAbilityByType", moduleName, StartAbilityByType);
|
||||
BindNativeFunction(env, object, "startAbilityAsCaller", moduleName, StartAbilityAsCaller);
|
||||
BindNativeFunction(env, object, "getUIExtensionHostWindowProxy", moduleName, GetUIExtensionHostWindowProxy);
|
||||
return object;
|
||||
}
|
||||
|
||||
@ -824,6 +845,7 @@ napi_value JsUIExtensionContentSession::CreateJsUIExtensionContentSession(napi_e
|
||||
BindNativeFunction(env, object, "startAbilityForResult", moduleName, StartAbilityForResult);
|
||||
BindNativeFunction(env, object, "startAbilityByType", moduleName, StartAbilityByType);
|
||||
BindNativeFunction(env, object, "startAbilityAsCaller", moduleName, StartAbilityAsCaller);
|
||||
BindNativeFunction(env, object, "getUIExtensionHostWindowProxy", moduleName, GetUIExtensionHostWindowProxy);
|
||||
return object;
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,7 @@ public:
|
||||
|
||||
static napi_value StartAbility(napi_env env, napi_callback_info info);
|
||||
static napi_value StartAbilityAsCaller(napi_env env, napi_callback_info info);
|
||||
static napi_value GetUIExtensionHostWindowProxy(napi_env env, napi_callback_info info);
|
||||
static napi_value StartAbilityForResult(napi_env env, napi_callback_info info);
|
||||
static napi_value TerminateSelf(napi_env env, napi_callback_info info);
|
||||
static napi_value TerminateSelfWithResult(napi_env env, napi_callback_info info);
|
||||
@ -74,6 +75,7 @@ public:
|
||||
protected:
|
||||
napi_value OnStartAbility(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnStartAbilityAsCaller(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnGetUIExtensionHostWindowProxy(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnStartAbilityForResult(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnTerminateSelf(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnTerminateSelfWithResult(napi_env env, NapiCallbackInfo& info);
|
||||
@ -95,7 +97,7 @@ protected:
|
||||
napi_env env, NapiCallbackInfo& info, std::shared_ptr<int> &innerErrorCode);
|
||||
void StartAbilityForResultRuntimeTask(napi_env env, AAFwk::Want &want,
|
||||
std::shared_ptr<NapiAsyncTask> asyncTask, size_t& unwrapArgc, AAFwk::StartOptions startOptions);
|
||||
|
||||
|
||||
private:
|
||||
sptr<AAFwk::SessionInfo> sessionInfo_;
|
||||
sptr<Rosen::Window> uiWindow_;
|
||||
|
Loading…
Reference in New Issue
Block a user