mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-30 10:31:17 +00:00
应用启动瞬间,若应用在锁屏之前启动,则不拦截应用
Signed-off-by: liusensen <liusen43@huawei.com>
This commit is contained in:
parent
7388f37670
commit
6b6fff0610
@ -361,8 +361,8 @@ void JsSceneSession::BindNativeMethod(napi_env env, napi_value objValue, const c
|
||||
JsSceneSession::SetNeedSyncSessionRect);
|
||||
BindNativeFunction(env, objValue, "setIsPendingToBackgroundState", moduleName,
|
||||
JsSceneSession::SetIsPendingToBackgroundState);
|
||||
BindNativeFunction(env, objValue, "setCanBeActivatedAfterScreenLocked", moduleName,
|
||||
JsSceneSession::SetCanBeActivatedAfterScreenLocked);
|
||||
BindNativeFunction(env, objValue, "setIsActivatedAfterScreenLocked", moduleName,
|
||||
JsSceneSession::SetIsActivatedAfterScreenLocked);
|
||||
}
|
||||
|
||||
void JsSceneSession::BindNativeMethodForKeyboard(napi_env env, napi_value objValue, const char* moduleName)
|
||||
@ -2093,11 +2093,11 @@ napi_value JsSceneSession::SetIsPendingToBackgroundState(napi_env env, napi_call
|
||||
return (me != nullptr) ? me->OnSetIsPendingToBackgroundState(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsSceneSession::SetCanBeActivatedAfterScreenLocked(napi_env env, napi_callback_info info)
|
||||
napi_value JsSceneSession::SetIsActivatedAfterScreenLocked(napi_env env, napi_callback_info info)
|
||||
{
|
||||
TLOGD(WmsLogTag::WMS_SCB, "[NAPI]");
|
||||
JsSceneSession* me = CheckParamsAndGetThis<JsSceneSession>(env, info);
|
||||
return (me != nullptr) ? me->OnSetCanBeActivatedAfterScreenLocked(env, info) : nullptr;
|
||||
return (me != nullptr) ? me->OnSetIsActivatedAfterScreenLocked(env, info) : nullptr;
|
||||
}
|
||||
|
||||
bool JsSceneSession::IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject)
|
||||
@ -5031,7 +5031,7 @@ napi_value JsSceneSession::OnSetIsPendingToBackgroundState(napi_env env, napi_ca
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSession::OnSetCanBeActivatedAfterScreenLocked(napi_env env, napi_callback_info info)
|
||||
napi_value JsSceneSession::OnSetIsActivatedAfterScreenLocked(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = ARGC_FOUR;
|
||||
napi_value argv[ARGC_FOUR] = {nullptr};
|
||||
@ -5041,20 +5041,20 @@ napi_value JsSceneSession::OnSetCanBeActivatedAfterScreenLocked(napi_env env, na
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM), "InputInvalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
bool canBeActivated = false;
|
||||
if (!ConvertFromJsValue(env, argv[0], canBeActivated)) {
|
||||
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]Failed to convert parameter to canBeActivated");
|
||||
bool isActivatedAfterScreenLocked = false;
|
||||
if (!ConvertFromJsValue(env, argv[0], isActivatedAfterScreenLocked)) {
|
||||
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]Failed to convert parameter to isActivatedAfterScreenLocked");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
TLOGD(WmsLogTag::WMS_LIFE, "[NAPI]canBeActivated: %{public}u", canBeActivated);
|
||||
TLOGD(WmsLogTag::WMS_LIFE, "[NAPI]isActivatedAfterScreenLocked: %{public}u", isActivatedAfterScreenLocked);
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]session is null, id: %{public}d", persistentId_);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
session->SetCanBeActivatedAfterScreenLocked(canBeActivated);
|
||||
session->SetIsActivatedAfterScreenLocked(isActivatedAfterScreenLocked);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ private:
|
||||
static napi_value CompatibleFullScreenClose(napi_env env, napi_callback_info info);
|
||||
static napi_value SetWindowEnableDragBySystem(napi_env env, napi_callback_info info);
|
||||
static napi_value SetIsPendingToBackgroundState(napi_env env, napi_callback_info info);
|
||||
static napi_value SetCanBeActivatedAfterScreenLocked(napi_env env, napi_callback_info info);
|
||||
static napi_value SetIsActivatedAfterScreenLocked(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);
|
||||
@ -208,7 +208,7 @@ private:
|
||||
napi_value OnSetNeedSyncSessionRect(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetWindowEnableDragBySystem(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetIsPendingToBackgroundState(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetCanBeActivatedAfterScreenLocked(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetIsActivatedAfterScreenLocked(napi_env env, napi_callback_info info);
|
||||
|
||||
bool IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject);
|
||||
void ProcessChangeSessionVisibilityWithStatusBarRegister();
|
||||
|
@ -483,8 +483,8 @@ public:
|
||||
*/
|
||||
bool GetIsPendingToBackgroundState() const;
|
||||
void SetIsPendingToBackgroundState(bool isPendingToBackgroundState);
|
||||
bool CanBeActivatedAfterScreenLocked() const;
|
||||
void SetCanBeActivatedAfterScreenLocked(bool canBeActivated);
|
||||
bool IsActivatedAfterScreenLocked() const;
|
||||
void SetIsActivatedAfterScreenLocked(bool isActivatedAfterScreenLocked);
|
||||
void SetAttachState(bool isAttach, WindowMode windowMode = WindowMode::WINDOW_MODE_UNDEFINED);
|
||||
bool GetAttachState() const;
|
||||
void RegisterDetachCallback(const sptr<IPatternDetachCallback>& callback);
|
||||
@ -784,7 +784,7 @@ private:
|
||||
*/
|
||||
std::atomic<bool> isAttach_ { false };
|
||||
std::atomic<bool> isPendingToBackgroundState_ { false };
|
||||
bool canBeActivatedAfterScreenLocked_ { true };
|
||||
bool isActivatedAfterScreenLocked_ { true };
|
||||
sptr<IPatternDetachCallback> detachCallback_ = nullptr;
|
||||
|
||||
std::shared_ptr<RSSurfaceNode> leashWinSurfaceNode_;
|
||||
|
@ -209,7 +209,7 @@ WSError SceneSession::Foreground(
|
||||
ScreenId defaultScreenId = ScreenSessionManagerClient::GetInstance().GetDefaultScreenId();
|
||||
auto sessionProperty = GetSessionProperty();
|
||||
if (GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW &&
|
||||
CanBeActivatedAfterScreenLocked() &&
|
||||
IsActivatedAfterScreenLocked() &&
|
||||
GetStateFromManager(ManagerState::MANAGER_STATE_SCREEN_LOCKED) &&
|
||||
(sessionProperty != nullptr && defaultScreenId == sessionProperty->GetDisplayId()) &&
|
||||
!IsShowWhenLocked()) {
|
||||
|
@ -1399,22 +1399,22 @@ void Session::SetIsPendingToBackgroundState(bool isPendingToBackgroundState)
|
||||
return isPendingToBackgroundState_.store(isPendingToBackgroundState);
|
||||
}
|
||||
|
||||
bool Session::CanBeActivatedAfterScreenLocked() const
|
||||
bool Session::IsActivatedAfterScreenLocked() const
|
||||
{
|
||||
return canBeActivatedAfterScreenLocked_;
|
||||
return isActivatedAfterScreenLocked_;
|
||||
}
|
||||
|
||||
void Session::SetCanBeActivatedAfterScreenLocked(bool canBeActivated)
|
||||
void Session::SetIsActivatedAfterScreenLocked(bool isActivatedAfterScreenLocked)
|
||||
{
|
||||
auto task = [weakThis = wptr(this), canBeActivated] {
|
||||
auto task = [weakThis = wptr(this), isActivatedAfterScreenLocked] {
|
||||
auto session = weakThis.promote();
|
||||
if (session == nullptr) {
|
||||
TLOGNE(WmsLogTag::WMS_LIFE, "session is null");
|
||||
return;
|
||||
}
|
||||
TLOGNI(WmsLogTag::WMS_LIFE, "id:%{public}d, canBeActivatedAfterScreenLocked:%{public}d",
|
||||
session->GetPersistentId(), canBeActivated);
|
||||
session->canBeActivatedAfterScreenLocked_ = canBeActivated;
|
||||
session->GetPersistentId(), isActivatedAfterScreenLocked);
|
||||
session->isActivatedAfterScreenLocked_ = isActivatedAfterScreenLocked;
|
||||
return;
|
||||
};
|
||||
PostTask(task, __func__);
|
||||
|
Loading…
Reference in New Issue
Block a user