syspara.cpp 3.7 KB
Newer Older
M
Mupceet 已提交
1
/*
M
Mupceet 已提交
2
 * Copyright (c) 2022 Huawei Device Co., Ltd.
M
Mupceet 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
 * 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 <cstdlib>
#include <cstdint>

#include "begetctl.h"
#include "shell.h"
#include "shell_utils.h"
#include "parameter.h"
#include "parameters.h"
#include "sysversion.h"

using SysParaInfoItem = struct {
    char *infoName;
    const char *(*getInfoValue)(void);
};

static const SysParaInfoItem SYSPARA_LIST[] = {
    {(char *)"DeviceType", GetDeviceType},
    {(char *)"Manufacture", GetManufacture},
    {(char *)"Brand", GetBrand},
    {(char *)"MarketName", GetMarketName},
    {(char *)"ProductSeries", GetProductSeries},
    {(char *)"ProductModel", GetProductModel},
    {(char *)"SoftwareModel", GetSoftwareModel},
    {(char *)"HardwareModel", GetHardwareModel},
    {(char *)"Serial", GetSerial},
    {(char *)"OSFullName", GetOSFullName},
    {(char *)"DisplayVersion", GetDisplayVersion},
    {(char *)"BootloaderVersion", GetBootloaderVersion},
    {(char *)"GetSecurityPatchTag", GetSecurityPatchTag},
    {(char *)"AbiList", GetAbiList},
    {(char *)"IncrementalVersion", GetIncrementalVersion},
    {(char *)"VersionId", GetVersionId},
    {(char *)"BuildType", GetBuildType},
    {(char *)"BuildUser", GetBuildUser},
    {(char *)"BuildHost", GetBuildHost},
    {(char *)"BuildTime", GetBuildTime},
    {(char *)"BuildRootHash", GetBuildRootHash},
    {(char *)"GetOsReleaseType", GetOsReleaseType},
    {(char *)"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, (char *)"Begin dump syspara\r\n");
    BShellEnvOutput(shell, (char *)"=======================\r\n");
    while (index < dumpInfoItemNum) {
        temp = SYSPARA_LIST[index].getInfoValue();
        BShellEnvOutput(shell, (char *)"%s:%s\r\n", SYSPARA_LIST[index].infoName, temp);
        index++;
    }
    BShellEnvOutput(shell, (char *)"FirstApiVersion:%d\r\n", GetFirstApiVersion());
    BShellEnvOutput(shell, (char *)"GetSerial:%s\r\n", GetSerial());
#ifndef OHOS_LITE
    BShellEnvOutput(shell, (char *)"acl serial:%s\r\n", AclGetSerial());
#endif
    char udid[65] = {0};
    GetDevUdid(udid, sizeof(udid));
    BShellEnvOutput(shell, (char *)"GetDevUdid:%s\r\n", udid);
#ifndef OHOS_LITE
    AclGetDevUdid(udid, sizeof(udid));
    BShellEnvOutput(shell, (char *)"Acl devUdid:%s\r\n", udid);
#endif
    BShellEnvOutput(shell, (char *)"Version:%d.%d.%d.%d\r\n",
        GetMajorVersion(), GetSeniorVersion(), GetFeatureVersion(), GetBuildVersion());
    BShellEnvOutput(shell, (char *)"GetSdkApiVersion:%d\r\n", GetSdkApiVersion());
    BShellEnvOutput(shell, (char *)"GetSystemCommitId:%lld\r\n", GetSystemCommitId());
    BShellEnvOutput(shell, (char *)"=======================\r\n");
    BShellEnvOutput(shell, (char *)"End dump syspara\r\n");
    return 0;
}

MODULE_CONSTRUCTOR(void)
{
M
Mupceet 已提交
92
    const CmdInfo infos[] = {
M
Mupceet 已提交
93 94 95 96 97 98
        {(char *)"dump", SysParaApiDumpCmd, (char *)"dump api", (char *)"dump api", (char *)"dump api"},
    };
    for (size_t i = 0; i < sizeof(infos) / sizeof(infos[0]); i++) {
        BShellEnvRegitsterCmd(GetShellHandle(), &infos[i]);
    }
}