diff --git a/window_scene/interfaces/include/ws_common.h b/window_scene/interfaces/include/ws_common.h index 0ddb810e93603639eaff582255ee2851d807ad30..6ce97b700dce090b016c95bbbedbe417545c6fab 100644 --- a/window_scene/interfaces/include/ws_common.h +++ b/window_scene/interfaces/include/ws_common.h @@ -284,6 +284,7 @@ struct SessionInfo { std::string continueSessionId_ = ""; bool isCalledRightlyByCallerId_ = false; uint32_t uiExtensionUsage_ = 0; + bool isAtomicService_ = false; }; enum class SessionFlag : uint32_t { 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 2d92d2211aa0bcda3ad72b18ad0b1ad26ecdc610..95c300e725c99e2ad9d437a49d709e71bbafca60 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 @@ -687,6 +687,8 @@ napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo) CreateJsValue(env, sessionInfo.requestOrientation_)); napi_set_named_property(env, objValue, "isCalledRightlyByCallerId", CreateJsValue(env, sessionInfo.isCalledRightlyByCallerId_)); + napi_set_named_property(env, objValue, "isAtomicService", + CreateJsValue(env, sessionInfo.isAtomicService_)); if (sessionInfo.processOptions != nullptr) { napi_set_named_property(env, objValue, "processOptions", CreateJsProcessOption(env, sessionInfo.processOptions)); @@ -743,6 +745,9 @@ void SetJsSessionInfoByWant(napi_env env, const SessionInfo& sessionInfo, napi_v CreateJsValue(env, sessionInfo.want->GetBoolParam(AAFwk::Want::PARAM_RESV_WITH_ANIMATION, true))); napi_set_named_property(env, objValue, "focusedOnShow", CreateJsValue(env, sessionInfo.want->GetBoolParam(AAFwk::Want::PARAM_RESV_WINDOW_FOCUSED, true))); + napi_set_named_property(env, objValue, "isStartupInstallFree", + CreateJsValue(env, (sessionInfo.want->GetFlags() & AAFwk::Want::FLAG_INSTALL_ON_DEMAND) == + AAFwk::Want::FLAG_INSTALL_ON_DEMAND)); } } diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 48cfcae7e17f08a37a64bbbc285a8a7f53777430..b0252373a4db9fb63c5bd563bea6d7a74ad0c802 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2579,6 +2579,7 @@ static SessionInfo MakeSessionInfoDuringPendingActivation(const sptrcallingTokenId; info.reuse = abilitySessionInfo->reuse; info.processOptions = abilitySessionInfo->processOptions; + info.isAtomicService_ = abilitySessionInfo->isAtomicService; if (info.want != nullptr) { info.windowMode = info.want->GetIntParam(AAFwk::Want::PARAM_RESV_WINDOW_MODE, 0); info.sessionAffinity = info.want->GetStringParam(Rosen::PARAM_KEY::PARAM_MISSION_AFFINITY_KEY); diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 3048646a65445c675fc391090c44ac0832cc1ead..689b564bae0dae854333a1641f3aa91447d14054 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -252,6 +252,7 @@ void Session::SetSessionInfo(const SessionInfo& info) sessionInfo_.uiAbilityId_ = info.uiAbilityId_; sessionInfo_.startSetting = info.startSetting; sessionInfo_.continueSessionId_ = info.continueSessionId_; + sessionInfo_.isAtomicService_ = info.isAtomicService_; } void Session::SetScreenId(uint64_t screenId) diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 1594a34a89bab00ce4e6d38e2705696322357486..161955e48fe15d902b38322e0b03de3e3799a09e 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -327,6 +327,10 @@ WSError SessionProxy::PendingSessionActivation(sptr abilityS WLOGFE("Write hasContinuousTask failed"); return WSError::WS_ERROR_IPC_FAILED; } + if (!data.WriteBool(abilitySessionInfo->isAtomicService)) { + TLOGE(WmsLogTag::WMS_LIFE, "Write isAtomicService failed"); + return WSError::WS_ERROR_IPC_FAILED; + } if (abilitySessionInfo->callerToken) { if (!data.WriteBool(true) || !data.WriteRemoteObject(abilitySessionInfo->callerToken)) { WLOGFE("Write callerToken info failed"); diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index 39a5c90b70b8d05765e178f6da0d4d24680a24b8..c211b1610637b5c5c3b338e702a0d22504c381bb 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -396,6 +396,7 @@ int SessionStub::HandlePendingSessionActivation(MessageParcel& data, MessageParc abilitySessionInfo->reuse = data.ReadBool(); abilitySessionInfo->processOptions.reset(data.ReadParcelable()); abilitySessionInfo->hasContinuousTask = data.ReadBool(); + abilitySessionInfo->isAtomicService = data.ReadBool(); if (data.ReadBool()) { abilitySessionInfo->callerToken = data.ReadRemoteObject(); } diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 9591f1a6fcc58fd830a3c175c22a3d915c402caa..70b1eb7994df72c90e441a9e230969c38db92faa 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -405,6 +405,8 @@ private: bool CheckRequestFocusImmdediately(sptr& sceneSession); bool CheckFocusIsDownThroughBlockingType(sptr& requestSceneSession, sptr& focusedSession, bool includingAppSession); + void InitSceneSession(sptr& sceneSession, const SessionInfo& sessionInfo, + const sptr& property); sptr GetNextFocusableSession(int32_t persistentId); sptr GetTopNearestBlockingFocusSession(uint32_t zOrder, bool includingAppSession); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index badd0443c7618246d95e2f5f38ea369c421c188a..c7834781a269fa39387dcfa4632128afcd679ded 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -642,6 +642,13 @@ static void AddAlphaToColor(float alpha, std::string& color) color.insert(1, strAlpha); } +static inline bool IsAtomicServiceFreeInstall(const SessionInfo& sessionInfo) +{ + return sessionInfo.isAtomicService_ && sessionInfo.want != nullptr && + (sessionInfo.want->GetFlags() & AAFwk::Want::FLAG_INSTALL_ON_DEMAND) == + AAFwk::Want::FLAG_INSTALL_ON_DEMAND; +} + void SceneSessionManager::ConfigWindowEffect(const WindowSceneConfig::ConfigItem& effectConfig) { AppWindowSceneConfig config; @@ -1435,65 +1442,70 @@ sptr SceneSessionManager::RequestSceneSession(const SessionInfo& s TLOGE(WmsLogTag::WMS_LIFE, "sceneSession is nullptr!"); return sceneSession; } - auto callerSession = GetSceneSession(sessionInfo.callerPersistentId_); - DisplayId curDisplayId = DISPLAY_ID_INVALID; - if (sessionInfo.screenId_ != SCREEN_ID_INVALID) { - curDisplayId = sessionInfo.screenId_; - } else if (callerSession && callerSession->GetSessionProperty()) { - curDisplayId = callerSession->GetSessionProperty()->GetDisplayId(); - } - if (sceneSession->GetSessionProperty()) { - sceneSession->GetSessionProperty()->SetDisplayId(curDisplayId); - sceneSession->SetScreenId(curDisplayId); - TLOGD(WmsLogTag::WMS_LIFE, "RequestSceneSession, synchronous screenId with displayid %{public}" PRIu64"", - curDisplayId); - } - sceneSession->SetEventHandler(taskScheduler_->GetEventHandler(), eventHandler_); - auto isScreenLockedCallback = [this]() { - return IsScreenLocked(); - }; - sceneSession->RegisterIsScreenLockedCallback(isScreenLockedCallback); - if (sessionInfo.isSystem_) { - sceneSession->SetCallingPid(IPCSkeleton::GetCallingRealPid()); - sceneSession->SetCallingUid(IPCSkeleton::GetCallingUid()); - auto rootContext = rootSceneContextWeak_.lock(); - sceneSession->SetAbilityToken(rootContext != nullptr ? rootContext->GetToken() : nullptr); - } else { - TLOGD(WmsLogTag::WMS_LIFE, "RequestSceneSession id: %{public}d, bundleName: %{public}s, " - "moduleName: %{public}s, abilityName: %{public}s want:%{public}s", sceneSession->GetPersistentId(), - sessionInfo.bundleName_.c_str(), sessionInfo.moduleName_.c_str(), sessionInfo.abilityName_.c_str(), - sessionInfo.want == nullptr ? "nullptr" : sessionInfo.want->ToString().c_str()); - } - RegisterSessionExceptionFunc(sceneSession); - FillSessionInfo(sceneSession); - auto persistentId = sceneSession->GetPersistentId(); - HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:RequestSceneSession(%d )", persistentId); - if (WindowHelper::IsMainWindow(sceneSession->GetWindowType())) { - WindowInfoReporter::GetInstance().InsertCreateReportInfo(sessionInfo.bundleName_); - } - if (property != nullptr && WindowHelper::IsPipWindow(property->GetWindowType())) { - sceneSession->SetPiPTemplateInfo(property->GetPiPTemplateInfo()); - } - sceneSession->SetSystemConfig(systemConfig_); - sceneSession->SetSnapshotScale(snapshotScale_); - UpdateParentSessionForDialog(sceneSession, property); - if (CheckCollaboratorType(sceneSession->GetCollaboratorType())) { - WLOGFI("ancoSceneState: %{public}d", sceneSession->GetSessionInfo().ancoSceneState); - PreHandleCollaborator(sceneSession); - } + InitSceneSession(sceneSession, sessionInfo, property); { std::unique_lock lock(sceneSessionMapMutex_); - sceneSessionMap_.insert({ persistentId, sceneSession }); + sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); } PerformRegisterInRequestSceneSession(sceneSession); NotifySessionUpdate(sessionInfo, ActionType::SINGLE_START); TLOGI(WmsLogTag::WMS_LIFE, "RequestSceneSession id: %{public}d, type: %{public}d", - persistentId, sceneSession->GetWindowType()); + sceneSession->GetPersistentId(), sceneSession->GetWindowType()); return sceneSession; }; return taskScheduler_->PostSyncTask(task, "RequestSceneSession:PID" + std::to_string(sessionInfo.persistentId_)); } +void SceneSessionManager::InitSceneSession(sptr& sceneSession, const SessionInfo& sessionInfo, + const sptr& property) +{ + auto callerSession = GetSceneSession(sessionInfo.callerPersistentId_); + DisplayId curDisplayId = DISPLAY_ID_INVALID; + if (sessionInfo.screenId_ != SCREEN_ID_INVALID) { + curDisplayId = sessionInfo.screenId_; + } else if (callerSession && callerSession->GetSessionProperty()) { + curDisplayId = callerSession->GetSessionProperty()->GetDisplayId(); + } + if (sceneSession->GetSessionProperty()) { + sceneSession->GetSessionProperty()->SetDisplayId(curDisplayId); + sceneSession->SetScreenId(curDisplayId); + TLOGD(WmsLogTag::WMS_LIFE, "synchronous screenId with displayid %{public}" PRIu64, + curDisplayId); + } + sceneSession->SetEventHandler(taskScheduler_->GetEventHandler(), eventHandler_); + sceneSession->RegisterIsScreenLockedCallback([this] { return IsScreenLocked(); }); + if (sessionInfo.isSystem_) { + sceneSession->SetCallingPid(IPCSkeleton::GetCallingRealPid()); + sceneSession->SetCallingUid(IPCSkeleton::GetCallingUid()); + auto rootContext = rootSceneContextWeak_.lock(); + sceneSession->SetAbilityToken(rootContext != nullptr ? rootContext->GetToken() : nullptr); + } else { + TLOGD(WmsLogTag::WMS_LIFE, "id: %{public}d, bundleName: %{public}s, " + "moduleName: %{public}s, abilityName: %{public}s want:%{public}s", sceneSession->GetPersistentId(), + sessionInfo.bundleName_.c_str(), sessionInfo.moduleName_.c_str(), sessionInfo.abilityName_.c_str(), + sessionInfo.want == nullptr ? "nullptr" : sessionInfo.want->ToString().c_str()); + } + RegisterSessionExceptionFunc(sceneSession); + // Skip FillSessionInfo when atomicService free-install start. + if (!IsAtomicServiceFreeInstall(sessionInfo)) { + FillSessionInfo(sceneSession); + } + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:RequestSceneSession(%d )", sceneSession->GetPersistentId()); + if (WindowHelper::IsMainWindow(sceneSession->GetWindowType())) { + WindowInfoReporter::GetInstance().InsertCreateReportInfo(sessionInfo.bundleName_); + } + if (property != nullptr && WindowHelper::IsPipWindow(property->GetWindowType())) { + sceneSession->SetPiPTemplateInfo(property->GetPiPTemplateInfo()); + } + sceneSession->SetSystemConfig(systemConfig_); + sceneSession->SetSnapshotScale(snapshotScale_); + UpdateParentSessionForDialog(sceneSession, property); + if (CheckCollaboratorType(sceneSession->GetCollaboratorType())) { + TLOGI(WmsLogTag::WMS_LIFE, "ancoSceneState: %{public}d", sceneSession->GetSessionInfo().ancoSceneState); + PreHandleCollaborator(sceneSession); + } +} + void SceneSessionManager::NotifySessionUpdate(const SessionInfo& sessionInfo, ActionType action, ScreenId fromScreenId) { sptr info = new (std::nothrow) DisplayChangeInfo(); @@ -5382,6 +5394,12 @@ void SceneSessionManager::NotifyCompleteFirstFrameDrawing(int32_t persistentId) } const auto& sessionInfo = scnSession->GetSessionInfo(); + if (IsAtomicServiceFreeInstall(sessionInfo)) { + TLOGI(WmsLogTag::WMS_LIFE, "AtomicService free-install start, id: %{public}d, type: %{public}d", + scnSession->GetPersistentId(), scnSession->GetWindowType()); + FillSessionInfo(scnSession); + } + TLOGI(WmsLogTag::WMS_MAIN, " id: %{public}d, app info: [%{public}s %{public}s %{public}s]", scnSession->GetPersistentId(), sessionInfo.bundleName_.c_str(), sessionInfo.moduleName_.c_str(), sessionInfo.abilityName_.c_str());