提交 4a5346e5 编写于 作者: C chengjinsong2

udid需要支持预设的const.product.udid

Signed-off-by: Nchengjinsong2 <chengjinsong2@huawei.com>
上级 2fa83a50
...@@ -26,9 +26,8 @@ ...@@ -26,9 +26,8 @@
#include "sysparam_errno.h" #include "sysparam_errno.h"
#ifdef USE_MBEDTLS #ifdef USE_MBEDTLS
#include "mbedtls/sha256.h" #include "mbedtls/sha256.h"
#elif !(defined OHOS_LITE)
#include "openssl/sha.h"
#endif #endif
#include "securec.h" #include "securec.h"
#include "beget_ext.h" #include "beget_ext.h"
...@@ -152,27 +151,6 @@ static int GetSha256Value(const char *input, char *udid, int udidSize) ...@@ -152,27 +151,6 @@ static int GetSha256Value(const char *input, char *udid, int udidSize)
} }
return EC_SUCCESS; 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 #else
static int GetSha256Value(const char *input, char *udid, int udidSize) static int GetSha256Value(const char *input, char *udid, int udidSize)
{ {
...@@ -204,6 +182,11 @@ INIT_LOCAL_API int GetDevUdid_(char *udid, int size) ...@@ -204,6 +182,11 @@ INIT_LOCAL_API int GetDevUdid_(char *udid, int size)
if (size < UDID_LEN || udid == NULL) { if (size < UDID_LEN || udid == NULL) {
return EC_FAILURE; 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 *manufacture = GetManufacture_();
const char *model = GetProductModel_(); const char *model = GetProductModel_();
const char *sn = GetSerial_(); const char *sn = GetSerial_();
...@@ -224,7 +207,7 @@ INIT_LOCAL_API int GetDevUdid_(char *udid, int size) ...@@ -224,7 +207,7 @@ INIT_LOCAL_API int GetDevUdid_(char *udid, int size)
return -1; return -1;
} }
int ret = GetSha256Value(tmp, udid, size); ret = GetSha256Value(tmp, udid, size);
free(tmp); free(tmp);
return ret; return ret;
} }
......
...@@ -32,6 +32,7 @@ persist.appspawn. = root:root:0775 ...@@ -32,6 +32,7 @@ persist.appspawn. = root:root:0775
#udid and sn, only read #udid and sn, only read
ohos.boot.sn = root:deviceprivate:0750 ohos.boot.sn = root:deviceprivate:0750
const.product.udid = root:deviceprivate:0750
const.actionable_compatible_property.enabled = root:root:0777 const.actionable_compatible_property.enabled = root:root:0777
const.postinstall.fstab.prefix = root:root:0777 const.postinstall.fstab.prefix = root:root:0777
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册