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