!556 更改Query

Merge pull request !556 from zhangyun/local_2024_11
This commit is contained in:
openharmony_ci 2024-11-22 06:02:43 +00:00 committed by Gitee
commit b860deb095
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -13,8 +13,12 @@
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <fstream>
#include <utility>
#include "parameter.h"
#include "devattest_interface.h"
@ -22,196 +26,156 @@
const int DEVATTEST_SUESS = 0;
const int UDIDSIZE_LEN = 64;
void ObtainProductParms()
{
int sdkApiVersion = GetSdkApiVersion();
if (sdkApiVersion != 0) {
printf("SdkApiVersion = %d\n", sdkApiVersion);
} else {
printf("SdkApiVersion = 0\n");
using namespace std;
template<typename KeyType, typename ValueType>
void writeTexToFile(const std::string& filename, const std::string& text1, const std::vector<std::pair<KeyType, ValueType>>& kvPairs, const std::string& text2) {
std::ofstream outFile(filename, std::ios::out | std::ios::trunc); // 使用std::ios::trunc以清空文件内容
if (!outFile.is_open()) {
std::cerr << "无法打开或创建文件: " << filename << std::endl;
return;
}
int firstApiVersion = GetFirstApiVersion();
if (firstApiVersion != 0) {
printf("firstApiVersion = %d\n", firstApiVersion);
} else {
printf("firstApiVersion = 0\n");
}
const char *bootloaderVersion = GetBootloaderVersion();
if (bootloaderVersion != nullptr) {
printf("bootloaderVersion = %s\n", bootloaderVersion);
} else {
printf("bootloaderVersion = nullptr\n");
}
const char *incrementalVersion = GetIncrementalVersion();
if (incrementalVersion != nullptr) {
printf("incrementalVersion = %s\n", incrementalVersion);
} else {
printf("incrementalVersion = nullptr\n");
}
const char *buildType = GetBuildType();
if (buildType != nullptr) {
printf("buildType = %s\n", buildType);
} else {
printf("buildType = nullptr\n");
}
const char *buildUser = GetBuildUser();
if (buildUser != nullptr) {
printf("buildUser = %s\n", buildUser);
} else {
printf("buildUser = nullptr\n");
}
const char *buildHost = GetBuildHost();
if (buildHost != nullptr) {
printf("buildHost = %s\n", buildHost);
} else {
printf("buildHost = nullptr\n");
}
const char *buildTime = GetBuildTime();
if (buildTime != nullptr) {
printf("buildTime = %s\n", buildTime);
} else {
printf("buildTime = nullptr\n");
}
const char *abiList = GetAbiList();
if (abiList != nullptr) {
printf("AbiList = %s\n", abiList);
} else {
printf("AbiList = nullptr\n");
outFile << text1 << std::endl;
for (const auto& pair : kvPairs) {
outFile << pair.first << " = " << pair.second << std::endl;
}
outFile << text2 << std::endl;
}
int main()
void intToConstCharPtrSafe(int num, char* buffer, size_t bufferSize) {
std::snprintf(buffer, bufferSize, "%d", num);
}
void ObtainProductParms(void)
{
printf("******To Obtain Product Params Start******\n");
std::vector<std::pair<const char*, const char*>> myVector;
char buffer1[50];
char buffer2[50];
char buffer3[50];
char buffer4[50];
const char *productType = GetDeviceType();
if (productType != nullptr) {
printf("Device Type = %s\n", productType);
} else {
printf("Device Type = nullptr\n");
}
printf("Device Type = %s\n", productType);
myVector.emplace_back("Device Type", productType);
const char *securityPatchTag = GetSecurityPatchTag();
if (securityPatchTag != nullptr) {
printf("Security Patch = %s\n", securityPatchTag);
} else {
printf("Security Patch = nullptr\n");
}
printf("Security Patch = %s\n", securityPatchTag);
myVector.emplace_back("Security Patch", securityPatchTag);
const char *osName = GetOSFullName();
if (osName != nullptr) {
printf("OsFullName = %s\n", osName);
} else {
printf("OsFullName = nullptr\n");
}
printf("OsFullName = %s\n", osName);
myVector.emplace_back("OsFullName", osName);
const char *displayVersion = GetDisplayVersion();
if (displayVersion != nullptr) {
printf("DisplayVersion = %s\n", displayVersion);
} else {
printf("DisplayVersion = nullptr\n");
}
printf("DisplayVersion = %s\n", displayVersion);
myVector.emplace_back("DisplayVersion", displayVersion);
const char *versionId = GetVersionId();
if (versionId != nullptr) {
printf("VersionID = %s\n", versionId);
} else {
printf("VersionID = nullptr\n");
}
printf("VersionID = %s\n", versionId);
myVector.emplace_back("VersionID", versionId);
AttestResultInfo attestResultInfo = {0};
attestResultInfo.ticket = NULL;
int32_t retStatus = GetAttestStatus(&attestResultInfo);
if (retStatus != DEVATTEST_SUESS) {
printf("[CLIENT MAIN] wrong. retStatus:%d\n", retStatus);
printf("authResult = %d\n", attestResultInfo.authResult);
printf("softwareResult = %d\n", attestResultInfo.softwareResult);
} else {
printf("authResult = %d\n", attestResultInfo.authResult);
printf("softwareResult = %d\n", attestResultInfo.softwareResult);
}
printf("authResult = %d\n", attestResultInfo.authResult);
printf("softwareResult = %d\n", attestResultInfo.softwareResult);
intToConstCharPtrSafe(attestResultInfo.authResult, buffer1, sizeof(buffer1));
const char* authResult1 = buffer1;
intToConstCharPtrSafe(attestResultInfo.softwareResult, buffer2, sizeof(buffer2));
const char* softwareResult1 = buffer2;
myVector.emplace_back("authResult", authResult1);
myVector.emplace_back("softwareResult", softwareResult1);
char udid[UDIDSIZE_LEN + 1] = {0};
int retUdid = GetDevUdid(udid, UDIDSIZE_LEN + 1);
if (retUdid == 0) {
printf("DevUdid = %s\n", udid);
} else {
printf("DevUdid = nullptr\n");
}
printf("DevUdid = %s\n", udid);
myVector.emplace_back("DevUdid", udid);
const char *manuFacture = GetManufacture();
if (manuFacture != nullptr) {
printf("manuFacture = %s\n", manuFacture);
} else {
printf("manuFacture = nullptr\n");
}
printf("manuFacture = %s\n", manuFacture);
myVector.emplace_back("manuFacture", manuFacture);
const char *productModel = GetProductModel();
if (productModel != nullptr) {
printf("productModel = %s\n", productModel);
} else {
printf("productModel = nullptr\n");
}
printf("productModel = %s\n", productModel);
myVector.emplace_back("productModel", productModel);
const char *serial = GetSerial();
if (serial != nullptr) {
printf("serial = %s\n", serial);
} else {
printf("serial = nullptr\n");
}
printf("serial = %s\n", serial);
myVector.emplace_back("serial", serial);
const char *brand = GetBrand();
if (brand != nullptr) {
printf("brand = %s\n", brand);
} else {
printf("brand = nullptr\n");
}
printf("brand = %s\n", brand);
myVector.emplace_back("brand", brand);
const char *productSeries = GetProductSeries();
if (productSeries != nullptr) {
printf("productSeries = %s\n", productSeries);
} else {
printf("productSeries = nullptr\n");
}
printf("productSeries = %s\n", productSeries);
myVector.emplace_back("productSeries", productSeries);
const char *softwareModel = GetSoftwareModel();
if (softwareModel != nullptr) {
printf("softwareModel = %s\n", softwareModel);
} else {
printf("softwareModel = nullptr\n");
}
printf("softwareModel = %s\n", softwareModel);
myVector.emplace_back("softwareModel", softwareModel);
const char *hardWareModel = GetHardwareModel();
if (hardWareModel != nullptr) {
printf("HardwareModel = %s\n", hardWareModel);
} else {
printf("HardwareModel = nullptr\n");
}
printf("HardwareModel = %s\n", hardWareModel);
myVector.emplace_back("HardwareModel", hardWareModel);
const char *buildRootHash = GetBuildRootHash();
if (buildRootHash != nullptr) {
printf("BuildRootHash = %s\n", buildRootHash);
} else {
printf("BuildRootHash = nullptr\n");
}
printf("BuildRootHash = %s\n", buildRootHash);
myVector.emplace_back("BuildRootHash", buildRootHash);
const char *marketName = GetMarketName();
if (marketName != nullptr) {
printf("marketName = %s\n", marketName);
} else {
printf("marketName = nullptr\n");
}
printf("marketName = %s\n", marketName);
myVector.emplace_back("marketName", marketName);
ObtainProductParms();
int sdkApiVersion = GetSdkApiVersion();
printf("SdkApiVersion = %d\n", sdkApiVersion);
intToConstCharPtrSafe(sdkApiVersion, buffer4, sizeof(buffer4));
const char* sdkApiVersion1 = buffer4;
myVector.emplace_back("SdkApiVersion", sdkApiVersion1);
int firstApiVersion = GetFirstApiVersion();
printf("firstApiVersion = %d\n", firstApiVersion);
intToConstCharPtrSafe(firstApiVersion, buffer3, sizeof(buffer3));
const char* firstApiVersion1 = buffer3;
myVector.emplace_back("firstApiVersion", firstApiVersion1);
const char *bootloaderVersion = GetBootloaderVersion();
printf("bootloaderVersion = %s\n", bootloaderVersion);
myVector.emplace_back("bootloaderVersion", bootloaderVersion);
const char *incrementalVersion = GetIncrementalVersion();
printf("incrementalVersion = %s\n", incrementalVersion);
myVector.emplace_back("incrementalVersion", incrementalVersion);
const char *buildType = GetBuildType();
printf("buildType = %s\n", buildType);
myVector.emplace_back("buildType", buildType);
const char *buildUser = GetBuildUser();
printf("buildUser = %s\n", buildUser);
myVector.emplace_back("buildUser", buildUser);
const char *buildHost = GetBuildHost();
printf("buildHost = %s\n", buildHost);
myVector.emplace_back("buildHost", buildHost);
const char *buildTime = GetBuildTime();
printf("buildTime = %s\n", buildTime);
myVector.emplace_back("buildTime", buildTime);
const char *abiList = GetAbiList();
printf("AbiList = %s\n", abiList);
myVector.emplace_back("AbiList", abiList);
printf("******To Obtain Product Params End ******\n");
std::string text1 = "******To Obtain Product Params Start******";
std::string text2 = "******To Obtain Product Params End ******";
writeTexToFile("querySmall.txt", text1, myVector, text2);
}
int main()
{
ObtainProductParms();
return 0;
}