!795 添加上线通知时发送广播功能

Merge pull request !795 from m30043719/master
This commit is contained in:
openharmony_ci 2024-02-04 06:45:57 +00:00 committed by Gitee
commit 21b5b9944d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 27 additions and 1 deletions

View File

@ -46,6 +46,7 @@ enum class FocusedReason {
NORMAL,
INIT,
SCREENOFF,
ONLINE,
MMI,
MAX
};
@ -75,6 +76,7 @@ public:
void NotifyDied(const sptr<IRemoteObject>& obj);
int32_t SetMissionContinueState(const int32_t missionId, const AAFwk::ContinueState& state);
void OnMMIEvent();
uint32_t NotifyDeviceOnline();
private:
int32_t GetCurrentMissionId();

View File

@ -97,7 +97,6 @@ void DnetworkAdapter::DmsDeviceStateCallback::OnDeviceOffline(const DmDeviceInfo
void DnetworkAdapter::DmsDeviceStateCallback::OnDeviceChanged(const DmDeviceInfo& deviceInfo)
{
HILOGI("called");
std::string networkId = deviceInfo.networkId;
HILOGI("OnDeviceChanged netwokId = %{public}s", AnonymizeNetworkId(networkId).c_str());
auto onlineNotifyTask = [deviceInfo]() {

View File

@ -21,6 +21,7 @@
#include "deviceManager/dms_device_info.h"
#include "dtbschedmgr_device_info_storage.h"
#include "dtbschedmgr_log.h"
#include "mission/dms_continue_send_manager.h"
namespace OHOS {
namespace DistributedSchedule {
@ -32,6 +33,7 @@ void DistributedDeviceNodeListener::OnDeviceOnline(const DistributedHardware::Dm
auto dmsDeviceInfo = std::make_shared<DmsDeviceInfo>(
deviceInfo.deviceName, deviceInfo.deviceTypeId, deviceInfo.networkId);
DtbschedmgrDeviceInfoStorage::GetInstance().DeviceOnlineNotify(dmsDeviceInfo);
DMSContinueSendMgr::GetInstance().NotifyDeviceOnline();
}
void DistributedDeviceNodeListener::OnDeviceOffline(const DistributedHardware::DmDeviceInfo& deviceInfo)

View File

@ -539,5 +539,15 @@ void DMSContinueSendMgr::OnMMIEvent()
HILOGD("OnMMIEvent, missionId = %{public}d", info_.currentMissionId);
DMSContinueSendMgr::GetInstance().NotifyMissionFocused(info_.currentMissionId, FocusedReason::MMI);
}
uint32_t DMSContinueSendMgr::NotifyDeviceOnline()
{
HILOGD("NotifyDeviceOnline called");
if (GetCurrentMissionId() <= 0) {
return INVALID_MISSION_ID;
}
NotifyMissionFocused(info_.currentMissionId, FocusedReason::ONLINE);
return ERR_OK;
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -696,5 +696,18 @@ HWTEST_F(DMSContinueManagerTest, testSendSoftbusEvent001, TestSize.Level1)
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "DMSContinueManagerTest testSendSoftbusEvent001 end" << std::endl;
}
/**
* @tc.name: testNotifyDeviceOnline001
* @tc.desc: NotifyDeviceOnline
* @tc.type: FUNC
*/
HWTEST_F(DMSContinueManagerTest, testNotifyDeviceOnline001, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest testNotifyDeviceOnline001 start" << std::endl;
uint32_t ret = DMSContinueSendMgr::GetInstance().NotifyDeviceOnline();
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "DMSContinueManagerTest testNotifyDeviceOnline001 end" << std::endl;
}
} // namespace DistributedSchedule
} // namespace OHOS