Home | History | Annotate | Download | only in jni
      1 /*
      2  * Copyright (C) 2013 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 /*
     18  *  Manage the listen-mode routing table.
     19  */
     20 #pragma once
     21 #include "SyncEvent.h"
     22 #include "NfcJniUtil.h"
     23 #include "RouteDataSet.h"
     24 #include "SecureElement.h"
     25 #include <vector>
     26 extern "C"
     27 {
     28     #include "nfa_api.h"
     29     #include "nfa_ee_api.h"
     30 }
     31 
     32 class RoutingManager
     33 {
     34 public:
     35     static const int ROUTE_HOST = 0;
     36     static const int ROUTE_ESE = 1;
     37 
     38     static RoutingManager& getInstance ();
     39     bool initialize(nfc_jni_native_data* native);
     40     bool addAidRouting(const UINT8* aid, UINT8 aidLen, int route);
     41     bool removeAidRouting(const UINT8* aid, UINT8 aidLen);
     42     bool commitRouting();
     43 private:
     44     RoutingManager();
     45     ~RoutingManager();
     46     RoutingManager(const RoutingManager&);
     47     RoutingManager& operator=(const RoutingManager&);
     48 
     49     void setDefaultRouting();
     50     void handleData (const UINT8* data, UINT8 dataLen);
     51     void notifyActivated ();
     52     void notifyDeactivated ();
     53     static void nfaEeCallback (tNFA_EE_EVT event, tNFA_EE_CBACK_DATA* eventData);
     54     static void stackCallback (UINT8 event, tNFA_CONN_EVT_DATA* eventData);
     55 
     56     // Fields below are final after initialize()
     57     nfc_jni_native_data* mNativeData;
     58     int mDefaultEe;
     59     SyncEvent mEeRegisterEvent;
     60     SyncEvent mRoutingEvent;
     61 };
     62 
     63