1 #include "android/hardware/nfc/1.0/Nfc.vts.h"
2 #include <cutils/properties.h>
3
4 using namespace android::hardware::nfc::V1_0;
5 using namespace android::hardware;
6
7 #define TRACEFILEPREFIX "/data/local/tmp/"
8
9 namespace android {
10 namespace vts {
11
HIDL_INSTRUMENTATION_FUNCTION_android_hardware_nfc_V1_0_INfc(details::HidlInstrumentor::InstrumentationEvent event,const char * package,const char * version,const char * interface,const char * method,std::vector<void * > * args)12 void HIDL_INSTRUMENTATION_FUNCTION_android_hardware_nfc_V1_0_INfc(
13 details::HidlInstrumentor::InstrumentationEvent event __attribute__((__unused__)),
14 const char* package,
15 const char* version,
16 const char* interface,
17 const char* method __attribute__((__unused__)),
18 std::vector<void *> *args __attribute__((__unused__))) {
19 if (strcmp(package, "android.hardware.nfc") != 0) {
20 LOG(WARNING) << "incorrect package. Expect: android.hardware.nfc actual: " << package;
21 }
22 std::string version_str = std::string(version);
23 int major_version = stoi(version_str.substr(0, version_str.find('.')));
24 int minor_version = stoi(version_str.substr(version_str.find('.') + 1));
25 if (major_version != 1 || minor_version > 0) {
26 LOG(WARNING) << "incorrect version. Expect: 1.0 or lower (if version != x.0), actual: " << version;
27 }
28 if (strcmp(interface, "INfc") != 0) {
29 LOG(WARNING) << "incorrect interface. Expect: INfc actual: " << interface;
30 }
31
32 VtsProfilingInterface& profiler = VtsProfilingInterface::getInstance(TRACEFILEPREFIX);
33
34 bool profiling_for_args = property_get_bool("hal.instrumentation.profile.args", true);
35 if (strcmp(method, "open") == 0) {
36 FunctionSpecificationMessage msg;
37 msg.set_name("open");
38 if (profiling_for_args) {
39 if (!args) {
40 LOG(WARNING) << "no argument passed";
41 } else {
42 switch (event) {
43 case details::HidlInstrumentor::CLIENT_API_ENTRY:
44 case details::HidlInstrumentor::SERVER_API_ENTRY:
45 case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
46 {
47 if ((*args).size() != 1) {
48 LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: open, event type: " << event;
49 break;
50 }
51 auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
52 sp<::android::hardware::nfc::V1_0::INfcClientCallback> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<sp<::android::hardware::nfc::V1_0::INfcClientCallback>*> ((*args)[0]);
53 if (arg_val_0 != nullptr) {
54 arg_0->set_type(TYPE_HIDL_CALLBACK);
55 arg_0->set_predefined_type("::android::hardware::nfc::V1_0::INfcClientCallback");
56 } else {
57 LOG(WARNING) << "argument 0 is null.";
58 }
59 break;
60 }
61 case details::HidlInstrumentor::CLIENT_API_EXIT:
62 case details::HidlInstrumentor::SERVER_API_EXIT:
63 case details::HidlInstrumentor::PASSTHROUGH_EXIT:
64 {
65 if ((*args).size() != 1) {
66 LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: open, event type: " << event;
67 break;
68 }
69 auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
70 ::android::hardware::nfc::V1_0::NfcStatus *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::nfc::V1_0::NfcStatus*> ((*args)[0]);
71 if (result_val_0 != nullptr) {
72 result_0->set_type(TYPE_ENUM);
73 profile____android__hardware__nfc__V1_0__NfcStatus(result_0, (*result_val_0));
74 } else {
75 LOG(WARNING) << "return value 0 is null.";
76 }
77 break;
78 }
79 default:
80 {
81 LOG(WARNING) << "not supported. ";
82 break;
83 }
84 }
85 }
86 }
87 profiler.AddTraceEvent(event, package, version, interface, msg);
88 }
89 if (strcmp(method, "write") == 0) {
90 FunctionSpecificationMessage msg;
91 msg.set_name("write");
92 if (profiling_for_args) {
93 if (!args) {
94 LOG(WARNING) << "no argument passed";
95 } else {
96 switch (event) {
97 case details::HidlInstrumentor::CLIENT_API_ENTRY:
98 case details::HidlInstrumentor::SERVER_API_ENTRY:
99 case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
100 {
101 if ((*args).size() != 1) {
102 LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: write, event type: " << event;
103 break;
104 }
105 auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
106 ::android::hardware::hidl_vec<uint8_t> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<uint8_t>*> ((*args)[0]);
107 if (arg_val_0 != nullptr) {
108 arg_0->set_type(TYPE_VECTOR);
109 arg_0->set_vector_size((*arg_val_0).size());
110 for (int arg_0_index = 0; arg_0_index < (int)(*arg_val_0).size(); arg_0_index++) {
111 auto *arg_0_vector_arg_0_index __attribute__((__unused__)) = arg_0->add_vector_value();
112 arg_0_vector_arg_0_index->set_type(TYPE_SCALAR);
113 arg_0_vector_arg_0_index->mutable_scalar_value()->set_uint8_t((*arg_val_0)[arg_0_index]);
114 }
115 } else {
116 LOG(WARNING) << "argument 0 is null.";
117 }
118 break;
119 }
120 case details::HidlInstrumentor::CLIENT_API_EXIT:
121 case details::HidlInstrumentor::SERVER_API_EXIT:
122 case details::HidlInstrumentor::PASSTHROUGH_EXIT:
123 {
124 if ((*args).size() != 1) {
125 LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: write, event type: " << event;
126 break;
127 }
128 auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
129 uint32_t *result_val_0 __attribute__((__unused__)) = reinterpret_cast<uint32_t*> ((*args)[0]);
130 if (result_val_0 != nullptr) {
131 result_0->set_type(TYPE_SCALAR);
132 result_0->mutable_scalar_value()->set_uint32_t((*result_val_0));
133 } else {
134 LOG(WARNING) << "return value 0 is null.";
135 }
136 break;
137 }
138 default:
139 {
140 LOG(WARNING) << "not supported. ";
141 break;
142 }
143 }
144 }
145 }
146 profiler.AddTraceEvent(event, package, version, interface, msg);
147 }
148 if (strcmp(method, "coreInitialized") == 0) {
149 FunctionSpecificationMessage msg;
150 msg.set_name("coreInitialized");
151 if (profiling_for_args) {
152 if (!args) {
153 LOG(WARNING) << "no argument passed";
154 } else {
155 switch (event) {
156 case details::HidlInstrumentor::CLIENT_API_ENTRY:
157 case details::HidlInstrumentor::SERVER_API_ENTRY:
158 case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
159 {
160 if ((*args).size() != 1) {
161 LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: coreInitialized, event type: " << event;
162 break;
163 }
164 auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
165 ::android::hardware::hidl_vec<uint8_t> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<uint8_t>*> ((*args)[0]);
166 if (arg_val_0 != nullptr) {
167 arg_0->set_type(TYPE_VECTOR);
168 arg_0->set_vector_size((*arg_val_0).size());
169 for (int arg_0_index = 0; arg_0_index < (int)(*arg_val_0).size(); arg_0_index++) {
170 auto *arg_0_vector_arg_0_index __attribute__((__unused__)) = arg_0->add_vector_value();
171 arg_0_vector_arg_0_index->set_type(TYPE_SCALAR);
172 arg_0_vector_arg_0_index->mutable_scalar_value()->set_uint8_t((*arg_val_0)[arg_0_index]);
173 }
174 } else {
175 LOG(WARNING) << "argument 0 is null.";
176 }
177 break;
178 }
179 case details::HidlInstrumentor::CLIENT_API_EXIT:
180 case details::HidlInstrumentor::SERVER_API_EXIT:
181 case details::HidlInstrumentor::PASSTHROUGH_EXIT:
182 {
183 if ((*args).size() != 1) {
184 LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: coreInitialized, event type: " << event;
185 break;
186 }
187 auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
188 ::android::hardware::nfc::V1_0::NfcStatus *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::nfc::V1_0::NfcStatus*> ((*args)[0]);
189 if (result_val_0 != nullptr) {
190 result_0->set_type(TYPE_ENUM);
191 profile____android__hardware__nfc__V1_0__NfcStatus(result_0, (*result_val_0));
192 } else {
193 LOG(WARNING) << "return value 0 is null.";
194 }
195 break;
196 }
197 default:
198 {
199 LOG(WARNING) << "not supported. ";
200 break;
201 }
202 }
203 }
204 }
205 profiler.AddTraceEvent(event, package, version, interface, msg);
206 }
207 if (strcmp(method, "prediscover") == 0) {
208 FunctionSpecificationMessage msg;
209 msg.set_name("prediscover");
210 if (profiling_for_args) {
211 if (!args) {
212 LOG(WARNING) << "no argument passed";
213 } else {
214 switch (event) {
215 case details::HidlInstrumentor::CLIENT_API_ENTRY:
216 case details::HidlInstrumentor::SERVER_API_ENTRY:
217 case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
218 {
219 if ((*args).size() != 0) {
220 LOG(ERROR) << "Number of arguments does not match. expect: 0, actual: " << (*args).size() << ", method name: prediscover, event type: " << event;
221 break;
222 }
223 break;
224 }
225 case details::HidlInstrumentor::CLIENT_API_EXIT:
226 case details::HidlInstrumentor::SERVER_API_EXIT:
227 case details::HidlInstrumentor::PASSTHROUGH_EXIT:
228 {
229 if ((*args).size() != 1) {
230 LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: prediscover, event type: " << event;
231 break;
232 }
233 auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
234 ::android::hardware::nfc::V1_0::NfcStatus *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::nfc::V1_0::NfcStatus*> ((*args)[0]);
235 if (result_val_0 != nullptr) {
236 result_0->set_type(TYPE_ENUM);
237 profile____android__hardware__nfc__V1_0__NfcStatus(result_0, (*result_val_0));
238 } else {
239 LOG(WARNING) << "return value 0 is null.";
240 }
241 break;
242 }
243 default:
244 {
245 LOG(WARNING) << "not supported. ";
246 break;
247 }
248 }
249 }
250 }
251 profiler.AddTraceEvent(event, package, version, interface, msg);
252 }
253 if (strcmp(method, "close") == 0) {
254 FunctionSpecificationMessage msg;
255 msg.set_name("close");
256 if (profiling_for_args) {
257 if (!args) {
258 LOG(WARNING) << "no argument passed";
259 } else {
260 switch (event) {
261 case details::HidlInstrumentor::CLIENT_API_ENTRY:
262 case details::HidlInstrumentor::SERVER_API_ENTRY:
263 case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
264 {
265 if ((*args).size() != 0) {
266 LOG(ERROR) << "Number of arguments does not match. expect: 0, actual: " << (*args).size() << ", method name: close, event type: " << event;
267 break;
268 }
269 break;
270 }
271 case details::HidlInstrumentor::CLIENT_API_EXIT:
272 case details::HidlInstrumentor::SERVER_API_EXIT:
273 case details::HidlInstrumentor::PASSTHROUGH_EXIT:
274 {
275 if ((*args).size() != 1) {
276 LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: close, event type: " << event;
277 break;
278 }
279 auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
280 ::android::hardware::nfc::V1_0::NfcStatus *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::nfc::V1_0::NfcStatus*> ((*args)[0]);
281 if (result_val_0 != nullptr) {
282 result_0->set_type(TYPE_ENUM);
283 profile____android__hardware__nfc__V1_0__NfcStatus(result_0, (*result_val_0));
284 } else {
285 LOG(WARNING) << "return value 0 is null.";
286 }
287 break;
288 }
289 default:
290 {
291 LOG(WARNING) << "not supported. ";
292 break;
293 }
294 }
295 }
296 }
297 profiler.AddTraceEvent(event, package, version, interface, msg);
298 }
299 if (strcmp(method, "controlGranted") == 0) {
300 FunctionSpecificationMessage msg;
301 msg.set_name("controlGranted");
302 if (profiling_for_args) {
303 if (!args) {
304 LOG(WARNING) << "no argument passed";
305 } else {
306 switch (event) {
307 case details::HidlInstrumentor::CLIENT_API_ENTRY:
308 case details::HidlInstrumentor::SERVER_API_ENTRY:
309 case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
310 {
311 if ((*args).size() != 0) {
312 LOG(ERROR) << "Number of arguments does not match. expect: 0, actual: " << (*args).size() << ", method name: controlGranted, event type: " << event;
313 break;
314 }
315 break;
316 }
317 case details::HidlInstrumentor::CLIENT_API_EXIT:
318 case details::HidlInstrumentor::SERVER_API_EXIT:
319 case details::HidlInstrumentor::PASSTHROUGH_EXIT:
320 {
321 if ((*args).size() != 1) {
322 LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: controlGranted, event type: " << event;
323 break;
324 }
325 auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
326 ::android::hardware::nfc::V1_0::NfcStatus *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::nfc::V1_0::NfcStatus*> ((*args)[0]);
327 if (result_val_0 != nullptr) {
328 result_0->set_type(TYPE_ENUM);
329 profile____android__hardware__nfc__V1_0__NfcStatus(result_0, (*result_val_0));
330 } else {
331 LOG(WARNING) << "return value 0 is null.";
332 }
333 break;
334 }
335 default:
336 {
337 LOG(WARNING) << "not supported. ";
338 break;
339 }
340 }
341 }
342 }
343 profiler.AddTraceEvent(event, package, version, interface, msg);
344 }
345 if (strcmp(method, "powerCycle") == 0) {
346 FunctionSpecificationMessage msg;
347 msg.set_name("powerCycle");
348 if (profiling_for_args) {
349 if (!args) {
350 LOG(WARNING) << "no argument passed";
351 } else {
352 switch (event) {
353 case details::HidlInstrumentor::CLIENT_API_ENTRY:
354 case details::HidlInstrumentor::SERVER_API_ENTRY:
355 case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
356 {
357 if ((*args).size() != 0) {
358 LOG(ERROR) << "Number of arguments does not match. expect: 0, actual: " << (*args).size() << ", method name: powerCycle, event type: " << event;
359 break;
360 }
361 break;
362 }
363 case details::HidlInstrumentor::CLIENT_API_EXIT:
364 case details::HidlInstrumentor::SERVER_API_EXIT:
365 case details::HidlInstrumentor::PASSTHROUGH_EXIT:
366 {
367 if ((*args).size() != 1) {
368 LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: powerCycle, event type: " << event;
369 break;
370 }
371 auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
372 ::android::hardware::nfc::V1_0::NfcStatus *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::nfc::V1_0::NfcStatus*> ((*args)[0]);
373 if (result_val_0 != nullptr) {
374 result_0->set_type(TYPE_ENUM);
375 profile____android__hardware__nfc__V1_0__NfcStatus(result_0, (*result_val_0));
376 } else {
377 LOG(WARNING) << "return value 0 is null.";
378 }
379 break;
380 }
381 default:
382 {
383 LOG(WARNING) << "not supported. ";
384 break;
385 }
386 }
387 }
388 }
389 profiler.AddTraceEvent(event, package, version, interface, msg);
390 }
391 }
392
393 } // namespace vts
394 } // namespace android
395