diff --git a/common/include/dtbschedmgr_log.h b/common/include/dtbschedmgr_log.h index d26a2714..c405cbdc 100644 --- a/common/include/dtbschedmgr_log.h +++ b/common/include/dtbschedmgr_log.h @@ -64,6 +64,41 @@ enum { // offset of dms error, only be used in this file. constexpr ErrCode DMS_SERVICE_ERR_OFFSET = ErrCodeOffset(SUBSYS_DISTRIBUTEDSCHEDULE, DMS_MODULE_TYPE_SERVICE); +enum DmsInterfaceSdkErr { + /** + * Result(16300501) for the distributed sched work abnormally. + */ + ERR_DMS_WORK_ABNORMALLY = 16300501, + /** + * Result(16300503) throw to js for the application is not installed on the remote end and installation-free is + * not supported. + */ + ERR_REMOTE_UNINSTALLED_AND_UNFREEINSTALL = 16300503, + /** + * Result(16300504) throw to js for the application is not installed on the remote end but installation-free is + * supported, try again with freeInstall flag. + */ + ERR_CONTINUE_WITHOUT_FREEINSTALL_FLAG = 16300504, + /** + * Result(16300506) throw to js for the local continuation task is already in progress. + */ + ERR_CONTINUE_ALREADY_IN_PROGRESS = 16300506, + /** + * Result(16300507) throw to js for Failed to get the missionInfo of the specified bundle name. + */ + ERR_GET_MISSION_INFO_OF_BUNDLE_NAME = 16300507, + /** + * Result(16300508) throw to js for bind error due to the remote device hotspot enable, try again after disable + * the remote device hotspot. + */ + ERR_BIND_REMOTE_HOTSPOT_ENABLE_STATE = 16300508, + /** + * Result(16300509) throw to js for the remote device has been linked with other devices, try again when + * the remote device is idle. + */ + ERR_BIND_REMOTE_IN_BUSY_LINK = 16300509, +}; + enum { /** * Result(29360128) for invalid parameters. diff --git a/services/dtbschedmgr/include/continue/dsched_continue.h b/services/dtbschedmgr/include/continue/dsched_continue.h index ce0932a1..b43174df 100644 --- a/services/dtbschedmgr/include/continue/dsched_continue.h +++ b/services/dtbschedmgr/include/continue/dsched_continue.h @@ -187,6 +187,7 @@ private: int32_t SetWantForContinuation(AAFwk::Want& newWant); void SetCleanMissionFlag(const OHOS::AAFwk::Want& want); + int32_t ConvertToDmsSdkErr(int32_t result); void NotifyContinuationCallbackResult(int32_t result); bool GetLocalDeviceId(std::string& localDeviceId); bool CheckDeviceIdFromRemote(const std::string& localDevId, const std::string& destDevId, @@ -210,6 +211,9 @@ private: private: static constexpr int32_t INVALID_SESSION_ID = -1; + static constexpr int32_t ERROR_BASE_DSOFTBUS_WIFI = -200000; + static constexpr int32_t ERROR_PEER_THREE_VAP_CONFLICT = ERROR_BASE_DSOFTBUS_WIFI - 6604; + static const std::map DMS_CONVERT_TO_SDK_ERR_MAP; std::shared_ptr stateMachine_; std::shared_ptr eventHandler_; diff --git a/services/dtbschedmgr/src/continue/dsched_continue.cpp b/services/dtbschedmgr/src/continue/dsched_continue.cpp index 28eecc65..cd21a5b0 100644 --- a/services/dtbschedmgr/src/continue/dsched_continue.cpp +++ b/services/dtbschedmgr/src/continue/dsched_continue.cpp @@ -43,6 +43,7 @@ #endif #include "scene_board_judgement.h" #include "softbus_adapter/transport/dsched_transport_softbus_adapter.h" +#include "softbus_error_code.h" namespace OHOS { namespace DistributedSchedule { @@ -78,6 +79,45 @@ constexpr int32_t GET_ABILITY_STATE_RETRY_TIMES = 40; constexpr int32_t GET_ABILITY_STATE_SLEEP_TIME = 50; } +const std::map DSchedContinue::DMS_CONVERT_TO_SDK_ERR_MAP = { + std::map::value_type(SoftBusErrNo::SOFTBUS_CONN_PASSIVE_TYPE_AP_STA_CHIP_CONFLICT, + DmsInterfaceSdkErr::ERR_BIND_REMOTE_HOTSPOT_ENABLE_STATE), + std::map::value_type(SoftBusErrNo::SOFTBUS_CONN_PASSIVE_TYPE_AP_P2P_CHIP_CONFLICT, + DmsInterfaceSdkErr::ERR_BIND_REMOTE_HOTSPOT_ENABLE_STATE), + std::map::value_type(SoftBusErrNo::SOFTBUS_CONN_PASSIVE_TYPE_AP_HML_CHIP_CONFLICT, + DmsInterfaceSdkErr::ERR_BIND_REMOTE_HOTSPOT_ENABLE_STATE), + std::map::value_type(SoftBusErrNo::SOFTBUS_CONN_PASSIVE_TYPE_AP_STA_HML_CHIP_CONFLICT, + DmsInterfaceSdkErr::ERR_BIND_REMOTE_HOTSPOT_ENABLE_STATE), + std::map::value_type(SoftBusErrNo::SOFTBUS_CONN_PASSIVE_TYPE_AP_STA_P2P_CHIP_CONFLICT, + DmsInterfaceSdkErr::ERR_BIND_REMOTE_HOTSPOT_ENABLE_STATE), + std::map::value_type(SoftBusErrNo::SOFTBUS_CONN_PASSIVE_TYPE_AP_P2P_HML_CHIP_CONFLICT, + DmsInterfaceSdkErr::ERR_BIND_REMOTE_HOTSPOT_ENABLE_STATE), + std::map::value_type(ERROR_PEER_THREE_VAP_CONFLICT, + DmsInterfaceSdkErr::ERR_BIND_REMOTE_HOTSPOT_ENABLE_STATE), + + std::map::value_type(SoftBusErrNo::SOFTBUS_CONN_PASSIVE_TYPE_HML_NUM_LIMITED_CONFLICT, + DmsInterfaceSdkErr::ERR_BIND_REMOTE_IN_BUSY_LINK), + std::map::value_type(SoftBusErrNo::SOFTBUS_CONN_PV1_PEER_GC_CONNECTED_TO_ANOTHER_DEVICE, + DmsInterfaceSdkErr::ERR_BIND_REMOTE_IN_BUSY_LINK), + std::map::value_type(SoftBusErrNo::SOFTBUS_CONN_PV2_PEER_GC_CONNECTED_TO_ANOTHER_DEVICE, + DmsInterfaceSdkErr::ERR_BIND_REMOTE_IN_BUSY_LINK), + std::map::value_type(SoftBusErrNo::SOFTBUS_CONN_PASSIVE_TYPE_STA_P2P_HML_55_CONFLICT, + DmsInterfaceSdkErr::ERR_BIND_REMOTE_IN_BUSY_LINK), + std::map::value_type(SoftBusErrNo::SOFTBUS_CONN_PASSIVE_TYPE_STA_P2P_HML_225_CONFLICT, + DmsInterfaceSdkErr::ERR_BIND_REMOTE_IN_BUSY_LINK), + std::map::value_type(SoftBusErrNo::SOFTBUS_CONN_PASSIVE_TYPE_STA_P2P_HML_255_CONFLICT, + DmsInterfaceSdkErr::ERR_BIND_REMOTE_IN_BUSY_LINK), + std::map::value_type(SoftBusErrNo::SOFTBUS_CONN_PASSIVE_TYPE_STA_P2P_HML_525_CONFLICT, + DmsInterfaceSdkErr::ERR_BIND_REMOTE_IN_BUSY_LINK), + std::map::value_type(SoftBusErrNo::SOFTBUS_CONN_PASSIVE_TYPE_STA_P2P_HML_555_CONFLICT, + DmsInterfaceSdkErr::ERR_BIND_REMOTE_IN_BUSY_LINK), + std::map::value_type(SoftBusErrNo::SOFTBUS_CONN_PASSIVE_TYPE_P2P_GO_GC_CONFLICT, + DmsInterfaceSdkErr::ERR_BIND_REMOTE_IN_BUSY_LINK), + + std::map::value_type(CONTINUE_ALREADY_IN_PROGRESS, + DmsInterfaceSdkErr::ERR_CONTINUE_ALREADY_IN_PROGRESS), +}; + DSchedContinue::DSchedContinue(int32_t subServiceType, int32_t direction, const sptr& callback, const DSchedContinueInfo& continueInfo) : subServiceType_(subServiceType), direction_(direction), continueInfo_(continueInfo), callback_(callback) @@ -1067,6 +1107,19 @@ int32_t DSchedContinue::ExecuteContinueEnd(int32_t result) return ERR_OK; } +int32_t DSchedContinue::ConvertToDmsSdkErr(int32_t result) +{ + if (result == ERR_OK) { + return result; + } + + auto it = DMS_CONVERT_TO_SDK_ERR_MAP.find(result); + if (it != DMS_CONVERT_TO_SDK_ERR_MAP.end()) { + return it->second; + } + return DmsInterfaceSdkErr::ERR_DMS_WORK_ABNORMALLY; +} + void DSchedContinue::NotifyContinuationCallbackResult(int32_t result) { HILOGD("continuation result is: %{public}d", result); @@ -1080,7 +1133,7 @@ void DSchedContinue::NotifyContinuationCallbackResult(int32_t result) HILOGE("write token failed"); return; } - PARCEL_WRITE_HELPER_NORET(data, Int32, (result == ERR_OK) ? 0 : NOTIFYCOMPLETECONTINUATION_FAILED); + PARCEL_WRITE_HELPER_NORET(data, Int32, ConvertToDmsSdkErr(result)); MessageParcel reply; MessageOption option; int32_t ret = callback_->SendRequest(NOTIFY_MISSION_CALLBACK_RESULT, data, reply, option);