• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #include <stdio.h>
16 #include <stdlib.h>
17 #include <securec.h>
18 #include <string.h>
19 
20 #include "parameter.h"
21 #include "devattest_client.h"
22 
23 const int UDIDSIZE_LEN = 64;
24 
25 using namespace OHOS::DevAttest;
26 using namespace OHOS;
27 
ObtainProductParms(void)28 void ObtainProductParms(void)
29 {
30     int sdkApiVersion = GetSdkApiVersion();
31     if (sdkApiVersion != 0) {
32         printf("SdkApiVersion = %d\n", sdkApiVersion);
33     } else {
34         printf("SdkApiVersion = 0\n");
35     }
36 
37     int firstApiVersion = GetFirstApiVersion();
38     if (firstApiVersion != 0) {
39         printf("firstApiVersion = %d\n", firstApiVersion);
40     } else {
41         printf("firstApiVersion = 0\n");
42     }
43 
44     const char *bootloaderVersion = GetBootloaderVersion();
45     if (bootloaderVersion != nullptr) {
46         printf("bootloaderVersion = %s\n", bootloaderVersion);
47     } else {
48         printf("bootloaderVersion = nullptr\n");
49     }
50 
51     const char *incrementalVersion = GetIncrementalVersion();
52     if (incrementalVersion != nullptr) {
53         printf("incrementalVersion = %s\n", incrementalVersion);
54     } else {
55         printf("incrementalVersion = nullptr\n");
56     }
57 
58     const char *buildType = GetBuildType();
59     if (buildType != nullptr) {
60         printf("buildType = %s\n", buildType);
61     } else {
62         printf("buildType = nullptr\n");
63     }
64 
65     const char *buildUser = GetBuildUser();
66     if (buildUser != nullptr) {
67         printf("buildUser = %s\n", buildUser);
68     } else {
69         printf("buildUser = nullptr\n");
70     }
71 
72     const char *buildHost = GetBuildHost();
73     if (buildHost != nullptr) {
74         printf("buildHost = %s\n", buildHost);
75     } else {
76         printf("buildHost = nullptr\n");
77     }
78 
79     const char *buildTime = GetBuildTime();
80     if (buildTime != nullptr) {
81         printf("buildTime = %s\n", buildTime);
82     } else {
83         printf("buildTime = nullptr\n");
84     }
85 
86     const char *abiList = GetAbiList();
87     if (abiList != nullptr) {
88         printf("AbiList = %s\n", abiList);
89     } else {
90         printf("AbiList = nullptr\n");
91     }
92 }
93 
main()94 int main()
95 {
96     printf("******To Obtain Product Params Start******\n");
97     const char *productType = GetDeviceType();
98     if (productType != nullptr) {
99         printf("Device Type = %s\n", productType);
100     } else {
101         printf("Device Type = nullptr\n");
102     }
103 
104     const char *securityPatchTag = GetSecurityPatchTag();
105     if (securityPatchTag != nullptr) {
106         printf("Security Patch = %s\n", securityPatchTag);
107     } else {
108         printf("Security Patch = nullptr\n");
109     }
110 
111     const char *osName = GetOSFullName();
112     if (osName != nullptr) {
113         printf("OsFullName = %s\n", osName);
114     } else {
115         printf("OsFullName = nullptr\n");
116     }
117 
118     const char *displayVersion = GetDisplayVersion();
119     if (displayVersion != nullptr) {
120         printf("DisplayVersion = %s\n", displayVersion);
121     } else {
122         printf("DisplayVersion = nullptr\n");
123     }
124 
125     const char *versionId = GetVersionId();
126     if (versionId != nullptr) {
127         printf("VersionID = %s\n", versionId);
128     } else {
129         printf("VersionID = nullptr\n");
130     }
131 
132     AttestResultInfo attestResultInfo;
133     (void)DevAttestClient::GetInstance().GetAttestStatus(attestResultInfo);
134     printf("authResult = %d\n", attestResultInfo.authResult_);
135     printf("softwareResult = %d\n", attestResultInfo.softwareResult_);
136 
137     char udid[UDIDSIZE_LEN + 1] = {0};
138     int ret = GetDevUdid(udid, UDIDSIZE_LEN + 1);
139     if (ret == 0) {
140         printf("DevUdid = %s\n", udid);
141     } else {
142         printf("DevUdid = nullptr\n");
143     }
144 
145     const char *manuFacture = GetManufacture();
146     if (manuFacture != nullptr) {
147         printf("manuFacture = %s\n", manuFacture);
148     } else {
149         printf("manuFacture = nullptr\n");
150     }
151 
152     const char *productModel = GetProductModel();
153     if (productModel != nullptr) {
154         printf("productModel = %s\n", productModel);
155     } else {
156         printf("productModel = nullptr\n");
157     }
158 
159     const char *serial = GetSerial();
160     if (serial != nullptr) {
161         printf("serial = %s\n", serial);
162     } else {
163         printf("serial = nullptr\n");
164     }
165 
166     const char *brand = GetBrand();
167     if (brand != nullptr) {
168         printf("brand = %s\n", brand);
169     } else {
170         printf("brand = nullptr\n");
171     }
172 
173     const char *productSeries = GetProductSeries();
174     if (productSeries != nullptr) {
175         printf("productSeries = %s\n", productSeries);
176     } else {
177         printf("productSeries = nullptr\n");
178     }
179 
180     const char *softwareModel = GetSoftwareModel();
181     if (softwareModel != nullptr) {
182         printf("softwareModel = %s\n", softwareModel);
183     } else {
184         printf("softwareModel = nullptr\n");
185     }
186 
187     const char *hardWareModel = GetHardwareModel();
188     if (hardWareModel != nullptr) {
189         printf("HardwareModel = %s\n", hardWareModel);
190     } else {
191         printf("HardwareModel = nullptr\n");
192     }
193 
194     const char *buildRootHash = GetBuildRootHash();
195     if (buildRootHash != nullptr) {
196         printf("BuildRootHash = %s\n", buildRootHash);
197     } else {
198         printf("BuildRootHash = nullptr\n");
199     }
200 
201     const char *marketName = GetMarketName();
202     if (marketName != nullptr) {
203         printf("marketName = %s\n", marketName);
204     } else {
205         printf("marketName = nullptr\n");
206     }
207 
208     ObtainProductParms();
209 
210     printf("******To Obtain Product Params End  ******\n");
211     return 0;
212 }
213