mirror of
https://gitee.com/openharmony/deviceprofile_device_info_manager
synced 2025-01-08 16:32:54 +00:00
commit
c8e24817e7
@ -65,6 +65,7 @@ public:
|
||||
bool UnMarshalling(MessageParcel& parcel) override;
|
||||
bool operator!=(const DeviceProfile& deviceProfile) const;
|
||||
std::string dump() const override;
|
||||
std::string AnnoymizeDump() const;
|
||||
|
||||
private:
|
||||
std::string deviceId_;
|
||||
|
@ -210,5 +210,40 @@ std::string DeviceProfile::dump() const
|
||||
free(jsonChars);
|
||||
return jsonStr;
|
||||
}
|
||||
|
||||
std::string DeviceProfile::AnnoymizeDump() const
|
||||
{
|
||||
cJSON* json = cJSON_CreateObject();
|
||||
if (!cJSON_IsObject(json)) {
|
||||
cJSON_Delete(json);
|
||||
return EMPTY_STRING;
|
||||
}
|
||||
cJSON_AddStringToObject(json, DEVICE_ID.c_str(), ProfileUtils::GetAnonyString(deviceId_).c_str());
|
||||
cJSON_AddStringToObject(json, DEVICE_TYPE_NAME.c_str(), deviceTypeName_.c_str());
|
||||
cJSON_AddNumberToObject(json, DEVICE_TYPE_ID.c_str(), deviceTypeId_);
|
||||
cJSON_AddStringToObject(json, DEVICE_NAME.c_str(), deviceName_.c_str());
|
||||
cJSON_AddStringToObject(json, MANUFACTURE_NAME.c_str(), manufactureName_.c_str());
|
||||
cJSON_AddStringToObject(json, DEVICE_MODEL.c_str(), deviceModel_.c_str());
|
||||
cJSON_AddStringToObject(json, STORAGE_CAPACITY.c_str(),
|
||||
ProfileUtils::GetAnonyString(std::to_string(storageCapability_)).c_str());
|
||||
cJSON_AddStringToObject(json, OS_SYS_CAPACITY.c_str(),
|
||||
ProfileUtils::GetAnonyString(osSysCap_).c_str());
|
||||
cJSON_AddStringToObject(json, OS_API_LEVEL.c_str(),
|
||||
ProfileUtils::GetAnonyString(std::to_string(osApiLevel_)).c_str());
|
||||
cJSON_AddStringToObject(json, OS_VERSION.c_str(),
|
||||
ProfileUtils::GetAnonyString(osVersion_).c_str());
|
||||
cJSON_AddStringToObject(json, OS_TYPE.c_str(),
|
||||
ProfileUtils::GetAnonyString(std::to_string(osType_)).c_str());
|
||||
char* jsonChars = cJSON_PrintUnformatted(json);
|
||||
if (jsonChars == NULL) {
|
||||
cJSON_Delete(json);
|
||||
HILOGE("cJSON formatted to string failed!");
|
||||
return EMPTY_STRING;
|
||||
}
|
||||
std::string jsonStr = jsonChars;
|
||||
cJSON_Delete(json);
|
||||
free(jsonChars);
|
||||
return jsonStr;
|
||||
}
|
||||
} // namespace DistributedDeviceProfile
|
||||
} // namespace OHOS
|
@ -59,14 +59,16 @@ int32_t SystemInfoCollector::GetOsType()
|
||||
GetParameter(OHOS_FULL_NAME, UNDEFINED_VALUE, osFullName, FULL_NAME_LEN);
|
||||
if (strcmp(apiVersion, UNDEFINED_VALUE) != 0 || strcmp(bootSN, UNDEFINED_VALUE) != 0 ||
|
||||
strcmp(osFullName, UNDEFINED_VALUE) != 0) {
|
||||
HILOGI("apiVersion: %{public}s bootSN: %{public}s osFullName: %{public}s", apiVersion,
|
||||
ProfileUtils::GetAnonyString(std::string(bootSN)).c_str(), osFullName);
|
||||
HILOGI("apiVersion: %{public}s bootSN: %{public}s osFullName: %{public}s",
|
||||
ProfileUtils::GetAnonyString(std::string(apiVersion)).c_str(),
|
||||
ProfileUtils::GetAnonyString(std::string(bootSN)).c_str(),
|
||||
ProfileUtils::GetAnonyString(std::string(osFullName)).c_str());
|
||||
return OH_OS_TYPE;
|
||||
}
|
||||
char versionSDK[VERSION_SDK_LEN + 1] = {0};
|
||||
GetParameter(VERSION_SDK, UNDEFINED_VALUE, versionSDK, VERSION_SDK_LEN);
|
||||
if (strcmp(versionSDK, UNDEFINED_VALUE) != 0) {
|
||||
HILOGI("versionSDK: %{public}s", versionSDK);
|
||||
HILOGI("versionSDK: %{public}s", ProfileUtils::GetAnonyString(std::string(versionSDK)).c_str());
|
||||
return HO_OS_TYPE;
|
||||
}
|
||||
HILOGE("GetOsType fail!");
|
||||
|
@ -91,9 +91,9 @@ int32_t DeviceProfileManager::ReInit()
|
||||
|
||||
int32_t DeviceProfileManager::PutDeviceProfile(const DeviceProfile& deviceProfile)
|
||||
{
|
||||
HILOGI("call! deviceProfile: %{public}s", deviceProfile.dump().c_str());
|
||||
HILOGI("call! deviceProfile: %{public}s", deviceProfile.AnnoymizeDump().c_str());
|
||||
if (!ProfileUtils::IsDevProfileValid(deviceProfile)) {
|
||||
HILOGE("the profile is invalid! deviceProfile: %{public}s", deviceProfile.dump().c_str());
|
||||
HILOGE("the profile is invalid! deviceProfile: %{public}s", deviceProfile.AnnoymizeDump().c_str());
|
||||
return DP_INVALID_PARAMS;
|
||||
}
|
||||
std::map<std::string, std::string> entries;
|
||||
@ -109,7 +109,7 @@ int32_t DeviceProfileManager::PutDeviceProfile(const DeviceProfile& deviceProfil
|
||||
return DP_KV_DB_PTR_NULL;
|
||||
}
|
||||
if (deviceProfileStore_->PutBatch(entries) != DP_SUCCESS) {
|
||||
HILOGE("PutDeviceProfile fail! deviceProfile: %{public}s", deviceProfile.dump().c_str());
|
||||
HILOGE("PutDeviceProfile fail! deviceProfile: %{public}s", deviceProfile.AnnoymizeDump().c_str());
|
||||
return DP_PUT_KV_DB_FAIL;
|
||||
}
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ int32_t SubscribeProfileManager::NotifyDeviceProfileAdd(const std::string& dbKey
|
||||
DeviceProfile deviceProfile;
|
||||
deviceProfile.SetDeviceId(ProfileUtils::GetDeviceIdByDBKey(dbKey));
|
||||
ProfileUtils::EntriesToDeviceProfile(values, deviceProfile);
|
||||
HILOGI("NotifyDeviceProfileAdd : %{public}s!", deviceProfile.dump().c_str());
|
||||
HILOGI("NotifyDeviceProfileAdd : %{public}s!", deviceProfile.AnnoymizeDump().c_str());
|
||||
auto subscriberInfos = GetSubscribeInfos(dbKey);
|
||||
for (const auto& subscriberInfo : subscriberInfos) {
|
||||
sptr<IProfileChangeListener> listenerProxy = iface_cast<IProfileChangeListener>(subscriberInfo.GetListener());
|
||||
@ -201,7 +201,7 @@ int32_t SubscribeProfileManager::NotifyDeviceProfileUpdate(const std::string& db
|
||||
DeviceProfile newDeviceProfile;
|
||||
newDeviceProfile.SetDeviceId(ProfileUtils::GetDeviceIdByDBKey(dbKey));
|
||||
ProfileUtils::EntriesToDeviceProfile(values, newDeviceProfile);
|
||||
HILOGI("NotifyDeviceProfileUpdate : %{public}s!", newDeviceProfile.dump().c_str());
|
||||
HILOGI("NotifyDeviceProfileUpdate : %{public}s!", newDeviceProfile.AnnoymizeDump().c_str());
|
||||
DeviceProfile oldDeviceProfile;
|
||||
ProfileCache::GetInstance().GetDeviceProfile(ProfileUtils::GetDeviceIdByDBKey(dbKey), oldDeviceProfile);
|
||||
auto subscriberInfos = GetSubscribeInfos(dbKey);
|
||||
@ -225,7 +225,7 @@ int32_t SubscribeProfileManager::NotifyDeviceProfileDelete(const std::string& db
|
||||
DeviceProfile deviceProfile;
|
||||
deviceProfile.SetDeviceId(ProfileUtils::GetDeviceIdByDBKey(dbKey));
|
||||
ProfileUtils::EntriesToDeviceProfile(values, deviceProfile);
|
||||
HILOGI("NotifyDeviceProfileDelete : %{public}s!", deviceProfile.dump().c_str());
|
||||
HILOGI("NotifyDeviceProfileDelete : %{public}s!", deviceProfile.AnnoymizeDump().c_str());
|
||||
auto subscriberInfos = GetSubscribeInfos(dbKey);
|
||||
for (const auto& subscriberInfo : subscriberInfos) {
|
||||
sptr<IProfileChangeListener> listenerProxy = iface_cast<IProfileChangeListener>(subscriberInfo.GetListener());
|
||||
|
@ -31,7 +31,7 @@ namespace {
|
||||
}
|
||||
int32_t ProfileControlUtils::PutDeviceProfile(std::shared_ptr<IKVAdapter> kvStore, const DeviceProfile& deviceProfile)
|
||||
{
|
||||
HILOGI("PutDeviceProfile : %{public}s!", deviceProfile.dump().c_str());
|
||||
HILOGI("PutDeviceProfile : %{public}s!", deviceProfile.AnnoymizeDump().c_str());
|
||||
if (kvStore == nullptr) {
|
||||
HILOGE("kvStore is nullptr!");
|
||||
return DP_INVALID_PARAMS;
|
||||
@ -236,7 +236,7 @@ int32_t ProfileControlUtils::GetDeviceProfile(std::shared_ptr<IKVAdapter> kvStor
|
||||
return DP_GET_KV_DB_FAIL;
|
||||
}
|
||||
ProfileUtils::EntriesToDeviceProfile(values, deviceProfile);
|
||||
HILOGI("GetDeviceProfile in db : %{public}s!", deviceProfile.dump().c_str());
|
||||
HILOGI("GetDeviceProfile in db : %{public}s!", deviceProfile.AnnoymizeDump().c_str());
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user