增加ablityInfo为null的判断

Signed-off-by: zhouxueer <zhouxueer@huawei.com>
Change-Id: I6a8d185075385ac5e795e4f6732546db365b519f
Signed-off-by: zhouxueer <zhouxueer@huawei.com>
This commit is contained in:
zhouxueer 2023-08-12 10:54:42 +08:00
parent 2d2638b6ac
commit 7795164735
3 changed files with 38 additions and 10 deletions

View File

@ -49,6 +49,8 @@
"image_framework", "image_framework",
"preferences", "preferences",
"hiview", "hiview",
"ffrt",
"dsoftbus",
"hicollie", "hicollie",
"eventhandler", "eventhandler",
"c_utils", "c_utils",

View File

@ -15,10 +15,14 @@
#include "scene_session_converter.h" #include "scene_session_converter.h"
#include "ability_info.h" #include "ability_info.h"
#include "window_manager_hilog.h"
using namespace std; using namespace std;
namespace OHOS { namespace OHOS {
namespace Rosen { namespace Rosen {
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "SceneSessionConverter" };
}
WSError SceneSessionConverter::ConvertToMissionInfos(std::vector<sptr<SceneSession>>& sceneSessionInfos, WSError SceneSessionConverter::ConvertToMissionInfos(std::vector<sptr<SceneSession>>& sceneSessionInfos,
std::vector<AAFwk::MissionInfo>& missionInfos) std::vector<AAFwk::MissionInfo>& missionInfos)
@ -31,10 +35,18 @@ WSError SceneSessionConverter::ConvertToMissionInfos(std::vector<sptr<SceneSessi
missionInfo.id = (*iter)->GetPersistentId(); missionInfo.id = (*iter)->GetPersistentId();
missionInfo.runningState = (*iter)->IsActive(); missionInfo.runningState = (*iter)->IsActive();
missionInfo.lockedState = ((*iter)->GetSessionInfo()).lockedState; missionInfo.lockedState = ((*iter)->GetSessionInfo()).lockedState;
missionInfo.label = ((*iter)->GetSessionInfo().abilityInfo)->label; if ((*iter)->GetSessionInfo().abilityInfo != nullptr) {
missionInfo.iconPath = ((*iter)->GetSessionInfo().abilityInfo)->iconPath; missionInfo.label = ((*iter)->GetSessionInfo().abilityInfo)->label;
missionInfo.want = *(((*iter)->GetSessionInfo()).want); missionInfo.iconPath = ((*iter)->GetSessionInfo().abilityInfo)->iconPath;
missionInfo.continuable = ((*iter)->GetSessionInfo().abilityInfo)->continuable; missionInfo.continuable = ((*iter)->GetSessionInfo().abilityInfo)->continuable;
} else {
WLOGFE("abilityInfo in SceneSession is nullptr, id: %{public}d", (*iter)->GetPersistentId());
}
if (((*iter)->GetSessionInfo()).want != nullptr) {
missionInfo.want = *(((*iter)->GetSessionInfo()).want);
} else {
WLOGFE("want in SceneSession is nullptr, id: %{public}d", (*iter)->GetPersistentId());
}
missionInfo.time = ((*iter)->GetSessionInfo()).time; missionInfo.time = ((*iter)->GetSessionInfo()).time;
missionInfo.continueState = (AAFwk::ContinueState)(AAFwk::ContinueState::CONTINUESTATE_UNKNOWN missionInfo.continueState = (AAFwk::ContinueState)(AAFwk::ContinueState::CONTINUESTATE_UNKNOWN
+ (((*iter)->GetSessionInfo()).continueState - Rosen::ContinueState::CONTINUESTATE_UNKNOWN)); + (((*iter)->GetSessionInfo()).continueState - Rosen::ContinueState::CONTINUESTATE_UNKNOWN));
@ -52,10 +64,18 @@ WSError SceneSessionConverter::ConvertToMissionInfo(sptr<SceneSession>& sceneSes
missionInfo.id = sceneSession->GetPersistentId(); missionInfo.id = sceneSession->GetPersistentId();
missionInfo.runningState = sceneSession->IsActive(); missionInfo.runningState = sceneSession->IsActive();
missionInfo.lockedState = (sceneSession->GetSessionInfo()).lockedState; missionInfo.lockedState = (sceneSession->GetSessionInfo()).lockedState;
missionInfo.label = (sceneSession->GetSessionInfo().abilityInfo)->label; if (sceneSession->GetSessionInfo().abilityInfo != nullptr) {
missionInfo.iconPath = (sceneSession->GetSessionInfo().abilityInfo)->iconPath; missionInfo.label = (sceneSession->GetSessionInfo().abilityInfo)->label;
missionInfo.want = *((sceneSession->GetSessionInfo()).want); missionInfo.iconPath = (sceneSession->GetSessionInfo().abilityInfo)->iconPath;
missionInfo.continuable = (sceneSession->GetSessionInfo().abilityInfo)->continuable; missionInfo.continuable = (sceneSession->GetSessionInfo().abilityInfo)->continuable;
} else {
WLOGFE("abilityInfo in SceneSession is nullptr, id: %{public}d", sceneSession->GetPersistentId());
}
if ((sceneSession->GetSessionInfo()).want != nullptr) {
missionInfo.want = *((sceneSession->GetSessionInfo()).want);
} else {
WLOGFE("want in SceneSession is nullptr, id: %{public}d", sceneSession->GetPersistentId());
}
missionInfo.time = (sceneSession->GetSessionInfo()).time; missionInfo.time = (sceneSession->GetSessionInfo()).time;
missionInfo.continueState = (AAFwk::ContinueState) (AAFwk::ContinueState::CONTINUESTATE_UNKNOWN missionInfo.continueState = (AAFwk::ContinueState) (AAFwk::ContinueState::CONTINUESTATE_UNKNOWN
+ ((sceneSession->GetSessionInfo()).continueState - Rosen::ContinueState::CONTINUESTATE_UNKNOWN)); + ((sceneSession->GetSessionInfo()).continueState - Rosen::ContinueState::CONTINUESTATE_UNKNOWN));

View File

@ -923,7 +923,9 @@ WSError SceneSessionManager::RequestSceneSessionDestruction(
if (needRemoveSession) { if (needRemoveSession) {
std::unique_lock<std::shared_mutex> lock(sceneSessionMapMutex_); std::unique_lock<std::shared_mutex> lock(sceneSessionMapMutex_);
sceneSessionMap_.erase(persistentId); sceneSessionMap_.erase(persistentId);
if (listenerController_ != nullptr && !(scnSession->GetSessionInfo().abilityInfo)->excludeFromMissions) { if (listenerController_ != nullptr &&
(scnSession->GetSessionInfo().abilityInfo) != nullptr &&
!(scnSession->GetSessionInfo().abilityInfo)->excludeFromMissions) {
WLOGFD("NotifySessionDestroyed, id: %{public}d", persistentId); WLOGFD("NotifySessionDestroyed, id: %{public}d", persistentId);
listenerController_->NotifySessionDestroyed(persistentId); listenerController_->NotifySessionDestroyed(persistentId);
} }
@ -2054,6 +2056,7 @@ void SceneSessionManager::NotifyCompleteFirstFrameDrawing(int32_t persistentId)
WLOGFI("NotifyCompleteFirstFrameDrawing, persistentId: %{public}d", persistentId); WLOGFI("NotifyCompleteFirstFrameDrawing, persistentId: %{public}d", persistentId);
auto scnSession = GetSceneSession(persistentId); auto scnSession = GetSceneSession(persistentId);
if (!scnSession && listenerController_ != nullptr && if (!scnSession && listenerController_ != nullptr &&
(scnSession->GetSessionInfo().abilityInfo) != nullptr &&
!(scnSession->GetSessionInfo().abilityInfo)->excludeFromMissions) { !(scnSession->GetSessionInfo().abilityInfo)->excludeFromMissions) {
WLOGFD("NotifySessionCreated, id: %{public}d", persistentId); WLOGFD("NotifySessionCreated, id: %{public}d", persistentId);
listenerController_->NotifySessionCreated(persistentId); listenerController_->NotifySessionCreated(persistentId);
@ -2065,6 +2068,7 @@ void SceneSessionManager::NotifySessionMovedToFront(int32_t persistentId)
WLOGFI("NotifySessionMovedToFront, persistentId: %{public}d", persistentId); WLOGFI("NotifySessionMovedToFront, persistentId: %{public}d", persistentId);
auto scnSession = GetSceneSession(persistentId); auto scnSession = GetSceneSession(persistentId);
if (!scnSession && listenerController_ != nullptr && if (!scnSession && listenerController_ != nullptr &&
(scnSession->GetSessionInfo().abilityInfo) != nullptr &&
!(scnSession->GetSessionInfo().abilityInfo)->excludeFromMissions) { !(scnSession->GetSessionInfo().abilityInfo)->excludeFromMissions) {
listenerController_->NotifySessionMovedToFront(persistentId); listenerController_->NotifySessionMovedToFront(persistentId);
} }
@ -2107,7 +2111,9 @@ WSError SceneSessionManager::SetSessionIcon(const sptr<IRemoteObject> &token,
if (sceneSession->GetAbilityToken() == token) { if (sceneSession->GetAbilityToken() == token) {
WLOGFI("try to update session icon."); WLOGFI("try to update session icon.");
sessionListener_->OnSessionIconChange(iter.first, icon); sessionListener_->OnSessionIconChange(iter.first, icon);
if (listenerController_ != nullptr && !(sceneSession->GetSessionInfo().abilityInfo)->excludeFromMissions) { if (listenerController_ != nullptr &&
(sceneSession->GetSessionInfo().abilityInfo) != nullptr &&
!(sceneSession->GetSessionInfo().abilityInfo)->excludeFromMissions) {
WLOGFD("NotifySessionIconChanged, id: %{public}d", iter.first); WLOGFD("NotifySessionIconChanged, id: %{public}d", iter.first);
listenerController_->NotifySessionIconChanged(iter.first, icon); listenerController_->NotifySessionIconChanged(iter.first, icon);
} }