fix json exception bug

Signed-off-by: zmx <zhangmingxiang@huawei.com>
Change-Id: Ia9cecd8aa4554ad21f9e8eb476b8786b2b8d06b6
Signed-off-by: zmx <zhangmingxiang@huawei.com>
This commit is contained in:
zmx 2022-04-20 13:53:14 +08:00
parent 04994fcd65
commit bb85b644f8
5 changed files with 30 additions and 8 deletions

View File

@ -13,7 +13,8 @@
declare_args() {
dmsfwk_standard_mission_manager = true
if (!defined(global_parts_info.multimedia_image_standard_image_native)) {
if (defined(global_parts_info) &&
!defined(global_parts_info.multimedia_multimedia_image_standard)) {
dmsfwk_standard_mission_manager = false
}
}

View File

@ -53,6 +53,16 @@ public:
* @param missionId, mission Id.
*/
void OnMissionMovedToFront(int32_t missionId) override;
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
/**
* @brief Called when a mission has changed it's icon.
*
* @param missionId, mission Id.
* @param icon, mission icon.
*/
void OnMissionIconUpdated(int32_t missionId, const std::shared_ptr<OHOS::Media::PixelMap> &icon) override;
#endif
};
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -35,16 +35,20 @@ const std::string FOUNDATION_PROCESS_NAME = "foundation";
IMPLEMENT_SINGLE_INSTANCE(DistributedSchedPermission);
void from_json(const nlohmann::json& jsonObject, GroupInfo& groupInfo)
{
try {
if (jsonObject.find(FIELD_GROUP_NAME) != jsonObject.end()) {
jsonObject.at(FIELD_GROUP_NAME).get_to(groupInfo.groupName);
}
if (jsonObject.find(FIELD_GROUP_ID) != jsonObject.end()) {
jsonObject.at(FIELD_GROUP_ID).get_to(groupInfo.groupId);
}
if (jsonObject.find(FIELD_GROUP_OWNER) != jsonObject.end()) {
jsonObject.at(FIELD_GROUP_OWNER).get_to(groupInfo.groupOwner);
}
if (jsonObject.find(FIELD_GROUP_TYPE) != jsonObject.end()) {
jsonObject.at(FIELD_GROUP_TYPE).get_to(groupInfo.groupType);
}
if (jsonObject.find(FIELD_GROUP_VISIBILITY) != jsonObject.end()) {
jsonObject.at(FIELD_GROUP_VISIBILITY).get_to(groupInfo.groupVisibility);
} catch (nlohmann::detail::type_error& ex) {
HILOGE("from_json type error");
} catch (nlohmann::detail::out_of_range& ex) {
HILOGE("from_json out of range");
}
}

View File

@ -48,5 +48,12 @@ void DistributedMissionChangeListener::OnMissionMovedToFront(int32_t missionId)
HILOGI("OnMissionMovedToFront, missionId = %{public}d", missionId);
DistributedSchedMissionManager::GetInstance().NotifyLocalMissionsChanged();
}
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
void DistributedMissionChangeListener::OnMissionIconUpdated(int32_t missionId,
const std::shared_ptr<OHOS::Media::PixelMap> &icon)
{
}
#endif
}
}

View File

@ -592,7 +592,7 @@ HWTEST_F(DistributedSchedConnectTest, DisconnectRemoteAbility001, TestSize.Level
DistributedSchedService::GetInstance().DisconnectRemoteAbility(connect, 0, 0);
{
std::lock_guard<std::mutex> autoLock(distributedLock);
EXPECT_EQ(connectionMap.size(), static_cast<size_t>(1));
EXPECT_EQ(connectionMap.size(), static_cast<size_t>(0));
}
RemoveSession(connect);
@ -630,7 +630,7 @@ HWTEST_F(DistributedSchedConnectTest, DisconnectRemoteAbility002, TestSize.Level
DistributedSchedService::GetInstance().DisconnectRemoteAbility(connect, 0, 0);
auto iter = trackingUidMap.find(uid);
if (iter != trackingUidMap.end()) {
EXPECT_EQ(trackingUidMap[uid], newCount);
EXPECT_EQ(trackingUidMap[uid], oldCount);
}
RemoveConnectInfo(connect);