1 /**
2 * Copyright (C) 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #define private public
18 #include "NfcTag.h"
19
20 bool isTestInProgress = false;
21
22 struct sigaction new_action, old_action;
23
sigabrt_handler(int signum,siginfo_t * info,void * context)24 void sigabrt_handler(int signum, siginfo_t* info, void* context) {
25 if (isTestInProgress && info->si_signo == SIGABRT) {
26 (*old_action.sa_sigaction)(signum, info, context);
27 return;
28 }
29 exit(EXIT_FAILURE);
30 }
31
main()32 int main() {
33 sigemptyset(&new_action.sa_mask);
34 new_action.sa_flags = SA_SIGINFO;
35 new_action.sa_sigaction = sigabrt_handler;
36 sigaction(SIGABRT, &new_action, &old_action);
37
38 NfcTag tag = {};
39 tag.mTechListTail = NfcTag::MAX_NUM_TECHNOLOGY;
40 tag.mNumTechList = NfcTag::MAX_NUM_TECHNOLOGY;
41 tNFA_ACTIVATED activationData = {};
42 isTestInProgress = true;
43 tag.discoverTechnologies(activationData);
44 isTestInProgress = false;
45 return EXIT_SUCCESS;
46 }
47