From f9fa2ad2d59e4605d1dbbca170d61374c6ec57fd Mon Sep 17 00:00:00 2001 From: majiajun <864428661@qq.com> Date: Fri, 7 Jan 2022 03:25:45 -0800 Subject: [PATCH] mission management interface modification Signed-off-by: majiajun <864428661@qq.com> Change-Id: I3e146d71ccbb335556f38b7f555756cf27b4c174 --- etc/init/BUILD.gn | 20 ++- interfaces/innerkits/uri/BUILD.gn | 2 +- ohos.build | 2 +- services/dtbschedmgr/BUILD.gn | 28 ++-- .../include/distributed_sched_adapter.h | 4 +- .../include/distributed_sched_interface.h | 28 ++-- .../include/distributed_sched_proxy.h | 19 ++- .../include/distributed_sched_service.h | 19 +-- .../include/distributed_sched_stub.h | 11 +- ...sion_info.h => distributed_mission_info.h} | 10 +- .../distributed_sched_mission_manager.h | 35 +++-- .../include/mission/mission_info_converter.h | 14 +- .../src/distributed_sched_adapter.cpp | 12 +- .../src/distributed_sched_proxy.cpp | 142 ++++++++++-------- .../src/distributed_sched_service.cpp | 39 ++--- .../src/distributed_sched_stub.cpp | 104 +++++++------ ..._info.cpp => distributed_mission_info.cpp} | 34 +++-- .../distributed_sched_mission_manager.cpp | 90 ++++++----- .../src/mission/mission_info_converter.cpp | 66 ++++---- services/dtbschedmgr/test/BUILD.gn | 29 ++-- .../mission/dms_mission_manager_test.cpp | 22 ++- .../mission/dms_mission_manager_test.h | 1 - .../test/unittest/mock_distributed_sched.cpp | 21 ++- .../test/unittest/mock_distributed_sched.h | 19 +-- 24 files changed, 402 insertions(+), 369 deletions(-) rename services/dtbschedmgr/include/mission/{mission_info.h => distributed_mission_info.h} (89%) rename services/dtbschedmgr/src/mission/{mission_info.cpp => distributed_mission_info.cpp} (86%) diff --git a/etc/init/BUILD.gn b/etc/init/BUILD.gn index 337d9c56..99e1b2b8 100644 --- a/etc/init/BUILD.gn +++ b/etc/init/BUILD.gn @@ -1,4 +1,3 @@ - # Copyright (c) 2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,18 +15,17 @@ import("//build/ohos.gni") ################################################################################# - group("etc") { - deps = [ ":distributedsched.rc" ] + deps = [ ":distributedsched.rc" ] } ohos_prebuilt_etc("distributedsched.rc") { - if (use_musl) { - source = "distributedsched.cfg" - } else { - source = "distributedsched.rc" - } - relative_install_dir = "init" - subsystem_name = "distributedschedule" - part_name = "dmsfwk_standard" + if (use_musl) { + source = "distributedsched.cfg" + } else { + source = "distributedsched.rc" + } + relative_install_dir = "init" + subsystem_name = "distributedschedule" + part_name = "dmsfwk_standard" } diff --git a/interfaces/innerkits/uri/BUILD.gn b/interfaces/innerkits/uri/BUILD.gn index 7a5ffe58..415cebb2 100755 --- a/interfaces/innerkits/uri/BUILD.gn +++ b/interfaces/innerkits/uri/BUILD.gn @@ -32,9 +32,9 @@ ohos_shared_library("zuri") { external_deps = [ "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", + "utils_base:utils", ] part_name = "dmsfwk_standard" } - deps = [ "//utils/native/base:utils" ] subsystem_name = "distributedschedule" } diff --git a/ohos.build b/ohos.build index a0e8824f..8f644df0 100644 --- a/ohos.build +++ b/ohos.build @@ -11,7 +11,7 @@ "distributed_sched_proxy.h", "caller_info.h", "uri.h", - "mission/mission_info.h" + "mission/distributed_mission_info.h" ] }, "name": "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri" diff --git a/services/dtbschedmgr/BUILD.gn b/services/dtbschedmgr/BUILD.gn index 183caf4a..4d473d1a 100644 --- a/services/dtbschedmgr/BUILD.gn +++ b/services/dtbschedmgr/BUILD.gn @@ -44,35 +44,31 @@ ohos_shared_library("distributedschedsvr") { "src/dtbschedmgr_device_info_storage.cpp", "src/mission/distributed_data_change_listener.cpp", "src/mission/distributed_data_storage.cpp", + "src/mission/distributed_mission_info.cpp", "src/mission/distributed_sched_mission_manager.cpp", "src/mission/mission_changed_notify.cpp", - "src/mission/mission_info.cpp", "src/mission/mission_info_converter.cpp", "src/mission/snapshot.cpp", ] configs = [ ":distributed_sched_config" ] - deps = [ - "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", - "//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager", - "//foundation/aafwk/standard/interfaces/innerkits/base:base", - "//foundation/aafwk/standard/interfaces/innerkits/want:want", - "//foundation/appexecfwk/standard/common:libappexecfwk_common", - "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base:appexecfwk_base", - "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core:appexecfwk_core", - "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", - "//foundation/distributeddatamgr/distributeddatamgr/interfaces/innerkits/distributeddata:distributeddata_inner", - "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk", - "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", - "//foundation/multimedia/image_standard/interfaces/innerkits:image_native", - "//utils/native/base:utils", - ] + deps = [ "//foundation/appexecfwk/standard/common:libappexecfwk_common" ] external_deps = [ + "aafwk_standard:ability_manager", + "aafwk_standard:want", + "appexecfwk_standard:appexecfwk_base", + "appexecfwk_standard:appexecfwk_core", + "appexecfwk_standard:libeventhandler", + "distributeddatamgr:distributeddata_inner", "dsoftbus_standard:softbus_client", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", + "multimedia_image_standard:image_native", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + "utils_base:utils", ] part_name = "dmsfwk_standard" diff --git a/services/dtbschedmgr/include/distributed_sched_adapter.h b/services/dtbschedmgr/include/distributed_sched_adapter.h index 06f3ad7b..07e43d47 100644 --- a/services/dtbschedmgr/include/distributed_sched_adapter.h +++ b/services/dtbschedmgr/include/distributed_sched_adapter.h @@ -22,7 +22,7 @@ #include "event_handler.h" #include "if_system_ability_manager.h" #include "iremote_object.h" -#include "mission/mission_info.h" +#include "mission/distributed_mission_info.h" #include "single_instance.h" #include "uri.h" @@ -43,7 +43,7 @@ public: bool QueryAbilityInfo(const OHOS::AAFwk::Want& want, AppExecFwk::AbilityInfo& abilityInfo); void ProcessConnectDied(const sptr& connect); int32_t GetBundleNameListFromBms(int32_t uid, std::vector& u16BundleNameList); - int32_t GetLocalMissionInfos(int32_t numMissions, std::vector& missionInfos); + int32_t GetLocalMissionInfos(int32_t numMissions, std::vector& missionInfos); int32_t GetBundleNameListFromBms(int32_t uid, std::vector& bundleNameList); bool AllowMissionUid(int32_t uid); int32_t RegisterMissionChange(bool willRegister); diff --git a/services/dtbschedmgr/include/distributed_sched_interface.h b/services/dtbschedmgr/include/distributed_sched_interface.h index e957a63a..e6a580ff 100644 --- a/services/dtbschedmgr/include/distributed_sched_interface.h +++ b/services/dtbschedmgr/include/distributed_sched_interface.h @@ -20,7 +20,7 @@ #include "ability_info.h" #include "caller_info.h" #include "iremote_broker.h" -#include "mission/mission_info.h" +#include "mission/distributed_mission_info.h" #include "ohos/aafwk/content/want.h" namespace OHOS { @@ -53,24 +53,24 @@ public: virtual int32_t DisconnectAbilityFromRemote(const sptr& connect, int32_t uid, const std::string& sourceDeviceId) = 0; virtual int32_t NotifyProcessDiedFromRemote(const CallerInfo& callerInfo) = 0; - - virtual int32_t PrepareAndSyncMissions(const std::u16string& devId, bool fixConflict, int64_t tag) = 0; - virtual int32_t RegisterRemoteMissionListener(const std::u16string& devId, const sptr& obj) = 0; - virtual int32_t UnRegisterRemoteMissionListener(const std::u16string& devId, const sptr& obj) = 0; + virtual int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) = 0; + virtual int32_t StartSyncMissionsFromRemote(const CallerInfo& callerInfo, + std::vector& missionInfos) = 0; + virtual int32_t StopSyncRemoteMissions(const std::string& devId) = 0; + virtual int32_t StopSyncMissionsFromRemote(const CallerInfo& callerInfo) = 0; + virtual int32_t RegisterMissionListener(const std::u16string& devId, const sptr& obj) = 0; + virtual int32_t UnRegisterMissionListener(const std::u16string& devId, const sptr& obj) = 0; virtual int32_t GetMissionInfos(const std::string& deviceId, int32_t numMissions, - std::vector& missionInfos) = 0; + std::vector& missionInfos) = 0; virtual int32_t StoreSnapshotInfo(const std::string& deviceId, int32_t missionId, const uint8_t* byteStream, size_t len) = 0; virtual int32_t RemoveSnapshotInfo(const std::string& deviceId, int32_t missionId) = 0; - virtual int32_t NotifyMissionsChangedFromRemote(const std::vector& missionInfos, + virtual int32_t NotifyMissionsChangedFromRemote(const std::vector& missionInfos, const CallerInfo& callerInfo) = 0; virtual int32_t CheckSupportOsd(const std::string& deviceId) = 0; virtual void GetCachedOsdSwitch(std::vector& deviceIds, std::vector& values) = 0; virtual int32_t GetOsdSwitchValueFromRemote() = 0; virtual int32_t UpdateOsdSwitchValueFromRemote(int32_t switchVal, const std::string& sourceDeviceId) = 0; - virtual int32_t PrepareAndSyncMissionsFromRemote(const CallerInfo& callerInfo, - std::vector& missionInfos) = 0; - virtual int32_t UnRegisterMissionListenerFromRemote(const CallerInfo& callerInfo) = 0; enum { START_REMOTE_ABILITY = 1, STOP_REMOTE_ABILITY = 3, @@ -95,17 +95,19 @@ public: REMOVE_SNAPSHOT_INFO = 83, REGISTER_MISSION_LISTENER = 84, UNREGISTER_MISSION_LISTENER = 85, - PREPARE_AND_SYNC_MISSIONS_FROM_REMOTE = 86, - UNREGISTER_MISSION_LISTENER_FROM_REMOTE = 87, + START_SYNC_MISSIONS_FROM_REMOTE = 86, + STOP_SYNC_MISSIONS_FROM_REMOTE = 87, CHECK_SUPPORTED_OSD = 88, CHECK_SUPPORT_OSD_FROM_REMOTE = 89, MISSION_CHANGED = 90, NOTIFY_MISSIONS_CHANGED_FROM_REMOTE = 91, - PREPARE_AND_SYNC_MISSIONS = 92, + START_SYNC_MISSIONS = 92, TRY_OPENP2PSESSION_FROM_REMOTE = 93, SWITCH_CHANGED = 94, NOTIFY_SWITCH_CHANGED_FROM_REMOTE = 95, GET_CACHED_SUPPORTED_OSD = 96, + ALL_CONNECT_TO_DMS = 97, + STOP_SYNC_MISSIONS = 98, }; }; } // namespace DistributedSchedule diff --git a/services/dtbschedmgr/include/distributed_sched_proxy.h b/services/dtbschedmgr/include/distributed_sched_proxy.h index 4d6b6c0e..355778ac 100644 --- a/services/dtbschedmgr/include/distributed_sched_proxy.h +++ b/services/dtbschedmgr/include/distributed_sched_proxy.h @@ -18,6 +18,8 @@ #include "distributed_sched_interface.h" #include "iremote_proxy.h" +#include "mission_info.h" +#include "mission/distributed_mission_info.h" namespace OHOS { namespace DistributedSchedule { @@ -42,23 +44,24 @@ public: int32_t DisconnectAbilityFromRemote(const sptr& connect, int32_t uid, const std::string& sourceDeviceId) override; int32_t NotifyProcessDiedFromRemote(const CallerInfo& callerInfo) override; - int32_t PrepareAndSyncMissions(const std::u16string& devId, bool fixConflict, int64_t tag) override; - int32_t RegisterRemoteMissionListener(const std::u16string& devId, const sptr& obj) override; - int32_t UnRegisterRemoteMissionListener(const std::u16string& devId, const sptr& obj) override; + int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override; + int32_t StopSyncRemoteMissions(const std::string& devId) override; + int32_t RegisterMissionListener(const std::u16string& devId, const sptr& obj) override; + int32_t UnRegisterMissionListener(const std::u16string& devId, const sptr& obj) override; int32_t GetMissionInfos(const std::string& deviceId, int32_t numMissions, - std::vector& missionInfos) override; + std::vector& missionInfos) override; int32_t StoreSnapshotInfo(const std::string& deviceId, int32_t missionId, const uint8_t* byteStream, size_t len) override; int32_t RemoveSnapshotInfo(const std::string& deviceId, int32_t missionId) override; - int32_t NotifyMissionsChangedFromRemote(const std::vector& missionInfos, + int32_t NotifyMissionsChangedFromRemote(const std::vector& missionInfos, const CallerInfo& callerInfo) override; int32_t CheckSupportOsd(const std::string& deviceId) override; void GetCachedOsdSwitch(std::vector& deviceIds, std::vector& values) override; int32_t GetOsdSwitchValueFromRemote() override; int32_t UpdateOsdSwitchValueFromRemote(int32_t switchVal, const std::string& sourceDeviceId) override; - int32_t PrepareAndSyncMissionsFromRemote(const CallerInfo& callerInfo, - std::vector& missionInfos) override; - int32_t UnRegisterMissionListenerFromRemote(const CallerInfo& callerInfo) override; + int32_t StartSyncMissionsFromRemote(const CallerInfo& callerInfo, + std::vector& missionInfos) override; + int32_t StopSyncMissionsFromRemote(const CallerInfo& callerInfo) override; private: bool CallerInfoMarshalling(const CallerInfo& callerInfo, MessageParcel& data); static inline BrokerDelegator delegator_; diff --git a/services/dtbschedmgr/include/distributed_sched_service.h b/services/dtbschedmgr/include/distributed_sched_service.h index 0f4ba735..618ba487 100644 --- a/services/dtbschedmgr/include/distributed_sched_service.h +++ b/services/dtbschedmgr/include/distributed_sched_service.h @@ -25,7 +25,7 @@ #include "distributed_sched_continuation.h" #include "iremote_object.h" #include "iremote_proxy.h" -#include "mission/mission_info.h" +#include "mission/distributed_mission_info.h" #include "nocopyable.h" #include "single_instance.h" #include "system_ability.h" @@ -74,11 +74,11 @@ public: int32_t uid, const std::string& sourceDeviceId) override; int32_t NotifyProcessDiedFromRemote(const CallerInfo& callerInfo) override; int32_t GetMissionInfos(const std::string& deviceId, int32_t numMissions, - std::vector& missionInfos) override; + std::vector& missionInfos) override; int32_t StoreSnapshotInfo(const std::string& deviceId, int32_t missionId, const uint8_t* byteStream, size_t len) override; int32_t RemoveSnapshotInfo(const std::string& deviceId, int32_t missionId) override; - int32_t NotifyMissionsChangedFromRemote(const std::vector& missionInfos, + int32_t NotifyMissionsChangedFromRemote(const std::vector& missionInfos, const CallerInfo& callerInfo) override; void ProcessConnectDied(const sptr& connect); void ProcessDeviceOffline(const std::string& deviceId); @@ -91,12 +91,13 @@ public: int32_t GetOsdSwitchValueFromRemote() override; int32_t UpdateOsdSwitchValueFromRemote(int32_t switchVal, const std::string& sourceDeviceId) override; std::unique_ptr GetRemoteSnapshotInfo(const std::u16string& deviceId, int32_t missionId) override; - int32_t RegisterRemoteMissionListener(const std::u16string& devId, const sptr& obj) override; - int32_t UnRegisterRemoteMissionListener(const std::u16string& devId, const sptr& obj) override; - int32_t PrepareAndSyncMissionsFromRemote(const CallerInfo& callerInfo, - std::vector& missionInfos) override; - int32_t UnRegisterMissionListenerFromRemote(const CallerInfo& callerInfo) override; - int32_t PrepareAndSyncMissions(const std::u16string& devId, bool fixConflict, int64_t tag) override; + int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override; + int32_t StartSyncMissionsFromRemote(const CallerInfo& callerInfo, + std::vector& missionInfos) override; + int32_t StopSyncRemoteMissions(const std::string& devId) override; + int32_t StopSyncMissionsFromRemote(const CallerInfo& callerInfo) override; + int32_t RegisterMissionListener(const std::u16string& devId, const sptr& obj) override; + int32_t UnRegisterMissionListener(const std::u16string& devId, const sptr& obj) override; private: DistributedSchedService(); bool Init(); diff --git a/services/dtbschedmgr/include/distributed_sched_stub.h b/services/dtbschedmgr/include/distributed_sched_stub.h index e1970745..d15c2523 100644 --- a/services/dtbschedmgr/include/distributed_sched_stub.h +++ b/services/dtbschedmgr/include/distributed_sched_stub.h @@ -53,13 +53,14 @@ private: int32_t StoreSnapshotInfoInner(MessageParcel& data, MessageParcel& reply); int32_t RemoveSnapshotInfoInner(MessageParcel& data, MessageParcel& reply); int32_t GetRemoteSnapshotInfoInner(MessageParcel& data, MessageParcel& reply); - int32_t RegisterRemoteMissionListenerInner(MessageParcel& data, MessageParcel& reply); - int32_t PrepareAndSyncMissionsFromRemoteInner(MessageParcel& data, MessageParcel& reply); - int32_t UnRegisterRemoteMissionListenerInner(MessageParcel& data, MessageParcel& reply); - int32_t UnRegisterMissionListenerFromRemoteInner(MessageParcel& data, MessageParcel& reply); + int32_t RegisterMissionListenerInner(MessageParcel& data, MessageParcel& reply); + int32_t UnRegisterMissionListenerInner(MessageParcel& data, MessageParcel& reply); + int32_t StartSyncRemoteMissionsInner(MessageParcel& data, MessageParcel& reply); + int32_t StartSyncMissionsFromRemoteInner(MessageParcel& data, MessageParcel& reply); + int32_t StopSyncRemoteMissionsInner(MessageParcel& data, MessageParcel& reply); + int32_t StopSyncMissionsFromRemoteInner(MessageParcel& data, MessageParcel& reply); int32_t NotifyLocalMissionsChangedInner(MessageParcel& data, MessageParcel& reply); int32_t NotifyMissionsChangedFromRemoteInner(MessageParcel& data, MessageParcel& reply); - int32_t PrepareAndSyncMissionsInner(MessageParcel& data, MessageParcel& reply); bool CheckCallingUid(); int32_t NotifyOsdSwitchChangedInner(MessageParcel& data, MessageParcel& reply); int32_t UpdateOsdSwitchValueFromRemoteInner(MessageParcel& data, MessageParcel& reply); diff --git a/services/dtbschedmgr/include/mission/mission_info.h b/services/dtbschedmgr/include/mission/distributed_mission_info.h similarity index 89% rename from services/dtbschedmgr/include/mission/mission_info.h rename to services/dtbschedmgr/include/mission/distributed_mission_info.h index 231aba1e..f57a8155 100644 --- a/services/dtbschedmgr/include/mission/mission_info.h +++ b/services/dtbschedmgr/include/mission/distributed_mission_info.h @@ -26,7 +26,7 @@ namespace OHOS { namespace DistributedSchedule { -struct MissionInfo : public Parcelable { +struct DstbMissionInfo : public Parcelable { int32_t id = -1; int32_t runingState = -1; int32_t userId = 0; @@ -48,17 +48,17 @@ struct MissionInfo : public Parcelable { std::string iconPath; int32_t color = 0; int32_t windowType = 0; - bool supportsMultiWindow = false; + bool lockedState = false; int32_t missionType = INT_MAX; int32_t windowTypeMode = 0; bool ReadFromParcel(Parcel& parcel); virtual bool Marshalling(Parcel& parcel) const override; - static MissionInfo* Unmarshalling(Parcel& parcel); + static DstbMissionInfo* Unmarshalling(Parcel& parcel); std::string ToString() const; - static bool ReadMissionInfoVectorFromParcel(Parcel& parcel, std::vector &missionInfos); - static bool WriteMissionInfoVectorFromParcel(Parcel& parcel, const std::vector &missionInfos); + static bool ReadMissionInfoVectorFromParcel(Parcel& parcel, std::vector &missionInfos); + static bool WriteMissionInfoVectorFromParcel(Parcel& parcel, const std::vector &missionInfos); }; } // namespace DistributedSchedule } // namespace OHOS diff --git a/services/dtbschedmgr/include/mission/distributed_sched_mission_manager.h b/services/dtbschedmgr/include/mission/distributed_sched_mission_manager.h index a04f98cf..c8842d1c 100644 --- a/services/dtbschedmgr/include/mission/distributed_sched_mission_manager.h +++ b/services/dtbschedmgr/include/mission/distributed_sched_mission_manager.h @@ -71,7 +71,8 @@ class DistributedSchedMissionManager { public: void Init(); - int32_t GetMissionInfos(const std::string& deviceId, int32_t numMissions, std::vector& missionInfos); + int32_t GetMissionInfos(const std::string& deviceId, int32_t numMissions, + std::vector& missionInfos); int32_t InitDataStorage(); int32_t StopDataStorage(); int32_t StoreSnapshotInfo(const std::string& deviceId, @@ -83,10 +84,12 @@ public: void DeviceOnlineNotify(const std::string& deviceId); void DeviceOfflineNotify(const std::string& deviceId); void DeleteDataStorage(const std::string& deviceId, bool isDelayed); - int32_t RegisterRemoteMissionListener(const std::u16string& devId, const sptr& obj); - int32_t UnRegisterRemoteMissionListener(const std::u16string& devId, const sptr& obj); - int32_t PrepareAndSyncMissionsFromRemote(const CallerInfo& callerInfo, std::vector& missionInfos); - void UnRegisterMissionListenerFromRemote(const std::string& deviceId); + int32_t RegisterMissionListener(const std::u16string& devId, const sptr& obj); + int32_t UnRegisterMissionListener(const std::u16string& devId, const sptr& obj); + int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag); + int32_t StartSyncMissionsFromRemote(const CallerInfo& callerInfo, std::vector& missionInfos); + int32_t StopSyncRemoteMissions(const std::string& dstDevId, bool offline, bool exit = false); + void StopSyncMissionsFromRemote(const std::string& deviceId); bool needSyncDevice(const std::string& deviceId); void NotifySnapshotChanged(const std::string& devId, int32_t missionId); @@ -94,8 +97,9 @@ public: void EnqueueCachedSnapshotInfo(const std::string& deviceId, int32_t missionId, std::unique_ptr snapshot); std::unique_ptr DequeueCachedSnapshotInfo(const std::string& deviceId, int32_t missionId); - int32_t NotifyMissionsChangedToRemote(const std::vector& missionInfos); - int32_t NotifyMissionsChangedFromRemote(const CallerInfo& callerInfo, const std::vector& missionInfos); + int32_t NotifyMissionsChangedToRemote(const std::vector& missionInfos); + int32_t NotifyMissionsChangedFromRemote(const CallerInfo& callerInfo, + const std::vector& missionInfos); int32_t CheckSupportOsd(const std::string& deviceId); int32_t CheckOsdSwitch(const std::string& deviceId); void GetCachedOsdSwitch(std::vector& deviceIds, std::vector& values); @@ -104,35 +108,34 @@ public: int32_t UpdateSwitchValueToRemote(); void UpdateConnCapSupportOsd(const std::string& deviceId); void NotifyOsdSwitchChanged(bool needNotifyChanged); - int32_t PrepareAndSyncMissions(const std::u16string& devId, bool fixConflict, int64_t tag); void OnRemoteDmsDied(const wptr& remote); void NotifyDmsProxyProcessDied(); void OnDnetDied(); private: std::map> deviceHandle_; mutable std::mutex remoteMissionInfosLock_; - std::map> deviceMissionInfos_; + std::map> deviceMissionInfos_; sptr GetRemoteDms(const std::string& deviceId); bool IsDeviceIdValidated(const std::string& deviceId); std::shared_ptr FetchDeviceHandler(const std::string& deviceId); bool GenerateCallerInfo(CallerInfo& callerInfo); void NotifyMissionsChangedToRemoteInner(const std::string& remoteUuid, - const std::vector& missionInfos, const CallerInfo& callerInfo); + const std::vector& missionInfos, const CallerInfo& callerInfo); std::string GenerateKeyInfo(const std::string& devId, int32_t missionId) { return devId + "_" + std::to_string(missionId); } bool AllowMissionUid(int32_t uid); - int32_t PrepareAndSyncMissions(const std::string& dstDevId, const std::string& localDevId); - int32_t PrepareAndSyncMissions(const std::string& dstDevId, const sptr& remoteDms); - int32_t UnRegisterRemoteMissionListenerInner(const std::string& dstDevId, bool offline, bool exit = false); + int32_t StartSyncRemoteMissions(const std::string& dstDevId, const std::string& localDevId); + int32_t StartSyncRemoteMissions(const std::string& dstDevId, const sptr& remoteDms); void CleanMissionResources(const std::string& dstDevId); - void RetryStartRemoteSyncMission(const std::string& dstDeviceId, const std::string& localDevId, int32_t retryTimes); + void RetryStartSyncRemoteMissions(const std::string& dstDeviceId, const std::string& localDevId, + int32_t retryTimes); bool HasSyncListener(const std::string& dstDeviceId); void DeleteCachedSnapshotInfo(const std::string& networkId); int32_t FetchCachedRemoteMissions(const std::string& srcId, int32_t numMissions, - std::vector& missionInfos); - void RebornMissionCache(const std::string& deviceId, const std::vector& missionInfos); + std::vector& missionInfos); + void RebornMissionCache(const std::string& deviceId, const std::vector& missionInfos); void CleanMissionCache(const std::string& deviceId); void UpdateSwitchValueToRemoteInner(std::set& remoteSyncDeviceSet, const std::string& localNetworkId); diff --git a/services/dtbschedmgr/include/mission/mission_info_converter.h b/services/dtbschedmgr/include/mission/mission_info_converter.h index fb238d3b..be6fe497 100644 --- a/services/dtbschedmgr/include/mission/mission_info_converter.h +++ b/services/dtbschedmgr/include/mission/mission_info_converter.h @@ -19,19 +19,17 @@ #include #include -#include "ability_mission_info.h" -#include "mission/mission_info.h" - -using AbilityMissionInfo = OHOS::AAFwk::AbilityMissionInfo; +#include "mission_info.h" +#include "mission/distributed_mission_info.h" namespace OHOS { namespace DistributedSchedule { class MissionInfoConverter { public: - static int32_t ConvertToMissionInfos(std::vector& abilityMissionInfos, - std::vector& missionInfos); - static int32_t ConvertToAbilityMissionInfos(std::vector& missionInfos, - std::vector& abilityMissionInfos); + static int32_t ConvertToDstbMissionInfos(std::vector& missionInfos, + std::vector& dstbMissionInfos); + static int32_t ConvertToMissionInfos(std::vector& dstbMissionInfos, + std::vector& missionInfos); }; } } diff --git a/services/dtbschedmgr/src/distributed_sched_adapter.cpp b/services/dtbschedmgr/src/distributed_sched_adapter.cpp index f27f1038..cad8efa3 100644 --- a/services/dtbschedmgr/src/distributed_sched_adapter.cpp +++ b/services/dtbschedmgr/src/distributed_sched_adapter.cpp @@ -190,21 +190,23 @@ int32_t DistributedSchedAdapter::GetBundleNameListFromBms(int32_t uid, std::vect return result ? ERR_OK : BUNDLE_MANAGER_SERVICE_ERR; } -int32_t DistributedSchedAdapter::GetLocalMissionInfos(int32_t numMissions, std::vector& missionInfos) +int32_t DistributedSchedAdapter::GetLocalMissionInfos(int32_t numMissions, + std::vector& missionInfos) + { ErrCode errCode = AAFwk::AbilityManagerClient::GetInstance()->Connect(); if (errCode != ERR_OK) { HILOGE("get ability server failed, errCode=%{public}d", errCode); return errCode; } - std::vector abilityMissions; - ErrCode ret = AAFwk::AbilityManagerClient::GetInstance()->GetRecentMissions(numMissions, - RECENT_WITH_EXCLUDED, abilityMissions); + std::vector amsMissions; + ErrCode ret = AAFwk::AbilityManagerClient::GetInstance()->GetMissionInfos("", numMissions, amsMissions); if (ret != ERR_OK) { HILOGE("GetRecentMissions failed, ret=%{public}d", ret); return ret; } - return MissionInfoConverter::ConvertToMissionInfos(abilityMissions, missionInfos); + HILOGI("GetMissionInfos size:%{public}zu", amsMissions.size()); + return MissionInfoConverter::ConvertToDstbMissionInfos(amsMissions, missionInfos); } bool DistributedSchedAdapter::AllowMissionUid(int32_t uid) diff --git a/services/dtbschedmgr/src/distributed_sched_proxy.cpp b/services/dtbschedmgr/src/distributed_sched_proxy.cpp index aec4952b..3c991c38 100644 --- a/services/dtbschedmgr/src/distributed_sched_proxy.cpp +++ b/services/dtbschedmgr/src/distributed_sched_proxy.cpp @@ -18,6 +18,7 @@ #include "dtbschedmgr_log.h" #include "ipc_types.h" +#include "mission/mission_info_converter.h" #include "parcel_helper.h" #include "string_ex.h" @@ -256,7 +257,7 @@ int32_t DistributedSchedProxy::NotifyProcessDiedFromRemote(const CallerInfo& cal PARCEL_TRANSACT_SYNC_RET_INT(remote, NOTIFY_PROCESS_DIED_FROM_REMOTE, data, reply); } -int32_t DistributedSchedProxy::PrepareAndSyncMissions(const std::u16string& devId, bool fixConflict, int64_t tag) +int32_t DistributedSchedProxy::StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) { HILOGI("called"); sptr remote = Remote(); @@ -270,26 +271,96 @@ int32_t DistributedSchedProxy::PrepareAndSyncMissions(const std::u16string& devI if (!data.WriteInterfaceToken(DMS_PROXY_INTERFACE_TOKEN)) { return ERR_FLATTEN_OBJECT; } - PARCEL_WRITE_HELPER(data, String16, devId); + PARCEL_WRITE_HELPER(data, String16, Str8ToStr16(devId)); PARCEL_WRITE_HELPER(data, Bool, fixConflict); PARCEL_WRITE_HELPER(data, Int64, tag); - PARCEL_TRANSACT_SYNC_RET_INT(remote, PREPARE_AND_SYNC_MISSIONS, data, reply); + PARCEL_TRANSACT_SYNC_RET_INT(remote, START_SYNC_MISSIONS, data, reply); } -int32_t DistributedSchedProxy::RegisterRemoteMissionListener(const std::u16string& devId, +int32_t DistributedSchedProxy::StartSyncMissionsFromRemote(const CallerInfo& callerInfo, + std::vector& missionInfos) +{ + HILOGI("called"); + sptr remote = Remote(); + if (remote == nullptr) { + HILOGE("remote service is null"); + return ERR_NULL_OBJECT; + } + MessageParcel data; + MessageParcel reply; + MessageOption option { MessageOption::TF_SYNC, WAIT_TIME }; + if (!data.WriteInterfaceToken(DMS_PROXY_INTERFACE_TOKEN)) { + return ERR_FLATTEN_OBJECT; + } + if (!CallerInfoMarshalling(callerInfo, data)) { + return ERR_FLATTEN_OBJECT; + } + int32_t error = remote->SendRequest(START_SYNC_MISSIONS_FROM_REMOTE, data, reply, option); + if (error != ERR_NONE) { + HILOGW("fail, error: %{public}d", error); + return error; + } + int32_t version = reply.ReadInt32(); + HILOGD("version : %{public}d", version); + return DstbMissionInfo::ReadMissionInfoVectorFromParcel(reply, missionInfos) ? ERR_NONE : ERR_FLATTEN_OBJECT; +} + +int32_t DistributedSchedProxy::StopSyncRemoteMissions(const std::string& devId) +{ + HILOGI("called"); + sptr remote = Remote(); + if (remote == nullptr) { + HILOGE("remote system abiity is null"); + return ERR_NULL_OBJECT; + } + MessageParcel data; + MessageParcel reply; + if (!data.WriteInterfaceToken(DMS_PROXY_INTERFACE_TOKEN)) { + return ERR_FLATTEN_OBJECT; + } + PARCEL_WRITE_HELPER(data, String16, Str8ToStr16(devId)); + PARCEL_TRANSACT_SYNC_RET_INT(remote, STOP_SYNC_MISSIONS, data, reply); +} + +int32_t DistributedSchedProxy::StopSyncMissionsFromRemote(const CallerInfo& callerInfo) +{ + HILOGI("called"); + sptr remote = Remote(); + if (remote == nullptr) { + HILOGE("remote service is null"); + return ERR_NULL_OBJECT; + } + MessageParcel data; + MessageParcel reply; + MessageOption option { MessageOption::TF_SYNC, WAIT_TIME }; + if (!data.WriteInterfaceToken(DMS_PROXY_INTERFACE_TOKEN)) { + return ERR_FLATTEN_OBJECT; + } + if (!CallerInfoMarshalling(callerInfo, data)) { + return ERR_FLATTEN_OBJECT; + } + int32_t error = remote->SendRequest(STOP_SYNC_MISSIONS_FROM_REMOTE, data, reply, option); + if (error != ERR_NONE) { + HILOGW("sendRequest fail, error: %{public}d", error); + return error; + } + return reply.ReadInt32(); +} + +int32_t DistributedSchedProxy::RegisterMissionListener(const std::u16string& devId, const sptr& obj) { return ERR_NONE; } -int32_t DistributedSchedProxy::UnRegisterRemoteMissionListener(const std::u16string& devId, +int32_t DistributedSchedProxy::UnRegisterMissionListener(const std::u16string& devId, const sptr& obj) { return ERR_NONE; } int32_t DistributedSchedProxy::GetMissionInfos(const std::string& deviceId, int32_t numMissions, - std::vector& missionInfos) + std::vector& missionInfos) { HILOGI("called"); sptr remote = Remote(); @@ -311,10 +382,10 @@ int32_t DistributedSchedProxy::GetMissionInfos(const std::string& deviceId, int3 HILOGW("sendRequest fail, error: %{public}d", ret); return ret; } - return MissionInfo::ReadMissionInfoVectorFromParcel(reply, missionInfos) ? ERR_NONE : ERR_FLATTEN_OBJECT; + return DstbMissionInfo::ReadMissionInfoVectorFromParcel(reply, missionInfos) ? ERR_NONE : ERR_FLATTEN_OBJECT; } -int32_t DistributedSchedProxy::NotifyMissionsChangedFromRemote(const std::vector& missionInfos, +int32_t DistributedSchedProxy::NotifyMissionsChangedFromRemote(const std::vector& missionInfos, const CallerInfo& callerInfo) { HILOGI("NotifyMissionsChangedFromRemote is called"); @@ -329,7 +400,7 @@ int32_t DistributedSchedProxy::NotifyMissionsChangedFromRemote(const std::vector return ERR_FLATTEN_OBJECT; } PARCEL_WRITE_HELPER(data, Int32, callerInfo.dmsVersion); - if (!MissionInfo::WriteMissionInfoVectorFromParcel(data, missionInfos)) { + if (!DstbMissionInfo::WriteMissionInfoVectorFromParcel(data, missionInfos)) { return ERR_FLATTEN_OBJECT; } PARCEL_WRITE_HELPER(data, String, callerInfo.sourceDeviceId); @@ -428,59 +499,6 @@ int32_t DistributedSchedProxy::RemoveSnapshotInfo(const std::string& deviceId, i return ERR_NONE; } -int32_t DistributedSchedProxy::PrepareAndSyncMissionsFromRemote(const CallerInfo& callerInfo, - std::vector& missionInfos) -{ - HILOGI("called"); - sptr remote = Remote(); - if (remote == nullptr) { - HILOGE("remote service is null"); - return ERR_NULL_OBJECT; - } - MessageParcel data; - MessageParcel reply; - MessageOption option { MessageOption::TF_SYNC, WAIT_TIME }; - if (!data.WriteInterfaceToken(DMS_PROXY_INTERFACE_TOKEN)) { - return ERR_FLATTEN_OBJECT; - } - if (!CallerInfoMarshalling(callerInfo, data)) { - return ERR_FLATTEN_OBJECT; - } - int32_t error = remote->SendRequest(PREPARE_AND_SYNC_MISSIONS_FROM_REMOTE, data, reply, option); - if (error != ERR_NONE) { - HILOGW("fail, error: %{public}d", error); - return error; - } - int32_t version = reply.ReadInt32(); - HILOGD("version : %{public}d", version); - return MissionInfo::ReadMissionInfoVectorFromParcel(reply, missionInfos) ? ERR_NONE : ERR_FLATTEN_OBJECT; -} - -int32_t DistributedSchedProxy::UnRegisterMissionListenerFromRemote(const CallerInfo& callerInfo) -{ - HILOGI("called"); - sptr remote = Remote(); - if (remote == nullptr) { - HILOGE("remote service is null"); - return ERR_NULL_OBJECT; - } - MessageParcel data; - MessageParcel reply; - MessageOption option { MessageOption::TF_SYNC, WAIT_TIME }; - if (!data.WriteInterfaceToken(DMS_PROXY_INTERFACE_TOKEN)) { - return ERR_FLATTEN_OBJECT; - } - if (!CallerInfoMarshalling(callerInfo, data)) { - return ERR_FLATTEN_OBJECT; - } - int32_t error = remote->SendRequest(UNREGISTER_MISSION_LISTENER_FROM_REMOTE, data, reply, option); - if (error != ERR_NONE) { - HILOGW("sendRequest fail, error: %{public}d", error); - return error; - } - return reply.ReadInt32(); -} - int32_t DistributedSchedProxy::UpdateOsdSwitchValueFromRemote(int32_t switchVal, const std::string& sourceDeviceId) { diff --git a/services/dtbschedmgr/src/distributed_sched_service.cpp b/services/dtbschedmgr/src/distributed_sched_service.cpp index c6d41cb2..9132dbd0 100644 --- a/services/dtbschedmgr/src/distributed_sched_service.cpp +++ b/services/dtbschedmgr/src/distributed_sched_service.cpp @@ -33,8 +33,8 @@ #include "file_ex.h" #include "ipc_skeleton.h" #include "iservice_registry.h" +#include "mission/distributed_mission_info.h" #include "mission/distributed_sched_mission_manager.h" -#include "mission/mission_info.h" #include "parcel_helper.h" #include "string_ex.h" #include "system_ability_definition.h" @@ -884,12 +884,12 @@ void DistributedSchedService::DumpElementLocked(const std::list& missionInfos) + std::vector& missionInfos) { return DistributedSchedMissionManager::GetInstance().GetMissionInfos(deviceId, numMissions, missionInfos); } -int32_t DistributedSchedService::NotifyMissionsChangedFromRemote(const std::vector& missionInfos, +int32_t DistributedSchedService::NotifyMissionsChangedFromRemote(const std::vector& missionInfos, const CallerInfo& callerInfo) { return DistributedSchedMissionManager::GetInstance() @@ -930,27 +930,37 @@ int32_t DistributedSchedService::RemoveSnapshotInfo(const std::string& deviceId, return DistributedSchedMissionManager::GetInstance().RemoveSnapshotInfo(deviceId, missionId); } -int32_t DistributedSchedService::RegisterRemoteMissionListener(const std::u16string& devId, +int32_t DistributedSchedService::RegisterMissionListener(const std::u16string& devId, const sptr& obj) { - return DistributedSchedMissionManager::GetInstance().RegisterRemoteMissionListener(devId, obj); + return DistributedSchedMissionManager::GetInstance().RegisterMissionListener(devId, obj); } -int32_t DistributedSchedService::UnRegisterRemoteMissionListener(const std::u16string& devId, +int32_t DistributedSchedService::UnRegisterMissionListener(const std::u16string& devId, const sptr& obj) { - return DistributedSchedMissionManager::GetInstance().UnRegisterRemoteMissionListener(devId, obj); + return DistributedSchedMissionManager::GetInstance().UnRegisterMissionListener(devId, obj); } -int32_t DistributedSchedService::PrepareAndSyncMissionsFromRemote(const CallerInfo& callerInfo, - std::vector& missionInfos) +int32_t DistributedSchedService::StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) { - return DistributedSchedMissionManager::GetInstance().PrepareAndSyncMissionsFromRemote(callerInfo, missionInfos); + return DistributedSchedMissionManager::GetInstance().StartSyncRemoteMissions(devId, fixConflict, tag); } -int32_t DistributedSchedService::UnRegisterMissionListenerFromRemote(const CallerInfo& callerInfo) +int32_t DistributedSchedService::StopSyncRemoteMissions(const std::string& devId) { - DistributedSchedMissionManager::GetInstance().UnRegisterMissionListenerFromRemote(callerInfo.sourceDeviceId); + return DistributedSchedMissionManager::GetInstance().StopSyncRemoteMissions(devId, false, true); +} + +int32_t DistributedSchedService::StartSyncMissionsFromRemote(const CallerInfo& callerInfo, + std::vector& missionInfos) +{ + return DistributedSchedMissionManager::GetInstance().StartSyncMissionsFromRemote(callerInfo, missionInfos); +} + +int32_t DistributedSchedService::StopSyncMissionsFromRemote(const CallerInfo& callerInfo) +{ + DistributedSchedMissionManager::GetInstance().StopSyncMissionsFromRemote(callerInfo.sourceDeviceId); return ERR_NONE; } @@ -960,10 +970,5 @@ int32_t DistributedSchedService::UpdateOsdSwitchValueFromRemote(int32_t switchVa return DistributedSchedMissionManager::GetInstance() .UpdateOsdSwitchValueFromRemote(switchVal, sourceDeviceId); } - -int32_t DistributedSchedService::PrepareAndSyncMissions(const std::u16string& devId, bool fixConflict, int64_t tag) -{ - return DistributedSchedMissionManager::GetInstance().PrepareAndSyncMissions(devId, fixConflict, tag); -} } // namespace DistributedSchedule } // namespace OHOS \ No newline at end of file diff --git a/services/dtbschedmgr/src/distributed_sched_stub.cpp b/services/dtbschedmgr/src/distributed_sched_stub.cpp index b3e88420..fa7deed8 100644 --- a/services/dtbschedmgr/src/distributed_sched_stub.cpp +++ b/services/dtbschedmgr/src/distributed_sched_stub.cpp @@ -51,11 +51,12 @@ DistributedSchedStub::DistributedSchedStub() localFuncsMap_[STORE_SNAPSHOT_INFO] = &DistributedSchedStub::StoreSnapshotInfoInner; localFuncsMap_[REMOVE_SNAPSHOT_INFO] = &DistributedSchedStub::RemoveSnapshotInfoInner; localFuncsMap_[GET_REMOTE_SNAPSHOT_INFO] = &DistributedSchedStub::GetRemoteSnapshotInfoInner; - localFuncsMap_[REGISTER_MISSION_LISTENER] = &DistributedSchedStub::RegisterRemoteMissionListenerInner; - localFuncsMap_[UNREGISTER_MISSION_LISTENER] = &DistributedSchedStub::UnRegisterRemoteMissionListenerInner; + localFuncsMap_[REGISTER_MISSION_LISTENER] = &DistributedSchedStub::RegisterMissionListenerInner; + localFuncsMap_[UNREGISTER_MISSION_LISTENER] = &DistributedSchedStub::UnRegisterMissionListenerInner; localFuncsMap_[GET_MISSION_INFOS] = &DistributedSchedStub::GetMissionInfosInner; localFuncsMap_[MISSION_CHANGED] = &DistributedSchedStub::NotifyLocalMissionsChangedInner; - localFuncsMap_[PREPARE_AND_SYNC_MISSIONS] = &DistributedSchedStub::PrepareAndSyncMissionsInner; + localFuncsMap_[START_SYNC_MISSIONS] = &DistributedSchedStub::StartSyncRemoteMissionsInner; + localFuncsMap_[STOP_SYNC_MISSIONS] = &DistributedSchedStub::StopSyncRemoteMissionsInner; localFuncsMap_[SWITCH_CHANGED] = &DistributedSchedStub::NotifyOsdSwitchChangedInner; localFuncsMap_[GET_CACHED_SUPPORTED_OSD] = &DistributedSchedStub::GetCachedOsdSwitchInner; @@ -67,10 +68,10 @@ DistributedSchedStub::DistributedSchedStub() remoteFuncsMap_[NOTIFY_PROCESS_DIED_FROM_REMOTE] = &DistributedSchedStub::NotifyProcessDiedFromRemoteInner; // request codes for mission mananger remoteFuncsMap_[CHECK_SUPPORT_OSD_FROM_REMOTE] = &DistributedSchedStub::GetOsdSwitchValueFromRemoteInner; - remoteFuncsMap_[PREPARE_AND_SYNC_MISSIONS_FROM_REMOTE] = - &DistributedSchedStub::PrepareAndSyncMissionsFromRemoteInner; - remoteFuncsMap_[UNREGISTER_MISSION_LISTENER_FROM_REMOTE] = - &DistributedSchedStub::UnRegisterMissionListenerFromRemoteInner; + remoteFuncsMap_[START_SYNC_MISSIONS_FROM_REMOTE] = + &DistributedSchedStub::StartSyncMissionsFromRemoteInner; + remoteFuncsMap_[STOP_SYNC_MISSIONS_FROM_REMOTE] = + &DistributedSchedStub::StopSyncMissionsFromRemoteInner; remoteFuncsMap_[NOTIFY_MISSIONS_CHANGED_FROM_REMOTE] = &DistributedSchedStub::NotifyMissionsChangedFromRemoteInner; remoteFuncsMap_[NOTIFY_SWITCH_CHANGED_FROM_REMOTE] = &DistributedSchedStub::UpdateOsdSwitchValueFromRemoteInner; } @@ -333,11 +334,11 @@ int32_t DistributedSchedStub::GetMissionInfosInner(MessageParcel& data, MessageP int32_t numMissions = 0; PARCEL_READ_HELPER(data, Int32, numMissions); - std::vector missionInfos; + std::vector missionInfos; int result = GetMissionInfos(Str16ToStr8(deviceId), numMissions, missionInfos); HILOGI("result = %{public}d", result); if (result == ERR_NONE) { - return MissionInfo::WriteMissionInfoVectorFromParcel(reply, missionInfos) ? ERR_NONE : ERR_FLATTEN_OBJECT; + return DstbMissionInfo::WriteMissionInfoVectorFromParcel(reply, missionInfos) ? ERR_NONE : ERR_FLATTEN_OBJECT; } return ERR_NULL_OBJECT; } @@ -372,11 +373,11 @@ int32_t DistributedSchedStub::GetRemoteSnapshotInfoInner(MessageParcel& data, Me return ERR_NONE; } -int32_t DistributedSchedStub::RegisterRemoteMissionListenerInner(MessageParcel& data, MessageParcel& reply) +int32_t DistributedSchedStub::RegisterMissionListenerInner(MessageParcel& data, MessageParcel& reply) { HILOGI("[PerformanceTest] called, IPC end = %{public}" PRId64, GetTickCount()); if (!EnforceInterfaceToken(data)) { - HILOGW("RegisterRemoteMissionListenerInner interface token check failed!"); + HILOGW("RegisterMissionListenerInner interface token check failed!"); return DMS_PERMISSION_DENIED; } u16string devId = data.ReadString16(); @@ -389,32 +390,11 @@ int32_t DistributedSchedStub::RegisterRemoteMissionListenerInner(MessageParcel& HILOGW("read IRemoteObject failed!"); return ERR_FLATTEN_OBJECT; } - int32_t result = RegisterRemoteMissionListener(devId, missionChangedListener); + int32_t result = RegisterMissionListener(devId, missionChangedListener); PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result); } -int32_t DistributedSchedStub::PrepareAndSyncMissionsFromRemoteInner(MessageParcel& data, MessageParcel& reply) -{ - CallerInfo callerInfo; - if (!CallerInfoUnmarshalling(callerInfo, data)) { - HILOGW("read callerInfo failed!"); - return ERR_FLATTEN_OBJECT; - } - std::vector missionInfos; - if (PrepareAndSyncMissionsFromRemote(callerInfo, missionInfos) != ERR_NONE) { - return ERR_FLATTEN_OBJECT; - } - if (!reply.WriteInt32(VERSION)) { - return ERR_FLATTEN_OBJECT; - } - if (!MissionInfo::WriteMissionInfoVectorFromParcel(reply, missionInfos)) { - HILOGE("write mission info failed!"); - return ERR_FLATTEN_OBJECT; - } - return ERR_NONE; -} - -int32_t DistributedSchedStub::UnRegisterRemoteMissionListenerInner(MessageParcel& data, MessageParcel& reply) +int32_t DistributedSchedStub::UnRegisterMissionListenerInner(MessageParcel& data, MessageParcel& reply) { HILOGI("[PerformanceTest] called, IPC end = %{public}" PRId64, GetTickCount()); u16string devId = data.ReadString16(); @@ -427,18 +407,51 @@ int32_t DistributedSchedStub::UnRegisterRemoteMissionListenerInner(MessageParcel HILOGW("read IRemoteObject failed!"); return ERR_FLATTEN_OBJECT; } - int32_t result = UnRegisterRemoteMissionListener(devId, missionChangedListener); + int32_t result = UnRegisterMissionListener(devId, missionChangedListener); PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result); } -int32_t DistributedSchedStub::UnRegisterMissionListenerFromRemoteInner(MessageParcel& data, MessageParcel& reply) +int32_t DistributedSchedStub::StartSyncMissionsFromRemoteInner(MessageParcel& data, MessageParcel& reply) { CallerInfo callerInfo; if (!CallerInfoUnmarshalling(callerInfo, data)) { HILOGW("read callerInfo failed!"); return ERR_FLATTEN_OBJECT; } - int32_t result = UnRegisterMissionListenerFromRemote(callerInfo); + std::vector missionInfos; + if (StartSyncMissionsFromRemote(callerInfo, missionInfos) != ERR_NONE) { + return ERR_FLATTEN_OBJECT; + } + if (!reply.WriteInt32(VERSION)) { + return ERR_FLATTEN_OBJECT; + } + if (!DstbMissionInfo::WriteMissionInfoVectorFromParcel(reply, missionInfos)) { + HILOGE("write mission info failed!"); + return ERR_FLATTEN_OBJECT; + } + return ERR_NONE; +} + +int32_t DistributedSchedStub::StopSyncRemoteMissionsInner(MessageParcel& data, MessageParcel& reply) +{ + HILOGI("[PerformanceTest] called, IPC end = %{public}" PRId64, GetTickCount()); + u16string devId = data.ReadString16(); + if (devId.empty()) { + HILOGW("read deviceId failed!"); + return ERR_FLATTEN_OBJECT; + } + int32_t result = StopSyncRemoteMissions(Str16ToStr8(devId)); + PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result); +} + +int32_t DistributedSchedStub::StopSyncMissionsFromRemoteInner(MessageParcel& data, MessageParcel& reply) +{ + CallerInfo callerInfo; + if (!CallerInfoUnmarshalling(callerInfo, data)) { + HILOGW("read callerInfo failed!"); + return ERR_FLATTEN_OBJECT; + } + int32_t result = StopSyncMissionsFromRemote(callerInfo); PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result); } @@ -469,8 +482,8 @@ int32_t DistributedSchedStub::GetCachedOsdSwitchInner(MessageParcel& data, Messa int32_t DistributedSchedStub::NotifyLocalMissionsChangedInner(MessageParcel& data, MessageParcel& reply) { - std::vector missionInfos; - if (!MissionInfo::ReadMissionInfoVectorFromParcel(data, missionInfos)) { + std::vector missionInfos; + if (!DstbMissionInfo::ReadMissionInfoVectorFromParcel(data, missionInfos)) { return ERR_FLATTEN_OBJECT; } int32_t result = DistributedSchedMissionManager::GetInstance().NotifyMissionsChangedToRemote(missionInfos); @@ -481,8 +494,8 @@ int32_t DistributedSchedStub::NotifyMissionsChangedFromRemoteInner(MessageParcel { int32_t version = data.ReadInt32(); HILOGD("version is %{public}d", version); - std::vector missionInfos; - if (!MissionInfo::ReadMissionInfoVectorFromParcel(data, missionInfos)) { + std::vector missionInfos; + if (!DstbMissionInfo::ReadMissionInfoVectorFromParcel(data, missionInfos)) { return ERR_FLATTEN_OBJECT; } CallerInfo callerInfo; @@ -557,17 +570,18 @@ int32_t DistributedSchedStub::UpdateOsdSwitchValueFromRemoteInner(MessageParcel& PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result); } -int32_t DistributedSchedStub::PrepareAndSyncMissionsInner(MessageParcel& data, MessageParcel& reply) +int32_t DistributedSchedStub::StartSyncRemoteMissionsInner(MessageParcel& data, MessageParcel& reply) { HILOGI("[PerformanceTest], IPC end = %{public}" PRId64, GetTickCount()); u16string devId = data.ReadString16(); - bool fixConflict = data.ReadBool(); - long tag = data.ReadInt64(); if (devId.empty()) { HILOGW("read deviceId failed!"); return ERR_FLATTEN_OBJECT; } - int32_t result = PrepareAndSyncMissions(devId, fixConflict, tag); + string deviceId = Str16ToStr8(devId); + bool fixConflict = data.ReadBool(); + long tag = data.ReadInt64(); + int32_t result = StartSyncRemoteMissions(deviceId, fixConflict, tag); PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result); } diff --git a/services/dtbschedmgr/src/mission/mission_info.cpp b/services/dtbschedmgr/src/mission/distributed_mission_info.cpp similarity index 86% rename from services/dtbschedmgr/src/mission/mission_info.cpp rename to services/dtbschedmgr/src/mission/distributed_mission_info.cpp index 57377345..7cfa53c9 100644 --- a/services/dtbschedmgr/src/mission/mission_info.cpp +++ b/services/dtbschedmgr/src/mission/distributed_mission_info.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "mission/mission_info.h" +#include "mission/distributed_mission_info.h" #include "adapter/adapter_constant.h" #include "dtbschedmgr_log.h" @@ -24,10 +24,10 @@ namespace OHOS { namespace DistributedSchedule { using namespace Constants::Adapter; namespace { -const std::string TAG = "MissionInfo"; +const std::string TAG = "DstbMissionInfo"; } -bool MissionInfo::ReadFromParcel(Parcel& parcel) +bool DstbMissionInfo::ReadFromParcel(Parcel& parcel) { id = parcel.ReadInt32(); runingState = parcel.ReadInt32(); @@ -52,16 +52,16 @@ bool MissionInfo::ReadFromParcel(Parcel& parcel) iconPath = Str16ToStr8(parcel.ReadString16()); color = parcel.ReadInt32(); windowType = parcel.ReadInt32(); - supportsMultiWindow = parcel.ReadBool(); + lockedState = parcel.ReadBool(); missionType = parcel.ReadInt32(); windowTypeMode = parcel.ReadInt32(); return true; } -MissionInfo* MissionInfo::Unmarshalling(Parcel& parcel) +DstbMissionInfo* DstbMissionInfo::Unmarshalling(Parcel& parcel) { - MissionInfo* info = new MissionInfo(); + DstbMissionInfo* info = new DstbMissionInfo(); if (info && !info->ReadFromParcel(parcel)) { HILOGE("read from parcel failed!"); delete info; @@ -70,7 +70,7 @@ MissionInfo* MissionInfo::Unmarshalling(Parcel& parcel) return info; } -bool MissionInfo::Marshalling(Parcel& parcel) const +bool DstbMissionInfo::Marshalling(Parcel& parcel) const { PARCEL_WRITE_HELPER_RET(parcel, Int32, id, false); PARCEL_WRITE_HELPER_RET(parcel, Int32, runingState, false); @@ -93,14 +93,15 @@ bool MissionInfo::Marshalling(Parcel& parcel) const PARCEL_WRITE_HELPER_RET(parcel, String16, Str8ToStr16(iconPath), false); PARCEL_WRITE_HELPER_RET(parcel, Int32, color, false); PARCEL_WRITE_HELPER_RET(parcel, Int32, windowType, false); - PARCEL_WRITE_HELPER_RET(parcel, Bool, supportsMultiWindow, false); + PARCEL_WRITE_HELPER_RET(parcel, Bool, lockedState, false); PARCEL_WRITE_HELPER_RET(parcel, Int32, missionType, false); PARCEL_WRITE_HELPER_RET(parcel, Int32, windowTypeMode, false); return true; } -bool MissionInfo::ReadMissionInfoVectorFromParcel(Parcel& parcel, std::vector &missionInfos) +bool DstbMissionInfo::ReadMissionInfoVectorFromParcel(Parcel& parcel, + std::vector &missionInfos) { int32_t empty = parcel.ReadInt32(); if (empty == VALUE_OBJECT) { @@ -111,16 +112,16 @@ bool MissionInfo::ReadMissionInfoVectorFromParcel(Parcel& parcel, std::vector(len); if ((size > parcel.GetReadableBytes()) || (missionInfos.max_size() < size)) { - HILOGE("Failed to read MissionInfo vector, size = %{public}zu", size); + HILOGE("Failed to read DstbMissionInfo vector, size = %{public}zu", size); return false; } missionInfos.clear(); for (size_t i = 0; i < size; i++) { - MissionInfo *ptr = parcel.ReadParcelable(); + DstbMissionInfo *ptr = parcel.ReadParcelable(); if (ptr == nullptr) { return false; } - HILOGD("read MissionInfo is:%{private}s", ptr->ToString().c_str()); + HILOGD("read DstbMissionInfo is:%{private}s", ptr->ToString().c_str()); missionInfos.emplace_back(*ptr); delete ptr; } @@ -130,7 +131,8 @@ bool MissionInfo::ReadMissionInfoVectorFromParcel(Parcel& parcel, std::vector &missionInfos) +bool DstbMissionInfo::WriteMissionInfoVectorFromParcel(Parcel& parcel, + const std::vector &missionInfos) { size_t size = missionInfos.size(); if (size == 0) { @@ -146,7 +148,7 @@ bool MissionInfo::WriteMissionInfoVectorFromParcel(Parcel& parcel, const std::ve return true; } -std::string MissionInfo::ToString() const +std::string DstbMissionInfo::ToString() const { std::string str = "id: " + std::to_string(id); str += " runingState: " + std::to_string(runingState); @@ -184,8 +186,8 @@ std::string MissionInfo::ToString() const str += " iconPath: " + iconPath; str += " color: " + std::to_string(color); str += " windowType: " + std::to_string(windowType); - str += " supportsMultiWindow: "; - str += supportsMultiWindow ? "true" : "false"; + str += " lockedState: "; + str += lockedState ? "true" : "false"; str += " missionType: " + std::to_string(missionType); str += " windowTypeMode: " + std::to_string(windowTypeMode); return str; diff --git a/services/dtbschedmgr/src/mission/distributed_sched_mission_manager.cpp b/services/dtbschedmgr/src/mission/distributed_sched_mission_manager.cpp index 0bd9c9ad..cb0853b2 100644 --- a/services/dtbschedmgr/src/mission/distributed_sched_mission_manager.cpp +++ b/services/dtbschedmgr/src/mission/distributed_sched_mission_manager.cpp @@ -67,7 +67,7 @@ void DistributedSchedMissionManager::Init() } int32_t DistributedSchedMissionManager::GetMissionInfos(const std::string& deviceId, - int32_t numMissions, std::vector& missionInfos) + int32_t numMissions, std::vector& missionInfos) { HILOGI("start!"); if (!AllowMissionUid(IPCSkeleton::GetCallingUid())) { @@ -249,7 +249,7 @@ void DistributedSchedMissionManager::DeviceOfflineNotify(const std::string& devi HILOGW("DeviceOfflineNotify deviceId empty!"); return; } - UnRegisterMissionListenerFromRemote(deviceId); + StopSyncMissionsFromRemote(deviceId); CleanMissionResources(deviceId); { std::lock_guard autoLock(remoteDmsLock_); @@ -329,7 +329,7 @@ void DistributedSchedMissionManager::DeleteDataStorage(const std::string& device } } -int32_t DistributedSchedMissionManager::RegisterRemoteMissionListener(const std::u16string& devId, +int32_t DistributedSchedMissionManager::RegisterMissionListener(const std::u16string& devId, const sptr& listener) { std::string uuid = DtbschedmgrDeviceInfoStorage::GetInstance().GetUuidByNetworkId(Str16ToStr8(devId)); @@ -363,7 +363,7 @@ int32_t DistributedSchedMissionManager::RegisterRemoteMissionListener(const std: HILOGW("RegisterSyncListener AddDeathRecipient failed!"); } if (listenerInfo.Size() > 1) { - HILOGI("RegisterRemoteMissionListener not notify remote DMS!"); + HILOGI("RegisterMissionListener not notify remote DMS!"); return ERR_NONE; } } @@ -375,7 +375,7 @@ int32_t DistributedSchedMissionManager::RegisterRemoteMissionListener(const std: return ERR_NONE; } -int32_t DistributedSchedMissionManager::PrepareAndSyncMissions(const std::string& dstDevId, +int32_t DistributedSchedMissionManager::StartSyncRemoteMissions(const std::string& dstDevId, const std::string& localDevId) { std::u16string devId = Str8ToStr16(dstDevId); @@ -386,16 +386,16 @@ int32_t DistributedSchedMissionManager::PrepareAndSyncMissions(const std::string } bool callFlag = iterItem->second.called; if (callFlag) { - HILOGI("PrepareAndSyncMissions already called!"); + HILOGI("StartSyncRemoteMissions already called!"); } } sptr remoteDms = GetRemoteDms(dstDevId); if (remoteDms == nullptr) { HILOGE("get remoteDms failed!"); - RetryStartRemoteSyncMission(dstDevId, localDevId, 0); + RetryStartSyncRemoteMissions(dstDevId, localDevId, 0); return GET_REMOTE_DMS_FAIL; } - int32_t ret = PrepareAndSyncMissions(dstDevId, remoteDms); + int32_t ret = StartSyncRemoteMissions(dstDevId, remoteDms); if (ret == ERR_NONE) { std::lock_guard autoLock(listenDeviceLock_); auto iterItem = listenDeviceMap_.find(devId); @@ -406,16 +406,16 @@ int32_t DistributedSchedMissionManager::PrepareAndSyncMissions(const std::string return ret; } -int32_t DistributedSchedMissionManager::PrepareAndSyncMissions(const std::string& dstDevId, +int32_t DistributedSchedMissionManager::StartSyncRemoteMissions(const std::string& dstDevId, const sptr& remoteDms) { - std::vector missionInfos; + std::vector missionInfos; CallerInfo callerInfo; if (!GenerateCallerInfo(callerInfo)) { return GET_LOCAL_DEVICE_ERR; } int64_t begin = GetTickCount(); - int32_t ret = remoteDms->PrepareAndSyncMissionsFromRemote(callerInfo, missionInfos); + int32_t ret = remoteDms->StartSyncMissionsFromRemote(callerInfo, missionInfos); HILOGI("[PerformanceTest] ret:%{public}d, spend %{public}" PRId64 " ms", ret, GetTickCount() - begin); if (ret == ERR_NONE) { @@ -424,20 +424,20 @@ int32_t DistributedSchedMissionManager::PrepareAndSyncMissions(const std::string return ret; } -int32_t DistributedSchedMissionManager::UnRegisterRemoteMissionListener(const std::u16string& devId, +int32_t DistributedSchedMissionManager::UnRegisterMissionListener(const std::u16string& devId, const sptr& listener) { if (listener == nullptr) { return INVALID_PARAMETERS_ERR; } if (!AllowMissionUid(IPCSkeleton::GetCallingUid())) { - HILOGE("UnRegisterRemoteMissionListener permission denied!"); + HILOGE("permission denied!"); return DMS_PERMISSION_DENIED; } std::string localDeviceId; if (!DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId) || localDeviceId == Str16ToStr8(devId)) { - HILOGE("UnRegisterRemoteMissionListener check deviceId fail"); + HILOGE("check deviceId fail"); return INVALID_PARAMETERS_ERR; } { @@ -449,7 +449,7 @@ int32_t DistributedSchedMissionManager::UnRegisterRemoteMissionListener(const st auto& listenerInfo = iterItem->second; auto ret = listenerInfo.Find(listener); if (!ret) { - HILOGI("UnRegisterRemoteMissionListener listener not registered!"); + HILOGI("listener not registered!"); return ERR_NONE; } listener->RemoveDeathRecipient(listenerDeath_); @@ -459,7 +459,7 @@ int32_t DistributedSchedMissionManager::UnRegisterRemoteMissionListener(const st } listenDeviceMap_.erase(iterItem); } - return UnRegisterRemoteMissionListenerInner(Str16ToStr8(devId), false, true); + return ERR_NONE; } void DistributedSchedMissionManager::CleanMissionResources(const std::string& dstDevId) @@ -478,10 +478,10 @@ void DistributedSchedMissionManager::CleanMissionResources(const std::string& ds } listenDeviceMap_.erase(iterDevice); } - UnRegisterRemoteMissionListenerInner(dstDevId, true); + StopSyncRemoteMissions(dstDevId, true); } -int32_t DistributedSchedMissionManager::UnRegisterRemoteMissionListenerInner(const std::string& dstDevId, +int32_t DistributedSchedMissionManager::StopSyncRemoteMissions(const std::string& dstDevId, bool offline, bool exit) { CleanMissionCache(dstDevId); @@ -493,7 +493,7 @@ int32_t DistributedSchedMissionManager::UnRegisterRemoteMissionListenerInner(con } sptr remoteDms = GetRemoteDms(dstDevId); if (remoteDms == nullptr) { - HILOGE("UnRegisterRemoteMissionListener DMS get remoteDms failed"); + HILOGE("DMS get remoteDms failed"); return GET_REMOTE_DMS_FAIL; } @@ -502,13 +502,12 @@ int32_t DistributedSchedMissionManager::UnRegisterRemoteMissionListenerInner(con return GET_LOCAL_DEVICE_ERR; } int64_t begin = GetTickCount(); - int32_t ret = remoteDms->UnRegisterMissionListenerFromRemote(callerInfo); - HILOGI("[PerformanceTest] UnRegisterMissionListenerFromRemote ret:%d, spend %{public}" PRId64 " ms", - ret, GetTickCount() - begin); + int32_t ret = remoteDms->StopSyncMissionsFromRemote(callerInfo); + HILOGI("[PerformanceTest] ret:%d, spend %{public}" PRId64 " ms", ret, GetTickCount() - begin); return ret; } -int32_t DistributedSchedMissionManager::PrepareAndSyncMissions(const std::u16string& dstDevId, bool fixConflict, +int32_t DistributedSchedMissionManager::StartSyncRemoteMissions(const std::string& dstDevId, bool fixConflict, int64_t tag) { std::string localDeviceId; @@ -516,25 +515,24 @@ int32_t DistributedSchedMissionManager::PrepareAndSyncMissions(const std::u16str HILOGE("check deviceId fail"); return INVALID_PARAMETERS_ERR; } - std::string deviceId = Str16ToStr8(dstDevId); - HILOGI("begin, deviceId is %{public}s, local deviceId is %{public}s", - DnetworkAdapter::AnonymizeDeviceId(deviceId).c_str(), + HILOGI("begin, dstDevId is %{public}s, local deviceId is %{public}s", + DnetworkAdapter::AnonymizeDeviceId(dstDevId).c_str(), DnetworkAdapter::AnonymizeDeviceId(localDeviceId).c_str()); - if (deviceId != INVAILD_LOCAL_DEVICE_ID && deviceId != localDeviceId && - CheckOsdSwitch(deviceId) != MISSION_OSD_ENABLED) { - NotifyOsdSwitchChanged(true, deviceId, MISSION_OSD_NOT_SUPPORTED); + if (dstDevId != INVAILD_LOCAL_DEVICE_ID && dstDevId != localDeviceId && + CheckOsdSwitch(dstDevId) != MISSION_OSD_ENABLED) { + NotifyOsdSwitchChanged(true, dstDevId, MISSION_OSD_NOT_SUPPORTED); return MISSION_OSD_NOT_SUPPORTED; } - auto ret = PrepareAndSyncMissions(deviceId, localDeviceId); + auto ret = StartSyncRemoteMissions(dstDevId, localDeviceId); if (ret != ERR_NONE) { - HILOGE("PrepareAndSyncMissions failed, %{public}d", ret); + HILOGE("StartSyncRemoteMissions failed, %{public}d", ret); return ret; } return ERR_NONE; } -int32_t DistributedSchedMissionManager::PrepareAndSyncMissionsFromRemote(const CallerInfo& callerInfo, - std::vector& missionInfos) +int32_t DistributedSchedMissionManager::StartSyncMissionsFromRemote(const CallerInfo& callerInfo, + std::vector& missionInfos) { auto deviceId = callerInfo.sourceDeviceId; HILOGD("remote version is %{public}d!", callerInfo.dmsVersion); @@ -561,7 +559,7 @@ int32_t DistributedSchedMissionManager::PrepareAndSyncMissionsFromRemote(const C return DistributedSchedAdapter::GetInstance().GetLocalMissionInfos(Mission::GET_MAX_MISSIONS, missionInfos); } -void DistributedSchedMissionManager::UnRegisterMissionListenerFromRemote(const std::string& deviceId) +void DistributedSchedMissionManager::StopSyncMissionsFromRemote(const std::string& deviceId) { HILOGD(" %{private}s!", deviceId.c_str()); { @@ -700,7 +698,7 @@ void DistributedSchedMissionManager::DeleteCachedSnapshotInfo(const std::string& } int32_t DistributedSchedMissionManager::FetchCachedRemoteMissions(const std::string& srcId, int32_t numMissions, - std::vector& missionInfos) + std::vector& missionInfos) { std::string uuid = DtbschedmgrDeviceInfoStorage::GetInstance().GetUuidByNetworkId(srcId); if (uuid.empty()) { @@ -727,7 +725,7 @@ int32_t DistributedSchedMissionManager::FetchCachedRemoteMissions(const std::str } void DistributedSchedMissionManager::RebornMissionCache(const std::string& deviceId, - const std::vector& missionInfos) + const std::vector& missionInfos) { HILOGI("start! deviceId is %{public}s", DnetworkAdapter::AnonymizeDeviceId(deviceId).c_str()); @@ -760,7 +758,7 @@ void DistributedSchedMissionManager::CleanMissionCache(const std::string& device } int32_t DistributedSchedMissionManager::NotifyMissionsChangedFromRemote(const CallerInfo& callerInfo, - const std::vector& missionInfos) + const std::vector& missionInfos) { HILOGI("NotifyMissionsChangedFromRemote version is %{public}d!", callerInfo.dmsVersion); std::u16string u16DevId = Str8ToStr16(callerInfo.sourceDeviceId); @@ -795,7 +793,7 @@ int32_t DistributedSchedMissionManager::NotifyMissionsChangedFromRemote(const Ca return INVALID_PARAMETERS_ERR; } -int32_t DistributedSchedMissionManager::NotifyMissionsChangedToRemote(const std::vector& missionInfos) +int32_t DistributedSchedMissionManager::NotifyMissionsChangedToRemote(const std::vector& missionInfos) { CallerInfo callerInfo; if (!GenerateCallerInfo(callerInfo)) { @@ -821,7 +819,7 @@ int32_t DistributedSchedMissionManager::NotifyMissionsChangedToRemote(const std: } void DistributedSchedMissionManager::NotifyMissionsChangedToRemoteInner(const std::string& deviceId, - const std::vector& missionInfos, const CallerInfo& callerInfo) + const std::vector& missionInfos, const CallerInfo& callerInfo) { sptr remoteDms = GetRemoteDms(deviceId); if (remoteDms == nullptr) { @@ -1050,7 +1048,7 @@ void DistributedSchedMissionManager::OnRemoteDmsDied(const wptr& } } -void DistributedSchedMissionManager::RetryStartRemoteSyncMission(const std::string& dstDeviceId, +void DistributedSchedMissionManager::RetryStartSyncRemoteMissions(const std::string& dstDeviceId, const std::string& localDevId, int32_t retryTimes) { auto retryFunc = [this, dstDeviceId, localDevId, retryTimes]() { @@ -1060,12 +1058,12 @@ void DistributedSchedMissionManager::RetryStartRemoteSyncMission(const std::stri } sptr remoteDms = GetRemoteDms(dstDeviceId); if (remoteDms == nullptr) { - HILOGI("RetryStartRemoteSyncMission DMS get remoteDms failed"); - RetryStartRemoteSyncMission(dstDeviceId, localDevId, retryTimes + 1); + HILOGI("RetryStartSyncRemoteMissions DMS get remoteDms failed"); + RetryStartSyncRemoteMissions(dstDeviceId, localDevId, retryTimes + 1); return; } - int32_t errNo = PrepareAndSyncMissions(dstDeviceId, remoteDms); - HILOGI("RetryStartRemoteSyncMission result:%{public}d", errNo); + int32_t errNo = StartSyncRemoteMissions(dstDeviceId, remoteDms); + HILOGI("RetryStartSyncRemoteMissions result:%{public}d", errNo); }; if (missionHandler_ != nullptr && retryTimes < MAX_RETRY_TIMES) { missionHandler_->PostTask(retryFunc, RETRY_DELAYED); @@ -1235,7 +1233,7 @@ void DistributedSchedMissionManager::OnMissionListenerDied(const sptr& if (!DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId)) { return; } - RetryStartRemoteSyncMission(devId, localDeviceId, 0); + RetryStartSyncRemoteMissions(devId, localDeviceId, 0); } } diff --git a/services/dtbschedmgr/src/mission/mission_info_converter.cpp b/services/dtbschedmgr/src/mission/mission_info_converter.cpp index 947d6cba..9f3f9826 100644 --- a/services/dtbschedmgr/src/mission/mission_info_converter.cpp +++ b/services/dtbschedmgr/src/mission/mission_info_converter.cpp @@ -21,49 +21,41 @@ using namespace std; namespace OHOS { namespace DistributedSchedule { -int32_t MissionInfoConverter::ConvertToMissionInfos(std::vector& abilityMissionInfos, - std::vector& missionInfos) -{ - if (abilityMissionInfos.empty()) { - return INVALID_PARAMETERS_ERR; - } - for (auto iter = abilityMissionInfos.begin(); iter != abilityMissionInfos.end(); iter++) { - MissionInfo missionInfo; - missionInfo.id = iter->id; - missionInfo.runingState = iter->runingState; - missionInfo.missionStackId = iter->missionStackId; - shared_ptr spWant = make_shared(iter->baseWant); - missionInfo.baseWant = spWant; - shared_ptr spTopAbility = make_shared(iter->topAbility); - missionInfo.topAbility = spTopAbility; - shared_ptr spBaseAbility = make_shared(iter->baseAbility); - missionInfo.baseAbility = spBaseAbility; - missionInfo.size = iter->size; - missionInfo.label = iter->missionDescription.label; - missionInfo.iconPath = iter->missionDescription.iconPath; - missionInfos.push_back(missionInfo); - } - return ERR_OK; -} - -int32_t MissionInfoConverter::ConvertToAbilityMissionInfos(std::vector& missionInfos, - std::vector& abilityMissionInfos) +int32_t MissionInfoConverter::ConvertToDstbMissionInfos(std::vector& missionInfos, + std::vector& dstbMissionInfos) { if (missionInfos.empty()) { return INVALID_PARAMETERS_ERR; } for (auto iter = missionInfos.begin(); iter != missionInfos.end(); iter++) { - AbilityMissionInfo missionInfo; + DstbMissionInfo dstbMissionInfo; + dstbMissionInfo.id = iter->id; + dstbMissionInfo.runingState = iter->runningState; + dstbMissionInfo.lockedState = iter->lockedState; + dstbMissionInfo.label = iter->label; + dstbMissionInfo.iconPath = iter->iconPath; + shared_ptr spWant = make_shared(iter->want); + dstbMissionInfo.baseWant = spWant; + dstbMissionInfos.push_back(dstbMissionInfo); + } + return ERR_OK; +} + +int32_t MissionInfoConverter::ConvertToMissionInfos(std::vector& dstbMissionInfos, + std::vector& missionInfos) +{ + if (dstbMissionInfos.empty()) { + return INVALID_PARAMETERS_ERR; + } + for (auto iter = dstbMissionInfos.begin(); iter != dstbMissionInfos.end(); iter++) { + AAFwk::MissionInfo missionInfo; missionInfo.id = iter->id; - missionInfo.runingState = iter->runingState; - missionInfo.missionStackId = iter->missionStackId; - missionInfo.baseWant = *(iter->baseWant); - missionInfo.topAbility = *(iter->topAbility); - missionInfo.baseAbility = *(iter->baseAbility); - missionInfo.size = iter->size; - missionInfo.missionDescription.label = iter->label; - missionInfo.missionDescription.iconPath = iter->iconPath; - abilityMissionInfos.push_back(missionInfo); + missionInfo.runningState = iter->runingState; + missionInfo.lockedState = iter->lockedState; + missionInfo.label = iter->label; + missionInfo.iconPath = iter->iconPath; + missionInfo.want = *(iter->baseWant); + missionInfos.push_back(missionInfo); } return ERR_OK; } diff --git a/services/dtbschedmgr/test/BUILD.gn b/services/dtbschedmgr/test/BUILD.gn index 0f01214f..8f4e32c3 100644 --- a/services/dtbschedmgr/test/BUILD.gn +++ b/services/dtbschedmgr/test/BUILD.gn @@ -28,26 +28,23 @@ config("test_config") { [ "//foundation/distributedschedule/dmsfwk/utils/native/include" ] } -dsched_deps = [ - "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", - "//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager", - "//foundation/aafwk/standard/interfaces/innerkits/base:base", - "//foundation/aafwk/standard/interfaces/innerkits/want:want", - "//foundation/appexecfwk/standard/common:libappexecfwk_common", - "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base:appexecfwk_base", - "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core:appexecfwk_core", - "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", - "//foundation/distributeddatamgr/distributeddatamgr/interfaces/innerkits/distributeddata:distributeddata_inner", - "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk", - "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", - "//foundation/multimedia/image_standard/interfaces/innerkits:image_native", - "//utils/native/base:utils", -] +dsched_deps = [ "//foundation/appexecfwk/standard/common:libappexecfwk_common" ] dsched_external_deps = [ + "aafwk_standard:ability_manager", + "aafwk_standard:want", + "appexecfwk_standard:appexecfwk_base", + "appexecfwk_standard:appexecfwk_core", + "appexecfwk_standard:libeventhandler", + "distributeddatamgr:distributeddata_inner", "dsoftbus_standard:softbus_client", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", + "multimedia_image_standard:image_native", + "permission_standard:libpermissionsdk_standard", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + "utils_base:utils", ] dsched_public_deps = [ @@ -73,9 +70,9 @@ dtbschedmgr_sources = [ "${distributed_service}/dtbschedmgr/src/dtbschedmgr_device_info_storage.cpp", "${distributed_service}/dtbschedmgr/src/mission/distributed_data_change_listener.cpp", "${distributed_service}/dtbschedmgr/src/mission/distributed_data_storage.cpp", + "${distributed_service}/dtbschedmgr/src/mission/distributed_mission_info.cpp", "${distributed_service}/dtbschedmgr/src/mission/distributed_sched_mission_manager.cpp", "${distributed_service}/dtbschedmgr/src/mission/mission_changed_notify.cpp", - "${distributed_service}/dtbschedmgr/src/mission/mission_info.cpp", "${distributed_service}/dtbschedmgr/src/mission/mission_info_converter.cpp", "${distributed_service}/dtbschedmgr/src/mission/snapshot.cpp", ] diff --git a/services/dtbschedmgr/test/unittest/mission/dms_mission_manager_test.cpp b/services/dtbschedmgr/test/unittest/mission/dms_mission_manager_test.cpp index 6b903821..566c0267 100644 --- a/services/dtbschedmgr/test/unittest/mission/dms_mission_manager_test.cpp +++ b/services/dtbschedmgr/test/unittest/mission/dms_mission_manager_test.cpp @@ -38,7 +38,6 @@ namespace DistributedSchedule { namespace { const std::string DEVICE_NAME = "DEVICE_PHONE_001"; const std::string DEVICE_ID = "123456789ABCD"; -const std::u16string U16DEVICE_ID = u"123456789ABCD"; const std::string BUNDLE_NAME = "ohos.test.test"; const int32_t NUM_MISSIONS = 100; } @@ -58,7 +57,6 @@ void DMSMissionManagerTest::SetUp() return; } localDeviceId_ = localDeviceId; - localDev_ = Str8ToStr16(localDeviceId); } void DMSMissionManagerTest::TearDown() @@ -95,7 +93,7 @@ sptr DMSMissionManagerTest::GetDms() */ HWTEST_F(DMSMissionManagerTest, testGetRemoteMissionInfo001, TestSize.Level1) { - std::vector infos; + std::vector infos; auto ret = DistributedSchedMissionManager::GetInstance().GetMissionInfos(DEVICE_ID, 0, infos); EXPECT_TRUE(ret != ERR_NONE); @@ -124,7 +122,7 @@ HWTEST_F(DMSMissionManagerTest, testGetRemoteMissionInfo002, TestSize.Level1) if (proxy == nullptr) { return; } - std::vector infos; + std::vector infos; auto ret = proxy->GetMissionInfos(DEVICE_ID, 0, infos); EXPECT_TRUE(ret != ERR_NONE); @@ -142,25 +140,25 @@ HWTEST_F(DMSMissionManagerTest, testGetRemoteMissionInfo002, TestSize.Level1) } /** - * @tc.name: testPrepareAndSyncMissions001 + * @tc.name: testStartSyncRemoteMissions001 * @tc.desc: prepare and sync missions from remote * @tc.type: FUNC * @tc.require:AR000GK67M */ -HWTEST_F(DMSMissionManagerTest, testPrepareAndSyncMissions001, TestSize.Level1) +HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions001, TestSize.Level1) { sptr proxy = GetDms(); if (proxy == nullptr) { return; } - std::vector infos; - auto ret = proxy->PrepareAndSyncMissions(U16DEVICE_ID, false, 0); + std::vector infos; + auto ret = proxy->StartSyncRemoteMissions(DEVICE_ID, false, 0); EXPECT_TRUE(ret != ERR_NONE); - ret = proxy->PrepareAndSyncMissions(localDev_, false, 0); + ret = proxy->StartSyncRemoteMissions(localDeviceId_, false, 0); EXPECT_TRUE(ret != ERR_NONE); - ret = proxy->PrepareAndSyncMissions(u"", false, 0); + ret = proxy->StartSyncRemoteMissions("", false, 0); EXPECT_TRUE(ret != ERR_NONE); } @@ -193,7 +191,7 @@ HWTEST_F(DMSMissionManagerTest, testGetMissionInfos001, TestSize.Level1) { std::string deviceid = DEVICE_ID; int32_t numMissions = NUM_MISSIONS; - std::vector missionInfos; + std::vector missionInfos; auto ret = DistributedSchedMissionManager::GetInstance().GetMissionInfos(deviceid, numMissions, missionInfos); EXPECT_TRUE(ret != ERR_NONE); @@ -207,7 +205,7 @@ HWTEST_F(DMSMissionManagerTest, testGetMissionInfos001, TestSize.Level1) */ HWTEST_F(DMSMissionManagerTest, testFetchCachedRemoteMissions001, TestSize.Level1) { - std::vector infos; + std::vector infos; auto ret = DistributedSchedMissionManager::GetInstance().FetchCachedRemoteMissions(DEVICE_ID, 0, infos); EXPECT_TRUE(ret != ERR_NONE); } diff --git a/services/dtbschedmgr/test/unittest/mission/dms_mission_manager_test.h b/services/dtbschedmgr/test/unittest/mission/dms_mission_manager_test.h index 451d043c..bf8f18c5 100644 --- a/services/dtbschedmgr/test/unittest/mission/dms_mission_manager_test.h +++ b/services/dtbschedmgr/test/unittest/mission/dms_mission_manager_test.h @@ -29,7 +29,6 @@ public: void SetUp() override; void TearDown() override; protected: - std::u16string localDev_; std::string localDeviceId_; sptr proxy_; sptr GetDms(); diff --git a/services/dtbschedmgr/test/unittest/mock_distributed_sched.cpp b/services/dtbschedmgr/test/unittest/mock_distributed_sched.cpp index 88a73522..f0c3c3c4 100644 --- a/services/dtbschedmgr/test/unittest/mock_distributed_sched.cpp +++ b/services/dtbschedmgr/test/unittest/mock_distributed_sched.cpp @@ -82,17 +82,17 @@ int32_t MockDistributedSched::NotifyProcessDiedFromRemote(const CallerInfo& call return 0; } -int32_t MockDistributedSched::PrepareAndSyncMissions(const std::u16string& devId, bool fixConflict, int64_t tag) +int32_t MockDistributedSched::StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) { return ERR_NONE; } -int32_t MockDistributedSched::RegisterRemoteMissionListener(const std::u16string& devId, const sptr& obj) +int32_t MockDistributedSched::RegisterMissionListener(const std::u16string& devId, const sptr& obj) { return ERR_NONE; } -int32_t MockDistributedSched::UnRegisterRemoteMissionListener(const std::u16string& devId, +int32_t MockDistributedSched::UnRegisterMissionListener(const std::u16string& devId, const sptr& obj) { return ERR_NONE; @@ -109,7 +109,7 @@ int32_t MockDistributedSched::RemoveSnapshotInfo(const std::string& deviceId, in return ERR_NONE; } -int32_t MockDistributedSched::NotifyMissionsChangedFromRemote(const std::vector& missionInfos, +int32_t MockDistributedSched::NotifyMissionsChangedFromRemote(const std::vector& missionInfos, const CallerInfo& callerInfo) { expectedTrue_ = false; @@ -133,18 +133,23 @@ int32_t MockDistributedSched::GetOsdSwitchValueFromRemote() } int32_t MockDistributedSched::GetMissionInfos(const std::string& deviceId, int32_t numMissions, - std::vector& missionInfos) + std::vector& missionInfos) { return ERR_NONE; } -int32_t MockDistributedSched::PrepareAndSyncMissionsFromRemote(const CallerInfo& callerInfo, - std::vector& missionInfos) +int32_t MockDistributedSched::StartSyncMissionsFromRemote(const CallerInfo& callerInfo, + std::vector& missionInfos) { return ERR_NONE; } -int32_t MockDistributedSched::UnRegisterMissionListenerFromRemote(const CallerInfo& callerInfo) +int32_t MockDistributedSched::StopSyncMissionsFromRemote(const CallerInfo& callerInfo) +{ + return ERR_NONE; +} + +int32_t MockDistributedSched::StopSyncRemoteMissions(const std::string& devId) { return ERR_NONE; } diff --git a/services/dtbschedmgr/test/unittest/mock_distributed_sched.h b/services/dtbschedmgr/test/unittest/mock_distributed_sched.h index d617d64c..fb785f4a 100644 --- a/services/dtbschedmgr/test/unittest/mock_distributed_sched.h +++ b/services/dtbschedmgr/test/unittest/mock_distributed_sched.h @@ -44,27 +44,28 @@ public: int32_t DisconnectAbilityFromRemote(const sptr& connect, int32_t uid, const std::string& sourceDeviceId) override; int32_t NotifyProcessDiedFromRemote(const CallerInfo& callerInfo) override; - int32_t PrepareAndSyncMissions(const std::u16string& devId, bool fixConflict, int64_t tag) override; - int32_t RegisterRemoteMissionListener(const std::u16string& devId, const sptr& obj) override; - int32_t UnRegisterRemoteMissionListener(const std::u16string& devId, const sptr& obj) override; + int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override; + int32_t RegisterMissionListener(const std::u16string& devId, const sptr& obj) override; + int32_t UnRegisterMissionListener(const std::u16string& devId, const sptr& obj) override; int32_t GetMissionInfos(const std::string& deviceId, int32_t numMissions, - std::vector& missionInfos) override; + std::vector& missionInfos) override; int32_t StoreSnapshotInfo(const std::string& deviceId, int32_t missionId, const uint8_t* byteStream, size_t len) override; int32_t RemoveSnapshotInfo(const std::string& deviceId, int32_t missionId) override; - int32_t NotifyMissionsChangedFromRemote(const std::vector& missionInfos, + int32_t NotifyMissionsChangedFromRemote(const std::vector& missionInfos, const CallerInfo& callerInfo) override; int32_t CheckSupportOsd(const std::string& deviceId) override; void GetCachedOsdSwitch(std::vector& deviceIds, std::vector& values) override; int32_t GetOsdSwitchValueFromRemote() override; int32_t UpdateOsdSwitchValueFromRemote(int32_t switchVal, const std::string& sourceDeviceId) override; - int32_t PrepareAndSyncMissionsFromRemote(const CallerInfo& callerInfo, - std::vector& missionInfos) override; - int32_t UnRegisterMissionListenerFromRemote(const CallerInfo& callerInfo) override; + int32_t StartSyncMissionsFromRemote(const CallerInfo& callerInfo, + std::vector& missionInfos) override; + int32_t StopSyncMissionsFromRemote(const CallerInfo& callerInfo) override; + int32_t StopSyncRemoteMissions(const std::string& devId) override; private: bool expectedTrue_ = false; }; } // namespace DistributedSchedule } // namespace OHOS -#endif // MOCK_DISTRIBUTED_SCHED_H \ No newline at end of file +#endif // MOCK_DISTRIBUTED_SCHED_H