• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "dump_syspara.h"
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include "securec.h"
20 #include "parameter.h"
21 #if defined(__LITEOS_RISCV__)
22 #include "wifiiot_at.h"
23 #endif
24 
25 #define API_VERSION_LEN 10
26 
GetSdkApiLevel()27 static const char* GetSdkApiLevel()
28 {
29     static char sdkApiVersion[API_VERSION_LEN] = {0};
30     int sdkApi = GetSdkApiVersion();
31     sprintf_s(sdkApiVersion, API_VERSION_LEN, "%d", sdkApi);
32     return (const char*)sdkApiVersion;
33 }
34 
GetFirstApiLevel()35 static const char* GetFirstApiLevel()
36 {
37     static char firstApiVersion[API_VERSION_LEN] = {0};
38     int firstApi = GetFirstApiVersion();
39     sprintf_s(firstApiVersion, API_VERSION_LEN, "%d", firstApi);
40     return (const char*)firstApiVersion;
41 }
42 
43 static const SysParaInfoItem SYSPARA_LIST[] = {
44     {"DeviceType", GetDeviceType},
45     {"Manufacture", GetManufacture},
46     {"Brand", GetBrand},
47     {"MarketName", GetMarketName},
48     {"ProductSeries", GetProductSeries},
49     {"ProductModel", GetProductModel},
50     {"SoftwareModel", GetSoftwareModel},
51     {"HardwareModel", GetHardwareModel},
52     {"Serial", GetSerial},
53     {"OSFullName", GetOSFullName},
54     {"DisplayVersion", GetDisplayVersion},
55     {"BootloaderVersion", GetBootloaderVersion},
56     {"GetSecurityPatchTag", GetSecurityPatchTag},
57     {"AbiList", GetAbiList},
58     {"SdkApiVersion", GetSdkApiLevel},
59     {"FirstApiVersion", GetFirstApiLevel},
60     {"IncrementalVersion", GetIncrementalVersion},
61     {"VersionId", GetVersionId},
62     {"BuildType", GetBuildType},
63     {"BuildUser", GetBuildUser},
64     {"BuildHost", GetBuildHost},
65     {"BuildTime", GetBuildTime},
66     {"BuildRootHash", GetBuildRootHash},
67 };
68 
QuerySysparaCmd()69 int QuerySysparaCmd()
70 {
71     int index = 0;
72     int dumpInfoItemNum = (sizeof(SYSPARA_LIST) / sizeof(SysParaInfoItem));
73     const char *temp = NULL;
74     int (*pfnPrintf)(const char *format, ...) = NULL;
75 #if defined(__LITEOS_RISCV__)
76     pfnPrintf = &AtPrintf;
77 #else
78     pfnPrintf = &printf;
79 #endif
80 
81     pfnPrintf("Begin dump syspara\r\n");
82     pfnPrintf("=======================\r\n");
83     while (index < dumpInfoItemNum) {
84         temp = SYSPARA_LIST[index].getInfoValue();
85         pfnPrintf("%s:%s\r\n", SYSPARA_LIST[index].infoName, temp);
86         index++;
87     }
88     pfnPrintf("=======================\r\n");
89     pfnPrintf("End dump syspara\r\n");
90     pfnPrintf = NULL;
91     return 0;
92 }
93