add saveSnapshotSync interface

Signed-off-by: 胡晗 <huhan17@huawei.com>
This commit is contained in:
胡晗 2024-11-21 14:44:46 +08:00
parent 42f9a06d3f
commit e515e87f03
2 changed files with 22 additions and 0 deletions

View File

@ -372,6 +372,8 @@ void JsSceneSession::BindNativeMethod(napi_env env, napi_value objValue, const c
JsSceneSession::SetFrameGravity);
BindNativeFunction(env, objValue, "setUseStartingWindowAboveLocked", moduleName,
JsSceneSession::SetUseStartingWindowAboveLocked);
BindNativeFunction(env, objValue, "saveSnapshotSync", moduleName,
JsSceneSession::SaveSnapshotSync);
}
void JsSceneSession::BindNativeMethodForKeyboard(napi_env env, napi_value objValue, const char* moduleName)
@ -2149,6 +2151,13 @@ napi_value JsSceneSession::SetUseStartingWindowAboveLocked(napi_env env, napi_ca
return (me != nullptr) ? me->OnSetUseStartingWindowAboveLocked(env, info) : nullptr;
}
napi_value JsSceneSession::SaveSnapshotSync(napi_env env, napi_callback_info info)
{
TLOGD(WmsLogTag::WMS_LAYOUT, "[NAPI]");
JsSceneSession* me = CheckParamsAndGetThis<JsSceneSession>(env, info);
return (me != nullptr) ? me->OnSaveSnapshotSync(env, info) : nullptr;
}
bool JsSceneSession::IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject)
{
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsSceneSession::IsCallbackRegistered[%s]", type.c_str());
@ -5301,4 +5310,15 @@ napi_value JsSceneSession::OnSetUseStartingWindowAboveLocked(napi_env env, napi_
session->SetUseStartingWindowAboveLocked(useStartingWindowAboveLocked);
return NapiGetUndefined(env);
}
napi_value JsSceneSession::OnSaveSnapshotSync(napi_env env, napi_callback_info info)
{
auto session = weakSession_.promote();
if (session == nullptr) {
TLOGE(WmsLogTag::DEFAULT, "[NAPI]session is nullptr, id:%{public}d", persistentId_);
return NapiGetUndefined(env);
}
session->SaveSnapshot(false);
return NapiGetUndefined(env);
}
} // namespace OHOS::Rosen

View File

@ -157,6 +157,7 @@ private:
static napi_value SetIsActivatedAfterScreenLocked(napi_env env, napi_callback_info info);
static napi_value SetFrameGravity(napi_env env, napi_callback_info info);
static napi_value SetUseStartingWindowAboveLocked(napi_env env, napi_callback_info info);
static napi_value SaveSnapshotSync(napi_env env, napi_callback_info info);
napi_value OnRegisterCallback(napi_env env, napi_callback_info info);
napi_value OnUpdateNativeVisibility(napi_env env, napi_callback_info info);
@ -217,6 +218,7 @@ private:
napi_value OnSetIsActivatedAfterScreenLocked(napi_env env, napi_callback_info info);
napi_value OnSetFrameGravity(napi_env env, napi_callback_info info);
napi_value OnSetUseStartingWindowAboveLocked(napi_env env, napi_callback_info info);
napi_value OnSaveSnapshotSync(napi_env env, napi_callback_info info);
bool IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject);
void ProcessChangeSessionVisibilityWithStatusBarRegister();