Exemplo n.º 1
0
bool RoutingManager::initialize ()
{
    unsigned long tech = 0;
    UINT8 mActualNumEe = 0;
    tNFA_EE_INFO mEeInfo [mActualNumEe];

    if ((GetNumValue(NAME_NXP_FWD_FUNCTIONALITY_ENABLE, &tech, sizeof(tech))))
    {
        mFwdFuntnEnable = tech;
        NXPLOG_API_E ("%s:NXP_FWD_FUNCTIONALITY_ENABLE=%d;", __FUNCTION__, mFwdFuntnEnable);
    }

    tNFA_STATUS nfaStat;
    {
        SyncEventGuard guard (mEeRegisterEvent);
        NXPLOG_API_D ("%s: try ee register", "RoutingManager::initialize()");
        nfaStat = NFA_EeRegister (nfaEeCallback);
        if (nfaStat != NFA_STATUS_OK)
        {
            NXPLOG_API_E ("%s: fail ee register; error=0x%X",
                          "RoutingManager::initialize()", nfaStat);
            return false;
        }
        mEeRegisterEvent.wait ();
    }
    if(mHostListnEnable)
    {
        // Tell the host-routing to only listen on Nfc-A/Nfc-B
        nfaStat = NFA_CeRegisterAidOnDH (NULL, 0, stackCallback);
        if (nfaStat != NFA_STATUS_OK)
        {
            NXPLOG_API_E ("Failed to register wildcard AID for DH");
        }
        // Tell the host-routing to only listen on Nfc-A/Nfc-B
        nfaStat = NFA_CeSetIsoDepListenTech(NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_B);
        if (nfaStat != NFA_STATUS_OK)
        {
            NXPLOG_API_E ("Failed to configure CE IsoDep technologies");
        }
    }
    memset(mRxDataBuffer, 0, MAX_CE_RX_BUFFER_SIZE);

    if ((nfaStat = NFA_AllEeGetInfo (&mActualNumEe, mEeInfo)) != NFA_STATUS_OK)
    {
        NXPLOG_API_E ("%s: fail get info; error=0x%X",
                      "RoutingManager::initialize()", nfaStat);
        mActualNumEe = 0;
    }
    return true;
}
bool RoutingManager::initialize (nfc_jni_native_data* native)
{
    static const char fn [] = "RoutingManager::initialize()";
    mNativeData = native;

    tNFA_STATUS nfaStat;
    {
        SyncEventGuard guard (mEeRegisterEvent);
        ALOGD ("%s: try ee register", fn);
        nfaStat = NFA_EeRegister (nfaEeCallback);
        if (nfaStat != NFA_STATUS_OK)
        {
            ALOGE ("%s: fail ee register; error=0x%X", fn, nfaStat);
            return false;
        }
        mEeRegisterEvent.wait ();
    }

    mRxDataBuffer.clear ();

    if (mActiveSe != 0) {
        {
            // Wait for EE info if needed
            SyncEventGuard guard (mEeInfoEvent);
            if (!mReceivedEeInfo)
            {
                ALOGE("Waiting for EE info");
                mEeInfoEvent.wait();
            }
        }
        for (UINT8 i = 0; i < mEeInfo.num_ee; i++)
        {
             ALOGD ("%s   EE[%u] Handle: 0x%04x  techA: 0x%02x  techB: 0x%02x  techF: 0x%02x  techBprime: 0x%02x",
                fn, i, mEeInfo.ee_disc_info[i].ee_handle,
                mEeInfo.ee_disc_info[i].la_protocol,
                mEeInfo.ee_disc_info[i].lb_protocol,
                mEeInfo.ee_disc_info[i].lf_protocol,
                mEeInfo.ee_disc_info[i].lbp_protocol);
             if (mEeInfo.ee_disc_info[i].ee_handle == (mActiveSe | NFA_HANDLE_GROUP_EE))
             {
                 if (mEeInfo.ee_disc_info[i].la_protocol != 0) mSeTechMask |= NFA_TECHNOLOGY_MASK_A;

                 if (mSeTechMask != 0x00)
                 {
                     ALOGD("Configuring tech mask 0x%02x on EE 0x%04x", mSeTechMask, mEeInfo.ee_disc_info[i].ee_handle);
                     nfaStat = NFA_CeConfigureUiccListenTech(mEeInfo.ee_disc_info[i].ee_handle, mSeTechMask);
                     if (nfaStat != NFA_STATUS_OK)
                         ALOGE ("Failed to configure UICC listen technologies.");
                     // Set technology routes to UICC if it's there
                     nfaStat = NFA_EeSetDefaultTechRouting(mEeInfo.ee_disc_info[i].ee_handle, mSeTechMask, mSeTechMask,
                             mSeTechMask);
                     if (nfaStat != NFA_STATUS_OK)
                         ALOGE ("Failed to configure UICC technology routing.");
                 }
             }
        }
    }

    // Tell the host-routing to only listen on Nfc-A
    nfaStat = NFA_CeSetIsoDepListenTech(NFA_TECHNOLOGY_MASK_A);
    if (nfaStat != NFA_STATUS_OK)
        ALOGE ("Failed to configure CE IsoDep technologies");

    // Register a wild-card for AIDs routed to the host
    nfaStat = NFA_CeRegisterAidOnDH (NULL, 0, stackCallback);
    if (nfaStat != NFA_STATUS_OK)
        ALOGE("Failed to register wildcard AID for DH");

    return true;
}