1 #include "test/vts/specification/hal/conventional/bluetooth/1.0/BluetoothHalV1.vts.h"
2 #include <hardware/hardware.h>
3 #include <hardware/bluetooth.h>
4 #include "vts_datatype.h"
5 #include "vts_measurement.h"
6 #include <iostream>
7
8
9 namespace android {
10 namespace vts {
Fuzz(FunctionSpecificationMessage * func_msg,void ** result,const string & callback_socket_name)11 bool FuzzerExtended_bluetooth_module_t::Fuzz(
12 FunctionSpecificationMessage* func_msg,
13 void** result, const string& callback_socket_name) {
14 const char* func_name = func_msg->name().c_str();
15 cout << "Function: " << __func__ << " '" << func_name << "'" << endl;
16 bluetooth_module_t* local_device = reinterpret_cast<bluetooth_module_t*>(device_);
17 if (local_device == NULL) {
18 cout << "use hmi " << (uint64_t)hmi_ << endl;
19 local_device = reinterpret_cast<bluetooth_module_t*>(hmi_);
20 }
21 if (local_device == NULL) {
22 cerr << "both device_ and hmi_ are NULL." << endl;
23 return false;
24 }
25 if (!strcmp(func_name, "get_bluetooth_interface")) {
26 cout << "match" << endl;
27 VtsMeasurement vts_measurement;
28 vts_measurement.Start();
29 cout << "hit2." << device_ << endl;
30 if (reinterpret_cast<bluetooth_module_t*>(local_device)->get_bluetooth_interface == NULL) {
31 cerr << "api not set." << endl;
32 return false;
33 }
34 cout << "Call an API." << endl;
35 cout << "local_device = " << local_device;
36 *result = const_cast<void*>(reinterpret_cast<const void*>(local_device->get_bluetooth_interface()));
37 vector<float>* measured = vts_measurement.Stop();
38 cout << "time " << (*measured)[0] << endl;
39 cout << "called" << endl;
40 return true;
41 }
42 cerr << "func not found" << endl;
43 return false;
44 }
GetAttribute(FunctionSpecificationMessage * func_msg,void ** result)45 bool FuzzerExtended_bluetooth_module_t::GetAttribute(
46 FunctionSpecificationMessage* func_msg,
47 void** result) {
48 const char* func_name = func_msg->name().c_str();
49 cout << "Function: " << __func__ << " '" << func_name << "'" << endl;
50 bluetooth_module_t* local_device = reinterpret_cast<bluetooth_module_t*>(device_);
51 if (local_device == NULL) {
52 cout << "use hmi " << (uint64_t)hmi_ << endl;
53 local_device = reinterpret_cast<bluetooth_module_t*>(hmi_);
54 }
55 if (local_device == NULL) {
56 cerr << "both device_ and hmi_ are NULL." << endl;
57 return false;
58 }
59 cerr << "attribute not found" << endl;
60 return false;
61 }
CallFunction(const FunctionSpecificationMessage &,const string &,FunctionSpecificationMessage *)62 bool FuzzerExtended_bluetooth_module_t::CallFunction(const FunctionSpecificationMessage&, const string&, FunctionSpecificationMessage* ) {
63 /* No implementation yet. */
64 return true;
65 }
VerifyResults(const FunctionSpecificationMessage &,const FunctionSpecificationMessage &)66 bool FuzzerExtended_bluetooth_module_t::VerifyResults(const FunctionSpecificationMessage&, const FunctionSpecificationMessage&) {
67 /* No implementation yet. */
68 return true;
69 }
70 extern "C" {
vts_func_1_7_1_()71 android::vts::FuzzerBase* vts_func_1_7_1_() {
72 return (android::vts::FuzzerBase*) new android::vts::FuzzerExtended_bluetooth_module_t();
73 }
74
75 }
76 } // namespace vts
77 } // namespace android
78