diff --git a/window_scene/common/include/session_helper.h b/window_scene/common/include/session_helper.h index 7c6bd137148d1e60d9e0e9137ab8816696242596..6e8e0340c4ea4321bd415aed666c282478e422f4 100644 --- a/window_scene/common/include/session_helper.h +++ b/window_scene/common/include/session_helper.h @@ -119,10 +119,9 @@ public: return usage == UIExtensionUsage::CONSTRAINED_EMBEDDED || usage == UIExtensionUsage::PREVIEW_EMBEDDED; } - static inline bool IsNeedSACalling(WindowType type) + static inline bool IsMagnificationWindow(WindowType type) { - return type == WindowType::WINDOW_TYPE_MAGNIFICATION || type == WindowType::WINDOW_TYPE_MAGNIFICATION_MENU || - type == WindowType::WINDOW_TYPE_SELECTION; + return type == WindowType::WINDOW_TYPE_MAGNIFICATION || type == WindowType::WINDOW_TYPE_MAGNIFICATION_MENU; } static AreaType GetAreaType(int32_t pointWinX, int32_t pointWinY, diff --git a/window_scene/interfaces/include/ws_common.h b/window_scene/interfaces/include/ws_common.h index a361507cdf4d8d6a2d3cd074b23a5e2ca9fe2d0c..8170e210650fe8e0c823e402cd157c948cd927bf 100644 --- a/window_scene/interfaces/include/ws_common.h +++ b/window_scene/interfaces/include/ws_common.h @@ -399,6 +399,7 @@ struct SessionInfo { int32_t requestCode = -1; int32_t errorCode = -1; std::string errorReason = ""; + bool shouldSkipKillInStartup = false; int32_t persistentId_ = INVALID_SESSION_ID; int32_t callerPersistentId_ = INVALID_SESSION_ID; std::string callerBundleName_ = ""; diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp index 4d3db9a4916b1f5838c4925d6be5da1fd5f3ece2..80303fcf4d9ad103ca13fab3f9930c82e843fa48 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp @@ -1444,6 +1444,8 @@ napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo) } napi_set_named_property(env, objValue, "errorReason", CreateJsValue(env, sessionInfo.errorReason)); + napi_set_named_property(env, objValue, "shouldSkipKillInStartup", + CreateJsValue(env, sessionInfo.shouldSkipKillInStartup)); napi_set_named_property(env, objValue, "isFromIcon", CreateJsValue(env, sessionInfo.isFromIcon_)); SetJsSessionInfoByWant(env, sessionInfo, objValue); napi_set_named_property(env, objValue, "supportWindowModes", diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index ee75932dd90e8ac3060657441df3067364d5491f..6c8cbb1133616b0daf975833ba4aa878fe775ba0 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -6557,8 +6557,9 @@ WSError SceneSession::NotifySessionExceptionInner(const sptr return WSError::WS_ERROR_NULLPTR; } if (SessionHelper::IsMainWindow(session->GetWindowType()) && !session->clientIdentityToken_.empty() && - isFromClient && (abilitySessionInfo->errorReason != ERROR_REASON_LOW_MEMORY_KILL && - session->clientIdentityToken_ != abilitySessionInfo->identityToken)) { + isFromClient && (session->clientIdentityToken_ != abilitySessionInfo->identityToken && + abilitySessionInfo->errorReason != ERROR_REASON_LOW_MEMORY_KILL && + !abilitySessionInfo->shouldSkipKillInStartup)) { TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s client exception not matched: %{public}s, %{public}s", where, session->clientIdentityToken_.c_str(), abilitySessionInfo->identityToken.c_str()); session->RemoveLifeCycleTask(LifeCycleTaskType::STOP); @@ -6576,6 +6577,7 @@ WSError SceneSession::NotifySessionExceptionInner(const sptr info.callerToken_ = abilitySessionInfo->callerToken; info.errorCode = abilitySessionInfo->errorCode; info.errorReason = abilitySessionInfo->errorReason; + info.shouldSkipKillInStartup = abilitySessionInfo->shouldSkipKillInStartup; info.persistentId_ = static_cast(abilitySessionInfo->persistentId); { std::lock_guard lock(session->sessionInfoMutex_); diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 650b67d7f21f1a9da7d9c4fd90ee5c2d696dc6d8..dd1f6fffba0b7a39b317699f1bf8b31cbd661e47 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -780,6 +780,10 @@ WSError SessionProxy::NotifySessionException(const sptr abil TLOGE(WmsLogTag::WMS_LIFE, "Write identity token info failed"); return WSError::WS_ERROR_IPC_FAILED; } + if (!data.WriteBool(abilitySessionInfo->shouldSkipKillInStartup)) { + TLOGE(WmsLogTag::WMS_LIFE, "Write shouldSkipKillInStartup failed"); + return WSError::WS_ERROR_IPC_FAILED; + } if (!data.WriteBool(exceptionInfo.needRemoveSession)) { TLOGE(WmsLogTag::WMS_LIFE, "Write needRemoveSession info failed"); return WSError::WS_ERROR_IPC_FAILED; diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index 87e37480e465c970065dd0833e45932f71c45dad..3cae3a99b46befda10ffbca2eed76b6397003dd1 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -689,6 +689,10 @@ int SessionStub::HandleSessionException(MessageParcel& data, MessageParcel& repl TLOGE(WmsLogTag::WMS_LIFE, "Read identityToken failed."); return ERR_INVALID_DATA; } + if (!data.ReadBool(abilitySessionInfo->shouldSkipKillInStartup)) { + TLOGE(WmsLogTag::WMS_LIFE, "Read shouldSkipKillInStartup failed."); + return ERR_INVALID_DATA; + } ExceptionInfo exceptionInfo; if (!data.ReadBool(exceptionInfo.needRemoveSession)) { TLOGE(WmsLogTag::WMS_LIFE, "Read needRemoveSession failed."); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 5e301e62aadced68b7b4c06c3037cbf37ac6ab81..907867710d7a3cc1bea10de2d3cf1bdf50b98f19 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -4142,7 +4142,7 @@ bool SceneSessionManager::CheckSystemWindowPermission(const sptr abilitySessionInfo = sptr::MakeSptr(); + ExceptionInfo exceptionInfo; + sceneSession->clientIdentityToken_ = "testToken1"; + abilitySessionInfo->identityToken = "testToken2"; + ASSERT_NE(abilitySessionInfo, nullptr); + + abilitySessionInfo->shouldSkipKillInStartup = true; + WSError result = sceneSession->NotifySessionExceptionInner(abilitySessionInfo, exceptionInfo, true); + EXPECT_EQ(result, WSError::WS_OK); + + usleep(WAIT_SYNC_IN_NS); +} + /** * @tc.name: RegisterSessionSnapshotFunc * @tc.desc: RegisterSessionSnapshotFunc diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 117d76fb874a8b204641918ec31c1dd321e452ca..e961ac51732af453d1a80a474c034bf9731a331c 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -253,7 +253,7 @@ WMError WindowSceneSessionImpl::GetParentSessionAndVerify(bool isToast, sptrGetWindowName().c_str(), GetType()); return WMError::WM_ERROR_NULLPTR; } - return WindowSceneSessionImpl::VerifySubWindowLevel(false, parentSession); + return WindowSceneSessionImpl::VerifySubWindowLevel(isToast, parentSession); } WMError WindowSceneSessionImpl::VerifySubWindowLevel(bool isToast, const sptr& parentSession) @@ -315,7 +315,7 @@ WMError WindowSceneSessionImpl::CreateAndConnectSpecificSession() } } else if (WindowHelper::IsSubWindow(type)) { sptr parentSession = nullptr; - auto ret = WindowSceneSessionImpl::VerifySubWindowLevel(hasToastFlag, parentSession); + auto ret = WindowSceneSessionImpl::GetParentSessionAndVerify(hasToastFlag, parentSession); if (ret != WMError::WM_OK) { return ret; }