From 38b8900e67cd3f678c7c186a0cd2f4c4b5d18a0c Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Mon, 16 May 2022 16:10:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=B1=8F=E8=94=BDdeviceid=E5=9C=A8log?= =?UTF-8?q?=E5=85=A8=E9=87=8F=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyb0625 --- ext/profile/src/profile_connector.cpp | 3 ++- .../native_cpp/src/device_manager_impl.cpp | 3 ++- .../src/mini/device_manager_impl.cpp | 3 ++- .../kits/js/src/native_devicemanager_js.cpp | 21 ++++++++----------- .../js_mini/src/native_devicemanager_js.cpp | 8 +++---- .../authentication/auth_message_processor.cpp | 11 +++++----- .../src/authentication/dm_auth_manager.cpp | 7 +++---- .../devicestate/dm_device_state_manager.cpp | 3 ++- .../src/ipc/standard/ipc_cmd_parser.cpp | 5 +++-- 9 files changed, 33 insertions(+), 31 deletions(-) diff --git a/ext/profile/src/profile_connector.cpp b/ext/profile/src/profile_connector.cpp index da1d4f5a1..d8d4b9fd6 100755 --- a/ext/profile/src/profile_connector.cpp +++ b/ext/profile/src/profile_connector.cpp @@ -15,6 +15,7 @@ #include "profile_connector.h" +#include "dm_anonymous.h" #include "dm_constants.h" #include "dm_log.h" @@ -111,7 +112,7 @@ void ProfileConnector::OnSyncCompleted(const SyncResult &syncResults) deviceId = iterResult.first; SyncStatus = iterResult.second; } - LOGI("ProfileEventCallback::OnSyncCompleted, deviceId = %s", deviceId.c_str()); + LOGI("ProfileEventCallback::OnSyncCompleted, deviceId = %s", GetAnonyString(deviceId).c_str()); std::lock_guard mutexLock(callbackMapMutex_); for (auto &iter : callbackMap_) { iter.second->OnProfileComplete(iter.first, deviceId); diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index 8f61f2ec4..53a78e984 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -16,6 +16,7 @@ #include "device_manager_impl.h" #include #include "device_manager_notify.h" +#include "dm_anonymous.h" #include "dm_constants.h" #include "dm_log.h" #include "ipc_authenticate_device_req.h" @@ -278,7 +279,7 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ int32_t DeviceManagerImpl::UnAuthenticateDevice(const std::string &pkgName, const DmDeviceInfo &deviceInfo) { LOGI("DeviceManager::UnAuthenticateDevice start , pkgName: %s, deviceId: %s", pkgName.c_str(), - deviceInfo.deviceId); + GetAnonyString(std::string(deviceInfo.deviceId)).c_str()); if (pkgName.empty() || (deviceInfo.deviceId[0] == '\0')) { LOGE("UnAuthenticateDevice error: Invalid para"); return ERR_DM_INPUT_PARAMETER_EMPTY; diff --git a/interfaces/inner_kits/native_cpp/src/mini/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/mini/device_manager_impl.cpp index 5e4388d8d..67aeb5bae 100644 --- a/interfaces/inner_kits/native_cpp/src/mini/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/mini/device_manager_impl.cpp @@ -240,7 +240,8 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ int32_t DeviceManagerImpl::UnAuthenticateDevice(const std::string &pkgName, const std::string &deviceId) { - LOGI("DeviceManager::UnAuthenticateDevice start , pkgName: %s, deviceId: %s", pkgName.c_str(), deviceId.c_str()); + LOGI("DeviceManager::UnAuthenticateDevice start , pkgName: %s, deviceId: %s", pkgName.c_str(), + GetAnonyString(deviceId).c_str()); if (deviceId.empty()) { LOGE("UnAuthenticateDevice error: Invalid para"); return ERR_DM_INPUT_PARAMETER_EMPTY; diff --git a/interfaces/kits/js/src/native_devicemanager_js.cpp b/interfaces/kits/js/src/native_devicemanager_js.cpp index 82f76a4ef..f057d9cf6 100644 --- a/interfaces/kits/js/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js/src/native_devicemanager_js.cpp @@ -1099,7 +1099,7 @@ void DeviceManagerNapi::CallGetTrustedDeviceListStatusSync(napi_env env, napi_st { for (unsigned int i = 0; i < deviceInfoListAsyncCallbackInfo->devList.size(); i++) { LOGI("DeviceManager::GetTrustedDeviceList deviceId:%s deviceName:%s deviceTypeId:%d ", - deviceInfoListAsyncCallbackInfo->devList[i].deviceId, + GetAnonyString(deviceInfoListAsyncCallbackInfo->devList[i].deviceId).c_str(), deviceInfoListAsyncCallbackInfo->devList[i].deviceName, deviceInfoListAsyncCallbackInfo->devList[i].deviceTypeId); } @@ -1178,7 +1178,7 @@ void DeviceManagerNapi::CallGetTrustedDeviceListStatus(napi_env env, napi_status { for (unsigned int i = 0; i < deviceInfoListAsyncCallbackInfo->devList.size(); i++) { LOGI("DeviceManager::GetTrustedDeviceList deviceId:%s deviceName:%s deviceTypeId:%d ", - deviceInfoListAsyncCallbackInfo->devList[i].deviceId, + GetAnonyString(deviceInfoListAsyncCallbackInfo->devList[i].deviceId).c_str(), deviceInfoListAsyncCallbackInfo->devList[i].deviceName, deviceInfoListAsyncCallbackInfo->devList[i].deviceTypeId); } @@ -1221,7 +1221,8 @@ void DeviceManagerNapi::CallGetLocalDeviceInfoSync(napi_env env, napi_status &st napi_value result[DM_NAPI_ARGS_TWO] = {0}; LOGI("DeviceManager::CallGetLocalDeviceInfoSync deviceId:%s deviceName:%s deviceTypeId:%d ", - deviceInfoAsyncCallbackInfo->deviceInfo.deviceId, deviceInfoAsyncCallbackInfo->deviceInfo.deviceName, + GetAnonyString(deviceInfoAsyncCallbackInfo->deviceInfo.deviceId).c_str(), + deviceInfoAsyncCallbackInfo->deviceInfo.deviceName, deviceInfoAsyncCallbackInfo->deviceInfo.deviceTypeId); if (deviceInfoAsyncCallbackInfo->status == 0) { @@ -1239,7 +1240,8 @@ void DeviceManagerNapi::CallGetLocalDeviceInfo(napi_env env, napi_status &status { napi_value result[DM_NAPI_ARGS_TWO] = {0}; LOGI("DeviceManager::CallGetLocalDeviceInfo deviceId:%s deviceName:%s deviceTypeId:%d ", - deviceInfoAsyncCallbackInfo->deviceInfo.deviceId, deviceInfoAsyncCallbackInfo->deviceInfo.deviceName, + GetAnonyString(deviceInfoAsyncCallbackInfo->deviceInfo.deviceId).c_str(), + deviceInfoAsyncCallbackInfo->deviceInfo.deviceName, deviceInfoAsyncCallbackInfo->deviceInfo.deviceTypeId); napi_value callResult = nullptr; napi_value handler = nullptr; @@ -1427,9 +1429,6 @@ napi_value DeviceManagerNapi::GetTrustedDeviceListSync(napi_env env, napi_callba LOGI("GetTrustedDeviceListSync in"); napi_value result = nullptr; napi_value thisVar = nullptr; - DmDeviceInfo deviceInfo; - LOGI("DeviceManager::GetTrustedDeviceListSync deviceId:%s deviceName:%s deviceTypeId:%d ", deviceInfo.deviceId, - deviceInfo.deviceName, deviceInfo.deviceTypeId); size_t argc = 0; bool isArray = false; napi_create_array(env, &result); @@ -1512,8 +1511,6 @@ napi_value DeviceManagerNapi::GetLocalDeviceInfoSync(napi_env env, napi_callback napi_value result = nullptr; napi_value thisVar = nullptr; DmDeviceInfo deviceInfo; - LOGI("DeviceManager::GetLocalDeviceInfoSync deviceId:%s deviceName:%s deviceTypeId:%d ", deviceInfo.deviceId, - deviceInfo.deviceName, deviceInfo.deviceTypeId); size_t argc = 0; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, nullptr, &thisVar, nullptr)); @@ -1525,8 +1522,8 @@ napi_value DeviceManagerNapi::GetLocalDeviceInfoSync(napi_env env, napi_callback LOGE("GetLocalDeviceInfoSync for failed, ret %d", ret); return result; } - LOGI("DeviceManager::GetLocalDeviceInfoSync deviceId:%s deviceName:%s deviceTypeId:%d ", deviceInfo.deviceId, - deviceInfo.deviceName, deviceInfo.deviceTypeId); + LOGI("DeviceManager::GetLocalDeviceInfoSync deviceId:%s deviceName:%s deviceTypeId:%d ", + GetAnonyString(std::string(deviceInfo.deviceId)).c_str(), deviceInfo.deviceName, deviceInfo.deviceTypeId); DmDeviceInfotoJsDeviceInfo(env, deviceInfo, result); return result; } @@ -1580,7 +1577,7 @@ napi_value DeviceManagerNapi::UnAuthenticateDevice(napi_env env, napi_callback_i DmDeviceInfo deviceInfo; JsToDmDeviceInfo(env, argv[0], deviceInfo); - LOGI("UnAuthenticateDevice deviceId = %s", deviceInfo.deviceId); + LOGI("UnAuthenticateDevice deviceId=%s", GetAnonyString(deviceInfo.deviceId).c_str()); DeviceManagerNapi *deviceManagerWrapper = nullptr; napi_unwrap(env, thisVar, reinterpret_cast(&deviceManagerWrapper)); int32_t ret = DeviceManager::GetInstance().UnAuthenticateDevice(deviceManagerWrapper->bundleName_, deviceInfo); diff --git a/interfaces/kits/js_mini/src/native_devicemanager_js.cpp b/interfaces/kits/js_mini/src/native_devicemanager_js.cpp index 459b41125..dbb2164d1 100644 --- a/interfaces/kits/js_mini/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js_mini/src/native_devicemanager_js.cpp @@ -766,7 +766,7 @@ JSIValue DeviceManagerModule::UnAuthenticateDevice(const JSIValue thisVal, const } std::string bundleName = GetJSIAppBundleName(); std::string deviceId = JSI::GetStringProperty(args[0], "deviceId"); - LOGI("UnAuthenticateDevice deviceId=%s", deviceId.c_str()); + LOGI("UnAuthenticateDevice deviceId=%s", GetAnonyString(deviceId.c_str())); int32_t ret = 0; ret = OHOS::DistributedHardware::DeviceManager::GetInstance().UnAuthenticateDevice(bundleName, deviceId); if (ret != 0) { @@ -789,8 +789,8 @@ JSIValue DeviceManagerModule::GetLocalDeviceInfoSync(const JSIValue thisVal, con LOGE("GetLocalDeviceInfoSync for failed, ret %d", ret); return JSI::CreateNull(); } - LOGI("DeviceManager::GetLocalDeviceInfoSync deviceId:%s deviceName:%s deviceTypeId:%d ", deviceInfo.deviceId, - deviceInfo.deviceName, deviceInfo.deviceTypeId); + LOGI("DeviceManager::GetLocalDeviceInfoSync deviceId:%s deviceName:%s deviceTypeId:%d ", + GetAnonyString(deviceInfo.deviceId), deviceInfo.deviceName, deviceInfo.deviceTypeId); JSIValue result = JSI::CreateObject(); char *deviceId = const_cast(deviceInfo.deviceId); char *deviceName = const_cast(deviceInfo.deviceName); @@ -985,7 +985,7 @@ JSIValue DeviceManagerModule::AuthenticateDevice(const JSIValue thisVal, const J DmDeviceInfo deviceInfo; JsToDmDeviceInfo(args[0], deviceInfo); - LOGI("deviceInfo %s , %s, %d", deviceInfo.deviceId, + LOGI("deviceInfo %s , %s, %d", GetAnonyString(deviceInfo.deviceId), deviceInfo.deviceName, deviceInfo.deviceTypeId); DmAppImageInfo appImageInfo(nullptr, 0, nullptr, 0); std::string extra; diff --git a/services/devicemanagerservice/src/authentication/auth_message_processor.cpp b/services/devicemanagerservice/src/authentication/auth_message_processor.cpp index 2a7ac9e03..ec92c7dca 100644 --- a/services/devicemanagerservice/src/authentication/auth_message_processor.cpp +++ b/services/devicemanagerservice/src/authentication/auth_message_processor.cpp @@ -16,6 +16,7 @@ #include "auth_message_processor.h" #include "dm_auth_manager.h" +#include "dm_anonymous.h" #include "dm_constants.h" #include "dm_log.h" @@ -130,7 +131,7 @@ void AuthMessageProcessor::CreateResponseAuthMessage(nlohmann::json &json) json[TAG_TOKEN] = authResponseContext_->token; if (authResponseContext_->reply == 0) { std::string groupId = authResponseContext_->groupId; - LOGI("AuthMessageProcessor::CreateSimpleMessage groupId %d", groupId.c_str()); + LOGI("AuthMessageProcessor::CreateSimpleMessage groupId %s", GetAnonyString(groupId).c_str()); nlohmann::json jsonObject = nlohmann::json::parse(groupId, nullptr, false); if (jsonObject.is_discarded()) { LOGE("DecodeRequestAuth jsonStr error"); @@ -142,8 +143,8 @@ void AuthMessageProcessor::CreateResponseAuthMessage(nlohmann::json &json) json[TAG_GROUP_ID] = groupId; json[TAG_GROUP_NAME] = authResponseContext_->groupName; json[TAG_AUTH_TOKEN] = authResponseContext_->authToken; - LOGI("AuthMessageProcessor::ParseAuthResponseMessage %s,%s", groupId.c_str(), - authResponseContext_->groupName.c_str()); + LOGI("AuthMessageProcessor::ParseAuthResponseMessage %s,%s", GetAnonyString(groupId).c_str(), + GetAnonyString(authResponseContext_->groupName).c_str()); } } @@ -234,8 +235,8 @@ void AuthMessageProcessor::ParseAuthResponseMessage(nlohmann::json &json) authResponseContext_->groupId = json[TAG_GROUP_ID]; authResponseContext_->groupName = json[TAG_GROUP_NAME]; authResponseContext_->authToken = json[TAG_AUTH_TOKEN]; - LOGI("AuthMessageProcessor::ParseAuthResponseMessage %s,%s", authResponseContext_->groupId.c_str(), - authResponseContext_->groupName.c_str()); + LOGI("AuthMessageProcessor::ParseAuthResponseMessage %s,%s", + GetAnonyString(authResponseContext_->groupId).c_str(), authResponseContext_->groupName.c_str()); } LOGI("AuthMessageProcessor::ParseAuthResponseMessage "); } diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index 3f690ae48..ff50edcfa 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -19,6 +19,7 @@ #include "auth_message_processor.h" #include "dm_ability_manager.h" +#include "dm_anonymous.h" #include "dm_config_manager.h" #include "dm_constants.h" #include "dm_log.h" @@ -142,8 +143,8 @@ int32_t DmAuthManager::UnAuthenticateDevice(const std::string &pkgName, const st hiChainConnector_->GetRelatedGroups(deviceUdid, groupList); if (groupList.size() > 0) { groupId = groupList.front().groupId; - LOGI(" DmAuthManager::UnAuthenticateDevice groupId=%s, deviceId=%s, deviceUdid=%s", groupId.c_str(), - deviceId.c_str(), deviceUdid.c_str()); + LOGI(" DmAuthManager::UnAuthenticateDevice groupId=%s, deviceId=%s, deviceUdid=%s", + GetAnonyString(groupId).c_str(), GetAnonyString(deviceId).c_str(), GetAnonyString(deviceUdid).c_str()); hiChainConnector_->DeleteGroup(groupId); } else { LOGE("DmAuthManager::UnAuthenticateDevice groupList.size = 0"); @@ -333,7 +334,6 @@ void DmAuthManager::OnGroupCreated(int64_t requestId, const std::string &groupId jsonObj[QR_CODE_KEY] = GenerateGroupName(); jsonObj[NFC_CODE_KEY] = GenerateGroupName(); authResponseContext_->authToken = jsonObj.dump(); - LOGI("DmAuthManager::AddMember start %s", authResponseContext_->authToken.c_str()); authResponseContext_->groupId = groupId; authResponseContext_->code = pinCode; authMessageProcessor_->SetResponseContext(authResponseContext_); @@ -529,7 +529,6 @@ int32_t DmAuthManager::AddMember(const std::string &deviceId) return ERR_DM_FAILED; } - LOGI("DmAuthManager::AddMember start %s", authResponseContext_->authToken.c_str()); nlohmann::json jsonObject; jsonObject[TAG_GROUP_ID] = authResponseContext_->groupId; jsonObject[TAG_GROUP_NAME] = authResponseContext_->groupName; diff --git a/services/devicemanagerservice/src/devicestate/dm_device_state_manager.cpp b/services/devicemanagerservice/src/devicestate/dm_device_state_manager.cpp index 4fc28dc12..0b089ef29 100755 --- a/services/devicemanagerservice/src/devicestate/dm_device_state_manager.cpp +++ b/services/devicemanagerservice/src/devicestate/dm_device_state_manager.cpp @@ -60,7 +60,8 @@ int32_t DmDeviceStateManager::RegisterProfileListener(const std::string &pkgName remoteDeviceInfos_[uuid] = saveInfo; } LOGI("RegisterProfileListener in, deviceId = %s, deviceUdid = %s, uuid = %s", - info.deviceId, deviceUdid.c_str(), uuid.c_str()); + GetAnonyString(std::string(info.deviceId)).c_str(), GetAnonyString(deviceUdid).c_str(), + GetAnonyString(uuid).c_str()); profileAdapter->RegisterProfileListener(pkgName, deviceUdid, shared_from_this()); } } diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp index 62791db81..260070f41 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp @@ -17,6 +17,7 @@ #include "device_manager_service.h" #include "dm_constants.h" +#include "dm_anonymous.h" #include "dm_device_info.h" #include "dm_log.h" #include "dm_subscribe_info.h" @@ -360,7 +361,7 @@ ON_IPC_CMD(UNAUTHENTICATE_DEVICE, MessageParcel &data, MessageParcel &reply) std::string pkgName = data.ReadString(); std::string deviceId = data.ReadString(); int32_t result = DM_OK; - LOGI("pkgName:%s, trustedDeviceInfo: %d", pkgName.c_str(), deviceId.c_str()); + LOGI("pkgName:%s, trustedDeviceInfo: %s", pkgName.c_str(), GetAnonyString(deviceId).c_str()); result = DeviceManagerService::GetInstance().UnAuthenticateDevice(pkgName, deviceId); if (!reply.WriteInt32(result)) { LOGE("write result failed"); @@ -395,7 +396,7 @@ ON_IPC_CMD(GET_LOCAL_DEVICE_INFO, MessageParcel &data, MessageParcel &reply) LOGE("write result failed"); return ERR_DM_IPC_WRITE_FAILED; } - LOGI("localDeviceInfo: %s", localDeviceInfo.deviceId); + LOGI("localDeviceInfo: %s", GetAnonyString(std::string(localDeviceInfo.deviceId)).c_str()); return DM_OK; } -- Gitee From 870abeb36788a4369f4c682c65ca198c45788a62 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Mon, 16 May 2022 17:04:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=B1=8F=E8=94=BDdeviceid=E5=9C=A8log?= =?UTF-8?q?=E5=85=A8=E9=87=8F=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyb0625 --- interfaces/kits/js_mini/src/native_devicemanager_js.cpp | 2 +- .../src/authentication/auth_message_processor.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/js_mini/src/native_devicemanager_js.cpp b/interfaces/kits/js_mini/src/native_devicemanager_js.cpp index dbb2164d1..9b5372db4 100644 --- a/interfaces/kits/js_mini/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js_mini/src/native_devicemanager_js.cpp @@ -789,7 +789,7 @@ JSIValue DeviceManagerModule::GetLocalDeviceInfoSync(const JSIValue thisVal, con LOGE("GetLocalDeviceInfoSync for failed, ret %d", ret); return JSI::CreateNull(); } - LOGI("DeviceManager::GetLocalDeviceInfoSync deviceId:%s deviceName:%s deviceTypeId:%d ", + LOGI("DeviceManager::GetLocalDeviceInfoSync deviceId:%s deviceName:%s deviceTypeId:%d ", GetAnonyString(deviceInfo.deviceId), deviceInfo.deviceName, deviceInfo.deviceTypeId); JSIValue result = JSI::CreateObject(); char *deviceId = const_cast(deviceInfo.deviceId); diff --git a/services/devicemanagerservice/src/authentication/auth_message_processor.cpp b/services/devicemanagerservice/src/authentication/auth_message_processor.cpp index ec92c7dca..3c1e63468 100644 --- a/services/devicemanagerservice/src/authentication/auth_message_processor.cpp +++ b/services/devicemanagerservice/src/authentication/auth_message_processor.cpp @@ -236,7 +236,7 @@ void AuthMessageProcessor::ParseAuthResponseMessage(nlohmann::json &json) authResponseContext_->groupName = json[TAG_GROUP_NAME]; authResponseContext_->authToken = json[TAG_AUTH_TOKEN]; LOGI("AuthMessageProcessor::ParseAuthResponseMessage %s,%s", - GetAnonyString(authResponseContext_->groupId).c_str(), authResponseContext_->groupName.c_str()); + GetAnonyString(authResponseContext_->groupId).c_str(), authResponseContext_->groupName.c_str()); } LOGI("AuthMessageProcessor::ParseAuthResponseMessage "); } -- Gitee