onBackPressed默认返回true

Signed-off-by: zhangyuhang72 <zhangyuhang72@huawei.com>
Change-Id: I99a324cef0b0965bb7bf01fd1f94f17c52bc7265
This commit is contained in:
zhangyuhang72 2024-03-27 10:00:44 +08:00
parent 1531018e6c
commit 9c97443b44
4 changed files with 6 additions and 6 deletions

View File

@ -26,7 +26,7 @@ class Ability {
onForeground(want) { }
onBackground() { }
onBackPressed() {
return false;
return true;
}
onPrepareToTerminate() {
return false;

View File

@ -1547,7 +1547,7 @@ void Ability::OnBackground()
bool Ability::OnBackPress()
{
TAG_LOGD(AAFwkTag::ABILITY, "call");
return false;
return true;
}
bool Ability::OnPrepareTerminate()

View File

@ -548,10 +548,10 @@ bool JsAbility::OnBackPress()
HandleScope handleScope(jsRuntime_);
auto env = jsRuntime_.GetNapiEnv();
napi_value jsValue = CallObjectMethod("onBackPressed", nullptr, 0, true);
bool ret = false;
bool ret = true;
if (!ConvertFromJsValue(env, jsValue, ret)) {
TAG_LOGW(AAFwkTag::ABILITY, "Get js value failed");
return false;
return true;
}
TAG_LOGD(AAFwkTag::ABILITY, "end, ret = %{public}d", ret);
return ret;

View File

@ -620,10 +620,10 @@ bool JsUIAbility::OnBackPress()
HandleScope handleScope(jsRuntime_);
auto env = jsRuntime_.GetNapiEnv();
napi_value jsValue = CallObjectMethod("onBackPressed", nullptr, 0, true);
bool ret = false;
bool ret = true;
if (!ConvertFromJsValue(env, jsValue, ret)) {
TAG_LOGE(AAFwkTag::UIABILITY, "Get js value failed.");
return false;
return true;
}
TAG_LOGD(AAFwkTag::UIABILITY, "End ret is %{public}d.", ret);
return ret;