mirror of
https://github.com/openharmony/device_manager.git
synced 2026-07-18 16:24:27 -04:00
@@ -50,33 +50,30 @@ enum {
|
||||
ERR_DM_NOT_INIT = -20002,
|
||||
ERR_DM_INIT_REPEATED = -20003,
|
||||
ERR_DM_INIT_FAILED = -20004,
|
||||
ERR_DM_UNINIT_FAILED = -20005,
|
||||
ERR_DM_POINT_NULL = -20006,
|
||||
ERR_DM_INPUT_PARAMETER_EMPTY = -20007,
|
||||
ERR_DM_NO_PERMISSION = -20008,
|
||||
ERR_DM_MALLOC_FAILED = -20009,
|
||||
ERR_DM_DISCOVERY_FAILED = -20010,
|
||||
ERR_DM_MAP_KEY_ALREADY_EXISTS = -20011,
|
||||
DM_PROFILE_EVENTS_FAILED = -20012,
|
||||
ERR_DM_IPC_WRITE_FAILED = -20013,
|
||||
ERR_DM_IPC_COPY_FAILED = -20014,
|
||||
ERR_DM_IPC_SEND_REQUEST_FAILED = -20015,
|
||||
ERR_DM_UNSUPPORTED_IPC_COMMAND = -20016,
|
||||
ERR_DM_IPC_RESPOND_FAILED = -20017,
|
||||
ERR_DM_IPC_WRITE_TOKEN_FAILED = -20018,
|
||||
ERR_DM_DISCOVERY_REPEATED = -20019,
|
||||
ERR_DM_UNSUPPORTED_AUTH_TYPE = -20020,
|
||||
ERR_DM_AUTH_BUSINESS_BUSY = -20021,
|
||||
ERR_DM_AUTH_OPEN_SESSION_FAILED = -20022,
|
||||
ERR_DM_AUTH_PEER_REJECT = -20023,
|
||||
ERR_DM_AUTH_REJECT = -20024,
|
||||
ERR_DM_AUTH_FAILED = -20025,
|
||||
ERR_DM_AUTH_NOT_START = -20026,
|
||||
ERR_DM_AUTH_MESSAGE_INCOMPLETE = -20027,
|
||||
ERR_DM_CREATE_GROUP_FAILED = -20028,
|
||||
ERR_DM_IPC_READ_TOKEN_FAILED = -20029,
|
||||
ERR_DM_AUTH_INPUT_PARAMETER_FAILED = -20030,
|
||||
ERR_DM_IPC_READ_FA_FAILED = -20031,
|
||||
ERR_DM_POINT_NULL = -20005,
|
||||
ERR_DM_INPUT_PARAMETER_EMPTY = -20006,
|
||||
ERR_DM_NO_PERMISSION = -20007,
|
||||
ERR_DM_MALLOC_FAILED = -20008,
|
||||
ERR_DM_DISCOVERY_FAILED = -20009,
|
||||
ERR_DM_MAP_KEY_ALREADY_EXISTS = -20010,
|
||||
ERR_DM_PROFILE_EVENTS_FAILED = -20011,
|
||||
ERR_DM_IPC_WRITE_FAILED = -20012,
|
||||
ERR_DM_IPC_COPY_FAILED = -20013,
|
||||
ERR_DM_IPC_SEND_REQUEST_FAILED = -20014,
|
||||
ERR_DM_UNSUPPORTED_IPC_COMMAND = -20015,
|
||||
ERR_DM_IPC_RESPOND_FAILED = -20016,
|
||||
ERR_DM_IPC_WRITE_FAILED = -20017,
|
||||
ERR_DM_DISCOVERY_REPEATED = -20018,
|
||||
ERR_DM_UNSUPPORTED_AUTH_TYPE = -20019,
|
||||
ERR_DM_AUTH_BUSINESS_BUSY = -20020,
|
||||
ERR_DM_AUTH_OPEN_SESSION_FAILED = -20021,
|
||||
ERR_DM_AUTH_PEER_REJECT = -20022,
|
||||
ERR_DM_AUTH_REJECT = -20023,
|
||||
ERR_DM_AUTH_FAILED = -20024,
|
||||
ERR_DM_AUTH_NOT_START = -20025,
|
||||
ERR_DM_AUTH_MESSAGE_INCOMPLETE = -20026,
|
||||
ERR_DM_CREATE_GROUP_FAILED = -20027,
|
||||
ERR_DM_IPC_READ_FAILED = -20028,
|
||||
};
|
||||
|
||||
const std::string TARGET_PKG_NAME_KEY = "targetPkgName";
|
||||
|
||||
@@ -84,7 +84,7 @@ int32_t PinAuthUi::InputPinDialog(std::shared_ptr<DmAuthManager> authManager)
|
||||
authManager->AddMember(std::stoi(params));
|
||||
}
|
||||
} else {
|
||||
authManager->SetReasonAndFinish(ERR_DM_AUTH_INPUT_PARAMETER_FAILED, AuthState::AUTH_REQUEST_JOIN);
|
||||
authManager->SetReasonAndFinish(ERR_DM_INPUT_PARAMETER_EMPTY, AuthState::AUTH_REQUEST_JOIN);
|
||||
}
|
||||
});
|
||||
LOGI("ShowConfigDialog end");
|
||||
|
||||
@@ -83,9 +83,9 @@ int32_t ProfileConnector::SubscribeProfileEvents(const std::list<std::string> &s
|
||||
subscribeInfos.emplace_back(eventSync);
|
||||
int32_t errCode = DistributedDeviceProfileClient::GetInstance().SubscribeProfileEvents(
|
||||
subscribeInfos, shared_from_this(), failedEvents);
|
||||
if (errCode != ERR_OK) {
|
||||
if (errCode != OHOS::ERR_OK) {
|
||||
LOGI("subscribe profile events result: %ud", errCode);
|
||||
return DM_PROFILE_EVENTS_FAILED;
|
||||
return ERR_DM_PROFILE_EVENTS_FAILED;
|
||||
}
|
||||
return DM_OK;
|
||||
}
|
||||
@@ -97,9 +97,9 @@ int32_t ProfileConnector::UnSubscribeProfileEvents()
|
||||
profileEvents.emplace_back(ProfileEvent::EVENT_SYNC_COMPLETED);
|
||||
int32_t errCode = DistributedDeviceProfileClient::GetInstance().UnsubscribeProfileEvents(
|
||||
profileEvents, shared_from_this(), failedEvents);
|
||||
if (errCode != ERR_OK) {
|
||||
if (errCode != OHOS::ERR_OK) {
|
||||
LOGI("unSubscribe profile events result:%ud", errCode);
|
||||
return DM_PROFILE_EVENTS_FAILED;
|
||||
return ERR_DM_PROFILE_EVENTS_FAILED;
|
||||
}
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ int32_t DeviceManagerImpl::UnInitDeviceManager(const std::string &pkgName)
|
||||
int32_t ret = ipcClientProxy_->UnInit(pkgName);
|
||||
if (ret != DM_OK) {
|
||||
LOGE("UnInitDeviceManager error: proxy unInit failed ret: %d", ret);
|
||||
return ERR_DM_UNINIT_FAILED;
|
||||
return ERR_DM_FAILED;
|
||||
}
|
||||
|
||||
DeviceManagerNotify::GetInstance().UnRegisterPackageCallback(pkgName);
|
||||
|
||||
@@ -35,7 +35,7 @@ int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr<IpcReq> r
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
LOGE("WriteInterfaceToken fail!");
|
||||
return ERR_DM_IPC_WRITE_TOKEN_FAILED;
|
||||
return ERR_DM_IPC_WRITE_FAILED;
|
||||
}
|
||||
if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) {
|
||||
return ERR_DM_IPC_SEND_REQUEST_FAILED;
|
||||
|
||||
@@ -29,7 +29,7 @@ int32_t IpcClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Messa
|
||||
auto remoteDescriptor = data.ReadInterfaceToken();
|
||||
if (GetDescriptor() != remoteDescriptor) {
|
||||
LOGI("ReadInterfaceToken fail!");
|
||||
return ERR_DM_IPC_READ_TOKEN_FAILED;
|
||||
return ERR_DM_IPC_READ_FAILED;
|
||||
}
|
||||
|
||||
if (IpcCmdRegister::GetInstance().OnIpcCmd((int32_t)code, data, reply) == DM_OK) {
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ int32_t MultipleUserConnector::GetCurrentAccountUserID(void)
|
||||
#ifdef OS_ACCOUNT_PART_EXISTS
|
||||
std::vector<int> ids;
|
||||
ErrCode ret = OsAccountManager::QueryActiveOsAccountIds(ids);
|
||||
if (ret != ERR_OK || ids.empty()) {
|
||||
if (ret != OHOS::ERR_OK || ids.empty()) {
|
||||
return -1;
|
||||
}
|
||||
return ids[0];
|
||||
|
||||
@@ -442,7 +442,7 @@ ON_IPC_CMD(SERVER_GET_DMFA_INFO, MessageParcel &data, MessageParcel &reply)
|
||||
DmAuthParam authParam;
|
||||
if (DeviceManagerService::GetInstance().GetFaParam(packName, authParam) != DM_OK) {
|
||||
LOGE("ipc read fa parm failed");
|
||||
return ERR_DM_IPC_READ_FA_FAILED;
|
||||
return ERR_DM_IPC_READ_FAILED;
|
||||
}
|
||||
int32_t appIconLen = authParam.imageinfo.GetAppIconLen();
|
||||
int32_t appThumbnailLen = authParam.imageinfo.GetAppThumbnailLen();
|
||||
|
||||
@@ -84,7 +84,7 @@ int32_t IpcServerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Messa
|
||||
auto remoteDescriptor = data.ReadInterfaceToken();
|
||||
if (GetDescriptor() != remoteDescriptor) {
|
||||
LOGI("ReadInterfaceToken fail!");
|
||||
return ERR_DM_IPC_READ_TOKEN_FAILED;
|
||||
return ERR_DM_IPC_READ_FAILED;
|
||||
}
|
||||
|
||||
int32_t ret = IpcCmdRegister::GetInstance().OnIpcCmd((int32_t)code, data, reply);
|
||||
|
||||
@@ -187,9 +187,9 @@ HWTEST_F(DeviceManagerImplTest, UnInitDeviceManager_001, testing::ext::TestSize.
|
||||
/**
|
||||
* @tc.name: UnInitDeviceManager_002
|
||||
* @tc.desc: 1. set packName not null
|
||||
* 2. MOCK IpcClientProxy UnInit return ERR_DM_UNINIT_FAILED
|
||||
* 2. MOCK IpcClientProxy UnInit return ERR_DM_FAILED
|
||||
* 3. call DeviceManagerImpl::UnInitDeviceManager with parameter
|
||||
* 4. check ret is ERR_DM_UNINIT_FAILED
|
||||
* 4. check ret is ERR_DM_FAILED
|
||||
* deviceTypeId
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000GHSJK
|
||||
@@ -201,10 +201,10 @@ HWTEST_F(DeviceManagerImplTest, UnInitDeviceManager_002, testing::ext::TestSize.
|
||||
// 2. call DeviceManagerImpl::InitDeviceManager with parameter
|
||||
std::shared_ptr<MockIpcClientProxy> mockInstance = std::make_shared<MockIpcClientProxy>();
|
||||
DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance;
|
||||
EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_UNINIT_FAILED));
|
||||
EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_FAILED));
|
||||
int32_t ret= DeviceManager::GetInstance().UnInitDeviceManager(packName);
|
||||
// 3. check ret is ERR_DM_UNINIT_FAILED
|
||||
ASSERT_EQ(ret, ERR_DM_UNINIT_FAILED);
|
||||
// 3. check ret is ERR_DM_FAILED
|
||||
ASSERT_EQ(ret, ERR_DM_FAILED);
|
||||
DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr;
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ HWTEST_F(DeviceManagerImplTest, UnInitDeviceManager_003, testing::ext::TestSize.
|
||||
* @tc.desc: 1. set packName not null
|
||||
* 2. MOCK IpcClientProxy UnInit return ERR_DM_INIT_FAILED
|
||||
* 3. call DeviceManagerImpl::UnInitDeviceManager with parameter
|
||||
* 4. check ret is ERR_DM_UNINIT_FAILED
|
||||
* 4. check ret is ERR_DM_FAILED
|
||||
* deviceTypeId
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000GHSJK
|
||||
@@ -251,8 +251,8 @@ HWTEST_F(DeviceManagerImplTest, UnInitDeviceManager_004, testing::ext::TestSize.
|
||||
DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance;
|
||||
EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_INIT_FAILED));
|
||||
int32_t ret= DeviceManager::GetInstance().UnInitDeviceManager(packName);
|
||||
// 3. check ret is ERR_DM_UNINIT_FAILED
|
||||
ASSERT_EQ(ret, ERR_DM_UNINIT_FAILED);
|
||||
// 3. check ret is ERR_DM_FAILED
|
||||
ASSERT_EQ(ret, ERR_DM_FAILED);
|
||||
DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr;
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ HWTEST_F(DeviceManagerImplTest, UnInitDeviceManager_004, testing::ext::TestSize.
|
||||
* @tc.desc: 1. set packName not null
|
||||
* 2. MOCK IpcClientProxy UnInit return ERR_DM_INIT_FAILED
|
||||
* 3. call DeviceManagerImpl::UnInitDeviceManager with parameter
|
||||
* 4. check ret is ERR_DM_UNINIT_FAILED
|
||||
* 4. check ret is ERR_DM_FAILED
|
||||
* deviceTypeId
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000GHSJK
|
||||
@@ -275,8 +275,8 @@ HWTEST_F(DeviceManagerImplTest, UnInitDeviceManager_005, testing::ext::TestSize.
|
||||
DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance;
|
||||
EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_INIT_FAILED));
|
||||
int32_t ret= DeviceManager::GetInstance().UnInitDeviceManager(packName);
|
||||
// 3. check ret is ERR_DM_UNINIT_FAILED
|
||||
ASSERT_EQ(ret, ERR_DM_UNINIT_FAILED);
|
||||
// 3. check ret is ERR_DM_FAILED
|
||||
ASSERT_EQ(ret, ERR_DM_FAILED);
|
||||
DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ HWTEST_F(IpcClientStubTest, OnRemoteRequest_001, testing::ext::TestSize.Level0)
|
||||
* set MessageParcel not null
|
||||
* 2. set set code is SERVER_DEVICE_FA_NOTIFY
|
||||
* 3. call IpcClientStub OnRemoteRequest with parameter
|
||||
* 4. check result is ERR_DM_IPC_READ_TOKEN_FAILED
|
||||
* 4. check result is ERR_DM_IPC_READ_FAILED
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000GHSJK
|
||||
*/
|
||||
@@ -104,8 +104,8 @@ HWTEST_F(IpcClientStubTest, OnRemoteRequest_002, testing::ext::TestSize.Level0)
|
||||
sptr<IpcClientStub> instance = new IpcClientStub();
|
||||
// 3. call IpcClientStub OnRemoteRequest with parameter
|
||||
int ret = instance->OnRemoteRequest(code, data, reply, option);
|
||||
// 4. check result is ERR_DM_IPC_READ_TOKEN_FAILED
|
||||
ASSERT_EQ(ret, ERR_DM_IPC_READ_TOKEN_FAILED);
|
||||
// 4. check result is ERR_DM_IPC_READ_FAILED
|
||||
ASSERT_EQ(ret, ERR_DM_IPC_READ_FAILED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -168,8 +168,8 @@ HWTEST_F(IpcServerStubTest, OnRemoteRequest_002, testing::ext::TestSize.Level0)
|
||||
int ret = 0;
|
||||
// 2. Call IpcServerStub OnRemoteRequest with param
|
||||
ret = IpcServerStub::GetInstance().OnRemoteRequest(code, data, reply, option);
|
||||
// 3. check ret not ERR_DM_IPC_READ_TOKEN_FAILED
|
||||
ASSERT_EQ(ret, ERR_DM_IPC_READ_TOKEN_FAILED);
|
||||
// 3. check ret not ERR_DM_IPC_READ_FAILED
|
||||
ASSERT_EQ(ret, ERR_DM_IPC_READ_FAILED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -138,7 +138,7 @@ HWTEST_F(ProfileConnectorTest, UnSubscribeProfileEvents_002, testing::ext::TestS
|
||||
profileConnector_ = std::make_shared<ProfileConnector>();
|
||||
int32_t ret = DM_OK;
|
||||
ret = profileConnector_->UnSubscribeProfileEvents();
|
||||
ASSERT_EQ(ret, DM_PROFILE_EVENTS_FAILED);
|
||||
ASSERT_EQ(ret, ERR_DM_PROFILE_EVENTS_FAILED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,20 +28,18 @@ static ERROR_INFO g_errorMessages[] = {
|
||||
{ERR_DM_NOT_INIT, "dm service is not initialized, please try again later."},
|
||||
{ERR_DM_INIT_REPEATED, "dm service repeated initialization."},
|
||||
{ERR_DM_INIT_FAILED, "dm service initialize failed."},
|
||||
{ERR_DM_UNINIT_FAILED, "dm Service uninitialization failed."},
|
||||
{ERR_DM_POINT_NULL, "dm service null pointer exception occurred."},
|
||||
{ERR_DM_INPUT_PARAMETER_EMPTY, "the function call input parameter is empty."},
|
||||
{ERR_DM_NO_PERMISSION, "no permission for function call."},
|
||||
{ERR_DM_MALLOC_FAILED, "memory allocation failed."},
|
||||
{ERR_DM_DISCOVERY_FAILED, "device discovery failed."},
|
||||
{ERR_DM_MAP_KEY_ALREADY_EXISTS, "map key already exists."},
|
||||
{DM_PROFILE_EVENTS_FAILED, "process profile events failed."},
|
||||
{ERR_DM_PROFILE_EVENTS_FAILED, "process profile events failed."},
|
||||
{ERR_DM_IPC_WRITE_FAILED, "ipc write object failed."},
|
||||
{ERR_DM_IPC_COPY_FAILED, "ipc copy data failed."},
|
||||
{ERR_DM_IPC_SEND_REQUEST_FAILED, "ipc send request failed."},
|
||||
{ERR_DM_UNSUPPORTED_IPC_COMMAND, "ipc command not supported."},
|
||||
{ERR_DM_IPC_RESPOND_FAILED, "ipc process failed to receive response."},
|
||||
{ERR_DM_IPC_WRITE_TOKEN_FAILED, "ipc write token failed."},
|
||||
{ERR_DM_DISCOVERY_REPEATED, "repeat device discovery warning."},
|
||||
{ERR_DM_UNSUPPORTED_AUTH_TYPE, "auth type not supported."},
|
||||
{ERR_DM_AUTH_BUSINESS_BUSY, "authentication service is busy."},
|
||||
@@ -52,9 +50,7 @@ static ERROR_INFO g_errorMessages[] = {
|
||||
{ERR_DM_AUTH_NOT_START, "auth process not started."},
|
||||
{ERR_DM_AUTH_MESSAGE_INCOMPLETE, "authentication message is incomplete."},
|
||||
{ERR_DM_CREATE_GROUP_FAILED, "create group failed."},
|
||||
{ERR_DM_IPC_READ_TOKEN_FAILED, "read ipc token failed."},
|
||||
{ERR_DM_AUTH_INPUT_PARAMETER_FAILED, "auth input parameter failed."},
|
||||
{ERR_DM_IPC_READ_FA_FAILED, "ipc read fa parms failed."},
|
||||
{ERR_DM_IPC_READ_FAILED, "ipc read object failed."},
|
||||
};
|
||||
|
||||
std::string GetErrorString(int failedReason)
|
||||
|
||||
Reference in New Issue
Block a user