From 4a5346e5043aa4b98449a9da2fee1ce381147357 Mon Sep 17 00:00:00 2001 From: chengjinsong2 Date: Wed, 12 Oct 2022 00:25:49 -0700 Subject: [PATCH] =?UTF-8?q?udid=E9=9C=80=E8=A6=81=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=A2=84=E8=AE=BE=E7=9A=84const.product.udid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chengjinsong2 --- interfaces/innerkits/syspara/param_comm.c | 31 +++++------------------ services/etc/param/ohos.para.dac | 1 + 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/interfaces/innerkits/syspara/param_comm.c b/interfaces/innerkits/syspara/param_comm.c index 47748317..fa9d7962 100644 --- a/interfaces/innerkits/syspara/param_comm.c +++ b/interfaces/innerkits/syspara/param_comm.c @@ -26,9 +26,8 @@ #include "sysparam_errno.h" #ifdef USE_MBEDTLS #include "mbedtls/sha256.h" -#elif !(defined OHOS_LITE) -#include "openssl/sha.h" #endif + #include "securec.h" #include "beget_ext.h" @@ -152,27 +151,6 @@ static int GetSha256Value(const char *input, char *udid, int udidSize) } return EC_SUCCESS; } -#elif !(defined OHOS_LITE) -static int GetSha256Value(const char *input, char *udid, int udidSize) -{ - char buf[DEV_BUF_LENGTH] = { 0 }; - unsigned char hash[SHA256_DIGEST_LENGTH] = { 0 }; - SHA256_CTX sha256; - if ((SHA256_Init(&sha256) == 0) || (SHA256_Update(&sha256, input, strlen(input)) == 0) || - (SHA256_Final(hash, &sha256) == 0)) { - return -1; - } - - for (size_t i = 0; i < SHA256_DIGEST_LENGTH; i++) { - unsigned char value = hash[i]; - (void)memset_s(buf, DEV_BUF_LENGTH, 0, DEV_BUF_LENGTH); - int len = sprintf_s(buf, sizeof(buf), "%02X", value); - if (len > 0 && strcat_s(udid, udidSize, buf) != 0) { - return -1; - } - } - return 0; -} #else static int GetSha256Value(const char *input, char *udid, int udidSize) { @@ -204,6 +182,11 @@ INIT_LOCAL_API int GetDevUdid_(char *udid, int size) if (size < UDID_LEN || udid == NULL) { return EC_FAILURE; } + + uint32_t len = size; + int ret = SystemGetParameter("const.product.udid", udid, &len); + BEGET_CHECK(ret != 0, return ret); + const char *manufacture = GetManufacture_(); const char *model = GetProductModel_(); const char *sn = GetSerial_(); @@ -224,7 +207,7 @@ INIT_LOCAL_API int GetDevUdid_(char *udid, int size) return -1; } - int ret = GetSha256Value(tmp, udid, size); + ret = GetSha256Value(tmp, udid, size); free(tmp); return ret; } diff --git a/services/etc/param/ohos.para.dac b/services/etc/param/ohos.para.dac index 34b58bbf..fb3df124 100755 --- a/services/etc/param/ohos.para.dac +++ b/services/etc/param/ohos.para.dac @@ -32,6 +32,7 @@ persist.appspawn. = root:root:0775 #udid and sn, only read ohos.boot.sn = root:deviceprivate:0750 +const.product.udid = root:deviceprivate:0750 const.actionable_compatible_property.enabled = root:root:0777 const.postinstall.fstab.prefix = root:root:0777 -- GitLab