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

!965 fix:osfullname 适配问题 挑单OpenHarmony-3.2-Beta2

Merge pull request !965 from Mupceet/cherry-pick-1658471318
......@@ -33,8 +33,6 @@
#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)) {
......@@ -73,11 +71,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 g_emptyStr);
BEGET_CHECK(res != NULL, return NULL);
ret = SystemGetParameter(key, res, &len);
if (ret != 0) {
free(res);
return g_emptyStr;
return NULL;
}
*paramHolder = res;
}
......
......@@ -241,17 +241,24 @@ 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)) {
int length = sprintf_s(value, OS_FULL_NAME_LEN, "%s(%s)", fillname, releaseType);
const char *fullName = GetFullName_();
if (fullName == NULL || releaseType == NULL) {
return NULL;
}
if (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)", fullName, releaseType);
if (length < 0) {
return EMPTY_STR;
free(value);
return NULL;
}
return value;
}
const char *osFullName = strdup(value);
return osFullName;
return strdup(fullName);
}
const char *GetOSFullName(void)
......@@ -270,13 +277,16 @@ 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 EMPTY_STR;
return NULL;
}
const char *versionId = strdup(value);
return versionId;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册