!8406 Multi user adaptation

Merge pull request !8406 from sunnyfeng/master
This commit is contained in:
openharmony_ci 2024-11-21 14:38:54 +00:00 committed by Gitee
commit e9fe8ed808
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
12 changed files with 181 additions and 41 deletions

View File

@ -85,6 +85,7 @@ int32_t AuthDeviceProfileListener::OnTrustDeviceProfileActive(const TrustDeviceP
{
AUTH_LOGI(AUTH_INIT, "dp active callback enter!");
DelNotTrustDevice(profile.GetDeviceId().c_str());
LnnUpdateHeartbeatInfo(UPDATE_HB_NETWORK_INFO);
if (IsHeartbeatEnable()) {
if (LnnStartHbByTypeAndStrategy(
HEARTBEAT_TYPE_BLE_V0 | HEARTBEAT_TYPE_BLE_V3, STRATEGY_HB_SEND_SINGLE, false) != SOFTBUS_OK) {
@ -100,6 +101,7 @@ int32_t AuthDeviceProfileListener::OnTrustDeviceProfileInactive(const TrustDevic
{
AUTH_LOGI(AUTH_INIT, "dp inactive callback enter!");
LnnUpdateOhosAccount(true);
LnnUpdateHeartbeatInfo(UPDATE_HB_NETWORK_INFO);
int32_t userId = profile.GetPeerUserId();
AUTH_LOGI(AUTH_INIT, "userId:%{public}d", userId);
NotifyRemoteDevOffLineByUserId(userId, profile.GetDeviceId().c_str());

View File

@ -2106,7 +2106,7 @@ static void UnpackUserIdCheckSum(JsonObj *json, NodeInfo *nodeInfo)
return;
}
int32_t ret = ConvertHexStringToBytes(nodeInfo->userIdCheckSum, USERID_CHECKSUM_LEN,
userIdCheckSumHexStr, USERID_CHECKSUM_HEXSTRING_LEN);
userIdCheckSumHexStr, strlen(userIdCheckSumHexStr));
if (ret != SOFTBUS_OK) {
AUTH_LOGE(AUTH_FSM, "ConvertHexStringToBytes failed! ret:%{public}d", ret);
}

View File

@ -489,6 +489,20 @@ static void DeviceStateChangeProcess(char *udid, ConnectionAddrType type, bool i
}
}
static void NotifyUserChange(bool isChange, NodeInfo *oldInfo, NodeInfo *newInfo)
{
uint8_t defaultUserIdCheckSum[USERID_CHECKSUM_LEN] = {0};
if (memcmp(newInfo->userIdCheckSum, defaultUserIdCheckSum, USERID_CHECKSUM_LEN) == 0) {
return;
}
if (isChange || memcmp(oldInfo->userIdCheckSum, newInfo->userIdCheckSum, USERID_CHECKSUM_LEN) != 0) {
isChange = true;
} else {
isChange = false;
}
NotifyForegroundUseridChange(newInfo->networkId, newInfo->discoveryType, isChange);
}
static void SetLnnConnNodeInfo(
LnnConntionInfo *connInfo, const char *networkId, LnnConnectionFsm *connFsm, int32_t retCode)
{
@ -496,6 +510,9 @@ static void SetLnnConnNodeInfo(
uint64_t localFeature;
(void)LnnGetLocalNumU64Info(NUM_KEY_FEATURE_CAPA, &localFeature);
uint8_t relation[CONNECTION_ADDR_MAX] = { 0 };
NodeInfo oldInfo;
(void)memset_s(&oldInfo, sizeof(NodeInfo), 0, sizeof(NodeInfo));
int32_t ret = LnnRetrieveDeviceInfoByNetworkId(networkId, &oldInfo);
report = LnnAddOnlineNode(connInfo->nodeInfo);
LnnOfflineTimingByHeartbeat(networkId, connInfo->addr.type);
if (LnnInsertLinkFinderInfo(networkId) != SOFTBUS_OK) {
@ -515,6 +532,9 @@ static void SetLnnConnNodeInfo(
}
NotifyJoinResult(connFsm, networkId, retCode);
ReportResult(connInfo->nodeInfo->deviceInfo.deviceUdid, report);
if (report == REPORT_ONLINE) {
NotifyUserChange(ret != SOFTBUS_OK, &oldInfo, connInfo->nodeInfo);
}
connInfo->flag |= LNN_CONN_INFO_FLAG_ONLINE;
LnnNotifyNodeStateChanged(&connInfo->addr);
LnnGetLnnRelation(networkId, CATEGORY_NETWORK_ID, relation, CONNECTION_ADDR_MAX);

View File

@ -21,6 +21,7 @@
#include "bus_center_info_key.h"
#include "bus_center_manager.h"
#include "lnn_async_callback_utils.h"
#include "lnn_ohos_account.h"
#include "lnn_file_utils.h"
#include "lnn_heartbeat_ctrl.h"
#include "lnn_huks_utils.h"
@ -51,6 +52,8 @@ static bool g_isDbListInit = false;
static struct HksBlob g_keyAlias = { sizeof(LNN_DB_KEY_AILAS), (uint8_t *)LNN_DB_KEY_AILAS };
static struct HksBlob g_ceKeyAlias = { sizeof(LNN_DB_KEY_AILAS), (uint8_t *)LNN_DB_KEY_AILAS };
static int32_t GetLocalAccountHexHash(char *accountHexHash);
static bool DeviceDbRecoveryInit(void)
{
if (SoftBusMutexInit(&g_deviceDbMutex, NULL) != SOFTBUS_OK) {
@ -270,7 +273,7 @@ static int32_t BuildTrustedDevInfoRecord(const char *udid, TrustedDevInfoRecord
{
uint8_t accountHash[SHA_256_HASH_LEN] = {0};
char accountHexHash[SHA_256_HEX_HASH_LEN] = {0};
int32_t userId = GetActiveOsAccountIds();
if (udid == NULL || record == NULL) {
LNN_LOGE(LNN_LEDGER, "invalid param");
return SOFTBUS_INVALID_PARAM;
@ -287,14 +290,16 @@ static int32_t BuildTrustedDevInfoRecord(const char *udid, TrustedDevInfoRecord
LNN_LOGE(LNN_LEDGER, "convert accountHash failed");
return SOFTBUS_ERR;
}
if (strcpy_s(record->accountHexHash, sizeof(record->accountHexHash), accountHexHash) != EOK) {
LNN_LOGE(LNN_LEDGER, "memcpy_s account hash failed");
return SOFTBUS_MEM_ERR;
if (sprintf_s(record->accountHexHash, SHA_256_HEX_HASH_LEN + LNN_INT32_NUM_STR_MAX_LEN + 1,
"%s-%d", accountHexHash, userId) < 0) {
LNN_LOGE(LNN_LEDGER, "sprintf_s fail");
return SOFTBUS_SPRINTF_ERR;
}
if (strcpy_s(record->udid, sizeof(record->udid), udid) != EOK) {
LNN_LOGE(LNN_LEDGER, "memcpy_s udid hash failed");
return SOFTBUS_MEM_ERR;
}
record->userId = userId;
return SOFTBUS_OK;
}
@ -386,6 +391,12 @@ static void RemoveTrustedDevInfoRecord(void *param)
LNN_LOGE(LNN_LEDGER, "encrypt database failed");
break;
}
// delete oldRecord
TrustedDevInfoRecord oldRecord = record;
(void)memset_s(oldRecord.accountHexHash, sizeof(oldRecord.accountHexHash), 0, sizeof(oldRecord.accountHexHash));
if (GetLocalAccountHexHash(oldRecord.accountHexHash) == SOFTBUS_OK) {
(void)RemoveRecordByKey(ctx, TABLE_TRUSTED_DEV_INFO, (uint8_t *)&oldRecord);
}
if (RemoveRecordByKey(ctx, TABLE_TRUSTED_DEV_INFO, (uint8_t *)&record) == SOFTBUS_OK) {
(void)LnnAsyncCallbackHelper(GetLooper(LOOP_TYPE_DEFAULT), CompleteUpdateTrustedDevInfo, NULL);
}
@ -411,7 +422,8 @@ static void DeleteDeviceFromList(TrustedDevInfoRecord *record)
DeviceDbInfo *next = NULL;
LIST_FOR_EACH_ENTRY_SAFE(item, next, &g_deviceInfoList, DeviceDbInfo, node) {
if (strcmp(item->infoRecord.accountHexHash, record->accountHexHash) == 0 &&
strcmp(item->infoRecord.udid, record->udid) == 0) {
strcmp(item->infoRecord.udid, record->udid) == 0 &&
item->infoRecord.userId == record->userId) {
char *anonyUdid = NULL;
Anonymize(record->udid, &anonyUdid);
LNN_LOGI(LNN_LEDGER, "delete device db from list. udid=%{public}s", AnonymizeWrapper(anonyUdid));
@ -433,7 +445,8 @@ static void InsertDeviceToList(TrustedDevInfoRecord *record)
DeviceDbInfo *item = NULL;
LIST_FOR_EACH_ENTRY(item, &g_deviceInfoList, DeviceDbInfo, node) {
if (strcmp(item->infoRecord.accountHexHash, record->accountHexHash) == 0 &&
strcmp(item->infoRecord.udid, record->udid) == 0) {
strcmp(item->infoRecord.udid, record->udid) == 0 &&
item->infoRecord.userId == record->userId) {
DeviceDbListUnlock();
return;
}
@ -561,32 +574,48 @@ static int32_t GetLocalAccountHexHash(char *accountHexHash)
return SOFTBUS_OK;
}
static int32_t GetAllDevNums(char *accountHexHash, uint32_t *num)
static int32_t GetAllDevNums(char *accountHexHash, uint32_t *num, int32_t userId)
{
DeviceDbInfo *item = NULL;
LIST_FOR_EACH_ENTRY(item, &g_deviceInfoList, DeviceDbInfo, node) {
if (strcmp(accountHexHash, item->infoRecord.accountHexHash) == 0) {
if (strcmp(accountHexHash, item->infoRecord.accountHexHash) == 0 && item->infoRecord.userId == userId) {
(*num)++;
}
}
return SOFTBUS_OK;
}
int32_t LnnGetTrustedDevInfoFromDb(char **udidArray, uint32_t *num)
static int32_t GenerateAccountHexHashWithUserId(char *accountHexHashAndUserId, int32_t *userId)
{
char accountHexHash[SHA_256_HEX_HASH_LEN] = {0};
if (udidArray == NULL || num == NULL) {
return SOFTBUS_INVALID_PARAM;
}
*userId = GetActiveOsAccountIds();
if (GetLocalAccountHexHash(accountHexHash) != SOFTBUS_OK) {
LNN_LOGE(LNN_LEDGER, "get local account hash failed");
return SOFTBUS_NETWORK_GET_NODE_INFO_ERR;
}
if (sprintf_s(accountHexHashAndUserId, SHA_256_HEX_HASH_LEN + LNN_INT32_NUM_STR_MAX_LEN + 1,
"%s-%d", accountHexHash, *userId) < 0) {
LNN_LOGE(LNN_LEDGER, "sprintf_s fail");
return SOFTBUS_SPRINTF_ERR;
}
return SOFTBUS_OK;
}
int32_t LnnGetTrustedDevInfoFromDb(char **udidArray, uint32_t *num)
{
char accountHexHashAndUserId[SHA_256_HEX_HASH_LEN + LNN_INT32_NUM_STR_MAX_LEN + 1] = {0};
int32_t userId = 0;
LNN_CHECK_AND_RETURN_RET_LOGE((udidArray != NULL) && (num != NULL), SOFTBUS_INVALID_PARAM, LNN_LEDGER,
"invalid param");
if (GenerateAccountHexHashWithUserId(accountHexHashAndUserId, &userId) != SOFTBUS_OK) {
return SOFTBUS_NETWORK_GET_NODE_INFO_ERR;
}
if (DeviceDbListLock() != SOFTBUS_OK) {
LNN_LOGE(LNN_LEDGER, "lock fail");
return SOFTBUS_LOCK_ERR;
}
int32_t ret = GetAllDevNums(accountHexHash, num);
int32_t ret = GetAllDevNums(accountHexHashAndUserId, num, userId);
if (ret != SOFTBUS_OK) {
LNN_LOGE(LNN_LEDGER, "get all dev num fail");
DeviceDbListUnlock();
@ -611,7 +640,8 @@ int32_t LnnGetTrustedDevInfoFromDb(char **udidArray, uint32_t *num)
if (cur >= *num) {
break;
}
if (strcmp(accountHexHash, item->infoRecord.accountHexHash) != 0) {
if (strcmp(accountHexHashAndUserId, item->infoRecord.accountHexHash) != 0 ||
item->infoRecord.userId != userId) {
continue;
}
if (strcpy_s(*udidArray + cur * UDID_BUF_LEN, UDID_BUF_LEN, item->infoRecord.udid) != EOK) {
@ -624,18 +654,13 @@ int32_t LnnGetTrustedDevInfoFromDb(char **udidArray, uint32_t *num)
return SOFTBUS_OK;
}
static int32_t GetTrustedDevInfoFromDb(char **udidArray, uint32_t *num)
static int32_t GetTrustedDevInfoFromDb(char **udidArray, uint32_t *num, char *accountHexHash)
{
char accountHexHash[SHA_256_HEX_HASH_LEN] = {0};
DbContext *ctx = NULL;
if (udidArray == NULL || num == NULL) {
return SOFTBUS_INVALID_PARAM;
}
if (GetLocalAccountHexHash(accountHexHash) != SOFTBUS_OK) {
LNN_LOGE(LNN_LEDGER, "get local account hash failed");
return SOFTBUS_NETWORK_GET_NODE_INFO_ERR;
}
if (DbLock() != SOFTBUS_OK) {
LNN_LOGE(LNN_LEDGER, "lock fail");
return SOFTBUS_LOCK_ERR;
@ -661,12 +686,11 @@ static int32_t GetTrustedDevInfoFromDb(char **udidArray, uint32_t *num)
return rc;
}
static int32_t RecoveryTrustedDevInfo(void)
static int32_t RecoveryTrustedDevInfoProcess(char *accountHexHash, int32_t activeUserId, bool oldData)
{
uint32_t num = 0;
char *udidArray = NULL;
char accountHexHash[SHA_256_HEX_HASH_LEN] = {0};
if (GetTrustedDevInfoFromDb(&udidArray, &num) != SOFTBUS_OK) {
if (GetTrustedDevInfoFromDb(&udidArray, &num, accountHexHash) != SOFTBUS_OK) {
LNN_LOGE(LNN_LEDGER, "get trusted dev info fail");
return SOFTBUS_NETWORK_GET_DEVICE_INFO_ERR;
}
@ -675,10 +699,10 @@ static int32_t RecoveryTrustedDevInfo(void)
LNN_LOGE(LNN_LEDGER, "get none trusted dev info");
return SOFTBUS_OK;
}
if (GetLocalAccountHexHash(accountHexHash) != SOFTBUS_OK) {
LNN_LOGE(LNN_LEDGER, "get local account hash failed");
SoftBusFree(udidArray);
return SOFTBUS_NETWORK_GET_NODE_INFO_ERR;
if (oldData && sprintf_s(accountHexHash, SHA_256_HEX_HASH_LEN + LNN_INT32_NUM_STR_MAX_LEN + 1,
"%s-%d", accountHexHash, activeUserId) < 0) {
LNN_LOGE(LNN_LEDGER, "sprintf_s fail");
return SOFTBUS_STRCPY_ERR;
}
if (DeviceDbListLock() != SOFTBUS_OK) {
LNN_LOGE(LNN_LEDGER, "db lock fail");
@ -694,14 +718,15 @@ static int32_t RecoveryTrustedDevInfo(void)
}
if (memcpy_s(udidStr, UDID_BUF_LEN, udidArray + i * UDID_BUF_LEN, UDID_BUF_LEN) != EOK ||
memcpy_s(info->infoRecord.udid, UDID_BUF_LEN, udidStr, UDID_BUF_LEN) != EOK ||
memcpy_s(info->infoRecord.accountHexHash, SHA_256_HEX_HASH_LEN, accountHexHash,
SHA_256_HEX_HASH_LEN) != EOK) {
memcpy_s(info->infoRecord.accountHexHash, SHA_256_HEX_HASH_LEN + LNN_INT32_NUM_STR_MAX_LEN + 1,
accountHexHash, SHA_256_HEX_HASH_LEN + LNN_INT32_NUM_STR_MAX_LEN + 1) != EOK) {
LNN_LOGE(LNN_LEDGER, "udid str cpy fail.");
DeviceDbListUnlock();
SoftBusFree(info);
SoftBusFree(udidArray);
return SOFTBUS_MEM_ERR;
}
info->infoRecord.userId = activeUserId;
ListNodeInsert(&g_deviceInfoList, &info->node);
}
DeviceDbListUnlock();
@ -709,6 +734,33 @@ static int32_t RecoveryTrustedDevInfo(void)
return SOFTBUS_OK;
}
static int32_t RecoveryTrustedDevInfo(void)
{
char accountHexHash[SHA_256_HEX_HASH_LEN + LNN_INT32_NUM_STR_MAX_LEN + 1] = {0};
char tempAccountAccountHexHash[SHA_256_HEX_HASH_LEN + LNN_INT32_NUM_STR_MAX_LEN + 1] = {0};
if (GetLocalAccountHexHash(accountHexHash) != SOFTBUS_OK) {
LNN_LOGE(LNN_LEDGER, "get local account hash failed");
return SOFTBUS_NETWORK_GET_NODE_INFO_ERR;
}
if (strcpy_s(tempAccountAccountHexHash, SHA_256_HEX_HASH_LEN + LNN_INT32_NUM_STR_MAX_LEN + 1,
accountHexHash)!= EOK) {
LNN_LOGE(LNN_LEDGER, "strcpy fail");
return SOFTBUS_STRCPY_ERR;
}
RecoveryTrustedDevInfoProcess(accountHexHash, LNN_DEFAULT_USERID, true);
char accountHexHashAndUserId[SHA_256_HEX_HASH_LEN + LNN_INT32_NUM_STR_MAX_LEN + 1] = {0};
int32_t userId = GetActiveOsAccountIds();
LNN_LOGI(LNN_LEDGER, "activeUserId=%{public}d", userId);
if (sprintf_s(accountHexHashAndUserId, SHA_256_HEX_HASH_LEN + LNN_INT32_NUM_STR_MAX_LEN + 1,
"%s-%d", tempAccountAccountHexHash, userId) < 0) {
LNN_LOGE(LNN_LEDGER, "sprintf_s fail");
return SOFTBUS_SPRINTF_ERR;
}
RecoveryTrustedDevInfoProcess(accountHexHashAndUserId, userId, false);
return SOFTBUS_OK;
}
static void ClearRecoveryDeviceList(void)
{
if (DeviceDbListLock() != SOFTBUS_OK) {

View File

@ -1221,7 +1221,6 @@ ReportCategory LnnAddOnlineNode(NodeInfo *info)
SoftBusMutexUnlock(&g_distributedNetLedger.lock);
NodeOnlineProc(info);
UpdateDpSameAccount(info->accountId, info->deviceInfo.deviceUdid);
CheckUserIdCheckSumChange(oldInfo, info);
if (infoAbility.isNetworkChanged) {
UpdateNetworkInfo(info->deviceInfo.deviceUdid);
}

View File

@ -55,6 +55,7 @@ typedef enum {
NOTIFY_NODE_STATUS_CHANGED,
NOTIFY_NETWORKID_UPDATE,
NOTIFY_LOCAL_NETWORKID_UPDATE,
NOTIFY_DEVICE_TRUSTED_CHANGED,
} NotifyType;
#define NETWORK_ID_UPDATE_DELAY_TIME (60 * 60 * 1000 * 24) // 24 hour
@ -108,6 +109,17 @@ static void HandleOnlineStateChangedMessage(SoftBusMessage *msg)
LnnDCProcessOnlineState(isOnline, (NodeBasicInfo *)msg->obj);
}
static void HandleDeviceTrustedChangedMessage(SoftBusMessage *msg)
{
if (msg->obj == NULL) {
LNN_LOGE(LNN_EVENT, "invalid online state message");
return;
}
int32_t type = (int32_t)msg->arg1;
uint32_t msgLen = (uint32_t)msg->arg2;
(void)LnnIpcNotifyDeviceTrustedChange(type, (const char*)msg->obj, msgLen);
}
static void HandleNodeBasicInfoChangedMessage(SoftBusMessage *msg)
{
if (msg->obj == NULL) {
@ -171,6 +183,9 @@ static void HandleNotifyMessage(SoftBusMessage *msg)
case NOTIFY_NETWORKID_UPDATE:
HandleNetworkUpdateMessage(msg);
break;
case NOTIFY_DEVICE_TRUSTED_CHANGED:
HandleDeviceTrustedChangedMessage(msg);
break;
default:
LNN_LOGE(LNN_EVENT, "unknown notify msgType=%{public}d", msg->what);
break;
@ -267,6 +282,47 @@ static int32_t PostNotifyNodeStatusMessage(int32_t what, uint64_t arg, const Nod
return PostMessageToHandlerDelay(msg, 0);
}
static char *DupDeviceTrustedChangeMsg(const char *msg)
{
if (msg == NULL) {
LNN_LOGW(LNN_EVENT, "msg is null");
return NULL;
}
int32_t len = strlen(msg) + 1;
char *dupMsg = SoftBusCalloc(len);
if (dupMsg == NULL) {
LNN_LOGE(LNN_EVENT, "malloc dupMsg err");
return NULL;
}
if (strcpy_s(dupMsg, len, msg) != EOK) {
LNN_LOGE(LNN_EVENT, "copy dupMsg fail");
SoftBusFree(dupMsg);
return NULL;
}
return dupMsg;
}
static int32_t PostNotifyDeviceTrustedChangeMessage(int32_t what, int32_t type, const char *notifyMsg, uint32_t msgLen)
{
SoftBusMessage *msg = SoftBusCalloc(sizeof(SoftBusMessage));
if (msg == NULL) {
LNN_LOGE(LNN_EVENT, "malloc msg err");
return SOFTBUS_MALLOC_ERR;
}
msg->what = what;
msg->arg1 = (uint64_t)type;
msg->arg2 = (uint64_t)msgLen;
msg->obj = DupDeviceTrustedChangeMsg(notifyMsg);
if (msg->obj == NULL) {
LNN_LOGE(LNN_EVENT, "dup notifyMsg err");
SoftBusFree(msg);
return SOFTBUS_MEM_ERR;
}
msg->handler = &g_notifyHandler;
msg->FreeMessage = FreeNotifyMessage;
return PostMessageToHandlerDelay(msg, 0);
}
static int32_t PostNotifyMessageDelay(int32_t what, uint64_t delayMillis)
{
SoftBusMessage *msg = SoftBusCalloc(sizeof(SoftBusMessage));
@ -452,11 +508,11 @@ void LnnNotifyLocalNetworkIdChanged(void)
void LnnNotifyDeviceTrustedChange(int32_t type, const char *msg, uint32_t msgLen)
{
if (msg == NULL) {
if (msg == NULL || msgLen == 0) {
LNN_LOGE(LNN_EVENT, "msg is null");
return;
}
(void)LnnIpcNotifyDeviceTrustedChange(type, msg, msgLen);
PostNotifyDeviceTrustedChangeMessage(NOTIFY_DEVICE_TRUSTED_CHANGED, type, msg, msgLen);
}
void LnnNotifyHichainProofException(

View File

@ -35,6 +35,8 @@ extern "C" {
#endif
#define DATABASE_NAME DEFAULT_STORAGE_PATH"/dsoftbus/dsoftbus.db3"
#define LNN_DEFAULT_USERID 100
#define LNN_INT32_NUM_STR_MAX_LEN 11
typedef struct {
sqlite3 *db;
@ -48,8 +50,9 @@ typedef enum {
} TableNameID;
typedef struct {
char accountHexHash[SHA_256_HEX_HASH_LEN];
char accountHexHash[SHA_256_HEX_HASH_LEN + LNN_INT32_NUM_STR_MAX_LEN + 1];
char udid[UDID_BUF_LEN];
int32_t userId;
} TrustedDevInfoRecord;
typedef enum {

View File

@ -885,6 +885,7 @@ ohos_unittest("AuthDeviceProfileListenerTest") {
module_out_path = module_output_path
sources = [
"$dsoftbus_root_path/core/authentication/bind/auth_device_profile_listener.cpp",
"$dsoftbus_root_path/core/bus_center/lnn/lane_hub/heartbeat/src/lnn_heartbeat_ctrl_virtual.c",
"unittest/auth_device_profile_listener_mock.cpp",
"unittest/auth_device_profile_listener_test.cpp",
]

View File

@ -41,11 +41,6 @@ void DelNotTrustDevice(const char *udid)
return GetInterface()->DelNotTrustDevice(udid);
}
bool IsHeartbeatEnable(void)
{
return GetInterface()->IsHeartbeatEnable();
}
void RestartCoapDiscovery(void)
{
return GetInterface()->RestartCoapDiscovery();

View File

@ -26,7 +26,6 @@ public:
AuthDeviceProfileListenerInterface() {};
virtual ~AuthDeviceProfileListenerInterface() {};
virtual void DelNotTrustDevice(const char *udid) = 0;
virtual bool IsHeartbeatEnable(void) = 0;
virtual void RestartCoapDiscovery(void) = 0;
virtual int32_t LnnStartHbByTypeAndStrategy(
LnnHeartbeatType hbType, LnnHeartbeatStrategyType strategyType, bool isRelay) = 0;
@ -38,7 +37,6 @@ public:
AuthDeviceProfileListenerInterfaceMock();
~AuthDeviceProfileListenerInterfaceMock() override;
MOCK_METHOD1(DelNotTrustDevice, void (const char *udid));
MOCK_METHOD0(IsHeartbeatEnable, bool());
MOCK_METHOD0(RestartCoapDiscovery, void(void));
MOCK_METHOD3(LnnStartHbByTypeAndStrategy, int32_t(LnnHeartbeatType, LnnHeartbeatStrategyType, bool));
MOCK_METHOD1(LnnUpdateOhosAccount, void (bool));

View File

@ -47,6 +47,7 @@ public:
virtual int32_t LnnUpdateNetworkId(const NodeInfo *newInfo) = 0;
virtual int32_t AuthGetServerSide(int64_t authId, bool *isServer) = 0;
virtual int32_t LnnRetrieveDeviceInfo(const char *udid, NodeInfo *deviceInfo) = 0;
virtual int32_t LnnRetrieveDeviceInfoByNetworkId(const char *networkId, NodeInfo *info) = 0;
virtual int32_t AuthRestoreAuthManager(const char *udidHash, const AuthConnInfo *connInfo, uint32_t requestId,
NodeInfo *nodeInfo, int64_t *authId) = 0;
virtual int32_t LnnLoadLocalBroadcastCipherKey(void) = 0;
@ -64,6 +65,7 @@ public:
virtual void LnnNotifyOOBEStateChangeEvent(SoftBusOOBEState state) = 0;
virtual void LnnNotifyHichainProofException(
const char *proofInfo, uint32_t proofLen, uint16_t deviceTypeId, int32_t errCode) = 0;
virtual void LnnNotifyDeviceTrustedChange(int32_t type, const char *msg, uint32_t msgLen) = 0;
};
class LnnConnFsmInterfaceMock : public LnnConnFsmInterface {
@ -78,6 +80,7 @@ public:
MOCK_METHOD1(LnnUpdateNetworkId, int32_t (const NodeInfo *));
MOCK_METHOD2(AuthGetServerSide, int32_t (int64_t, bool *));
MOCK_METHOD2(LnnRetrieveDeviceInfo, int32_t (const char *, NodeInfo *));
MOCK_METHOD2(LnnRetrieveDeviceInfoByNetworkId, int32_t (const char *, NodeInfo *));
MOCK_METHOD5(AuthRestoreAuthManager, int32_t (const char *, const AuthConnInfo *, uint32_t, NodeInfo *,
int64_t *));
MOCK_METHOD0(LnnLoadLocalBroadcastCipherKey, int32_t (void));
@ -94,6 +97,7 @@ public:
MOCK_METHOD1(LnnConvAddrTypeToDiscType, DiscoveryType (ConnectionAddrType));
MOCK_METHOD1(LnnNotifyOOBEStateChangeEvent, void (SoftBusOOBEState));
MOCK_METHOD4(LnnNotifyHichainProofException, void(const char *, uint32_t, uint16_t, int32_t));
MOCK_METHOD3(LnnNotifyDeviceTrustedChange, void(int32_t type, const char *msg, uint32_t msgLen));
};
} // namespace OHOS
#endif // LNN_CONNECTION_FSM_MOCK_H

View File

@ -76,6 +76,11 @@ int32_t LnnRetrieveDeviceInfo(const char *udid, NodeInfo *deviceInfo)
return GetLnnConnInterface()->LnnRetrieveDeviceInfo(udid, deviceInfo);
}
int32_t LnnRetrieveDeviceInfoByNetworkId(const char *networkId, NodeInfo *info)
{
return GetLnnConnInterface()->LnnRetrieveDeviceInfo(networkId, info);
}
int32_t AuthRestoreAuthManager(const char *udidHash, const AuthConnInfo *connInfo, uint32_t requestId,
NodeInfo *nodeInfo, int64_t *authId)
{
@ -152,5 +157,10 @@ void LnnNotifyHichainProofException(
{
return GetLnnConnInterface()->LnnNotifyHichainProofException(proofInfo, proofLen, deviceTypeId, errCode);
}
void LnnNotifyDeviceTrustedChange(int32_t type, const char *msg, uint32_t msgLen)
{
return GetLnnConnInterface()->LnnNotifyDeviceTrustedChange(type, msg, msgLen);
}
}
} // namespace OHOS