1 #include <android-base/logging.h>
2 #include <android-base/stringprintf.h>
3 
4 #include "debug_nfcsnoop.h"
5 #include "fuzzers/integration/nfc_integration_fuzzer.pb.h"
6 #include "gki_common.h"
7 #include "gki_int.h"
8 #include "nfa_ee_api.h"
9 #include "nfc_integration_fuzzer_impl.h"
10 #include "src/libfuzzer/libfuzzer_macro.h"
11 
12 extern bool nfa_poll_bail_out_mode;
13 uint8_t mute_tech_route_option;
14 
DEFINE_BINARY_PROTO_FUZZER(const Session & session)15 DEFINE_BINARY_PROTO_FUZZER(const Session& session) {
16   static bool init = false;
17   if (!init) {
18     nfa_poll_bail_out_mode = true;
19     // 0x90 is the protocol value on Pixel 4a. The default value (0xFF)
20     // will prevent Mifare from being discoverable.
21     p_nfa_proprietary_cfg->pro_protocol_mfc = 0x90;
22     debug_nfcsnoop_init();
23     gki_buffer_init();
24     gki_cb.com.OSRdyTbl[BTU_TASK] = TASK_READY;
25     gki_cb.com.OSRdyTbl[MMI_TASK] = TASK_READY;
26     gki_cb.com.OSRdyTbl[NFC_TASK] = TASK_READY;
27     init = true;
28     mute_tech_route_option = false;
29   }
30 
31   // Print the testcase in debug mode
32   if (android::base::GetMinimumLogSeverity() <= android::base::DEBUG) {
33     std::string str;
34     google::protobuf::TextFormat::PrintToString(session, &str);
35     LOG(INFO) << str;
36   }
37 
38   NfcIntegrationFuzzer nfc_integration_fuzzer(&session);
39   if (!nfc_integration_fuzzer.Setup()) {
40     return;
41   }
42 
43   nfc_integration_fuzzer.RunCommands();
44 }
45