未验证 提交 37b2b9f5 编写于 作者: O openharmony_ci 提交者: Gitee

回退 'Pull Request !945 : fix:osfullname 适配问题'

上级 b3895ca4
......@@ -33,6 +33,8 @@
#include "securec.h"
#include "beget_ext.h"
static const char *g_emptyStr = "";
INIT_LOCAL_API int IsValidParamValue(const char *value, uint32_t len)
{
if ((value == NULL) || (strlen(value) + 1 > len)) {
......@@ -71,11 +73,11 @@ INIT_LOCAL_API const char *GetProperty(const char *key, const char **paramHolder
int ret = SystemGetParameter(key, NULL, &len);
if (ret == 0 && len > 0) {
char *res = (char *)malloc(len + 1);
BEGET_CHECK(res != NULL, return NULL);
BEGET_CHECK(res != NULL, return g_emptyStr);
ret = SystemGetParameter(key, res, &len);
if (ret != 0) {
free(res);
return NULL;
return g_emptyStr;
}
*paramHolder = res;
}
......
......@@ -241,20 +241,17 @@ int GetDevUdid(char *udid, int size)
static const char *BuildOSFullName(void)
{
const char release[] = "Release";
char value[OS_FULL_NAME_LEN] = {0};
const char *releaseType = GetOsReleaseType();
const char *fillname = GetFullName_();
if ((releaseType != NULL) && (strncmp(releaseType, release, sizeof(release) - 1) != 0)) {
char *value = calloc(1, OS_FULL_NAME_LEN);
if (value == NULL) {
return NULL;
}
int length = sprintf_s(value, OS_FULL_NAME_LEN, "%s(%s)", fillname, releaseType);
if (length < 0) {
return NULL;
return EMPTY_STR;
}
return value;
}
return strdup(fillname);
const char *osFullName = strdup(value);
return osFullName;
}
const char *GetOSFullName(void)
......@@ -273,16 +270,13 @@ const char *GetOSFullName(void)
static const char *BuildVersionId(void)
{
char value[VERSION_ID_MAX_LEN] = {0};
if (GetDeviceType() == NULL) {
return NULL;
}
int len = sprintf_s(value, VERSION_ID_MAX_LEN, "%s/%s/%s/%s/%s/%s/%s/%s/%s/%s",
GetDeviceType(), GetManufacture(), GetBrand(), GetProductSeries(),
GetOSFullName(), GetProductModel(), GetSoftwareModel(),
GetSdkApiVersion_(), GetIncrementalVersion(), GetBuildType());
if (len <= 0) {
return NULL;
return EMPTY_STR;
}
const char *versionId = strdup(value);
return versionId;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册