已关闭
feat: add SetCommand and RegisterCommandCb command test #12520
wang-ge创建于 15 天前关闭于 4 天前
feat: add SetCommand and RegisterCommandCb command test #12520
已关闭
共 33 个文件变更+763-42
| @@ -49,6 +49,7 @@ void AuthNotifyDeviceDisconnect(AuthHandle authHandle); | |||
| 49 | void AuthAddNodeToLimitMap(const char *udid, int32_t reason); | 49 | void AuthAddNodeToLimitMap(const char *udid, int32_t reason); |
| 50 | void AuthDeleteLimitMap(const char *udidHash); | 50 | void AuthDeleteLimitMap(const char *udidHash); |
| 51 | int32_t AuthRegisterToDpDelay(void); | 51 | int32_t AuthRegisterToDpDelay(void); |
| 52 | +int32_t AuthNotifyDeviceNotTrusted(const char *peerUdid, int32_t localUserId); | ||
| 52 | 53 | ||
| 53 | 54 | ||
| 54 | 55 | ||
| @@ -49,6 +49,7 @@ typedef struct { | |||
| 49 | const char *deviceId; | 49 | const char *deviceId; |
| 50 | int32_t peerUserId; | 50 | int32_t peerUserId; |
| 51 | int32_t localUserId; | 51 | int32_t localUserId; |
| 52 | + const char *credId; | ||
| 52 | } UpdateDpAclParams; | 53 | } UpdateDpAclParams; |
| 53 | 54 | ||
| 54 | typedef struct { | 55 | typedef struct { |
| @@ -31,6 +31,7 @@ typedef enum { | |||
| 31 | ACCOUNT_RELATED = 1, /**< ACCOUNT_RELATED form identity_service_define */ | 31 | ACCOUNT_RELATED = 1, /**< ACCOUNT_RELATED form identity_service_define */ |
| 32 | ACCOUNT_UNRELATED = 2, /**< ACCOUNT_UNRELATED form identity_service_define */ | 32 | ACCOUNT_UNRELATED = 2, /**< ACCOUNT_UNRELATED form identity_service_define */ |
| 33 | ACCOUNT_SHARED = 3, /**< ACCOUNT_SHARED form identity_service_define */ | 33 | ACCOUNT_SHARED = 3, /**< ACCOUNT_SHARED form identity_service_define */ |
| 34 | + ACCOUNT_RELATED_APP = 4, /**< app-level same-account */ | ||
| 34 | ACCOUNT_BUTT, | 35 | ACCOUNT_BUTT, |
| 35 | } SoftbusCredType; | 36 | } SoftbusCredType; |
| 36 | 37 | ||
| @@ -451,6 +451,24 @@ static void OnDeviceNotTrusted(const char *peerUdid, int32_t localUserId, Handle | |||
| 451 | AuthRemoveDeviceKeyByUdidPacked(peerUdid); | 451 | AuthRemoveDeviceKeyByUdidPacked(peerUdid); |
| 452 | } | 452 | } |
| 453 | 453 | ||
| 454 | +int32_t AuthNotifyDeviceNotTrusted(const char *peerUdid, int32_t localUserId) | ||
| 455 | +{ | ||
| 456 | + if (peerUdid == NULL) { | ||
| 457 | + AUTH_LOGE(AUTH_HICHAIN, "peerUdid is null"); | ||
| 458 | + return SOFTBUS_INVALID_PARAM; | ||
| 459 | + } | ||
| 460 | + char networkId[NETWORK_ID_BUF_LEN] = {0}; | ||
| 461 | + if (LnnGetNetworkIdByUdid(peerUdid, networkId, NETWORK_ID_BUF_LEN) != SOFTBUS_OK) { | ||
| 462 | + AUTH_LOGW(AUTH_HICHAIN, "peer device not in ledger, no need offline"); | ||
| 463 | + return SOFTBUS_NOT_FIND; | ||
| 464 | + } | ||
| 465 | + AUTH_LOGI(AUTH_HICHAIN, "notify device offline by acl enter"); | ||
| 466 | + OnDeviceNotTrusted(peerUdid, localUserId, HICHAIN_DEVICE); | ||
| 467 | + return SOFTBUS_OK; | ||
| 468 | +} | ||
| 469 | + | ||
| 470 | + | ||
| 471 | + | ||
| 454 | int32_t RegAuthVerifyListener(const AuthVerifyListener *listener) | 472 | int32_t RegAuthVerifyListener(const AuthVerifyListener *listener) |
| 455 | { | 473 | { |
| 456 | if (listener == NULL) { | 474 | if (listener == NULL) { |
| @@ -9,11 +9,12 @@ | |||
| 9 | * Unless required by applicable law or agreed to in writing, software | 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, | 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | - * See the License for the specific language governing permission and | 12 | + * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. | 13 | * limitations under the License. |
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | + | ||
| 17 | 18 | ||
| 18 | extern "C" { | 19 | extern "C" { |
| 19 | bool IsPotentialTrustedDeviceDp(const char *deviceIdHash, bool isOnlyPointToPoint) | 20 | bool IsPotentialTrustedDeviceDp(const char *deviceIdHash, bool isOnlyPointToPoint) |
| @@ -34,19 +35,33 @@ bool DpHasAccessControlProfile(const char *udid, bool isNeedUserId, int32_t loca | |||
| 34 | void UpdateDpSameAccount(UpdateDpAclParams *aclParams, SessionKey sessionKey, bool isNeedUpdateDk, | 35 | void UpdateDpSameAccount(UpdateDpAclParams *aclParams, SessionKey sessionKey, bool isNeedUpdateDk, |
| 35 | AclWriteState aclState, bool *isNeedUpdateAclState) | 36 | AclWriteState aclState, bool *isNeedUpdateAclState) |
| 36 | { | 37 | { |
| 37 | - (void)aclParams; | ||
| 38 | (void)sessionKey; | 38 | (void)sessionKey; |
| 39 | (void)isNeedUpdateDk; | 39 | (void)isNeedUpdateDk; |
| 40 | - (void)aclState; | 40 | + if (aclParams == nullptr || aclParams->deviceId == nullptr || isNeedUpdateAclState == nullptr) { |
| 41 | - (void)isNeedUpdateAclState; | 41 | + return; |
| 42 | + } | ||
| 43 | + *isNeedUpdateAclState = false; | ||
| 44 | + if (aclState == ACL_NOT_WRITE) { | ||
| 45 | + return; | ||
| 46 | + } | ||
| 47 | + if (isNeedUpdateDk || aclState == ACL_CAN_WRITE) { | ||
| 48 | + *isNeedUpdateAclState = true; | ||
| 49 | + } | ||
| 42 | } | 50 | } |
| 43 | 51 | ||
| 44 | void UpdateDpSameAccountWithoutUserKey(UpdateDpAclParams *aclParams, AclWriteState aclState, | 52 | void UpdateDpSameAccountWithoutUserKey(UpdateDpAclParams *aclParams, AclWriteState aclState, |
| 45 | bool *isNeedUpdateAclState) | 53 | bool *isNeedUpdateAclState) |
| 46 | { | 54 | { |
| 47 | - (void)aclParams; | 55 | + if (aclParams == nullptr || aclParams->deviceId == nullptr || isNeedUpdateAclState == nullptr) { |
| 48 | - (void)aclState; | 56 | + return; |
| 49 | - (void)isNeedUpdateAclState; | 57 | + } |
| 58 | + *isNeedUpdateAclState = false; | ||
| 59 | + if (aclState == ACL_NOT_WRITE) { | ||
| 60 | + return; | ||
| 61 | + } | ||
| 62 | + if (aclState == ACL_CAN_WRITE) { | ||
| 63 | + *isNeedUpdateAclState = true; | ||
| 64 | + } | ||
| 50 | } | 65 | } |
| 51 | 66 | ||
| 52 | void DelNotTrustDevice(const char *udid) | 67 | void DelNotTrustDevice(const char *udid) |
| @@ -149,11 +149,21 @@ static void DfxRecordLnnEndHichainEnd(int64_t authSeq, int32_t reason) | |||
| 149 | 149 | ||
| 150 | static void OnFinish(int64_t authSeq, int operationCode, const char *returnData) | 150 | static void OnFinish(int64_t authSeq, int operationCode, const char *returnData) |
| 151 | { | 151 | { |
| 152 | - (void)returnData; | ||
| 153 | AclWriteState aclState = (operationCode == AUTH_FORM_IDENTICAL_ACCOUNT ? ACL_CAN_WRITE : ACL_NOT_WRITE); | 152 | AclWriteState aclState = (operationCode == AUTH_FORM_IDENTICAL_ACCOUNT ? ACL_CAN_WRITE : ACL_NOT_WRITE); |
| 154 | DfxRecordLnnEndHichainEnd(authSeq, SOFTBUS_OK); | 153 | DfxRecordLnnEndHichainEnd(authSeq, SOFTBUS_OK); |
| 155 | AUTH_LOGI(AUTH_HICHAIN, "hichain OnFinish: operationCode=%{public}d, authSeq=%{public}" PRId64, | 154 | AUTH_LOGI(AUTH_HICHAIN, "hichain OnFinish: operationCode=%{public}d, authSeq=%{public}" PRId64, |
| 156 | operationCode, authSeq); | 155 | operationCode, authSeq); |
| 156 | + if (operationCode == AUTH_FORM_IDENTICAL_ACCOUNT && returnData != NULL) { | ||
| 157 | + cJSON *retJson = cJSON_Parse(returnData); | ||
| 158 | + if (retJson != NULL) { | ||
| 159 | + cJSON *authTypeJson = cJSON_GetObjectItem(retJson, "authType"); | ||
| 160 | + if (authTypeJson != NULL && cJSON_IsNumber(authTypeJson) && authTypeJson->valueint == 4) { | ||
| 161 | + AUTH_LOGI(AUTH_HICHAIN, "app-level same-account credential auth success, authSeq=%{public}" PRId64, | ||
| 162 | + authSeq); | ||
| 163 | + } | ||
| 164 | + cJSON_Delete(retJson); | ||
| 165 | + } | ||
| 166 | + } | ||
| 157 | (void)AuthSessionHandleAuthFinish(authSeq, aclState); | 167 | (void)AuthSessionHandleAuthFinish(authSeq, aclState); |
| 158 | } | 168 | } |
| 159 | 169 | ||
| @@ -74,6 +74,21 @@ static char *IdServiceGenerateQueryParamByCredType(int32_t peerUserId, const cha | |||
| 74 | return NULL; | 74 | return NULL; |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | + if (credType == ACCOUNT_RELATED_APP) { | ||
| 78 | + if (!AddNumberToJsonObject(msg, FIELD_ISSUER, 2) || | ||
| 79 | + !AddNumberToJsonObject(msg, FIELD_CRED_TYPE, 1) || | ||
| 80 | + !AddNumberToJsonObject(msg, FIELD_PROOF_TYPE, 2)) { | ||
| 81 | + AUTH_LOGE(AUTH_HICHAIN, "add json object fail"); | ||
| 82 | + cJSON_Delete(msg); | ||
| 83 | + return NULL; | ||
| 84 | + } | ||
| 85 | + char *data = cJSON_PrintUnformatted(msg); | ||
| 86 | + if (data == NULL) { | ||
| 87 | + AUTH_LOGE(AUTH_HICHAIN, "json transform unformatted fail"); | ||
| 88 | + } | ||
| 89 | + cJSON_Delete(msg); | ||
| 90 | + return data; | ||
| 91 | + } | ||
| 77 | if (!AddStringToJsonObject(msg, FIELD_DEVICE_ID_HASH, udidHash) || | 92 | if (!AddStringToJsonObject(msg, FIELD_DEVICE_ID_HASH, udidHash) || |
| 78 | !AddNumberToJsonObject(msg, FIELD_CRED_TYPE, credType) || | 93 | !AddNumberToJsonObject(msg, FIELD_CRED_TYPE, credType) || |
| 79 | (credType == ACCOUNT_UNRELATED && !AddStringToJsonObject(msg, FIELD_PEER_USER_SPACE_ID, peerUserIdString))) { | 94 | (credType == ACCOUNT_UNRELATED && !AddStringToJsonObject(msg, FIELD_PEER_USER_SPACE_ID, peerUserIdString))) { |
| @@ -208,6 +223,15 @@ int32_t AuthIdServiceQueryCredential(int32_t peerUserId, const char *udidHash, c | |||
| 208 | ret = credManger->queryCredentialByParams(localUserId, authParams, credList); | 223 | ret = credManger->queryCredentialByParams(localUserId, authParams, credList); |
| 209 | cJSON_free(authParams); | 224 | cJSON_free(authParams); |
| 210 | } | 225 | } |
| 226 | + if (ret != HC_SUCCESS || IsInvalidCredList(*credList)) { | ||
| 227 | + IdServiceDestroyCredentialList(credList); | ||
| 228 | + *credList = NULL; | ||
| 229 | + authParams = IdServiceGenerateQueryParamByCredType(peerUserId, udidHash, ACCOUNT_RELATED_APP); | ||
| 230 | + AUTH_CHECK_AND_RETURN_RET_LOGE(authParams != NULL, SOFTBUS_CREATE_JSON_ERR, | ||
| 231 | + AUTH_HICHAIN, "hichain identity service generate query parameter fail"); | ||
| 232 | + ret = credManger->queryCredentialByParams(localUserId, authParams, credList); | ||
| 233 | + cJSON_free(authParams); | ||
| 234 | + } | ||
| 211 | if (ret != HC_SUCCESS) { | 235 | if (ret != HC_SUCCESS) { |
| 212 | return QueryCredentialFailedLog(ret); | 236 | return QueryCredentialFailedLog(ret); |
| 213 | } | 237 | } |
| @@ -556,7 +556,7 @@ static void UpdateDpAclSKId(AuthFsm *authFsm) | |||
| 556 | .accountId = 0, | 556 | .accountId = 0, |
| 557 | .deviceId = info->udid, | 557 | .deviceId = info->udid, |
| 558 | .peerUserId = info->userId, | 558 | .peerUserId = info->userId, |
| 559 | - .localUserId = info->nodeInfo.localUserId | 559 | + .localUserId = info->nodeInfo.localUserId, |
| 560 | }; | 560 | }; |
| 561 | bool isNeedUpdateDk = (info->nodeInfo.aclState == ACL_CAN_WRITE) && | 561 | bool isNeedUpdateDk = (info->nodeInfo.aclState == ACL_CAN_WRITE) && |
| 562 | IsSupportFeatureByCapaBit(info->nodeInfo.authCapacity, BIT_SUPPORT_USERKEY_NEGO); | 562 | IsSupportFeatureByCapaBit(info->nodeInfo.authCapacity, BIT_SUPPORT_USERKEY_NEGO); |
| @@ -594,6 +594,7 @@ static void CompleteAuthSession(AuthFsm *authFsm, int32_t result) | |||
| 594 | if (result == SOFTBUS_OK) { | 594 | if (result == SOFTBUS_OK) { |
| 595 | AuthManagerSetAuthFinished(authFsm->authSeq, &authFsm->info); | 595 | AuthManagerSetAuthFinished(authFsm->authSeq, &authFsm->info); |
| 596 | UpdateDpAclSKId(authFsm); | 596 | UpdateDpAclSKId(authFsm); |
| 597 | + LnnNotifyCommandToDmAuthPassed(authFsm->info.udid, authFsm->info.userId, authFsm->info.credId); | ||
| 597 | if (authFsm->info.normalizedType == NORMALIZED_KEY_ERROR) { | 598 | if (authFsm->info.normalizedType == NORMALIZED_KEY_ERROR) { |
| 598 | AUTH_LOGI(AUTH_FSM, "only hichain verify, save the device key"); | 599 | AUTH_LOGI(AUTH_FSM, "only hichain verify, save the device key"); |
| 599 | SaveDeviceKey(authFsm, AUTH_LINK_TYPE_NORMALIZED, authFsm->info.connInfo.type); | 600 | SaveDeviceKey(authFsm, AUTH_LINK_TYPE_NORMALIZED, authFsm->info.connInfo.type); |
| @@ -1028,19 +1028,30 @@ static cJSON *QueryAllCredTypePerPeerUserId(cJSON *peerUserIdsJson, CredTypeQuer | |||
| 1028 | return credTypesJson; | 1028 | return credTypesJson; |
| 1029 | } | 1029 | } |
| 1030 | 1030 | ||
| 1031 | +static int32_t GetCredTypeSortPriority(int32_t credType) | ||
| 1032 | +{ | ||
| 1033 | + switch (credType) { | ||
| 1034 | + case ACCOUNT_RELATED: | ||
| 1035 | + return 0; | ||
| 1036 | + case ACCOUNT_RELATED_APP: | ||
| 1037 | + return 1; | ||
| 1038 | + case ACCOUNT_SHARED: | ||
| 1039 | + return 2; | ||
| 1040 | + case ACCOUNT_UNRELATED: | ||
| 1041 | + return 3; | ||
| 1042 | + default: | ||
| 1043 | + return 4; | ||
| 1044 | + } | ||
| 1045 | +} | ||
| 1046 | + | ||
| 1031 | static int32_t CredTypesSortCmp(const void *info1, const void *info2) | 1047 | static int32_t CredTypesSortCmp(const void *info1, const void *info2) |
| 1032 | { | 1048 | { |
| 1033 | CredTypeSortInfo *credTypeInfo1 = (CredTypeSortInfo *)info1; | 1049 | CredTypeSortInfo *credTypeInfo1 = (CredTypeSortInfo *)info1; |
| 1034 | CredTypeSortInfo *credTypeInfo2 = (CredTypeSortInfo *)info2; | 1050 | CredTypeSortInfo *credTypeInfo2 = (CredTypeSortInfo *)info2; |
| 1035 | int32_t mainUserId = credTypeInfo1->mainUserId; | 1051 | int32_t mainUserId = credTypeInfo1->mainUserId; |
| 1036 | if (credTypeInfo1->peerUserId == credTypeInfo2->peerUserId) { | 1052 | if (credTypeInfo1->peerUserId == credTypeInfo2->peerUserId) { |
| 1037 | - if (credTypeInfo1->credType == ACCOUNT_RELATED) { | 1053 | + return GetCredTypeSortPriority(credTypeInfo1->credType) - |
| 1038 | - return -1; | 1054 | + GetCredTypeSortPriority(credTypeInfo2->credType); |
| 1039 | - } else if (credTypeInfo1->credType == ACCOUNT_UNRELATED) { | ||
| 1040 | - return 1; | ||
| 1041 | - } else { | ||
| 1042 | - return (credTypeInfo2->credType == ACCOUNT_RELATED) ? 1: -1; | ||
| 1043 | - } | ||
| 1044 | } | 1055 | } |
| 1045 | if (credTypeInfo1->peerUserId == mainUserId) { | 1056 | if (credTypeInfo1->peerUserId == mainUserId) { |
| 1046 | return -1; | 1057 | return -1; |
| @@ -87,6 +87,9 @@ void SoftBusDumpBusCenterPrintInfo(int fd, NodeBasicInfo *nodeInfo); | |||
| 87 | int32_t LnnServerJoin(ConnectionAddr *addr, const char *pkgName, bool isForceJoin); | 87 | int32_t LnnServerJoin(ConnectionAddr *addr, const char *pkgName, bool isForceJoin); |
| 88 | int32_t LnnServerLeave(const char *networkId, const char *pkgName); | 88 | int32_t LnnServerLeave(const char *networkId, const char *pkgName); |
| 89 | int32_t LnnDisSetDisplayName(const char *pkgName, const char *nameData, uint32_t len); | 89 | int32_t LnnDisSetDisplayName(const char *pkgName, const char *nameData, uint32_t len); |
| 90 | +int32_t LnnDisSetCommand(int32_t code, const char *value, uint32_t inLen, uint32_t callingUid); | ||
| 91 | +int32_t LnnDisRegisterCommandCb(const char *pkgName, uint32_t callingUid); | ||
| 92 | +int32_t LnnNotifyCommandToDmAuthPassed(const char *peerUdid, int32_t peerUserId, const char *credId); | ||
| 90 | int32_t LnnCreateGroupOwner(const char *pkgName, const struct GroupOwnerConfig *config, | 93 | int32_t LnnCreateGroupOwner(const char *pkgName, const struct GroupOwnerConfig *config, |
| 91 | struct GroupOwnerResult *result); | 94 | struct GroupOwnerResult *result); |
| 92 | void LnnDestroyGroupOwner(const char *pkgName); | 95 | void LnnDestroyGroupOwner(const char *pkgName); |
| @@ -56,6 +56,9 @@ int32_t LnnIpcGetAllMetaNodeInfo(MetaNodeInfo *infos, int32_t *infoNum); | |||
| 56 | int32_t LnnIpcNotifyJoinResult(void *addr, uint32_t addrTypeLen, const char *networkId, int32_t retCode); | 56 | int32_t LnnIpcNotifyJoinResult(void *addr, uint32_t addrTypeLen, const char *networkId, int32_t retCode); |
| 57 | int32_t LnnIpcNotifyLeaveResult(const char *networkId, int32_t retCode); | 57 | int32_t LnnIpcNotifyLeaveResult(const char *networkId, int32_t retCode); |
| 58 | int32_t LnnIpcNotifyOnlineState(bool isOnline, void *info, uint32_t infoTypeLen); | 58 | int32_t LnnIpcNotifyOnlineState(bool isOnline, void *info, uint32_t infoTypeLen); |
| 59 | +int32_t LnnIpcSetCommand(int32_t code, const char *value, uint32_t inLen, uint32_t callingUid); | ||
| 60 | +int32_t LnnIpcRegisterCommandCb(const char *pkgName, uint32_t callingUid); | ||
| 61 | +int32_t LnnIpcNotifyCommandToDm(int32_t code, const char *value, uint32_t inLen); | ||
| 59 | int32_t LnnIpcNotifyBasicInfoChanged(void *info, uint32_t infoTypeLen, int32_t type); | 62 | int32_t LnnIpcNotifyBasicInfoChanged(void *info, uint32_t infoTypeLen, int32_t type); |
| 60 | int32_t LnnIpcNotifyNodeStatusChanged(void *info, uint32_t infoTypeLen, int32_t type); | 63 | int32_t LnnIpcNotifyNodeStatusChanged(void *info, uint32_t infoTypeLen, int32_t type); |
| 61 | int32_t LnnIpcLocalNetworkIdChanged(void); | 64 | int32_t LnnIpcLocalNetworkIdChanged(void); |
| @@ -31,6 +31,8 @@ int32_t ClientOnJoinLNNResult(const char *pkgName, void *addr, uint32_t addrType | |||
| 31 | int32_t ClientOnLeaveLNNResult(const char *pkgName, const char *networkId, int32_t retCode); | 31 | int32_t ClientOnLeaveLNNResult(const char *pkgName, const char *networkId, int32_t retCode); |
| 32 | int32_t ClinetOnNodeOnlineStateChanged(bool isOnline, void *info, uint32_t infoTypeLen); | 32 | int32_t ClinetOnNodeOnlineStateChanged(bool isOnline, void *info, uint32_t infoTypeLen); |
| 33 | int32_t ClinetOnNodeBasicInfoChanged(void *info, uint32_t infoTypeLen, int32_t type); | 33 | int32_t ClinetOnNodeBasicInfoChanged(void *info, uint32_t infoTypeLen, int32_t type); |
| 34 | +int32_t ClientOnCommand(const char *pkgName, int32_t code, const char *value, uint32_t inLen, | ||
| 35 | + char *res, uint32_t resLen); | ||
| 34 | int32_t ClientOnTimeSyncResult( | 36 | int32_t ClientOnTimeSyncResult( |
| 35 | const char *pkgName, int32_t pid, const void *info, uint32_t infoTypeLen, int32_t retCode); | 37 | const char *pkgName, int32_t pid, const void *info, uint32_t infoTypeLen, int32_t retCode); |
| 36 | int32_t ClientOnPublishLNNResult(const char *pkgName, int32_t pid, int32_t publishId, int32_t reason); | 38 | int32_t ClientOnPublishLNNResult(const char *pkgName, int32_t pid, int32_t publishId, int32_t reason); |
| @@ -323,12 +323,10 @@ int32_t ClientOnRefreshDeviceFound(const char *pkgName, int32_t pid, const void | |||
| 323 | return SOFTBUS_INVALID_PARAM; | 323 | return SOFTBUS_INVALID_PARAM; |
| 324 | } | 324 | } |
| 325 | IpcIo io; | 325 | IpcIo io; |
| 326 | - uint8_t tmpData[sizeof(DeviceInfo) + sizeof(uint32_t)]; | 326 | + uint8_t tmpData[MAX_SOFT_BUS_IPC_LEN_EX]; |
| 327 | - IpcIoInit(&io, tmpData, sizeof(tmpData), 0); | 327 | + IpcIoInit(&io, tmpData, MAX_SOFT_BUS_IPC_LEN_EX, 0); |
| 328 | - if (!WriteUint32(&io, deviceLen) || !WriteBuffer(&io, device, deviceLen)) { | 328 | + WriteUint32(&io, deviceLen); |
| 329 | - LNN_LOGE(LNN_EVENT, "write device info failed, deviceLen=%{public}u", deviceLen); | 329 | + WriteBuffer(&io, device, deviceLen); |
| 330 | - return SOFTBUS_NETWORK_PACK_DATA_FAILED; | ||
| 331 | - } | ||
| 332 | SvcIdentity svc = {0}; | 330 | SvcIdentity svc = {0}; |
| 333 | if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) { | 331 | if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) { |
| 334 | LNN_LOGE(LNN_EVENT, "get svc failed"); | 332 | LNN_LOGE(LNN_EVENT, "get svc failed"); |
| @@ -343,4 +341,52 @@ int32_t ClientOnRefreshDeviceFound(const char *pkgName, int32_t pid, const void | |||
| 343 | return SOFTBUS_NETWORK_SEND_REQUEST_FAILED; | 341 | return SOFTBUS_NETWORK_SEND_REQUEST_FAILED; |
| 344 | } | 342 | } |
| 345 | return SOFTBUS_OK; | 343 | return SOFTBUS_OK; |
| 346 | -} | 344 | +} |
| 345 | + | ||
| 346 | +int32_t ClientOnCommand(const char *pkgName, int32_t code, const char *value, uint32_t inLen, | ||
| 347 | + char *res, uint32_t resLen) | ||
| 348 | +{ | ||
| 349 | + if (pkgName == NULL || value == NULL) { | ||
| 350 | + return SOFTBUS_INVALID_PARAM; | ||
| 351 | + } | ||
| 352 | + LNN_LOGI(LNN_EVENT, "1"); | ||
| 353 | + SvcIdentity svc; | ||
| 354 | + if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) { | ||
| 355 | + LNN_LOGI(LNN_EVENT, "command subscriber not found"); | ||
| 356 | + return SOFTBUS_NOT_FIND; | ||
| 357 | + } | ||
| 358 | + IpcIo io; | ||
| 359 | + uint8_t tmpData[MAX_SOFT_BUS_IPC_LEN_EX]; | ||
| 360 | + LNN_LOGI(LNN_EVENT, "2"); | ||
| 361 | + IpcIoInit(&io, tmpData, MAX_SOFT_BUS_IPC_LEN_EX, 0); | ||
| 362 | + LNN_LOGI(LNN_EVENT, "3"); | ||
| 363 | + if (!WriteInt32(&io, code)) { | ||
| 364 | + LNN_LOGE(LNN_EVENT, "write code fail"); | ||
| 365 | + return SOFTBUS_INVALID_PARAM; | ||
| 366 | + } | ||
| 367 | + LNN_LOGI(LNN_EVENT, "4"); | ||
| 368 | + if (!WriteString(&io, value)) { | ||
| 369 | + LNN_LOGE(LNN_EVENT, "write value fail, overflow"); | ||
| 370 | + return SOFTBUS_INVALID_PARAM; | ||
| 371 | + } | ||
| 372 | + LNN_LOGI(LNN_EVENT, "5"); | ||
| 373 | + uint8_t replyData[MAX_SOFT_BUS_IPC_LEN_EX] = {0}; | ||
| 374 | + IpcIo reply = {0}; | ||
| 375 | + IpcIoInit(&reply, replyData, MAX_SOFT_BUS_IPC_LEN_EX, 0); | ||
| 376 | + LNN_LOGI(LNN_EVENT, "6"); | ||
| 377 | + MessageOption option; | ||
| 378 | + MessageOptionInit(&option); | ||
| 379 | + LNN_LOGI(LNN_EVENT, "7"); | ||
| 380 | + option.flags = TF_OP_SYNC; | ||
| 381 | + LNN_LOGI(LNN_EVENT, "[CMD-DBG] uid=%{public}d", getuid()); | ||
| 382 | + int32_t ans = SendRequest(svc, CLIENT_ON_COMMAND, &io, &reply, option, NULL); | ||
| 383 | + LNN_LOGI(LNN_EVENT, "8"); | ||
| 384 | + if (ans != SOFTBUS_OK) { | ||
| 385 | + LNN_LOGW(LNN_EVENT, "send command failed, ans=%{public}d", ans); | ||
| 386 | + return ans; | ||
| 387 | + } | ||
| 388 | + size_t sz = 0; | ||
| 389 | + const char *dmRes = (const char *)ReadString(&reply, &sz); | ||
| 390 | + LNN_LOGI(LNN_EVENT, "[CMD-DBG] dm res=%{public}s", (dmRes != NULL) ? dmRes : "none"); | ||
| 391 | + return SOFTBUS_OK; | ||
| 392 | +} | ||
| @@ -631,4 +631,29 @@ int32_t LnnIpcGetTrustedDevices(DeviceNodeInfo **info, int32_t *nums) | |||
| 631 | (void)nums; | 631 | (void)nums; |
| 632 | LNN_LOGI(LNN_EVENT, "not implement"); | 632 | LNN_LOGI(LNN_EVENT, "not implement"); |
| 633 | return SOFTBUS_OK; | 633 | return SOFTBUS_OK; |
| 634 | -} | 634 | +} |
| 635 | + | ||
| 636 | + | ||
| 637 | +int32_t LnnIpcSetCommand(int32_t code, const char *value, uint32_t inLen, uint32_t callingUid) | ||
| 638 | +{ | ||
| 639 | + if (value == NULL || inLen == 0) { | ||
| 640 | + return SOFTBUS_INVALID_PARAM; | ||
| 641 | + } | ||
| 642 | + return LnnDisSetCommand(code, value, inLen, callingUid); | ||
| 643 | +} | ||
| 644 | + | ||
| 645 | +int32_t LnnIpcRegisterCommandCb(const char *pkgName, uint32_t callingUid) | ||
| 646 | +{ | ||
| 647 | + if (pkgName == NULL) { | ||
| 648 | + return SOFTBUS_INVALID_PARAM; | ||
| 649 | + } | ||
| 650 | + return LnnDisRegisterCommandCb(pkgName, callingUid); | ||
| 651 | +} | ||
| 652 | + | ||
| 653 | +int32_t LnnIpcNotifyCommandToDm(int32_t code, const char *value, uint32_t inLen) | ||
| 654 | +{ | ||
| 655 | + if (value == NULL || inLen == 0) { | ||
| 656 | + return SOFTBUS_INVALID_PARAM; | ||
| 657 | + } | ||
| 658 | + return ClientOnCommand("ohos.distributedhardware.devicemanager", code, value, inLen, NULL, 0); | ||
| 659 | +} | ||
| @@ -260,6 +260,7 @@ int32_t LnnFreeLane(uint32_t laneReqId) | |||
| 260 | return SOFTBUS_OK; | 260 | return SOFTBUS_OK; |
| 261 | } | 261 | } |
| 262 | 262 | ||
| 263 | + | ||
| 263 | int32_t InitLane(void) | 264 | int32_t InitLane(void) |
| 264 | { | 265 | { |
| 265 | if (SoftBusMutexInit(&g_laneMutex, NULL) != SOFTBUS_OK) { | 266 | if (SoftBusMutexInit(&g_laneMutex, NULL) != SOFTBUS_OK) { |
| @@ -28,6 +28,7 @@ | |||
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | + | ||
| 31 | 32 | ||
| 32 | 33 | ||
| 33 | 34 | ||
| @@ -721,6 +722,90 @@ static bool IsNeedNotifyOfflineByAdv(const char *udid) | |||
| 721 | return true; | 722 | return true; |
| 722 | } | 723 | } |
| 723 | 724 | ||
| 725 | +static char *PackNotTrustedMsg(const char *networkId, const int64_t *authSeq, uint32_t num) | ||
| 726 | +{ | ||
| 727 | + uint32_t discoveryType = 0; | ||
| 728 | + if (LnnGetRemoteNumInfo(networkId, NUM_KEY_DISCOVERY_TYPE, (int32_t *)&discoveryType) != SOFTBUS_OK) { | ||
| 729 | + LNN_LOGE(LNN_BUILDER, "[NTI-DBG] get remote discoveryType fail"); | ||
| 730 | + return NULL; | ||
| 731 | + } | ||
| 732 | + JsonObj *json = JSON_CreateObject(); | ||
| 733 | + if (json == NULL) { | ||
| 734 | + LNN_LOGE(LNN_BUILDER, "[NTI-DBG] create json fail"); | ||
| 735 | + return NULL; | ||
| 736 | + } | ||
| 737 | + | ||
| 738 | + NodeInfo nodeInfo = {.discoveryType = discoveryType}; | ||
| 739 | + int64_t seq = authSeq[DISCOVERY_TYPE_WIFI]; | ||
| 740 | + | ||
| 741 | + if (LnnHasDiscoveryType(&nodeInfo, DISCOVERY_TYPE_WIFI) && | ||
| 742 | + !JSON_AddInt64ToObject(json, NETWORK_TYPE_WIFI, seq)) { | ||
| 743 | + LNN_LOGE(LNN_BUILDER, "[NTI-DBG] add wifi authSeq to json fail"); | ||
| 744 | + JSON_Delete(json); | ||
| 745 | + return NULL; | ||
| 746 | + } | ||
| 747 | + if (LnnIsRemoteSupportAuthCapBit(networkId, BIT_SUPPORT_SESSION_NOT_TRUST_OFFLINE)) { | ||
| 748 | + seq = authSeq[DISCOVERY_TYPE_SESSION_KEY]; | ||
| 749 | + if (LnnHasDiscoveryType(&nodeInfo, DISCOVERY_TYPE_SESSION_KEY) && | ||
| 750 | + !JSON_AddInt64ToObject(json, NETWORK_TYPE_SESSION_KEY, seq)) { | ||
| 751 | + LNN_LOGE(LNN_BUILDER, "[NTI-DBG] add sessionKey authSeq to json fail"); | ||
| 752 | + JSON_Delete(json); | ||
| 753 | + return NULL; | ||
| 754 | + } | ||
| 755 | + } | ||
| 756 | + char *msg = JSON_PrintUnformatted(json); | ||
| 757 | + JSON_Delete(json); | ||
| 758 | + if (msg == NULL) { | ||
| 759 | + LNN_LOGE(LNN_BUILDER, "[NTI-DBG] print json to string fail"); | ||
| 760 | + } | ||
| 761 | + return msg; | ||
| 762 | +} | ||
| 763 | + | ||
| 764 | +int32_t LnnSendNotTrustedInfo(const NotTrustedDelayInfo *info, uint32_t num, LnnSyncInfoMsgComplete complete) | ||
| 765 | +{ | ||
| 766 | + LNN_LOGI(LNN_BUILDER, "begin"); | ||
| 767 | + if (info == NULL || num != DISCOVERY_TYPE_COUNT) { | ||
| 768 | + LNN_LOGE(LNN_BUILDER, "[NTI-DBG] invalid param, info=%{public}d, num=%{public}u", | ||
| 769 | + info != NULL, num); | ||
| 770 | + return SOFTBUS_INVALID_PARAM; | ||
| 771 | + } | ||
| 772 | + char networkId[NETWORK_ID_BUF_LEN] = {0}; | ||
| 773 | + uint32_t udidLen = strlen(info->udid) + 1; | ||
| 774 | + if (udidLen > UDID_BUF_LEN) { | ||
| 775 | + LNN_LOGE(LNN_BUILDER, "[NTI-DBG] udid too long, len=%{public}u", udidLen); | ||
| 776 | + return SOFTBUS_INVALID_PARAM; | ||
| 777 | + } | ||
| 778 | + if (LnnConvertDlId(info->udid, CATEGORY_UDID, CATEGORY_NETWORK_ID, | ||
| 779 | + networkId, NETWORK_ID_BUF_LEN) != SOFTBUS_OK) { | ||
| 780 | + LNN_LOGE(LNN_BUILDER, "[NTI-DBG] convert udid to networkId fail"); | ||
| 781 | + return SOFTBUS_NETWORK_GET_NODE_INFO_ERR; | ||
| 782 | + } | ||
| 783 | + char *msg = PackNotTrustedMsg(networkId, info->authSeq, num); | ||
| 784 | + if (msg == NULL) { | ||
| 785 | + LNN_LOGE(LNN_BUILDER, "[NTI-DBG] pack not trusted msg fail"); | ||
| 786 | + return SOFTBUS_CREATE_JSON_ERR; | ||
| 787 | + } | ||
| 788 | + LNN_LOGI(LNN_BUILDER, "send not trusted msg=%{public}s", msg); | ||
| 789 | + SendSyncInfoParam *data = CreateSyncInfoParam(LNN_INFO_TYPE_NOT_TRUSTED, networkId, (uint8_t *)msg, | ||
| 790 | + strlen(msg) + 1, complete); | ||
| 791 | + if (data == NULL) { | ||
| 792 | + LNN_LOGE(LNN_BUILDER, "[NTI-DBG] create sync info param fail"); | ||
| 793 | + JSON_Free(msg); | ||
| 794 | + return SOFTBUS_NETWORK_SEND_SYNC_INFO_FAILED; | ||
| 795 | + } | ||
| 796 | + int32_t ret = LnnAsyncCallbackHelper(GetLooper(LOOP_TYPE_DEFAULT), | ||
| 797 | + LnnSendAsyncInfoMsg, (void *)data); | ||
| 798 | + JSON_Free(msg); | ||
| 799 | + if (ret != SOFTBUS_OK) { | ||
| 800 | + LNN_LOGE(LNN_BUILDER, "[NTI-DBG] async callback helper fail, ret=%{public}d", ret); | ||
| 801 | + SoftBusFree(data->msg); | ||
| 802 | + SoftBusFree(data); | ||
| 803 | + return ret; | ||
| 804 | + } | ||
| 805 | + LNN_LOGI(LNN_BUILDER, "lnn send not trusted info success"); | ||
| 806 | + return SOFTBUS_OK; | ||
| 807 | +} | ||
| 808 | + | ||
| 724 | static void OnDeviceNotTrusted(const char *peerUdid) | 809 | static void OnDeviceNotTrusted(const char *peerUdid) |
| 725 | { | 810 | { |
| 726 | if (peerUdid == NULL) { | 811 | if (peerUdid == NULL) { |
| @@ -743,32 +828,41 @@ static void OnDeviceNotTrusted(const char *peerUdid) | |||
| 743 | } | 828 | } |
| 744 | useUdid = SelectUseUdid(peerUdid, udid); | 829 | useUdid = SelectUseUdid(peerUdid, udid); |
| 745 | if (useUdid == NULL) { | 830 | if (useUdid == NULL) { |
| 831 | + LNN_LOGE(LNN_BUILDER, "SelectUseUdid returned NULL"); | ||
| 746 | return; | 832 | return; |
| 747 | } | 833 | } |
| 748 | LNN_CHECK_AND_RETURN_LOGW(!IsNeedNotifyOfflineByAdv(peerUdid), LNN_BUILDER, "need notify offline by adv"); | 834 | LNN_CHECK_AND_RETURN_LOGW(!IsNeedNotifyOfflineByAdv(peerUdid), LNN_BUILDER, "need notify offline by adv"); |
| 749 | NotTrustedDelayInfo *info = (NotTrustedDelayInfo *)SoftBusCalloc(sizeof(NotTrustedDelayInfo)); | 835 | NotTrustedDelayInfo *info = (NotTrustedDelayInfo *)SoftBusCalloc(sizeof(NotTrustedDelayInfo)); |
| 750 | LNN_CHECK_AND_RETURN_LOGE(info != NULL, LNN_BUILDER, "malloc NotTrustedDelayInfo fail"); | 836 | LNN_CHECK_AND_RETURN_LOGE(info != NULL, LNN_BUILDER, "malloc NotTrustedDelayInfo fail"); |
| 751 | if (AuthGetLatestAuthSeqList(useUdid, info->authSeq, DISCOVERY_TYPE_COUNT) != SOFTBUS_OK) { | 837 | if (AuthGetLatestAuthSeqList(useUdid, info->authSeq, DISCOVERY_TYPE_COUNT) != SOFTBUS_OK) { |
| 752 | - LNN_LOGE(LNN_BUILDER, "get latest AuthSeq list fail"); | 838 | + LNN_LOGE(LNN_BUILDER, "[NTI-DBG] get latest AuthSeq list fail"); |
| 753 | SoftBusFree(info); | 839 | SoftBusFree(info); |
| 754 | return; | 840 | return; |
| 755 | } | 841 | } |
| 842 | + LNN_LOGI(LNN_BUILDER, | ||
| 843 | + "[NTI-DBG] authSeq: wifi=%{public}" PRId64 ", ble=%{public}" PRId64 ", br=%{public}" PRId64 | ||
| 844 | + ", usb=%{public}" PRId64 ", sessionKey=%{public}" PRId64, | ||
| 845 | + info->authSeq[DISCOVERY_TYPE_WIFI], info->authSeq[DISCOVERY_TYPE_BLE], | ||
| 846 | + info->authSeq[DISCOVERY_TYPE_BR], info->authSeq[DISCOVERY_TYPE_USB], | ||
| 847 | + info->authSeq[DISCOVERY_TYPE_SESSION_KEY]); | ||
| 756 | if (strcpy_s(info->udid, UDID_BUF_LEN, useUdid) != EOK) { | 848 | if (strcpy_s(info->udid, UDID_BUF_LEN, useUdid) != EOK) { |
| 757 | - LNN_LOGE(LNN_BUILDER, "copy udid fail"); | 849 | + LNN_LOGE(LNN_BUILDER, "[NTI-DBG] copy udid fail"); |
| 758 | SoftBusFree(info); | 850 | SoftBusFree(info); |
| 759 | return; | 851 | return; |
| 760 | } | 852 | } |
| 761 | - if (LnnSendNotTrustedInfoPacked(info, DISCOVERY_TYPE_COUNT, | 853 | + if (LnnSendNotTrustedInfo(info, DISCOVERY_TYPE_COUNT, |
| 762 | LnnProcessCompleteNotTrustedMsg) != SOFTBUS_OK) { | 854 | LnnProcessCompleteNotTrustedMsg) != SOFTBUS_OK) { |
| 763 | - LNN_LOGE(LNN_BUILDER, "send NotTrustedInfo fail"); | 855 | + LNN_LOGE(LNN_BUILDER, "[NTI-DBG] send NotTrustedInfo fail, fallback to 5s delay"); |
| 764 | OnLnnProcessNotTrustedMsgDelay((void *)info); | 856 | OnLnnProcessNotTrustedMsgDelay((void *)info); |
| 765 | return; | 857 | return; |
| 766 | } | 858 | } |
| 767 | if (LnnAsyncCallbackDelayHelper(GetLooper(LOOP_TYPE_DEFAULT), OnLnnProcessNotTrustedMsgDelay, | 859 | if (LnnAsyncCallbackDelayHelper(GetLooper(LOOP_TYPE_DEFAULT), OnLnnProcessNotTrustedMsgDelay, |
| 768 | (void *)info, NOT_TRUSTED_DEVICE_MSG_DELAY) != SOFTBUS_OK) { | 860 | (void *)info, NOT_TRUSTED_DEVICE_MSG_DELAY) != SOFTBUS_OK) { |
| 769 | - LNN_LOGE(LNN_BUILDER, "async not trusted msg delay fail"); | 861 | + LNN_LOGE(LNN_BUILDER, "[NTI-DBG] async not trusted msg delay fail"); |
| 770 | SoftBusFree(info); | 862 | SoftBusFree(info); |
| 863 | + return; | ||
| 771 | } | 864 | } |
| 865 | + LNN_LOGI(LNN_BUILDER, "[NTI-DBG] 5s delay helper scheduled, waiting for peer confirm"); | ||
| 772 | } | 866 | } |
| 773 | 867 | ||
| 774 | AuthVerifyListener g_verifyListener = { | 868 | AuthVerifyListener g_verifyListener = { |
| @@ -826,6 +920,10 @@ static int32_t InitSyncInfoReg(void) | |||
| 826 | return rc; | 920 | return rc; |
| 827 | } | 921 | } |
| 828 | rc = LnnRegSyncInfoHandler(LNN_INFO_TYPE_NODE_ADDR, OnReceiveNodeAddrChangedMsg); | 922 | rc = LnnRegSyncInfoHandler(LNN_INFO_TYPE_NODE_ADDR, OnReceiveNodeAddrChangedMsg); |
| 923 | + rc = LnnRegSyncInfoHandler(LNN_INFO_TYPE_NOT_TRUSTED, LnnProcessCompleteNotTrustedMsg); | ||
| 924 | + if (rc != SOFTBUS_OK) { | ||
| 925 | + LNN_LOGE(LNN_BUILDER, "regist not trusted handler fail, rc=%{public}d", rc); | ||
| 926 | + } | ||
| 829 | if (rc != SOFTBUS_OK) { | 927 | if (rc != SOFTBUS_OK) { |
| 830 | LNN_LOGE(LNN_INIT, "register node addr changed msg fail, rc=%{public}d", rc); | 928 | LNN_LOGE(LNN_INIT, "register node addr changed msg fail, rc=%{public}d", rc); |
| 831 | return rc; | 929 | return rc; |
| @@ -99,7 +99,6 @@ int32_t LnnClearAuthTypeValue(uint32_t *authTypeValue, AuthType type) | |||
| 99 | NodeInfo *GetNodeInfoFromMap(const DoubleHashMap *map, const char *id) | 99 | NodeInfo *GetNodeInfoFromMap(const DoubleHashMap *map, const char *id) |
| 100 | { | 100 | { |
| 101 | if (map == NULL || id == NULL) { | 101 | if (map == NULL || id == NULL) { |
| 102 | - LNN_LOGE(LNN_LEDGER, "para error!"); | ||
| 103 | return NULL; | 102 | return NULL; |
| 104 | } | 103 | } |
| 105 | NodeInfo *info = NULL; | 104 | NodeInfo *info = NULL; |
| @@ -112,7 +111,7 @@ NodeInfo *GetNodeInfoFromMap(const DoubleHashMap *map, const char *id) | |||
| 112 | if ((info = (NodeInfo *)LnnMapGet(&map->ipMap, id)) != NULL) { | 111 | if ((info = (NodeInfo *)LnnMapGet(&map->ipMap, id)) != NULL) { |
| 113 | return info; | 112 | return info; |
| 114 | } | 113 | } |
| 115 | - LNN_LOGE(LNN_LEDGER, "id not exist!"); | 114 | + MapGetSize(&map->udidMap); |
| 116 | return NULL; | 115 | return NULL; |
| 117 | } | 116 | } |
| 118 | 117 | ||
| @@ -385,6 +384,7 @@ NodeInfo *LnnGetNodeInfoById(const char *id, IdCategory type) | |||
| 385 | LNN_LOGE(LNN_LEDGER, "para error"); | 384 | LNN_LOGE(LNN_LEDGER, "para error"); |
| 386 | return info; | 385 | return info; |
| 387 | } | 386 | } |
| 387 | + id, type, MapGetSize(&map->udidMap); | ||
| 388 | if (type == CATEGORY_UDID) { | 388 | if (type == CATEGORY_UDID) { |
| 389 | return GetNodeInfoFromMap(map, id); | 389 | return GetNodeInfoFromMap(map, id); |
| 390 | } | 390 | } |
| @@ -19,17 +19,16 @@ bus_center_ledger_src = [ | |||
| 19 | "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/common/src/lnn_net_ledger.c", | 19 | "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/common/src/lnn_net_ledger.c", |
| 20 | "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/common/src/lnn_node_info.c", | 20 | "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/common/src/lnn_node_info.c", |
| 21 | "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/local_ledger/src/lnn_local_net_ledger.c", | 21 | "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/local_ledger/src/lnn_local_net_ledger.c", |
| 22 | + "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/common/src/lnn_net_capability.c", | ||
| 22 | ] | 23 | ] |
| 23 | 24 | ||
| 24 | if (dsoftbus_feature_lnn_frame && dsoftbus_feature_lnn_ledger_ext) { | 25 | if (dsoftbus_feature_lnn_frame && dsoftbus_feature_lnn_ledger_ext) { |
| 25 | bus_center_ledger_src += [ | 26 | bus_center_ledger_src += [ |
| 26 | - "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/common/src/lnn_net_capability.c", | ||
| 27 | "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/common/src/lnn_sle_capability.c", | 27 | "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/common/src/lnn_sle_capability.c", |
| 28 | "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/distributed_ledger/src/lnn_meta_node_ledger.c", | 28 | "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/distributed_ledger/src/lnn_meta_node_ledger.c", |
| 29 | ] | 29 | ] |
| 30 | } else { | 30 | } else { |
| 31 | bus_center_ledger_src += [ | 31 | bus_center_ledger_src += [ |
| 32 | - "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/common/src/lnn_net_capability_virtual.c", | ||
| 33 | "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/common/src/lnn_sle_capability_virtual.c", | 32 | "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/common/src/lnn_sle_capability_virtual.c", |
| 34 | "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/distributed_ledger/src/lnn_meta_node_ledger_virtual.c", | 33 | "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/distributed_ledger/src/lnn_meta_node_ledger_virtual.c", |
| 35 | ] | 34 | ] |
| @@ -26,6 +26,10 @@ | |||
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + | ||
| 29 | 33 | ||
| 30 | 34 | ||
| 31 | 35 | ||
| @@ -367,3 +371,157 @@ void BusCenterServerDeinit(void) | |||
| 367 | DeinitConversationQuery(); | 371 | DeinitConversationQuery(); |
| 368 | LNN_LOGI(LNN_INIT, "bus center server deinit"); | 372 | LNN_LOGI(LNN_INIT, "bus center server deinit"); |
| 369 | } | 373 | } |
| 374 | + | ||
| 375 | + | ||
| 376 | + | ||
| 377 | + | ||
| 378 | + | ||
| 379 | + | ||
| 380 | + | ||
| 381 | + | ||
| 382 | + | ||
| 383 | + | ||
| 384 | + | ||
| 385 | + | ||
| 386 | + | ||
| 387 | + | ||
| 388 | + | ||
| 389 | +static char g_commandPkg[PKG_NAME_SIZE_MAX] = {0}; | ||
| 390 | +static uint32_t g_commandUid = 0; | ||
| 391 | +static bool g_commandRegistered = false; | ||
| 392 | + | ||
| 393 | +int32_t LnnDisRegisterCommandCb(const char *pkgName, uint32_t callingUid) | ||
| 394 | +{ | ||
| 395 | + if (pkgName == NULL || strcmp(pkgName, "ohos.distributedhardware.devicemanager") != 0) { | ||
| 396 | + LNN_LOGE(LNN_STATE, "invalid pkgName"); | ||
| 397 | + return SOFTBUS_INVALID_PARAM; | ||
| 398 | + } | ||
| 399 | + if (strcpy_s(g_commandPkg, PKG_NAME_SIZE_MAX, pkgName) != EOK) { | ||
| 400 | + return SOFTBUS_MEM_ERR; | ||
| 401 | + } | ||
| 402 | + g_commandUid = callingUid; | ||
| 403 | + g_commandRegistered = true; | ||
| 404 | + LNN_LOGI(LNN_STATE, "command cb registered for DM, uid=%{public}u", callingUid); | ||
| 405 | + return SOFTBUS_OK; | ||
| 406 | +} | ||
| 407 | + | ||
| 408 | +int32_t LnnDisSetCommand(int32_t code, const char *value, uint32_t inLen, uint32_t callingUid) | ||
| 409 | +{ | ||
| 410 | + if (value == NULL || inLen == 0) { | ||
| 411 | + LNN_LOGE(LNN_STATE, "invalid param"); | ||
| 412 | + return SOFTBUS_INVALID_PARAM; | ||
| 413 | + } | ||
| 414 | + if (!g_commandRegistered || g_commandUid != callingUid) { | ||
| 415 | + LNN_LOGE(LNN_STATE, "command not registered or uid mismatch"); | ||
| 416 | + return SOFTBUS_PERMISSION_DENIED; | ||
| 417 | + } | ||
| 418 | + LNN_LOGI(LNN_STATE, "set command enter, code=%{public}d, value=%{public}s", code, value); | ||
| 419 | + if (code != 0) { | ||
| 420 | + LNN_LOGE(LNN_STATE, "unknown command code=%{public}d", code); | ||
| 421 | + return SOFTBUS_INVALID_PARAM; | ||
| 422 | + } | ||
| 423 | + cJSON *json = cJSON_ParseWithLength(value, inLen); | ||
| 424 | + if (json == NULL) { | ||
| 425 | + LNN_LOGE(LNN_STATE, "parse value json fail"); | ||
| 426 | + return SOFTBUS_PARSE_JSON_ERR; | ||
| 427 | + } | ||
| 428 | + /* deleted ACL profile: { bindType, authenticationType, bindLevel, trustDeviceId, | ||
| 429 | + accesser{deviceId,userId,accountId,tokenId,bundleName,deviceName,credentialId}, | ||
| 430 | + accessee{...} } */ | ||
| 431 | + cJSON *trustDeviceIdJson = cJSON_GetObjectItem(json, ACL_KEY_TRUST_DEVICE_ID); | ||
| 432 | + cJSON *accesserJson = cJSON_GetObjectItem(json, ACL_KEY_ACCESSER); | ||
| 433 | + cJSON *accesseeJson = cJSON_GetObjectItem(json, ACL_KEY_ACCESSEE); | ||
| 434 | + if (trustDeviceIdJson == NULL || !cJSON_IsString(trustDeviceIdJson) || | ||
| 435 | + accesserJson == NULL || accesseeJson == NULL) { | ||
| 436 | + LNN_LOGE(LNN_STATE, "invalid acl fields"); | ||
| 437 | + cJSON_Delete(json); | ||
| 438 | + return SOFTBUS_INVALID_PARAM; | ||
| 439 | + } | ||
| 440 | + char peerUdid[UDID_BUF_LEN] = {0}; | ||
| 441 | + const char *peerUdidTmp = cJSON_GetStringValue(trustDeviceIdJson); | ||
| 442 | + if (strcpy_s(peerUdid, UDID_BUF_LEN, peerUdidTmp) != EOK) { | ||
| 443 | + LNN_LOGE(LNN_STATE, "[CMD-DBG] copy peerUdid fail"); | ||
| 444 | + cJSON_Delete(json); | ||
| 445 | + return SOFTBUS_MEM_ERR; | ||
| 446 | + } | ||
| 447 | + cJSON *localUserIdJson = cJSON_GetObjectItem(accesserJson, ACL_KEY_USER_ID); | ||
| 448 | + cJSON *peerUserIdJson = cJSON_GetObjectItem(accesseeJson, ACL_KEY_USER_ID); | ||
| 449 | + int32_t localUserId = (localUserIdJson != NULL && cJSON_IsNumber(localUserIdJson)) ? | ||
| 450 | + (int32_t)localUserIdJson->valuedouble : -1; | ||
| 451 | + int32_t peerUserId = (peerUserIdJson != NULL && cJSON_IsNumber(peerUserIdJson)) ? | ||
| 452 | + (int32_t)peerUserIdJson->valuedouble : -1; | ||
| 453 | + cJSON *accesserDevJson = cJSON_GetObjectItem(accesserJson, ACL_KEY_DEVICE_ID); | ||
| 454 | + char accesserDevId[UDID_BUF_LEN] = {0}; | ||
| 455 | + if (accesserDevJson != NULL && cJSON_IsString(accesserDevJson)) { | ||
| 456 | + (void)strcpy_s(accesserDevId, UDID_BUF_LEN, cJSON_GetStringValue(accesserDevJson)); | ||
| 457 | + } | ||
| 458 | + cJSON_Delete(json); | ||
| 459 | + LNN_LOGI(LNN_STATE, | ||
| 460 | + "[CMD-DBG] offline by acl: peer(trustDeviceId)=%.10s..., local(accesser)=%.10s..., " | ||
| 461 | + "localUserId=%{public}d, peerUserId=%{public}d", | ||
| 462 | + peerUdid, accesserDevId, localUserId, peerUserId); | ||
| 463 | + int32_t ret = AuthNotifyDeviceNotTrusted(peerUdid, localUserId); | ||
| 464 | + if (ret != SOFTBUS_OK) { | ||
| 465 | + LNN_LOGW(LNN_STATE, "[CMD-DBG] AuthNotifyDeviceNotTrusted ret=%{public}d, peer not connected, skip", ret); | ||
| 466 | + } | ||
| 467 | + return SOFTBUS_OK; | ||
| 468 | +} | ||
| 469 | + | ||
| 470 | +int32_t LnnNotifyCommandToDmAuthPassed(const char *peerUdid, int32_t peerUserId, const char *credId) | ||
| 471 | +{ | ||
| 472 | + const char *credIdSafe = (credId != NULL && credId[0] != '\0') ? credId : "-1"; | ||
| 473 | + LNN_LOGI(LNN_STATE, "[ACL-DBG] enter, peerUdid=%.10s..., peerUserId=%{public}d, credId=%.10s...", peerUdid, peerUserId, credIdSafe); | ||
| 474 | + if (peerUdid == NULL || peerUdid[0] == '\0') { | ||
| 475 | + LNN_LOGE(LNN_STATE, "invalid param"); | ||
| 476 | + return SOFTBUS_INVALID_PARAM; | ||
| 477 | + } | ||
| 478 | + if (!g_commandRegistered) { | ||
| 479 | + LNN_LOGW(LNN_STATE, "command cb not registered, skip notify"); | ||
| 480 | + return SOFTBUS_OK; | ||
| 481 | + } | ||
| 482 | + int32_t localUserId = JudgeDeviceTypeAndGetOsAccountIds(); | ||
| 483 | + const NodeInfo *localNode = LnnGetLocalNodeInfo(); | ||
| 484 | + const char *localUdid = (localNode != NULL) ? localNode->deviceInfo.deviceUdid : ""; | ||
| 485 | + const char *localName = (localNode != NULL) ? localNode->deviceInfo.deviceName : ""; | ||
| 486 | + LNN_LOGI(LNN_STATE, "[ACL-DBG] localUdid=%.10s..., localName=%{public}s, localUserId=%{public}d", localUdid, localName, localUserId); | ||
| 487 | + cJSON *json = cJSON_CreateObject(); | ||
| 488 | + if (json == NULL) { | ||
| 489 | + return SOFTBUS_CREATE_JSON_ERR; | ||
| 490 | + } | ||
| 491 | + // (void)AddNumberToJsonObject(json, ACL_KEY_BIND_TYPE, 1); // not use | ||
| 492 | + // (void)AddNumberToJsonObject(json, ACL_KEY_AUTH_TYPE, 1); // not use | ||
| 493 | + // (void)AddNumberToJsonObject(json, ACL_KEY_BIND_LEVEL, 0); // not use | ||
| 494 | + (void)AddStringToJsonObject(json, ACL_KEY_TRUST_DEVICE_ID, peerUdid); | ||
| 495 | + cJSON *accesser = cJSON_CreateObject(); | ||
| 496 | + if (accesser != NULL) { | ||
| 497 | + (void)AddStringToJsonObject(accesser, ACL_KEY_DEVICE_ID, localUdid); | ||
| 498 | + (void)AddNumberToJsonObject(accesser, ACL_KEY_USER_ID, localUserId); | ||
| 499 | + (void)AddStringToJsonObject(accesser, ACL_KEY_ACCOUNT_ID, "-1"); | ||
| 500 | + (void)AddNumberToJsonObject(accesser, ACL_KEY_TOKEN_ID, 0); | ||
| 501 | + (void)AddStringToJsonObject(accesser, ACL_KEY_BUNDLE_NAME, "softbus_auth");//什么包名 | ||
| 502 | + (void)AddStringToJsonObject(accesser, ACL_KEY_DEVICE_NAME, localName); | ||
| 503 | + (void)AddStringToJsonObject(accesser, ACL_KEY_CREDENTIAL_ID, credIdSafe); | ||
| 504 | + cJSON_AddItemToObject(json, ACL_KEY_ACCESSER, accesser); | ||
| 505 | + } | ||
| 506 | + cJSON *accessee = cJSON_CreateObject(); | ||
| 507 | + if (accessee != NULL) { | ||
| 508 | + (void)AddStringToJsonObject(accessee, ACL_KEY_DEVICE_ID, peerUdid); | ||
| 509 | + (void)AddNumberToJsonObject(accessee, ACL_KEY_USER_ID, peerUserId); | ||
| 510 | + (void)AddStringToJsonObject(accessee, ACL_KEY_ACCOUNT_ID, "-1"); | ||
| 511 | + (void)AddNumberToJsonObject(accessee, ACL_KEY_TOKEN_ID, 0); | ||
| 512 | + (void)AddStringToJsonObject(accessee, ACL_KEY_BUNDLE_NAME, "-1"); | ||
| 513 | + (void)AddStringToJsonObject(accessee, ACL_KEY_DEVICE_NAME, "-1");//包名传什么 | ||
| 514 | + (void)AddStringToJsonObject(accessee, ACL_KEY_CREDENTIAL_ID, "-1");// notuse | ||
| 515 | + cJSON_AddItemToObject(json, ACL_KEY_ACCESSEE, accessee); | ||
| 516 | + } | ||
| 517 | + char *value = cJSON_PrintUnformatted(json); | ||
| 518 | + cJSON_Delete(json); | ||
| 519 | + if (value == NULL) { | ||
| 520 | + return SOFTBUS_CREATE_JSON_ERR; | ||
| 521 | + } | ||
| 522 | + LNN_LOGI(LNN_STATE, "[CMD-DBG] notify ACL write to dm, value=%{public}s", value); | ||
| 523 | + int32_t ret = LnnIpcNotifyCommandToDm(0, value, (uint32_t)strlen(value) + 1); | ||
| 524 | + LNN_LOGI(LNN_STATE, "[ACL-DBG] LnnIpcNotifyCommandToDm ret=%{public}d", ret); | ||
| 525 | + cJSON_free(value); | ||
| 526 | + return ret; | ||
| 527 | +} | ||
| @@ -27,7 +27,7 @@ extern "C" { | |||
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | -#define MAX_SOFT_BUS_IPC_LEN_EX 2048 | 30 | +#define MAX_SOFT_BUS_IPC_LEN_EX 1024 |
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | struct CommonScvId { | 33 | struct CommonScvId { |
| @@ -115,6 +115,8 @@ enum SoftBusFuncId { | |||
| 115 | SERVER_POST_CONVERSATION_DATA, | 115 | SERVER_POST_CONVERSATION_DATA, |
| 116 | SERVER_REGISTER_CONVERSATION_LISTENER, | 116 | SERVER_REGISTER_CONVERSATION_LISTENER, |
| 117 | SERVER_UNREGISTER_CONVERSATION_LISTENER, | 117 | SERVER_UNREGISTER_CONVERSATION_LISTENER, |
| 118 | + SERVER_SET_COMMAND, | ||
| 119 | + SERVER_REGISTER_COMMAND_CB, | ||
| 118 | 120 | ||
| 119 | CLIENT_ON_CHANNEL_OPENED = 256, | 121 | CLIENT_ON_CHANNEL_OPENED = 256, |
| 120 | CLIENT_ON_CHANNEL_OPENFAILED, | 122 | CLIENT_ON_CHANNEL_OPENFAILED, |
| @@ -158,6 +160,7 @@ enum SoftBusFuncId { | |||
| 158 | CLIENT_ON_FINISH_AUTH_RESULT, | 160 | CLIENT_ON_FINISH_AUTH_RESULT, |
| 159 | CLIENT_ON_ERROR_AUTH_RESULT, | 161 | CLIENT_ON_ERROR_AUTH_RESULT, |
| 160 | CLIENT_GENERAL_SERVER_STOPPED, | 162 | CLIENT_GENERAL_SERVER_STOPPED, |
| 163 | + CLIENT_ON_COMMAND, | ||
| 161 | CLIENT_ON_CONVERSATION_RECV_MSG, | 164 | CLIENT_ON_CONVERSATION_RECV_MSG, |
| 162 | CLIENT_ON_PROFILE_DELETED, | 165 | CLIENT_ON_PROFILE_DELETED, |
| 163 | SOFTBUS_FUNC_ID_BUIT, | 166 | SOFTBUS_FUNC_ID_BUIT, |
| @@ -39,6 +39,7 @@ int32_t ServerUnregDataLevelChangeCb(IpcIo *req, IpcIo *reply); | |||
| 39 | int32_t ServerSetDataLevel(IpcIo *req, IpcIo *reply); | 39 | int32_t ServerSetDataLevel(IpcIo *req, IpcIo *reply); |
| 40 | int32_t ServerStartTimeSync(IpcIo *req, IpcIo *reply); | 40 | int32_t ServerStartTimeSync(IpcIo *req, IpcIo *reply); |
| 41 | int32_t ServerStopTimeSync(IpcIo *req, IpcIo *reply); | 41 | int32_t ServerStopTimeSync(IpcIo *req, IpcIo *reply); |
| 42 | +int32_t ServerSetDisplayName(IpcIo *req, IpcIo *reply); | ||
| 42 | int32_t ServerPublishLNN(IpcIo *req, IpcIo *reply); | 43 | int32_t ServerPublishLNN(IpcIo *req, IpcIo *reply); |
| 43 | int32_t ServerStopPublishLNN(IpcIo *req, IpcIo *reply); | 44 | int32_t ServerStopPublishLNN(IpcIo *req, IpcIo *reply); |
| 44 | int32_t ServerRefreshLNN(IpcIo *req, IpcIo *reply); | 45 | int32_t ServerRefreshLNN(IpcIo *req, IpcIo *reply); |
| @@ -50,6 +51,8 @@ int32_t ServerShiftLnnGear(IpcIo *req, IpcIo *reply); | |||
| 50 | int32_t ServerTriggerRangeForMsdp(IpcIo *req, IpcIo *reply); | 51 | int32_t ServerTriggerRangeForMsdp(IpcIo *req, IpcIo *reply); |
| 51 | int32_t ServerRegRangeCbForMsdp(IpcIo *req, IpcIo *reply); | 52 | int32_t ServerRegRangeCbForMsdp(IpcIo *req, IpcIo *reply); |
| 52 | int32_t ServerUnregRangeCbForMsdp(IpcIo *req, IpcIo *reply); | 53 | int32_t ServerUnregRangeCbForMsdp(IpcIo *req, IpcIo *reply); |
| 54 | +int32_t ServerSetCommand(IpcIo *req, IpcIo *reply); | ||
| 55 | +int32_t ServerRegisterCommandCb(IpcIo *req, IpcIo *reply); | ||
| 53 | 56 | ||
| 54 | 57 | ||
| 55 | 58 | ||
| @@ -26,6 +26,7 @@ | |||
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | + | ||
| 29 | 30 | ||
| 30 | 31 | ||
| 31 | 32 | ||
| @@ -393,6 +394,29 @@ int32_t ServerStartTimeSync(IpcIo *req, IpcIo *reply) | |||
| 393 | return SOFTBUS_OK; | 394 | return SOFTBUS_OK; |
| 394 | } | 395 | } |
| 395 | 396 | ||
| 397 | +int32_t ServerSetDisplayName(IpcIo *req, IpcIo *reply) | ||
| 398 | +{ | ||
| 399 | + size_t length; | ||
| 400 | + const char *pkgName = (const char *)ReadString(req, &length); | ||
| 401 | + if (pkgName == NULL || length >= PKG_NAME_SIZE_MAX) { | ||
| 402 | + return SOFTBUS_INVALID_PARAM; | ||
| 403 | + } | ||
| 404 | + static const char *DM_PACKAGE_NAME = "ohos.distributedhardware.devicemanager"; | ||
| 405 | + if (strcmp(DM_PACKAGE_NAME, pkgName) != 0) { | ||
| 406 | + return SOFTBUS_INVALID_PARAM; | ||
| 407 | + } | ||
| 408 | + int32_t callingUid = GetCallingUid(); | ||
| 409 | + if (CheckPermission(pkgName, callingUid) != SOFTBUS_OK) { | ||
| 410 | + return SOFTBUS_PERMISSION_DENIED; | ||
| 411 | + } | ||
| 412 | + const char *nameData = (const char *)ReadString(req, &length); | ||
| 413 | + if (nameData == NULL || length == 0 || length >= MAX_SOFT_BUS_IPC_LEN) { | ||
| 414 | + return SOFTBUS_INVALID_PARAM; | ||
| 415 | + } | ||
| 416 | + int32_t ret = LnnIpcSetDisplayName(pkgName, nameData, (uint32_t)length); | ||
| 417 | + return ret; | ||
| 418 | +} | ||
| 419 | + | ||
| 396 | int32_t ServerStopTimeSync(IpcIo *req, IpcIo *reply) | 420 | int32_t ServerStopTimeSync(IpcIo *req, IpcIo *reply) |
| 397 | { | 421 | { |
| 398 | LNN_LOGI(LNN_STATE, "ipc server pop"); | 422 | LNN_LOGI(LNN_STATE, "ipc server pop"); |
| @@ -775,3 +799,46 @@ int32_t ServerUnregRangeCbForMsdp(IpcIo *req, IpcIo *reply) | |||
| 775 | (void)reply; | 799 | (void)reply; |
| 776 | return SOFTBUS_FUNC_NOT_SUPPORT; | 800 | return SOFTBUS_FUNC_NOT_SUPPORT; |
| 777 | } | 801 | } |
| 802 | + | ||
| 803 | +int32_t ServerSetCommand(IpcIo *req, IpcIo *reply) | ||
| 804 | +{ | ||
| 805 | + int32_t code = 0; | ||
| 806 | + size_t len = 0; | ||
| 807 | + if (!ReadInt32(req, &code)) { | ||
| 808 | + LNN_LOGE(LNN_STATE, "read code failed"); | ||
| 809 | + return SOFTBUS_INVALID_PARAM; | ||
| 810 | + } | ||
| 811 | + const char *value = (const char *)ReadString(req, &len); | ||
| 812 | + if (value == NULL || len == 0) { | ||
| 813 | + LNN_LOGE(LNN_STATE, "read value failed, len=%{public}zu", len); | ||
| 814 | + return SOFTBUS_INVALID_PARAM; | ||
| 815 | + } | ||
| 816 | + uint32_t inLen = (uint32_t)len; | ||
| 817 | + int32_t callingUid = GetCallingUid(); | ||
| 818 | + int32_t ret = LnnIpcSetCommand(code, value, inLen, (uint32_t)callingUid); | ||
| 819 | + if (!WriteInt32(reply, ret)) { | ||
| 820 | + return SOFTBUS_NETWORK_WRITEINT32_FAILED; | ||
| 821 | + } | ||
| 822 | + return ret; | ||
| 823 | +} | ||
| 824 | + | ||
| 825 | +int32_t ServerRegisterCommandCb(IpcIo *req, IpcIo *reply) | ||
| 826 | +{ | ||
| 827 | + size_t length; | ||
| 828 | + const char *pkgName = (const char *)ReadString(req, &length); | ||
| 829 | + if (pkgName == NULL || length >= PKG_NAME_SIZE_MAX) { | ||
| 830 | + LNN_LOGE(LNN_STATE, "read pkgName failed"); | ||
| 831 | + return SOFTBUS_INVALID_PARAM; | ||
| 832 | + } | ||
| 833 | + static const char *DM_PACKAGE_NAME = "ohos.distributedhardware.devicemanager"; | ||
| 834 | + if (strcmp(DM_PACKAGE_NAME, pkgName) != 0) { | ||
| 835 | + return SOFTBUS_INVALID_PARAM; | ||
| 836 | + } | ||
| 837 | + int32_t callingUid = GetCallingUid(); | ||
| 838 | + if (CheckPermission(pkgName, callingUid) != SOFTBUS_OK) { | ||
| 839 | + LNN_LOGE(LNN_STATE, "no permission"); | ||
| 840 | + return SOFTBUS_PERMISSION_DENIED; | ||
| 841 | + } | ||
| 842 | + int32_t ret = LnnIpcRegisterCommandCb(pkgName, (uint32_t)callingUid); | ||
| 843 | + return ret; | ||
| 844 | +} | ||
| @@ -217,6 +217,9 @@ const ServerInvokeCmd g_serverInvokeCmdTbl[] = { | |||
| 217 | { SERVER_PROCESS_INNER_EVENT, ServerProcessInnerEvent }, | 217 | { SERVER_PROCESS_INNER_EVENT, ServerProcessInnerEvent }, |
| 218 | { SERVER_PRIVILEGE_CLOSE_CHANNEL, ServerPrivilegeCloseChannel }, | 218 | { SERVER_PRIVILEGE_CLOSE_CHANNEL, ServerPrivilegeCloseChannel }, |
| 219 | { SERVER_SET_NODE_KEY_INFO, ServerSetNodeKeyInfo }, | 219 | { SERVER_SET_NODE_KEY_INFO, ServerSetNodeKeyInfo }, |
| 220 | + { SERVER_SET_DISPLAY_NAME, ServerSetDisplayName }, | ||
| 221 | + { SERVER_SET_COMMAND, ServerSetCommand }, | ||
| 222 | + { SERVER_REGISTER_COMMAND_CB, ServerRegisterCommandCb }, | ||
| 220 | }; | 223 | }; |
| 221 | 224 | ||
| 222 | static int32_t Invoke(IServerProxy *iProxy, int funcId, void *origin, IpcIo *req, IpcIo *reply) | 225 | static int32_t Invoke(IServerProxy *iProxy, int funcId, void *origin, IpcIo *req, IpcIo *reply) |
| @@ -1191,6 +1191,15 @@ int32_t ProcessAccountAuth(const char *pkgName, int64_t requestId, const uint8_t | |||
| 1191 | * @version 1.0 | 1191 | * @version 1.0 |
| 1192 | */ | 1192 | */ |
| 1193 | int32_t ProcessPushMsg(PushMsg msg); | 1193 | int32_t ProcessPushMsg(PushMsg msg); |
| 1194 | + | ||
| 1195 | +/* command callback registered by device manager, invoked by soft bus */ | ||
| 1196 | +typedef struct { | ||
| 1197 | + int32_t (*onCommand)(int32_t code, const char *value, uint32_t inLen, | ||
| 1198 | + char *res, uint32_t resLen); | ||
| 1199 | +} ITrustedDeviceCb; | ||
| 1200 | + | ||
| 1201 | +int32_t SetCommand(int32_t code, const char *value, uint32_t inLen); | ||
| 1202 | +int32_t RegisterCommandCb(const char *pkgName, ITrustedDeviceCb *cb); | ||
| 1194 | 1203 | ||
| 1195 | } | 1204 | } |
| 1196 | 1205 | ||
| @@ -78,4 +78,7 @@ int32_t ServerIpcGetTrustedDevices(DeviceNodeInfo **info, int32_t *nums); | |||
| 78 | 78 | ||
| 79 | 79 | ||
| 80 | 80 | ||
| 81 | +int32_t ServerIpcSetCommand(int32_t code, const char *value, uint32_t inLen); | ||
| 82 | +int32_t ServerIpcRegisterCommandCb(const char *pkgName); | ||
| 83 | + | ||
| 81 | 84 | ||
| @@ -910,10 +910,25 @@ int32_t ServerIpcProcessPushMsg(const uint8_t *data, uint32_t len) | |||
| 910 | 910 | ||
| 911 | int32_t ServerIpcSetDisplayName(const char *pkgName, const char *nameData, uint32_t len) | 911 | int32_t ServerIpcSetDisplayName(const char *pkgName, const char *nameData, uint32_t len) |
| 912 | { | 912 | { |
| 913 | - (void)pkgName; | 913 | + if (pkgName == NULL || nameData == NULL || len == 0 || len >= MAX_SOFT_BUS_IPC_LEN) { |
| 914 | - (void)nameData; | 914 | + return SOFTBUS_INVALID_PARAM; |
| 915 | - (void)len; | 915 | + } |
| 916 | - return SOFTBUS_FUNC_NOT_SUPPORT; | 916 | + if (g_serverProxy == NULL) { |
| 917 | + return SOFTBUS_SERVER_NOT_INIT; | ||
| 918 | + } | ||
| 919 | + | ||
| 920 | + uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0}; | ||
| 921 | + IpcIo request = {0}; | ||
| 922 | + IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0); | ||
| 923 | + WriteString(&request, pkgName); | ||
| 924 | + WriteString(&request, nameData); | ||
| 925 | + /* asynchronous invocation */ | ||
| 926 | + int32_t ans = g_serverProxy->Invoke(g_serverProxy, SERVER_SET_DISPLAY_NAME, &request, NULL, NULL); | ||
| 927 | + if (ans != SOFTBUS_OK) { | ||
| 928 | + LNN_LOGE(LNN_EVENT, "SetDisplayName invoke failed=%{public}d", ans); | ||
| 929 | + return SOFTBUS_NETWORK_PROXY_INVOKE_FAILED; | ||
| 930 | + } | ||
| 931 | + return SOFTBUS_OK; | ||
| 917 | } | 932 | } |
| 918 | 933 | ||
| 919 | int32_t ServerIpcCreateGroupOwner(const char *pkgName, const struct GroupOwnerConfig *config, | 934 | int32_t ServerIpcCreateGroupOwner(const char *pkgName, const struct GroupOwnerConfig *config, |
| @@ -974,4 +989,50 @@ int32_t ServerIpcGetTrustedDevices(DeviceNodeInfo **info, int32_t *nums) | |||
| 974 | (void)info; | 989 | (void)info; |
| 975 | (void)nums; | 990 | (void)nums; |
| 976 | return SOFTBUS_FUNC_NOT_SUPPORT; | 991 | return SOFTBUS_FUNC_NOT_SUPPORT; |
| 977 | -} | 992 | +} |
| 993 | + | ||
| 994 | +int32_t ServerIpcSetCommand(int32_t code, const char *value, uint32_t inLen) | ||
| 995 | +{ | ||
| 996 | + if (value == NULL || inLen == 0) { | ||
| 997 | + return SOFTBUS_INVALID_PARAM; | ||
| 998 | + } | ||
| 999 | + if (g_serverProxy == NULL) { | ||
| 1000 | + return SOFTBUS_SERVER_NOT_INIT; | ||
| 1001 | + } | ||
| 1002 | + uint8_t data[MAX_SOFT_BUS_IPC_LEN_EX] = {0}; | ||
| 1003 | + IpcIo request = {0}; | ||
| 1004 | + IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN_EX, 0); | ||
| 1005 | + WriteInt32(&request, code); | ||
| 1006 | + WriteString(&request, value); | ||
| 1007 | + uint8_t replyData[MAX_SOFT_BUS_IPC_LEN] = {0}; | ||
| 1008 | + IpcIo reply = {0}; | ||
| 1009 | + IpcIoInit(&reply, replyData, MAX_SOFT_BUS_IPC_LEN, 0); | ||
| 1010 | + int32_t ans = g_serverProxy->Invoke(g_serverProxy, SERVER_SET_COMMAND, &request, &reply, NULL); | ||
| 1011 | + if (ans != SOFTBUS_OK) { | ||
| 1012 | + return SOFTBUS_NETWORK_PROXY_INVOKE_FAILED; | ||
| 1013 | + } | ||
| 1014 | + int32_t serverRet = 0; | ||
| 1015 | + if (!ReadInt32(&reply, &serverRet)) { | ||
| 1016 | + return SOFTBUS_NETWORK_READINT32_FAILED; | ||
| 1017 | + } | ||
| 1018 | + return serverRet; | ||
| 1019 | +} | ||
| 1020 | + | ||
| 1021 | +int32_t ServerIpcRegisterCommandCb(const char *pkgName) | ||
| 1022 | +{ | ||
| 1023 | + if (pkgName == NULL) { | ||
| 1024 | + return SOFTBUS_INVALID_PARAM; | ||
| 1025 | + } | ||
| 1026 | + if (g_serverProxy == NULL) { | ||
| 1027 | + return SOFTBUS_SERVER_NOT_INIT; | ||
| 1028 | + } | ||
| 1029 | + uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0}; | ||
| 1030 | + IpcIo request = {0}; | ||
| 1031 | + IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0); | ||
| 1032 | + WriteString(&request, pkgName); | ||
| 1033 | + int32_t ans = g_serverProxy->Invoke(g_serverProxy, SERVER_REGISTER_COMMAND_CB, &request, NULL, NULL); | ||
| 1034 | + if (ans != SOFTBUS_OK) { | ||
| 1035 | + return SOFTBUS_NETWORK_PROXY_INVOKE_FAILED; | ||
| 1036 | + } | ||
| 1037 | + return SOFTBUS_OK; | ||
| 1038 | +} | ||
| @@ -453,4 +453,18 @@ int32_t ServerIpcGetTrustedDevices(DeviceNodeInfo **info, int32_t *nums) | |||
| 453 | LNN_EVENT, "server not init"); | 453 | LNN_EVENT, "server not init"); |
| 454 | int32_t ret = g_serverProxy->GetTrustedDevices(info, nums); | 454 | int32_t ret = g_serverProxy->GetTrustedDevices(info, nums); |
| 455 | return ret; | 455 | return ret; |
| 456 | -} | 456 | +} |
| 457 | + | ||
| 458 | +int32_t ServerIpcSetCommand(int32_t code, const char *value, uint32_t inLen) | ||
| 459 | +{ | ||
| 460 | + (void)code; | ||
| 461 | + (void)value; | ||
| 462 | + (void)inLen; | ||
| 463 | + return SOFTBUS_FUNC_NOT_SUPPORT; | ||
| 464 | +} | ||
| 465 | + | ||
| 466 | +int32_t ServerIpcRegisterCommandCb(const char *pkgName) | ||
| 467 | +{ | ||
| 468 | + (void)pkgName; | ||
| 469 | + return SOFTBUS_FUNC_NOT_SUPPORT; | ||
| 470 | +} | ||
| @@ -127,6 +127,10 @@ int32_t UnregisterConversationListenerInner(const ConversationBusiness *info); | |||
| 127 | int32_t GetTrustedDevicesInner(DeviceNodeInfo **info, int32_t *nums); | 127 | int32_t GetTrustedDevicesInner(DeviceNodeInfo **info, int32_t *nums); |
| 128 | int32_t LnnConversationRecvMsg(const ConversationBusiness *info, const char *udid, const char *data, uint32_t length); | 128 | int32_t LnnConversationRecvMsg(const ConversationBusiness *info, const char *udid, const char *data, uint32_t length); |
| 129 | void RestartRegisterConversationListener(void); | 129 | void RestartRegisterConversationListener(void); |
| 130 | +int32_t SetCommandInner(int32_t code, const char *value, uint32_t inLen); | ||
| 131 | +int32_t RegisterCommandCbInner(const char *pkgName, ITrustedDeviceCb *cb); | ||
| 132 | +int32_t ClientOnCommandInner(int32_t code, const char *value, uint32_t inLen, | ||
| 133 | + char *res, uint32_t resLen); | ||
| 130 | 134 | ||
| 131 | 135 | ||
| 132 | } | 136 | } |
| @@ -2270,4 +2270,67 @@ void RestartRegisterConversationListener(void) | |||
| 2270 | AnonymizeFree(anonyAbilityName); | 2270 | AnonymizeFree(anonyAbilityName); |
| 2271 | } | 2271 | } |
| 2272 | (void)SoftBusMutexUnlock(&g_busCenterClient.lock); | 2272 | (void)SoftBusMutexUnlock(&g_busCenterClient.lock); |
| 2273 | -} | 2273 | +} |
| 2274 | + | ||
| 2275 | +static ITrustedDeviceCb g_commandCb; | ||
| 2276 | + | ||
| 2277 | +int32_t SetCommandInner(int32_t code, const char *value, uint32_t inLen) | ||
| 2278 | +{ | ||
| 2279 | + if (value == NULL || inLen == 0) { | ||
| 2280 | + LNN_LOGE(LNN_STATE, "invalid param"); | ||
| 2281 | + return SOFTBUS_INVALID_PARAM; | ||
| 2282 | + } | ||
| 2283 | + if (!g_busCenterClient.isInit) { | ||
| 2284 | + LNN_LOGE(LNN_STATE, "buscenter client not init"); | ||
| 2285 | + return SOFTBUS_NO_INIT; | ||
| 2286 | + } | ||
| 2287 | + return ServerIpcSetCommand(code, value, inLen); | ||
| 2288 | +} | ||
| 2289 | + | ||
| 2290 | +int32_t RegisterCommandCbInner(const char *pkgName, ITrustedDeviceCb *cb) | ||
| 2291 | +{ | ||
| 2292 | + if (pkgName == NULL || cb == NULL || cb->onCommand == NULL) { | ||
| 2293 | + LNN_LOGE(LNN_STATE, "invalid param"); | ||
| 2294 | + return SOFTBUS_INVALID_PARAM; | ||
| 2295 | + } | ||
| 2296 | + if (!g_busCenterClient.isInit) { | ||
| 2297 | + LNN_LOGE(LNN_STATE, "buscenter client not init"); | ||
| 2298 | + return SOFTBUS_NO_INIT; | ||
| 2299 | + } | ||
| 2300 | + int32_t ret = SoftBusMutexLock(&g_busCenterClient.lock); | ||
| 2301 | + if (ret != SOFTBUS_OK) { | ||
| 2302 | + LNN_LOGE(LNN_STATE, "lock fail"); | ||
| 2303 | + return SOFTBUS_LOCK_ERR; | ||
| 2304 | + } | ||
| 2305 | + g_commandCb.onCommand = cb->onCommand; | ||
| 2306 | + (void)SoftBusMutexUnlock(&g_busCenterClient.lock); | ||
| 2307 | + LNN_LOGI(LNN_STATE, "register command cb succ"); | ||
| 2308 | + return ServerIpcRegisterCommandCb(pkgName); | ||
| 2309 | +} | ||
| 2310 | + | ||
| 2311 | +int32_t ClientOnCommandInner(int32_t code, const char *value, uint32_t inLen, | ||
| 2312 | + char *res, uint32_t resLen) | ||
| 2313 | +{ | ||
| 2314 | + if (value == NULL || inLen == 0) { | ||
| 2315 | + return SOFTBUS_INVALID_PARAM; | ||
| 2316 | + } | ||
| 2317 | + LNN_LOGI(LNN_STATE, "7.41"); | ||
| 2318 | + int32_t ret = SoftBusMutexLock(&g_busCenterClient.lock); | ||
| 2319 | + LNN_LOGI(LNN_STATE, "7.42"); | ||
| 2320 | + if (ret != SOFTBUS_OK) { | ||
| 2321 | + return SOFTBUS_LOCK_ERR; | ||
| 2322 | + } | ||
| 2323 | + ITrustedDeviceCb cb = g_commandCb; | ||
| 2324 | + LNN_LOGI(LNN_STATE, "7.43"); | ||
| 2325 | + (void)SoftBusMutexUnlock(&g_busCenterClient.lock); | ||
| 2326 | + LNN_LOGI(LNN_STATE, "7.44"); | ||
| 2327 | + if (cb.onCommand == NULL) { | ||
| 2328 | + LNN_LOGW(LNN_STATE, "command cb not registered"); | ||
| 2329 | + return SOFTBUS_NOT_FIND; | ||
| 2330 | + } | ||
| 2331 | + LNN_LOGI(LNN_STATE, "[CMD-DBG] invoke onCommand, code=%{public}d", code); | ||
| 2332 | + int32_t result; | ||
| 2333 | + result = cb.onCommand(code, value, inLen, res, resLen); | ||
| 2334 | + LNN_LOGI(LNN_STATE, "[CMD-DBG] res , res=%{public}s", res); | ||
| 2335 | + return result; | ||
| 2336 | +} | ||
| @@ -783,4 +783,32 @@ int32_t ProcessAccountAuth(const char *pkgName, int64_t requestId, const uint8_t | |||
| 783 | return ret; | 783 | return ret; |
| 784 | } | 784 | } |
| 785 | return ProcessAccountAuthInner(pkgName, requestId, data, dataLen, cb); | 785 | return ProcessAccountAuthInner(pkgName, requestId, data, dataLen, cb); |
| 786 | -} | 786 | +} |
| 787 | + | ||
| 788 | +int32_t SetCommand(int32_t code, const char *value, uint32_t inLen) | ||
| 789 | +{ | ||
| 790 | + if (value == NULL || inLen == 0) { | ||
| 791 | + LNN_LOGE(LNN_STATE, "invalid param"); | ||
| 792 | + return SOFTBUS_INVALID_PARAM; | ||
| 793 | + } | ||
| 794 | + return SetCommandInner(code, value, inLen); | ||
| 795 | +} | ||
| 796 | + | ||
| 797 | +int32_t RegisterCommandCb(const char *pkgName, ITrustedDeviceCb *cb) | ||
| 798 | +{ | ||
| 799 | + static const char *DM_PACKAGE_NAME = "ohos.distributedhardware.devicemanager"; | ||
| 800 | + if (pkgName == NULL || cb == NULL || cb->onCommand == NULL) { | ||
| 801 | + LNN_LOGE(LNN_STATE, "invalid param"); | ||
| 802 | + return SOFTBUS_INVALID_PARAM; | ||
| 803 | + } | ||
| 804 | + if (strcmp(DM_PACKAGE_NAME, pkgName) != 0) { | ||
| 805 | + LNN_LOGE(LNN_STATE, "only device manager is allowed"); | ||
| 806 | + return SOFTBUS_INVALID_PARAM; | ||
| 807 | + } | ||
| 808 | + int32_t ret = CommonInit(pkgName); | ||
| 809 | + if (ret != SOFTBUS_OK) { | ||
| 810 | + LNN_LOGE(LNN_STATE, "common init fail, ret=%{public}d", ret); | ||
| 811 | + return ret; | ||
| 812 | + } | ||
| 813 | + return RegisterCommandCbInner(pkgName, cb); | ||
| 814 | +} | ||
| @@ -45,6 +45,7 @@ struct SoftBusIpcClientCmd { | |||
| 45 | int32_t (*func)(IpcIo *data, IpcIo *reply); | 45 | int32_t (*func)(IpcIo *data, IpcIo *reply); |
| 46 | }; | 46 | }; |
| 47 | 47 | ||
| 48 | +static int32_t ClientOnCommandStub(IpcIo *data, IpcIo *reply); | ||
| 48 | static struct SoftBusIpcClientCmd g_softBusIpcClientCmdTbl[] = { | 49 | static struct SoftBusIpcClientCmd g_softBusIpcClientCmdTbl[] = { |
| 49 | { CLIENT_ON_JOIN_RESULT, ClientOnJoinLNNResult }, | 50 | { CLIENT_ON_JOIN_RESULT, ClientOnJoinLNNResult }, |
| 50 | { CLIENT_ON_JOIN_METANODE_RESULT, ClientOnJoinMetaNodeResult }, | 51 | { CLIENT_ON_JOIN_METANODE_RESULT, ClientOnJoinMetaNodeResult }, |
| @@ -62,6 +63,7 @@ static struct SoftBusIpcClientCmd g_softBusIpcClientCmdTbl[] = { | |||
| 62 | { CLIENT_ON_CHANNEL_MSGRECEIVED, ClientOnChannelMsgreceived }, | 63 | { CLIENT_ON_CHANNEL_MSGRECEIVED, ClientOnChannelMsgreceived }, |
| 63 | { CLIENT_SET_CHANNEL_INFO, ClientSetChannelInfo }, | 64 | { CLIENT_SET_CHANNEL_INFO, ClientSetChannelInfo }, |
| 64 | { CLIENT_ON_CHANNEL_BIND, ClientOnChannelBind }, | 65 | { CLIENT_ON_CHANNEL_BIND, ClientOnChannelBind }, |
| 66 | + { CLIENT_ON_COMMAND, ClientOnCommandStub }, | ||
| 65 | { CLIENT_CHECK_COLLAB_RELATION, ClientCheckCollabRelation }, | 67 | { CLIENT_CHECK_COLLAB_RELATION, ClientCheckCollabRelation }, |
| 66 | }; | 68 | }; |
| 67 | 69 | ||
| @@ -262,3 +264,33 @@ int ClientRegisterService(const char *pkgName) | |||
| 262 | COMM_LOGI(COMM_SDK, "ClientRegisterService success"); | 264 | COMM_LOGI(COMM_SDK, "ClientRegisterService success"); |
| 263 | return SOFTBUS_OK; | 265 | return SOFTBUS_OK; |
| 264 | } | 266 | } |
| 267 | + | ||
| 268 | +static int32_t ClientOnCommandStub(IpcIo *data, IpcIo *reply) | ||
| 269 | +{ | ||
| 270 | + if (data == NULL || reply == NULL) { | ||
| 271 | + return SOFTBUS_INVALID_PARAM; | ||
| 272 | + } | ||
| 273 | + COMM_LOGI(COMM_SDK, "7.1"); | ||
| 274 | + int32_t code = 0; | ||
| 275 | + if (!ReadInt32(data, &code)) { | ||
| 276 | + COMM_LOGI(COMM_SDK, "7.2"); | ||
| 277 | + return SOFTBUS_INVALID_PARAM; | ||
| 278 | + } | ||
| 279 | + COMM_LOGI(COMM_SDK, "7.3"); | ||
| 280 | + size_t len = 0; | ||
| 281 | + const char *value = (const char *)ReadString(data, &len); | ||
| 282 | + if (value == NULL || len == 0) { | ||
| 283 | + return SOFTBUS_INVALID_PARAM; | ||
| 284 | + } | ||
| 285 | + char res[256] = {0}; | ||
| 286 | + COMM_LOGI(COMM_SDK, "7.4"); | ||
| 287 | + int32_t ret = ClientOnCommandInner(code, value, (uint32_t)len, res, sizeof(res)); | ||
| 288 | + COMM_LOGI(COMM_SDK, "7.5"); | ||
| 289 | + COMM_LOGI(COMM_SDK, "[CMD-DBG] client on command, code=%{public}d, ret=%{public}d, res=%{public}s", | ||
| 290 | + code, ret, res); | ||
| 291 | + if (!WriteString(reply, res)) { | ||
| 292 | + COMM_LOGE(COMM_SDK, "write res failed"); | ||
| 293 | + } | ||
| 294 | + COMM_LOGI(COMM_SDK, "7.6"); | ||
| 295 | + return ret; | ||
| 296 | +} | ||
| @@ -91,6 +91,7 @@ private: | |||
| 91 | int32_t OnLeaveLNNResultInner(MessageParcel &data, MessageParcel &reply); | 91 | int32_t OnLeaveLNNResultInner(MessageParcel &data, MessageParcel &reply); |
| 92 | int32_t OnNodeOnlineStateChangedInner(MessageParcel &data, MessageParcel &reply); | 92 | int32_t OnNodeOnlineStateChangedInner(MessageParcel &data, MessageParcel &reply); |
| 93 | int32_t OnNodeBasicInfoChangedInner(MessageParcel &data, MessageParcel &reply); | 93 | int32_t OnNodeBasicInfoChangedInner(MessageParcel &data, MessageParcel &reply); |
| 94 | + int32_t OnCommandInner(MessageParcel &data, MessageParcel &reply); | ||
| 94 | int32_t OnNodeStatusChangedInner(MessageParcel &data, MessageParcel &reply); | 95 | int32_t OnNodeStatusChangedInner(MessageParcel &data, MessageParcel &reply); |
| 95 | int32_t OnLocalNetworkIdChangedInner(MessageParcel &data, MessageParcel &reply); | 96 | int32_t OnLocalNetworkIdChangedInner(MessageParcel &data, MessageParcel &reply); |
| 96 | int32_t OnNodeDeviceTrustedChangeInner(MessageParcel &data, MessageParcel &reply); | 97 | int32_t OnNodeDeviceTrustedChangeInner(MessageParcel &data, MessageParcel &reply); |
| @@ -1323,3 +1323,16 @@ int32_t SoftBusClientStub::OnProfileDeletedInner(MessageParcel &data, MessagePar | |||
| 1323 | return SOFTBUS_OK; | 1323 | return SOFTBUS_OK; |
| 1324 | } | 1324 | } |
| 1325 | } // namespace OHOS | 1325 | } // namespace OHOS |
| 1326 | + | ||
| 1327 | +int32_t SoftBusClientStub::OnCommandInner(MessageParcel &data, MessageParcel &reply) | ||
| 1328 | +{ | ||
| 1329 | + int32_t code = 0; | ||
| 1330 | + if (!data.ReadInt32(code)) { | ||
| 1331 | + return SOFTBUS_INVALID_PARAM; | ||
| 1332 | + } | ||
| 1333 | + const char *value = data.ReadCString(); | ||
| 1334 | + if (value == nullptr) { | ||
| 1335 | + return SOFTBUS_INVALID_PARAM; | ||
| 1336 | + } | ||
| 1337 | + return ClientOnCommandInner(code, value, static_cast<uint32_t>(strlen(value)), nullptr, 0); | ||
| 1338 | +} | ||