修改认证失败问题

Signed-off-by: puhui <puhui1@huawei.com>
This commit is contained in:
puhui
2022-01-18 20:47:52 +08:00
parent 0ea5991f12
commit 233c080428
6 changed files with 21 additions and 20 deletions
@@ -258,7 +258,7 @@ int32_t DeviceManagerImpl::StartDeviceDiscovery(const std::string &pkgName, cons
ret = rsp->GetErrCode();
if (ret != DM_OK) {
LOGE("StartDeviceDiscovery error: Failed with ret %d", ret);
return DM_IPC_RESPOND_ERROR;
return ret;
}
LOGI("StartDeviceDiscovery completed, pkgName: %s", pkgName.c_str());
@@ -292,7 +292,7 @@ int32_t DeviceManagerImpl::StopDeviceDiscovery(const std::string &pkgName, uint1
ret = rsp->GetErrCode();
if (ret != DM_OK) {
LOGE("StopDeviceDiscovery error: Failed with ret %d", ret);
return DM_IPC_RESPOND_ERROR;
return ret;
}
DeviceManagerNotify::GetInstance().UnRegisterDiscoveryCallback(pkgName, subscribeId);
@@ -122,7 +122,8 @@ class DmAuthManager final : public ISoftbusSessionCallback,
public std::enable_shared_from_this<DmAuthManager> {
public:
DmAuthManager(std::shared_ptr<SoftbusConnector> softbusConnector,
std::shared_ptr<DeviceManagerServiceListener> listener);
std::shared_ptr<DeviceManagerServiceListener> listener,
std::shared_ptr<HiChainConnector> hiChainConnector_);
~DmAuthManager();
int32_t AuthenticateDevice(const std::string &pkgName, int32_t authType, const std::string &deviceId,
const std::string &extra);
@@ -158,7 +159,6 @@ public:
void ShowAuthInfoDialog();
void ShowStartAuthDialog();
int32_t GetAuthenticationParam(DmAuthParam &authParam);
int32_t RegisterCallback();
int32_t OnUserOperation(int32_t action);
void UserSwitchEventCallback(void);
@@ -59,6 +59,7 @@ private:
std::shared_ptr<SoftbusConnector> softbusConnector_;
std::shared_ptr<DeviceManagerServiceListener> listener_;
std::shared_ptr<DmAbilityManager> abilityMgr_;
std::shared_ptr<HiChainConnector> hiChainConnector_;
};
} // namespace DistributedHardware
} // namespace OHOS
@@ -59,20 +59,17 @@ static void TimeOut(void *data)
}
DmAuthManager::DmAuthManager(std::shared_ptr<SoftbusConnector> softbusConnector,
std::shared_ptr<DeviceManagerServiceListener> listener)
: softbusConnector_(softbusConnector), listener_(listener)
std::shared_ptr<DeviceManagerServiceListener> listener,
std::shared_ptr<HiChainConnector> hiChainConnector)
: softbusConnector_(softbusConnector), hiChainConnector_(hiChainConnector), listener_(listener)
{
LOGI("DmAuthManager constructor");
hiChainConnector_ = std::make_shared<HiChainConnector>();
DmConfigManager &dmConfigManager = DmConfigManager::GetInstance();
dmConfigManager.GetAuthAdapter(authenticationMap_);
}
DmAuthManager::~DmAuthManager()
{
softbusConnector_->GetSoftbusSession()->UnRegisterSessionCallback();
hiChainConnector_->UnRegisterHiChainCallback();
LOGI("DmAuthManager destructor");
}
@@ -697,13 +694,6 @@ int32_t DmAuthManager::GetAuthenticationParam(DmAuthParam &authParam)
return DM_OK;
}
int32_t DmAuthManager::RegisterCallback()
{
softbusConnector_->GetSoftbusSession()->RegisterSessionCallback(shared_from_this());
hiChainConnector_->RegisterHiChainCallback(shared_from_this());
return DM_OK;
}
int32_t DmAuthManager::OnUserOperation(int32_t action)
{
switch (action) {
@@ -37,6 +37,8 @@ DeviceManagerService::~DeviceManagerService()
if (dmCommonEventManager.UnsubscribeServiceEvent(CommonEventSupport::COMMON_EVENT_USER_STOPPED)) {
LOGI("subscribe service event success");
}
softbusConnector_->GetSoftbusSession()->UnRegisterSessionCallback();
hiChainConnector_->UnRegisterHiChainCallback();
}
int32_t DeviceManagerService::Init()
@@ -59,6 +61,13 @@ int32_t DeviceManagerService::Init()
return DM_MAKE_SHARED_FAIL;
}
}
if (hiChainConnector_ == nullptr) {
hiChainConnector_ = std::make_shared<HiChainConnector>();
if (hiChainConnector_ == nullptr) {
LOGE("Init failed, hiChainConnector_ apply for failure");
return DM_MAKE_SHARED_FAIL;
}
}
if (deviceInfoMgr_ == nullptr) {
deviceInfoMgr_ = std::make_shared<DmDeviceInfoManager>(softbusConnector_);
if (deviceInfoMgr_ == nullptr) {
@@ -82,12 +91,13 @@ int32_t DeviceManagerService::Init()
}
}
if (authMgr_ == nullptr) {
authMgr_ = std::make_shared<DmAuthManager>(softbusConnector_, listener_);
authMgr_ = std::make_shared<DmAuthManager>(softbusConnector_, listener_, hiChainConnector_);
if (authMgr_ == nullptr) {
LOGE("Init failed, authMgr_ apply for failure");
return DM_MAKE_SHARED_FAIL;
}
authMgr_->RegisterCallback();
softbusConnector_->GetSoftbusSession()->RegisterSessionCallback(authMgr_);
hiChainConnector_->RegisterHiChainCallback(authMgr_);
}
DmCommonEventManager &dmCommonEventManager = DmCommonEventManager::GetInstance();
CommomEventCallback callback = std::bind(&DmAuthManager::UserSwitchEventCallback, *authMgr_.get());
@@ -31,7 +31,7 @@ DmDeviceStateManager::DmDeviceStateManager(std::shared_ptr<SoftbusConnector> sof
DmDeviceStateManager::~DmDeviceStateManager()
{
LOGI("DmDeviceStateManager destructor");
softbusConnector_->UnRegisterSoftbusStateCallback("");
softbusConnector_->UnRegisterSoftbusStateCallback("DM_PKG_NAME");
}
void DmDeviceStateManager::OnDeviceOnline(const std::string &pkgName, const DmDeviceInfo &info)