• 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 
16 #include <stdio.h>
17 #include <stdlib.h>
18 
19 #include "parameter.h"
20 #include "devattest_interface.h"
21 
22 const int DEVATTEST_SUESS = 0;
23 const int UDIDSIZE_LEN = 64;
24 
ObtainProductParms()25 void ObtainProductParms()
26 {
27     int sdkApiVersion = GetSdkApiVersion();
28     if (sdkApiVersion != 0) {
29         printf("SdkApiVersion = %d\n", sdkApiVersion);
30     }
31 
32     int firstApiVersion = GetFirstApiVersion();
33     if (firstApiVersion != 0) {
34         printf("firstApiVersion = %d\n", firstApiVersion);
35     }
36 
37     const char *bootloaderVersion = GetBootloaderVersion();
38     if (bootloaderVersion != nullptr) {
39         printf("bootloaderVersion = %s\n", bootloaderVersion);
40     }
41 
42     const char *incrementalVersion = GetIncrementalVersion();
43     if (incrementalVersion != nullptr) {
44         printf("incrementalVersion = %s\n", incrementalVersion);
45     }
46 
47     const char *buildType = GetBuildType();
48     if (buildType != nullptr) {
49         printf("buildType = %s\n", buildType);
50     }
51 
52     const char *buildUser = GetBuildUser();
53     if (buildUser != nullptr) {
54         printf("buildUser = %s\n", buildUser);
55     }
56 
57     const char *buildHost = GetBuildHost();
58     if (buildHost != nullptr) {
59         printf("buildHost = %s\n", buildHost);
60     }
61 
62     const char *buildTime = GetBuildTime();
63     if (buildTime != nullptr) {
64         printf("buildTime = %s\n", buildTime);
65     }
66 
67     const char *abiList = GetAbiList();
68     if (abiList != nullptr) {
69         printf("AbiList = %s\n", abiList);
70     }
71 }
72 
main()73 int main()
74 {
75     printf("******To Obtain Product Params Start******\n");
76     const char *productType = GetDeviceType();
77     if (productType != nullptr) {
78         printf("Device Type = %s\n", productType);
79     }
80 
81     const char *securityPatchTag = GetSecurityPatchTag();
82     if (securityPatchTag != nullptr) {
83         printf("Security Patch = %s\n", securityPatchTag);
84     }
85 
86     const char *osName = GetOSFullName();
87     if (osName != nullptr) {
88         printf("OsFullName = %s\n", osName);
89     }
90 
91     const char *displayVersion = GetDisplayVersion();
92     if (displayVersion != nullptr) {
93         printf("DisplayVersion = %s\n", displayVersion);
94     }
95 
96     const char *versionId = GetVersionId();
97     if (versionId != nullptr) {
98         printf("VersionID = %s\n", versionId);
99     }
100 
101     AttestResultInfo attestResultInfo = { 0 };
102     attestResultInfo.ticket = NULL;
103     int32_t retStatus = GetAttestStatus(&attestResultInfo);
104     if (retStatus != DEVATTEST_SUESS) {
105         printf("[CLIENT MAIN] wrong. retStatus:%d\n", retStatus);
106     }
107     printf("authResult = %d\n",attestResultInfo.authResult);
108     printf("softwareResult = %d\n",attestResultInfo.softwareResult);
109 
110     char udid[UDIDSIZE_LEN + 1] = { 0 };
111     int retUdid = GetDevUdid(udid, UDIDSIZE_LEN + 1);
112     if (retUdid == 0) {
113         printf("DevUdid = %s\n", udid);
114     }
115 
116     const char *manuFacture = GetManufacture();
117     if (manuFacture != nullptr) {
118         printf("manuFacture = %s\n", manuFacture);
119     }
120 
121     const char *productModel = GetProductModel();
122     if (productModel != nullptr) {
123         printf("productModel = %s\n", productModel);
124     }
125 
126     const char *serial = GetSerial();
127     if (serial != nullptr) {
128         printf("serial = %s\n", serial);
129     }
130 
131     const char *brand = GetBrand();
132     if (brand != nullptr) {
133         printf("brand = %s\n", brand);
134     }
135 
136     const char *productSeries = GetProductSeries();
137     if (productSeries != nullptr) {
138         printf("productSeries = %s\n", productSeries);
139     }
140 
141     const char *softwareModel = GetSoftwareModel();
142     if (softwareModel != nullptr) {
143         printf("softwareModel = %s\n", softwareModel);
144     }
145 
146     const char *hardWareModel = GetHardwareModel();
147     if (hardWareModel != nullptr) {
148         printf("HardwareModel = %s\n", hardWareModel);
149     }
150 
151     const char *buildRootHash = GetBuildRootHash();
152     if (buildRootHash != nullptr) {
153         printf("BuildRootHash = %s\n", buildRootHash);
154     }
155 
156     const char *marketName = GetMarketName();
157     if (marketName != nullptr) {
158         printf("marketName = %s\n", marketName);
159     }
160 
161     ObtainProductParms();
162 
163     printf("******To Obtain Product Params End  ******\n");
164     return 0;
165 }
166