• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 <cstdlib>
17 #include <cstdint>
18 
19 #include "begetctl.h"
20 #include "shell.h"
21 #include "shell_utils.h"
22 #include "parameter.h"
23 #include "parameters.h"
24 #include "sysversion.h"
25 
26 using SysParaInfoItem = struct {
27     const char *infoName;
28     const char *(*getInfoValue)(void);
29 };
30 
31 static const SysParaInfoItem SYSPARA_LIST[] = {
32     {"DeviceType", GetDeviceType},
33     {"Manufacture", GetManufacture},
34     {"Brand", GetBrand},
35     {"MarketName", GetMarketName},
36     {"ProductSeries", GetProductSeries},
37     {"ProductModel", GetProductModel},
38     {"ProductModelAlias", GetProductModel},
39     {"SoftwareModel", GetSoftwareModel},
40     {"HardwareModel", GetHardwareModel},
41     {"Serial", GetSerial},
42     {"OSFullName", GetOSFullName},
43     {"DisplayVersion", GetDisplayVersion},
44     {"BootloaderVersion", GetBootloaderVersion},
45     {"GetSecurityPatchTag", GetSecurityPatchTag},
46     {"AbiList", GetAbiList},
47     {"IncrementalVersion", GetIncrementalVersion},
48     {"VersionId", GetVersionId},
49     {"BuildType", GetBuildType},
50     {"BuildUser", GetBuildUser},
51     {"BuildHost", GetBuildHost},
52     {"BuildTime", GetBuildTime},
53     {"BuildRootHash", GetBuildRootHash},
54     {"GetOsReleaseType", GetOsReleaseType},
55     {"GetHardwareProfile", GetHardwareProfile},
56 };
57 
SysParaApiDumpCmd(BShellHandle shell,int32_t argc,char * argv[])58 static int32_t SysParaApiDumpCmd(BShellHandle shell, int32_t argc, char *argv[])
59 {
60     int index = 0;
61     int dumpInfoItemNum = (sizeof(SYSPARA_LIST) / sizeof(SYSPARA_LIST[0]));
62     const char *temp = nullptr;
63     BShellEnvOutput(shell, const_cast<char *>("Begin dump syspara\r\n"));
64     BShellEnvOutput(shell, const_cast<char *>("=======================\r\n"));
65     while (index < dumpInfoItemNum) {
66         temp = SYSPARA_LIST[index].getInfoValue();
67         BShellEnvOutput(shell, const_cast<char *>("%s:%s\r\n"), SYSPARA_LIST[index].infoName, temp);
68         index++;
69     }
70     BShellEnvOutput(shell, const_cast<char *>("FirstApiVersion:%d\r\n"), GetFirstApiVersion());
71     BShellEnvOutput(shell, const_cast<char *>("GetSerial:%s\r\n"), GetSerial());
72 #ifndef OHOS_LITE
73     BShellEnvOutput(shell, const_cast<char *>("acl serial:%s\r\n"), AclGetSerial());
74 #endif
75     char udid[65] = {0};
76     GetDevUdid(udid, sizeof(udid));
77     BShellEnvOutput(shell, const_cast<char *>("GetDevUdid:%s\r\n"), udid);
78 #ifndef OHOS_LITE
79     AclGetDevUdid(udid, sizeof(udid));
80     BShellEnvOutput(shell, const_cast<char *>("Acl devUdid:%s\r\n"), udid);
81 #endif
82     BShellEnvOutput(shell, const_cast<char *>("Version:%d.%d.%d.%d\r\n"),
83         GetMajorVersion(), GetSeniorVersion(), GetFeatureVersion(), GetBuildVersion());
84     BShellEnvOutput(shell, const_cast<char *>("GetSdkApiVersion:%d\r\n"), GetSdkApiVersion());
85     BShellEnvOutput(shell, const_cast<char *>("GetSystemCommitId:%lld\r\n"), GetSystemCommitId());
86     BShellEnvOutput(shell, const_cast<char *>("=======================\r\n"));
87     BShellEnvOutput(shell, const_cast<char *>("End dump syspara\r\n"));
88     return 0;
89 }
90 
MODULE_CONSTRUCTOR(void)91 MODULE_CONSTRUCTOR(void)
92 {
93     const CmdInfo infos[] = {
94         {
95             const_cast<char *>("dump"), SysParaApiDumpCmd, const_cast<char *>("dump api"),
96             const_cast<char *>("dump api"), const_cast<char *>("dump api")
97         },
98     };
99     for (size_t i = 0; i < sizeof(infos) / sizeof(infos[0]); i++) {
100         BShellEnvRegisterCmd(GetShellHandle(), &infos[i]);
101     }
102 }
103