提交 c4676cdd 编写于 作者: L laiguizhong

osfullname 适配问题修复

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