/* * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include "begetctl.h" #include "shell.h" #include "shell_utils.h" #include "parameter.h" #include "parameters.h" #include "sysversion.h" using SysParaInfoItem = struct { const char *infoName; const char *(*getInfoValue)(void); }; static const SysParaInfoItem SYSPARA_LIST[] = { {"DeviceType", GetDeviceType}, {"Manufacture", GetManufacture}, {"Brand", GetBrand}, {"MarketName", GetMarketName}, {"ProductSeries", GetProductSeries}, {"ProductModel", GetProductModel}, {"ProductModelAlias", GetProductModel}, {"SoftwareModel", GetSoftwareModel}, {"HardwareModel", GetHardwareModel}, {"Serial", GetSerial}, {"OSFullName", GetOSFullName}, {"DisplayVersion", GetDisplayVersion}, {"BootloaderVersion", GetBootloaderVersion}, {"GetSecurityPatchTag", GetSecurityPatchTag}, {"AbiList", GetAbiList}, {"IncrementalVersion", GetIncrementalVersion}, {"VersionId", GetVersionId}, {"BuildType", GetBuildType}, {"BuildUser", GetBuildUser}, {"BuildHost", GetBuildHost}, {"BuildTime", GetBuildTime}, {"BuildRootHash", GetBuildRootHash}, {"GetOsReleaseType", GetOsReleaseType}, {"GetHardwareProfile", GetHardwareProfile}, }; static int32_t SysParaApiDumpCmd(BShellHandle shell, int32_t argc, char *argv[]) { int index = 0; int dumpInfoItemNum = (sizeof(SYSPARA_LIST) / sizeof(SYSPARA_LIST[0])); const char *temp = nullptr; BShellEnvOutput(shell, const_cast("Begin dump syspara\r\n")); BShellEnvOutput(shell, const_cast("=======================\r\n")); while (index < dumpInfoItemNum) { temp = SYSPARA_LIST[index].getInfoValue(); BShellEnvOutput(shell, const_cast("%s:%s\r\n"), SYSPARA_LIST[index].infoName, temp); index++; } BShellEnvOutput(shell, const_cast("FirstApiVersion:%d\r\n"), GetFirstApiVersion()); BShellEnvOutput(shell, const_cast("GetSerial:%s\r\n"), GetSerial()); #ifndef OHOS_LITE BShellEnvOutput(shell, const_cast("acl serial:%s\r\n"), AclGetSerial()); #endif char udid[65] = {0}; GetDevUdid(udid, sizeof(udid)); BShellEnvOutput(shell, const_cast("GetDevUdid:%s\r\n"), udid); #ifndef OHOS_LITE AclGetDevUdid(udid, sizeof(udid)); BShellEnvOutput(shell, const_cast("Acl devUdid:%s\r\n"), udid); #endif BShellEnvOutput(shell, const_cast("Version:%d.%d.%d.%d\r\n"), GetMajorVersion(), GetSeniorVersion(), GetFeatureVersion(), GetBuildVersion()); BShellEnvOutput(shell, const_cast("GetSdkApiVersion:%d\r\n"), GetSdkApiVersion()); BShellEnvOutput(shell, const_cast("GetSystemCommitId:%lld\r\n"), GetSystemCommitId()); BShellEnvOutput(shell, const_cast("=======================\r\n")); BShellEnvOutput(shell, const_cast("End dump syspara\r\n")); return 0; } MODULE_CONSTRUCTOR(void) { const CmdInfo infos[] = { { const_cast("dump"), SysParaApiDumpCmd, const_cast("dump api"), const_cast("dump api"), const_cast("dump api") }, }; for (size_t i = 0; i < sizeof(infos) / sizeof(infos[0]); i++) { BShellEnvRegisterCmd(GetShellHandle(), &infos[i]); } }