• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "android/hardware/nfc/1.0/NfcClientCallback.vts.h"
2 #include "vts_measurement.h"
3 #include <android-base/logging.h>
4 #include <android/hidl/allocator/1.0/IAllocator.h>
5 #include <fmq/MessageQueue.h>
6 #include <sys/stat.h>
7 #include <unistd.h>
8 
9 
10 using namespace android::hardware::nfc::V1_0;
11 namespace android {
12 namespace vts {
GetService(bool get_stub,const char * service_name)13 bool FuzzerExtended_android_hardware_nfc_V1_0_INfcClientCallback::GetService(bool get_stub, const char* service_name) {
14     static bool initialized = false;
15     if (!initialized) {
16         LOG(INFO) << "HIDL getService";
17         if (service_name) {
18           LOG(INFO) << "  - service name: " << service_name;
19         }
20         hw_binder_proxy_ = ::android::hardware::nfc::V1_0::INfcClientCallback::getService(service_name, get_stub);
21         if (hw_binder_proxy_ == nullptr) {
22             LOG(ERROR) << "getService() returned a null pointer.";
23             return false;
24         }
25         LOG(DEBUG) << "hw_binder_proxy_ = " << hw_binder_proxy_.get();
26         initialized = true;
27     }
28     return true;
29 }
30 
31 
sendEvent(::android::hardware::nfc::V1_0::NfcEvent arg0,::android::hardware::nfc::V1_0::NfcStatus arg1)32 ::android::hardware::Return<void> Vts_android_hardware_nfc_V1_0_INfcClientCallback::sendEvent(
33     ::android::hardware::nfc::V1_0::NfcEvent arg0 __attribute__((__unused__)),
34     ::android::hardware::nfc::V1_0::NfcStatus arg1 __attribute__((__unused__))) {
35     LOG(INFO) << "sendEvent called";
36     AndroidSystemCallbackRequestMessage callback_message;
37     callback_message.set_id(GetCallbackID("sendEvent"));
38     callback_message.set_name("Vts_android_hardware_nfc_V1_0_INfcClientCallback::sendEvent");
39     VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
40     var_msg0->set_type(TYPE_ENUM);
41     SetResult__android__hardware__nfc__V1_0__NfcEvent(var_msg0, arg0);
42     VariableSpecificationMessage* var_msg1 = callback_message.add_arg();
43     var_msg1->set_type(TYPE_ENUM);
44     SetResult__android__hardware__nfc__V1_0__NfcStatus(var_msg1, arg1);
45     RpcCallToAgent(callback_message, callback_socket_name_);
46     return ::android::hardware::Void();
47 }
48 
sendData(const::android::hardware::hidl_vec<uint8_t> & arg0)49 ::android::hardware::Return<void> Vts_android_hardware_nfc_V1_0_INfcClientCallback::sendData(
50     const ::android::hardware::hidl_vec<uint8_t>& arg0 __attribute__((__unused__))) {
51     LOG(INFO) << "sendData called";
52     AndroidSystemCallbackRequestMessage callback_message;
53     callback_message.set_id(GetCallbackID("sendData"));
54     callback_message.set_name("Vts_android_hardware_nfc_V1_0_INfcClientCallback::sendData");
55     VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
56     var_msg0->set_type(TYPE_VECTOR);
57     var_msg0->set_vector_size(arg0.size());
58     for (int i = 0; i < (int)arg0.size(); i++) {
59         auto *var_msg0_vector_i = var_msg0->add_vector_value();
60         var_msg0_vector_i->set_type(TYPE_SCALAR);
61         var_msg0_vector_i->set_scalar_type("uint8_t");
62         var_msg0_vector_i->mutable_scalar_value()->set_uint8_t(arg0[i]);
63     }
64     RpcCallToAgent(callback_message, callback_socket_name_);
65     return ::android::hardware::Void();
66 }
67 
VtsFuzzerCreateVts_android_hardware_nfc_V1_0_INfcClientCallback(const string & callback_socket_name)68 sp<::android::hardware::nfc::V1_0::INfcClientCallback> VtsFuzzerCreateVts_android_hardware_nfc_V1_0_INfcClientCallback(const string& callback_socket_name) {
69     static sp<::android::hardware::nfc::V1_0::INfcClientCallback> result;
70     result = new Vts_android_hardware_nfc_V1_0_INfcClientCallback(callback_socket_name);
71     return result;
72 }
73 
Fuzz(FunctionSpecificationMessage *,void **,const string &)74 bool FuzzerExtended_android_hardware_nfc_V1_0_INfcClientCallback::Fuzz(
75     FunctionSpecificationMessage* /*func_msg*/,
76     void** /*result*/, const string& /*callback_socket_name*/) {
77     return true;
78 }
GetAttribute(FunctionSpecificationMessage *,void **)79 bool FuzzerExtended_android_hardware_nfc_V1_0_INfcClientCallback::GetAttribute(
80     FunctionSpecificationMessage* /*func_msg*/,
81     void** /*result*/) {
82     LOG(ERROR) << "attribute not found.";
83     return false;
84 }
CallFunction(const FunctionSpecificationMessage & func_msg,const string & callback_socket_name,FunctionSpecificationMessage * result_msg)85 bool FuzzerExtended_android_hardware_nfc_V1_0_INfcClientCallback::CallFunction(
86     const FunctionSpecificationMessage& func_msg,
87     const string& callback_socket_name __attribute__((__unused__)),
88     FunctionSpecificationMessage* result_msg) {
89     const char* func_name = func_msg.name().c_str();
90     if (hw_binder_proxy_ == nullptr) {
91         LOG(ERROR) << "hw_binder_proxy_ is null. ";
92         return false;
93     }
94     if (!strcmp(func_name, "sendEvent")) {
95         ::android::hardware::nfc::V1_0::NfcEvent arg0;
96         MessageTo__android__hardware__nfc__V1_0__NfcEvent(func_msg.arg(0), &(arg0), callback_socket_name);
97         ::android::hardware::nfc::V1_0::NfcStatus arg1;
98         MessageTo__android__hardware__nfc__V1_0__NfcStatus(func_msg.arg(1), &(arg1), callback_socket_name);
99         LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
100         hw_binder_proxy_->sendEvent(arg0, arg1);
101         result_msg->set_name("sendEvent");
102         return true;
103     }
104     if (!strcmp(func_name, "sendData")) {
105         ::android::hardware::hidl_vec<uint8_t> arg0;
106         arg0.resize(func_msg.arg(0).vector_value_size());
107         for (int arg0_index = 0; arg0_index < func_msg.arg(0).vector_value_size(); arg0_index++) {
108             arg0[arg0_index] = func_msg.arg(0).vector_value(arg0_index).scalar_value().uint8_t();
109         }
110         LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
111         hw_binder_proxy_->sendData(arg0);
112         result_msg->set_name("sendData");
113         return true;
114     }
115     if (!strcmp(func_name, "notifySyspropsChanged")) {
116         LOG(INFO) << "Call notifySyspropsChanged";
117         hw_binder_proxy_->notifySyspropsChanged();
118         result_msg->set_name("notifySyspropsChanged");
119         return true;
120     }
121     return false;
122 }
123 
VerifyResults(const FunctionSpecificationMessage & expected_result,const FunctionSpecificationMessage & actual_result)124 bool FuzzerExtended_android_hardware_nfc_V1_0_INfcClientCallback::VerifyResults(const FunctionSpecificationMessage& expected_result __attribute__((__unused__)),
125     const FunctionSpecificationMessage& actual_result __attribute__((__unused__))) {
126     if (!strcmp(actual_result.name().c_str(), "sendEvent")) {
127         if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
128         return true;
129     }
130     if (!strcmp(actual_result.name().c_str(), "sendData")) {
131         if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
132         return true;
133     }
134     return false;
135 }
136 
137 extern "C" {
vts_func_4_android_hardware_nfc_V1_0_INfcClientCallback_()138 android::vts::DriverBase* vts_func_4_android_hardware_nfc_V1_0_INfcClientCallback_() {
139     return (android::vts::DriverBase*) new android::vts::FuzzerExtended_android_hardware_nfc_V1_0_INfcClientCallback();
140 }
141 
vts_func_4_android_hardware_nfc_V1_0_INfcClientCallback_with_arg(uint64_t hw_binder_proxy)142 android::vts::DriverBase* vts_func_4_android_hardware_nfc_V1_0_INfcClientCallback_with_arg(uint64_t hw_binder_proxy) {
143     ::android::hardware::nfc::V1_0::INfcClientCallback* arg = nullptr;
144     if (hw_binder_proxy) {
145         arg = reinterpret_cast<::android::hardware::nfc::V1_0::INfcClientCallback*>(hw_binder_proxy);
146     } else {
147         LOG(INFO) << " Creating DriverBase with null proxy.";
148     }
149     android::vts::DriverBase* result =
150         new android::vts::FuzzerExtended_android_hardware_nfc_V1_0_INfcClientCallback(
151             arg);
152     if (arg != nullptr) {
153         arg->decStrong(arg);
154     }
155     return result;
156 }
157 
158 }
159 }  // namespace vts
160 }  // namespace android
161