⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atcmd.cpp

📁 ril source code for Windows CE
💻 CPP
📖 第 1 页 / 共 4 页
字号:

#ifdef RIL_WATSON_REPORT
            // If the radio was previously hung, Watson logging was reported once and disabled to 
            // prevent duplicate logs reported when the radio hangs.
            // We are receiving data from the radio, so make sure the Watson called flag is reset
            // so subsequent problems will be reported.
            g_fWatsonCalled = FALSE;
#endif // RIL_WATSON_REPORT
            
#pragma prefast( suppress: 5484, "PREfast noise: dwDesiredAccess must be set to EVENT_ALL_ACCESS under CE" )
            HANDLE hReady = OpenEvent( EVENT_ALL_ACCESS, FALSE, SIMTKIT_READY_EVENT );
            if (g_CachedToolKitNotifs[0] && hReady != NULL && (WAIT_OBJECT_0 == WaitForSingleObject(hReady,0)))
            {
                UINT i;
                
                // shell's started.  safe to send toolkit notifications now.
                for (i = 0; (i < MAX_TOOLKITNOTIFS) && (g_CachedToolKitNotifs[i]); i++)
                {
                    CResponse *pRspCached = g_CachedToolKitNotifs[i];
                    void* pBlobCached;
                    UINT cbBlobCached;
                    pRspCached->GetBlob(pBlobCached, cbBlobCached);
                    (void)BroadcastRealBlobNotification(pRspCached->GetNotifyCode(), pBlobCached, cbBlobCached);
                    pRspCached->DeleteBlob();
                    pBlobCached = NULL;
                    cbBlobCached = 0;
                    delete pRspCached;
                    g_CachedToolKitNotifs[i] = NULL;
                }
            }

            if ( hReady != NULL )
            {
                CloseHandle( hReady );
                hReady = NULL;
            }

            /* SIM security notification */
            if ( !pRsp->FUnrecognized() )
            {
                if ( pRsp->GetNotifyCode() == RIL_RESULT_ERROR )
                {
                    DWORD dwLockedState = RIL_LOCKEDSTATE_UNKNOWN;

                    /* check if the command failed because of SIM security */
                    HRESULT hrErrorCode = pRsp->GetError();
                    switch( hrErrorCode )
                    {
                    case RIL_E_SIMPINREQUIRED:
                        dwLockedState = RIL_LOCKEDSTATE_SIM_PIN;
                        break;
                    case RIL_E_SIMPUKREQUIRED:
                        dwLockedState = RIL_LOCKEDSTATE_SIM_PUK;
                        break;
                    case RIL_E_PHSIMPINREQUIRED:
                        dwLockedState = RIL_LOCKEDSTATE_PH_SIM_PIN;
                        break;
                    case RIL_E_PHFSIMPINREQUIRED:
                        dwLockedState = RIL_LOCKEDSTATE_PH_FSIM_PIN;
                        break;
                    case RIL_E_PHFSIMPUKREQUIRED:
                        dwLockedState = RIL_LOCKEDSTATE_PH_FSIM_PUK;
                        break;
                    case RIL_E_SIMPIN2REQUIRED:
                        dwLockedState = RIL_LOCKEDSTATE_SIM_PIN2;
                        break;
                    case RIL_E_SIMPUK2REQUIRED:
                        dwLockedState = RIL_LOCKEDSTATE_SIM_PUK2;
                        break;
                    case RIL_E_NETWKPINREQUIRED:
                        dwLockedState = RIL_LOCKEDSTATE_PH_NET_PIN;
                        break;
                    case RIL_E_NETWKPUKREQUIRED:
                        dwLockedState = RIL_LOCKEDSTATE_PH_NET_PUK;
                        break;
                    case RIL_E_SUBSETPINREQUIRED:
                        dwLockedState = RIL_LOCKEDSTATE_PH_NETSUB_PIN;
                        break;
                    case RIL_E_SUBSETPUKREQUIRED:
                        dwLockedState = RIL_LOCKEDSTATE_PH_NETSUB_PUK;
                        break;
                    case RIL_E_SVCPINREQUIRED:
                        dwLockedState = RIL_LOCKEDSTATE_PH_SP_PIN;
                        break;
                    case RIL_E_SVCPUKREQUIRED:
                        dwLockedState = RIL_LOCKEDSTATE_PH_SP_PUK;
                        break;
                    case RIL_E_CORPPINREQUIRED:
                        dwLockedState = RIL_LOCKEDSTATE_PH_CORP_PIN;
                        break;
                    case RIL_E_CORPPUKREQUIRED:
                        dwLockedState = RIL_LOCKEDSTATE_PH_CORP_PUK;
                        break;
                    case RIL_E_INCORRECTPASSWORD:
                    default:
                        break;
                    }

                    if ( dwLockedState != RIL_LOCKEDSTATE_UNKNOWN )
                    {
                        RILSIMSECURITYSTATUS rsss;
                        memset( &rsss, 0, sizeof(rsss) );
                        rsss.cbSize = sizeof(rsss);
                        rsss.dwLockedState = dwLockedState;
                        rsss.dwSimSecurityState = RIL_SIMSECURITYSTATE_PINREQUESTED;
                        BroadcastRealBlobNotification( RIL_NOTIFY_SIMSECURITYSTATUS, &rsss, sizeof(rsss) );

                        /* keep track of the last locked state */
                        g_lastLockedState = rsss.dwLockedState;

                        /* queue up command marked CMDOPT_RETRYONSIMLOCKED */
                        if ( FWaitingForRsp() && m_pCurrCommand != NULL && m_pCurrCommand->CmdOptIsSet( CMDOPT_RETRYONSIMLOCKED ) )
                        {
                            /* not re-queuing dial commands */
                            BOOL fToQueue = ( !m_pCurrCommand->FDial() );

                            if ( fToQueue )
                            {
                                /* dup the command */
                                CCommand *pCmd = new CCommand;
                                if ( pCmd != NULL && pCmd->Init(m_pCurrCommand) )
                                {
                                    /* clear RETRYONSIMLOCKED */
                                    pCmd->ClrCmdOpt( CMDOPT_RETRYONSIMLOCKED );
                                    /* queue the command */
                                    /* dont anticipate a lot of commands in this state */
                                    if (!g_pSimLockedQueue->Put(pCmd, 0))
                                    {
                                        DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : CRilHandle::ResponseThread : Unable to queue cmd\r\n")));
                                        delete pCmd;
                                        pCmd = NULL;
                                    }
                                    pCmd = NULL;
                                }
                                else
                                {
                                    DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : CRilHandle::ResponseThread : Unable to construct or Init CCommand\r\n")));
                                    delete pCmd;
                                    pCmd = NULL;
                                }
                            }
                        }
                    }
                }
                else if ( FWaitingForRsp() && m_pCurrCommand != NULL && m_pCurrCommand->CmdOptIsSet( CMDOPT_UNLOCKING ) )
                {
                    RILSIMSECURITYSTATUS rsss;
                    memset( &rsss, 0, sizeof(rsss) );
                    rsss.cbSize = sizeof(rsss);
                    rsss.dwLockedState = g_lastLockedState;
                    rsss.dwSimSecurityState = RIL_SIMSECURITYSTATE_PINRECEIVED;
                    BroadcastRealBlobNotification( RIL_NOTIFY_SIMSECURITYSTATUS, &rsss, sizeof(rsss) );
                    g_lastLockedState = RIL_LOCKEDSTATE_UNKNOWN;

                    // Submit commands previously failed because of SIM security.
                    // If the SIM was unlocked, they'll now succeed.
                    // Otherwise they'll fail as expected.
                    CCommand *pCmd = NULL;
                    while (g_pSimLockedQueue->Get(pCmd, 0)==S_OK)
                    {
                        if (!g_pCmdQ->Put(pCmd, 0))
                        {
                            DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : CRilHandle::ResponseThread : Unable to submit cmd\r\n")));
                            delete pCmd;
                            pCmd = NULL;
                        }
                    }
                    pCmd = NULL;
                }
            }
                
            if (pRsp->FUnrecognized())
            {
                // We couldn't recognize this response -- assume it was corrupted and throw it away
#ifdef DEBUG
                DEBUGMSG(ZONE_INFO, (TEXT("RILDrv : i : CRilHandle::ResponseThread : Ignoring an unrecognized response: %d chars of %s\r\n"),
                           pRsp->GetLength(), VerboseString(TString(pRsp->GetData()))));
#endif // DEBUG
                RIL_EVENTLOG_MSG((RILLOG_EVENT_UNRECOGNIZEDRSP, PrintableString(pRsp->GetData(), pRsp->GetLength())));
                delete pRsp;
                pRsp = NULL;

            }
            else if (!pRsp->FUnsolicited() || 
                     (RIL_RESULT_BUSY == pRsp->GetNotifyCode() && FWaitingForRsp() && (NULL != m_pCurrCommand && m_pCurrCommand->FDial()) ))
            {
                if (!pRsp->GetNotifyCode() && m_fInited)
                {
                    DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : CRilHandle::ResponseThread : Module reset itself?!, rebooting via CPM\r\n")));
                }

                // This is a command result -- is someone waiting for it?

                void* rbBlob=NULL;
                UINT rcbBlob=0;
                bool fIsCPIN=FALSE;
                pRsp->GetBlob(rbBlob, rcbBlob);

                hr = PDD_IsSIMPINNotification(rbBlob, rcbBlob, pRsp->GetNotifyCode(), fIsCPIN);
                if ( FAILED( hr ) && E_NOTIMPL != hr )
                {
                    DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : HandleRxData : PDD_IsSIMPINNotification failed , hr = [0x%08x]\r\n"), hr));
                    goto Exit;
                }

                if (FWaitingForRsp() && ((FALSE == fDataOnNotificationComPort) || fIsCPIN))
                {
#if 0 // NOT USED
                    // Treat +CLCC responses while waiting for dial as notifications
                    if ((m_pCurrCommand->FDial()) && (ParseCLCCNotification(this, m_pCurrCommand, pRsp)))
                    {
                        delete pRsp;
                        pRsp = NULL;
                    }
                    else
#endif // 0
#ifdef RIL_RADIO_RESILIENCE
                    if ( FWaitingForRsp() && m_pCurrCommand && (RIL_RESULT_OK != pRsp->GetNotifyCode()) && (m_pCurrCommand->CmdOptIsSet(CMDOPT_CPINENTERED)) )
                    {
                        // Someone just tried to set the CPIN and failed.  Flush the CPIN cache so we don't auto-unlock the phone or PUK the SIM.
                        SavePINSecure("");
                    }

                    if (RIL_RESULT_ERROR == pRsp->GetNotifyCode())
                    {
                        UINT cbSize = 0;
                        LPVOID pBlob = NULL;
                        pRsp->GetBlob(pBlob, cbSize);
                        if((sizeof(HRESULT) == cbSize) && (RIL_E_RADIOREBOOTED == *(HRESULT *)pBlob))
                        {
                            // Reset g_rcdRingingCallData.fCalltypeValid
                            g_rcdRingingCallData.fCalltypeValid = FALSE;


                            // The command failed because the radio rebooted.
                            // Send up a disconnect notification just in case.
                            (void)m_pComDevice->ExitDataMode();
                            (void)BroadcastDWORDBlobNotification(RIL_NOTIFY_DISCONNECT,
                                                                 RIL_DISCINIT_REMOTE);
                        }
                    }
#endif // RIL_RADIO_RESILIENCE

                    // Yes -- place it into the Response Q
                    bool fQueueResponse = TRUE;
                    hr = PDD_QueueResponse(m_pCurrCommand, pRsp, fQueueResponse);

                    if ( FAILED( hr ) )
                    {
                        DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : HandleRxData : PDD_QueueResponse failed , hr = [0x%08x]\r\n"), hr));
                        goto Exit;
                    }

                    if ( fQueueResponse ) {
                            if (!QueueRsp(this, pRsp))
                            {
                                DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : CRilHandle::ResponseThread : QueueRsp failed\r\n")));
                                goto Exit;
                            }
                            DEBUGCHK(NULL == pRsp);
                    }
                }
                else
                {
                    // No -- see if it's one of the exceptions, and if not, throw it away
                    if (RIL_RESULT_NOCARRIER == pRsp->GetNotifyCode())
                    {
                        // This is an unsolicited NOCARRIER, the remote end must have hung up -- exit
                        //    out of the data mode and send out a notification
                        (void)m_pComDevice->ExitDataMode();

                        // Reset g_rcdRingingCallData.fCalltypeValid
                        g_rcdRingingCallData.fCalltypeValid = FALSE;

                        if (!g_rppPDDParams->fIgnoreUnsolicitedNoCarrier) {
                        (void)BroadcastDWORDBlobNotification(RIL_NOTIFY_DISCONNECT,
                                                             RIL_DISCINIT_REMOTE);
                        DEBUGMSG(ZONE_INFO, (TEXT("RILDrv : i : CRilHandle::ResponseThread : Detected remote disconnect (AT)\r\n")));
                            }
                        // Indicate call is inactive to audio driver only if call list is empty
                        IndicateCallActivityToAudioSubsystem(FALSE, TRUE);
                    }
                    else
                    {
#ifdef DEBUG
                        DEBUGMSG(ZONE_INFO, (TEXT("RILDrv : i : CRilHandle::ResponseThread : Ignoring a response no one is waiting for: %d chars of %s\r\n"),
                                   pRsp->GetLength(), VerboseString(TString(pRsp->GetData()))));
#endif // DEBUG
                        RIL_EVENTLOG_MSG((RILLOG_EVENT_NOONEWAITING, PrintableString(pRsp->GetData(), pRsp->GetLength())));
                    }
                    delete pRsp;
                    pRsp = NULL;
                }
            }
            else
            {
                if (RIL_RESULT_BUSY == pRsp->GetNotifyCode())
                {
                    // Reset g_rcdRingingCallData.fCalltypeValid
                    g_rcdRingingCallData.fCalltypeValid = FALSE;

                    (void)BroadcastDWORDBlobNotification(RIL_NOTIFY_DISCONNECT, RIL_DISCINIT_BUSY);
                    DEBUGMSG(ZONE_INFO, (TEXT("RILDrv : i : CRilHandle::ResponseThread : Detected busy signal\r\n")));
                }
                else
                {
                    // This is an unsolicited notification -- broadcast it to all clients
                    // (with the exceptions :
                    //     CONNECT's received while in data mode, because they are effectively
                    //         internal to RIL/VSP
                    //     Notify Codes of NULL, which means the parser is declining to send a
                    //         properly parsed radio notification

                    // Make sure the registration actually changed (rather than the location data only) before
                    //  sending up a RIL_NOTIFY_REGSTATUSCHANGED.
                    if ((!((RIL_NOTIFY_REGSTATUSCHANGED == pRsp->GetNotifyCode()) && g_fSuppressRegStatusNotification)) &&
                        (!((RIL_NOTIFY_GPRSREGSTATUSCHANGED == pRsp->GetNotifyCode()) && g_fSuppressGPRSRegStatusNotification)))
                    {
                        if ((!m_pComDevice->FDataMode() || RIL_NOTIFY_CONNECT != pRsp->GetNotifyCode()) &&
                            (NULL != pRsp->GetNotifyCode()))             
                        {
                            pRsp->GetBlob(pBlob, cbBlob);
                            (void)BroadcastRealBlobNotification(pRsp->GetNotifyCode(), pBlob, cbBlob);
                            pRsp->DeleteBlob();
                            pBlob = NULL;
                            cbBlob = 0;
                        }
                    }

                    // See if the last command caused us to enter (or return) to data mode
                    if (RIL_NOTIFY_CONNECT == pRsp->GetNotifyCode())
                    {
                        // Yes -- let the virtual serial driver know
                        if (m_pComDevice->EnterDataMode(szRemainder, cbRemainder))
                        {
                            szRemainder += cbRemainder;
                            cbRemainder = 0;

                            // Place a response to command that caused connection into the Response Queue
                            //    (the response will later be changed to OK)
                            if (!QueueRsp(this, pRsp))
                            {
                                DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : CRilHandle::ResponseThread : QueueRsp failed\r\n")));
                                goto Exit;
                            }
                            DEBUGCHK(NULL == pRsp);

                            DEBUGMSG(ZONE_INFO, (TEXT("RILDrv : i : CRilHandle::ResponseThread : Waiting for command mode\r\n")));
                            // Wait until module drops out of data mode
                            if (!m_pComDevice->WaitForCommandMode())
                            {
                                DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : CRilHandle::ResponseThread : WaitForCommandMode failed\r\n")));
                                goto Exit;
                            }
                            DEBUGMSG(ZONE_INFO, (TEXT("RILDrv : i : CRilHandle::ResponseThread : Done waiting for command mode\r\n")));
                        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -