Ejemplo n.º 1
0
//  Override from base class
BOOL CChannel_ATCmd::OpenPort()
{
    BOOL bRetVal = FALSE;

    RIL_LOG_INFO("CChannel_ATCmd::OpenPort() - Opening COM Port: %s...\r\n", g_szCmdPort);
    RIL_LOG_INFO("CChannel_ATCmd::OpenPort() - g_bIsSocket=[%d]...\r\n", g_bIsSocket);

    bRetVal = m_Port.Open(g_szCmdPort, g_bIsSocket);

    RIL_LOG_INFO("CChannel_ATCmd::OpenPort() - Opening COM Port: %s\r\n", bRetVal ? "SUCCESS"
            : "FAILED!");

    return bRetVal;
}
BOOL CellInfoCache::updateCache(const P_ND_N_CELL_INFO_DATA pData, const INT32 aItemsCount)
{
    BOOL ret = FALSE;

    RIL_LOG_VERBOSE("CellInfoCache::updateCache() - aItemsCount %d \r\n",aItemsCount);
    if (NULL == pData || aItemsCount > RRIL_MAX_CELL_ID_COUNT)
    {
        RIL_LOG_INFO("CellInfoCache::updateCache() - Invalid data\r\n");
        goto Error;
    }
    else
    {
        // if there were more items in the cache before
        if (aItemsCount != m_iCacheSize)
        {
            ret = TRUE;
        }
        else
        {
            for (INT32 storeIndex= 0; storeIndex < aItemsCount; storeIndex++)
            {
                if (checkCache(pData->pnCellData[storeIndex]) < 0 ) // new item
                {
                    ret = TRUE;
                    break;
                }
            }
        }
    }

    if (ret)
    {
        RIL_LOG_INFO("CellInfoCache::updateCache() -"
                "Updating cache with %d items\r\n", aItemsCount);
        // Access mutex
        CMutex::Lock(m_pCacheLock);
        m_iCacheSize = aItemsCount;
        memset(&m_sCellInfo, 0, sizeof(S_ND_N_CELL_INFO_DATA));
        for (INT32 j = 0; j < m_iCacheSize; j++)
        {
            m_sCellInfo.pnCellData[j] = pData->pnCellData[j];
        }
        // release mutex
        CMutex::Unlock(m_pCacheLock);
    }
Error:
    return ret;
}
Ejemplo n.º 3
0
// CContextInitString
void CContextInitString::Execute(BOOL bRes, UINT32 /*uiErrorCode*/)
{
    if (m_bFinalCmd)
    {
        RIL_LOG_INFO("CContextInitString::Execute() - Last command for init index [%d] on channel"
                " [%d] had result [%s]\r\n", m_eInitIndex, m_uiChannel, bRes ? "OK" : "FAIL");

        if (!bRes)
        {
            char szIndex[MAX_STRING_SIZE_FOR_INT] = { '\0' };
            char szChannel[MAX_STRING_SIZE_FOR_INT] = { '\0' };
            snprintf(szIndex, sizeof(szIndex), "%d", (int) m_eInitIndex);
            snprintf(szChannel, sizeof(szChannel), "%u", m_uiChannel);

            RIL_LOG_CRITICAL("CContextInitString::Execute() - "
                    "Init command send failed, set system state as uninitialized !\r\n");
            CSystemManager::GetInstance().SetInitializationUnsuccessful();
            DO_REQUEST_CLEAN_UP(4, "Init command failed", "", szIndex, szChannel);
        }
        else
        {
            CSystemManager::GetInstance().TriggerInitStringCompleteEvent(m_uiChannel, m_eInitIndex);
        }
    }
}
Ejemplo n.º 4
0
BOOL CPort::OpenSocket(const char* pszSocketName)
{
    RIL_LOG_VERBOSE("CPort::OpenSocket() - Enter\r\n");

    // TODO : Pull this from repository
    const char szSocketInit[] = "gsm";

    UINT32 uiBytesWritten = 0;
    UINT32 uiBytesRead = 0;
    char szResponse[10] = {0};

    BOOL fRet = FALSE;

    const UINT32 uiRetries = 30;
    const UINT32 uiInterval = 2000;

    for (UINT32 uiAttempts = 0; uiAttempts < uiRetries; uiAttempts++)
    {
        fRet = CFile::Open(m_pFile, pszSocketName, 0, 0, TRUE);

        if (fRet)
        {
            m_fIsPortOpen = TRUE;
            RIL_LOG_INFO("CPort::OpenSocket() - Port is open!!\r\n");
            break;
        }

        Sleep(uiInterval);
    }

    if (fRet)
    {
        if (Write(szSocketInit, strlen(szSocketInit), uiBytesWritten))
        {
            if (Read(szResponse, sizeof(szResponse), uiBytesRead))
            {
                m_fIsPortOpen = TRUE;
            }
            else
            {
                RIL_LOG_CRITICAL("CPort::OpenSocket() - Unable to read response from socket\r\n");
                fRet = FALSE;
            }
        }
        else
        {
            RIL_LOG_CRITICAL("CPort::OpenSocket() - Unable to write \"%s\" to socket\r\n",
                    szSocketInit);
            fRet = FALSE;
        }
    }

    RIL_LOG_VERBOSE("CPort::OpenSocket() - Exit\r\n");
    return fRet;
}
Ejemplo n.º 5
0
BOOL setmtu(int s, struct ifreq* ifr)
{
    ifr->ifr_mtu = CTE::GetTE().GetMTU();
    RIL_LOG_INFO("setmtu - calling SIOCSIFMTU\r\n");
    if(ioctl(s, SIOCSIFMTU, ifr) < 0)
    {
        RIL_LOG_CRITICAL("setmtu: ERROR: SIOCSIFMTU\r\n");
        return FALSE;
    }
    return TRUE;
}
Ejemplo n.º 6
0
BOOL setflags(int s, struct ifreq* ifr, int set, int clr)
{
    int ret;
    RIL_LOG_INFO("setflags - calling SIOCGIFFLAGS\r\n");
    ret = ioctl(s, SIOCGIFFLAGS, ifr);
    if (ret < 0)
    {
        RIL_LOG_CRITICAL("setflags : SIOCGIFFLAGS : %s\r\n", strerror(errno));
        return FALSE;
    }

    ifr->ifr_flags = (ifr->ifr_flags & (~clr)) | set;
    RIL_LOG_INFO("setflags - calling SIOCGIFFLAGS 2\r\n");
    ret = ioctl(s, SIOCSIFFLAGS, ifr);
    if (ret < 0)
    {
        RIL_LOG_CRITICAL("setflags: SIOCSIFFLAGS 2 : %s\r\n", strerror(errno));
        return FALSE;
    }
    return TRUE;
}
Ejemplo n.º 7
0
BOOL setaddr(int s, struct ifreq* ifr, const char* addr)
{
    int ret;
    init_sockaddr_in((struct sockaddr_in*) &ifr->ifr_addr, addr);
    RIL_LOG_INFO("setaddr - calling SIOCSIFADDR\r\n");
    errno = 0; // NOERROR
    ret = ioctl(s, SIOCSIFADDR, ifr);
    if (ret < 0)
    {
        RIL_LOG_CRITICAL("setaddr() : SIOCSIFADDR : %s\r\n",
            strerror(errno));
        return FALSE;
    }
    return TRUE;
}
Ejemplo n.º 8
0
BOOL CSilo_Data::ParseNoCarrier(CResponse* const pResponse, const char*& /*rszPointer*/)
{
    RIL_LOG_INFO("CSilo_Data::ParseNoCarrier() - Enter\r\n");

    BOOL fRet = FALSE;
    CChannel_Data* pChannelData = NULL;

    if (pResponse == NULL)
    {
        RIL_LOG_CRITICAL("CSilo_Data::ParseNoCarrier() : pResponse was NULL\r\n");
        goto Error;
    }

    pResponse->SetUnsolicitedFlag(TRUE);

    // Free this channel's context ID.
    pChannelData =
            CChannel_Data::GetChnlFromRilChannelNumber(m_pChannel->GetRilChannel());
    if (NULL != pChannelData)
    {
        RIL_LOG_INFO("CSilo_Data::ParseNoCarrier() : Calling DataConfigDown  chnl=[%u],"
                " cid=[%u]\r\n", m_pChannel->GetRilChannel(), pChannelData->GetContextID());

        //  Release network interface
        if (!CTE::GetTE().DataConfigDown(pChannelData->GetContextID(), TRUE))
        {
            RIL_LOG_CRITICAL("CSilo_Data::ParseNoCarrier() - DataConfigDown FAILED chnl=[%u],"
                    " cid=[%u]\r\n", m_pChannel->GetRilChannel(), pChannelData->GetContextID());
        }
    }
    fRet = TRUE;

Error:
    RIL_LOG_INFO("CSilo_Data::ParseNoCarrier() - Exit\r\n");
    return fRet;
}
Ejemplo n.º 9
0
//
// IMS network support reporting
//
BOOL CSilo_IMS::ParseCIREPI(CResponse* const pResponse, const char*& rszPointer)
{
    RIL_LOG_VERBOSE("CSilo_IMS::ParseCIREPI() - Enter\r\n");

    BOOL   fRet = FALSE;
    UINT32 uiNwimsvops = 0;
    char   szAlpha[MAX_BUFFER_SIZE];
    int pos = 0;
    sOEM_HOOK_RAW_UNSOL_IMS_SUPPORT_STATUS data;

    if (NULL == pResponse)
    {
        RIL_LOG_CRITICAL("CSilo_IMS::ParseCIREPI() - pResponse is NULL.\r\n");
        goto Error;
    }

    pResponse->SetUnsolicitedFlag(TRUE);

    // Throw out the alpha chars if there are any
    (void)ExtractQuotedString(rszPointer, szAlpha, MAX_BUFFER_SIZE, rszPointer);

    // Parse "<nwimsvops>"
    if (!ExtractUInt32(rszPointer, uiNwimsvops, rszPointer))
    {
        RIL_LOG_CRITICAL("CSilo_IMS::ParseCIREPI() - Could not parse IMS Voice over PS"
                "support indication\r\n");
        goto Error;
    }

    data.command = RIL_OEM_HOOK_RAW_UNSOL_IMS_SUPPORT_STATUS;
    data.status = uiNwimsvops;

    // Framework will trigger IMS registration depending on this information.
    RIL_LOG_INFO("CSilo_IMS::ParseCIREPI() - CIREPI=[%d]\r\n", uiNwimsvops);

    pResponse->SetResultCode(RIL_UNSOL_OEM_HOOK_RAW);

    if (!pResponse->SetData((void*)&data,
            sizeof(sOEM_HOOK_RAW_UNSOL_IMS_SUPPORT_STATUS), TRUE))
    {
        goto Error;
    }

    fRet = TRUE;
Error:
    RIL_LOG_VERBOSE("CSilo_IMS::ParseCIREPI() - Exit\r\n");
    return fRet;
}
Ejemplo n.º 10
0
//
// IMS SRVCC Handover reporting
//
BOOL CSilo_IMS::ParseCIREPH(CResponse* const pResponse, const char*& rszPointer)
{
    RIL_LOG_VERBOSE("CSilo_IMS::ParseCIREPH() - Enter\r\n");

    BOOL   fRet     = FALSE;
    UINT32 uiSrvcch = 0;
    char   szAlpha[MAX_BUFFER_SIZE];
    sOEM_HOOK_RAW_UNSOL_IMS_SRVCCH_STATUS data;

    if (NULL == pResponse)
    {
        RIL_LOG_CRITICAL("CSilo_IMS::ParseCIREPH() - pResponse is NULL.\r\n");
        goto Error;
    }

    pResponse->SetUnsolicitedFlag(TRUE);

    // Throw out the alpha chars if there are any
    (void)ExtractQuotedString(rszPointer, szAlpha, MAX_BUFFER_SIZE, rszPointer);

    // Parse "<srvcch>"
    if (!ExtractUInt32(rszPointer, uiSrvcch, rszPointer))
    {
        RIL_LOG_CRITICAL("CSilo_IMS::ParseCIREPH() - Could not parse IMS SRVCC"
                "Handover information\r\n");
        goto Error;
    }

    data.command = RIL_OEM_HOOK_RAW_UNSOL_IMS_SRVCCH_STATUS;
    data.status = uiSrvcch;

    RIL_LOG_INFO("CSilo_IMS::ParseCIREPH() - CIREPH=[%d]\r\n", uiSrvcch);

    pResponse->SetResultCode(RIL_UNSOL_OEM_HOOK_RAW);

    if (!pResponse->SetData((void*)&data,
            sizeof(sOEM_HOOK_RAW_UNSOL_IMS_SRVCCH_STATUS), TRUE))
    {
        goto Error;
    }

    fRet = TRUE;
Error:
    RIL_LOG_VERBOSE("CSilo_IMS::ParseCIREPH() - Exit\r\n");
    return fRet;
}
Ejemplo n.º 11
0
BOOL CPort::WaitForAvailableData(UINT32 uiTimeout)
{
    RIL_LOG_VERBOSE("CPort::WaitForAvailableData() - Enter\r\n");
    BOOL fRet = FALSE;
    UINT32 uiMask = 0;

    if (m_fIsPortOpen)
    {
        fRet = CFile::WaitForEvent(m_pFile, uiMask, uiTimeout);

        if(fRet)
        {
            if (uiMask & FILE_EVENT_ERROR)
            {
                RIL_LOG_CRITICAL("CPort::WaitForAvailableData() - FILE_EVENT_ERROR received"
                        " on port\r\n");
            }

            if (uiMask & FILE_EVENT_BREAK)
            {
                RIL_LOG_INFO("CPort::WaitForAvailableData() - FILE_EVENT_BREAK received on"
                        " port\r\n");
            }

            if (uiMask & FILE_EVENT_RXCHAR)
            {
                fRet = TRUE;
            }
        }
        else
        {
            RIL_LOG_CRITICAL("CPort::WaitForAvailableData() - Returning failure\r\n");
        }
    }
    else
    {
        CModemRestart::SaveRequestReason(3, "Port is not open", "", CFile::GetName(m_pFile));
        RIL_LOG_CRITICAL("CPort::WaitForAvailableData() - Port is not open!\r\n");
    }

Error:
    RIL_LOG_VERBOSE("CPort::WaitForAvailableData() - Exit\r\n");
    return fRet;
}
Ejemplo n.º 12
0
CInitializer* CTE_XMM2230::GetInitializer()
{
    RIL_LOG_VERBOSE("CTE_XMM2230::GetInitializer() - Enter\r\n");
    CInitializer* pRet = NULL;

    RIL_LOG_INFO("CTE_XMM2230::GetInitializer() - Creating CInit2230 initializer\r\n");
    m_pInitializer = new CInit2230();
    if (NULL == m_pInitializer)
    {
        RIL_LOG_CRITICAL("CTE_XMM2230::GetInitializer() - Failed to create a CInit2230 "
                "initializer!\r\n");
        goto Error;
    }

    pRet = m_pInitializer;

Error:
    RIL_LOG_VERBOSE("CTE_XMM2230::GetInitializer() - Exit\r\n");
    return pRet;
}
Ejemplo n.º 13
0
BOOL setaddr6(int sockfd6, struct ifreq* ifr, const char* addr)
{
    int ret;

    struct in6_ifreq ifr6;
    inet_pton(AF_INET6, addr, &ifr6.ifr6_addr);

    ioctl(sockfd6, SIOGIFINDEX, ifr);
    ifr6.ifr6_ifindex = ifr->ifr_ifindex;
    ifr6.ifr6_prefixlen = 64; //prefix_len;

    RIL_LOG_INFO("setaddr6() - calling SIOCSIFADDR ADDR:%s INET:%s\r\n",addr,ifr->ifr_name);
    errno = 0;
    ret = ioctl(sockfd6, SIOCSIFADDR, &ifr6);
    if (ret < 0)
    {
        RIL_LOG_CRITICAL("setaddr6() : SIOCSIFADDR : %s\r\n",
                strerror(errno));
        return FALSE;
    }

    return TRUE;
}
Ejemplo n.º 14
0
RIL_RESULT_CODE CTE_XMM2230::ParseBasebandVersion(RESPONSE_DATA& rRspData)
{
    RIL_LOG_VERBOSE("CTE_XMM2230::ParseBasebandVersion() - Enter\r\n");

    RIL_RESULT_CODE res = RRIL_RESULT_ERROR;
    const char* pszRsp = rRspData.szResponse;
    /* As baseband version is stored in a system property, it cannot be longer than
     * PROPERTY_VALUE_MAX-1 characters long (PROPERTY_VALUE_MAX counts the zero termination).
     *
     * + 1 is needed here as 'sscanf' will read PROPERTY_VALUE_MAX characters AND will add the
     * zero termination (cf comment above sscanf code).
     */
    char* pszBasebandVersion = (char*) malloc(PROPERTY_VALUE_MAX + 1);
    if (NULL == pszBasebandVersion)
    {
        RIL_LOG_CRITICAL("CTE_XMM2230::ParseBasebandVersion() - Could not allocate memory"
                "for pszBasebandVersion\r\n");
        goto Error;
    }

    memset(pszBasebandVersion, 0, PROPERTY_VALUE_MAX + 1);

    /* Modem version is what is reported between '*' in the +XGENDATA reply:
     *    +XGENDATA: "    XMM2230_REV_2.0 2013-Jul-31 13:42:17
     *    *CLV_2230_MODEM_01.1332.A*
     *    OK
     *
     * This is retrieved using 'sscanf':
     *   = %*[^*]  : consumes (without storing) everything that is not '*'
     *   = %*c     : consumes (without storing) the '*' character
     *   = %XXX[^*]: stores up to XXX chars or up to next '*' character in pszBasebandVersion
     *               XXX's numerical value is constructed by converting the PROPERTY_VALUE_MAX
     *               define to a string using the TO_STRING macro
     */
    if (!sscanf(pszRsp, "%*[^*]%*c%" TO_STRING(PROPERTY_VALUE_MAX) "[^*]", pszBasebandVersion))
    {
        RIL_LOG_CRITICAL("CTE_XMM2230::ParseBasebandVersion() - Could not "
                "extract the baseband version string.\r\n");
        goto Error;
    }
    if (pszBasebandVersion[PROPERTY_VALUE_MAX - 1] != '\0')
    {
        RIL_LOG_WARNING("CTE_XMM6360::ParseBasebandVersion() - "
                "Modem version too long, reporting truncated version.\r\n");
        pszBasebandVersion[PROPERTY_VALUE_MAX - 1] = '\0';
    }

    if (pszBasebandVersion[0] == '\0')
    {
        RIL_LOG_CRITICAL("CTE_XMM2230::ParseBasebandVersion() - "
                "Invalid baseband version string.\r\n");
        goto Error;
    }

    RIL_LOG_INFO("CTE_XMM2230::ParseBasebandVersion() - "
            "pszBasebandVersion=[%s]\r\n", pszBasebandVersion);

    rRspData.pData   = (void*)pszBasebandVersion;
    rRspData.uiDataSize  = sizeof(char*);

    res = RRIL_RESULT_OK;

Error:
    if (RRIL_RESULT_OK != res)
    {
        free(pszBasebandVersion);
        pszBasebandVersion = NULL;
    }

    RIL_LOG_VERBOSE("CTE_XMM2230::ParseBasebandVersion() - Exit\r\n");
    return res;
}
Ejemplo n.º 15
0
//
// Thermal sensor notification
//
BOOL CSilo_MISC::ParseXDRVI(CResponse* const pResponse, const char*& rszPointer)
{
    RIL_LOG_VERBOSE("CSilo_MISC::ParseXDRVI() - Enter\r\n");
    BOOL   fRet = FALSE;
    sOEM_HOOK_RAW_UNSOL_THERMAL_ALARM_IND* pData = NULL;
    UINT32 nIpcChrGrp;
    UINT32 nIpcChrTempThresholdInd;
    UINT32 nXdrvResult;
    UINT32 nSensorId;
    UINT32 nTemp;

    if (NULL == pResponse)
    {
        RIL_LOG_CRITICAL("CSilo_MISC::ParseXDRVI() - pResponse is NULL.\r\n");
        goto Error;
    }

    pResponse->SetUnsolicitedFlag(TRUE);

    // Extract "<IPC_CHR_GRP>"
    if (!ExtractUInt32(rszPointer, nIpcChrGrp, rszPointer))
    {
        RIL_LOG_CRITICAL("CSilo_MISC::ParseXDRVI() - Could not parse nIpcChrGrp.\r\n");
        goto Error;
    }

    // Parse <IPC_CHR_TEMP_THRESHOLD_IND>
    if (!SkipString(rszPointer, ",", rszPointer) ||
        !ExtractUInt32(rszPointer, nIpcChrTempThresholdInd, rszPointer))
    {
         RIL_LOG_CRITICAL("CSilo_MISC::ParseXDRVI() -"
                 " Unable to parse <IPC_CHR_TEMP_THRESHOLD_IND>!\r\n");
         goto Error;
    }

    // Parse <xdrv_result>
    if (!SkipString(rszPointer, ",", rszPointer) ||
        !ExtractUInt32(rszPointer, nXdrvResult, rszPointer))
    {
         RIL_LOG_CRITICAL("CSilo_MISC::ParseXDRVI() - Unable to parse <xdrv_result>!\r\n");
         goto Error;
    }

    // Parse <temp_sensor_id>
    if (!SkipString(rszPointer, ",", rszPointer) ||
        !ExtractUInt32(rszPointer, nSensorId, rszPointer))
    {
         RIL_LOG_CRITICAL("CSilo_MISC::ParseXDRVI() - Unable to parse <temp_sensor_id>!\r\n");
         goto Error;
    }

    // Parse <temp>
    if (!SkipString(rszPointer, ",", rszPointer) ||
        !ExtractUInt32(rszPointer, nTemp, rszPointer))
    {
         RIL_LOG_CRITICAL("CSilo_MISC::ParseXDRVI() - Unable to parse <temp>!\r\n");
         goto Error;
    }

    RIL_LOG_INFO("CSilo_MISC::ParseXDRVI - IPC_CHR_GRP: %u, IPC_CHR_TEMP_THRESHOLD_IND: %u,"
            " xdrv_result: %u\r\n", nIpcChrGrp, nIpcChrTempThresholdInd, nXdrvResult);
    RIL_LOG_INFO("CSilo_MISC::ParseXDRVI - temp_sensor_id: %u, temp: %u\r\n", nSensorId, nTemp);

    pData = (sOEM_HOOK_RAW_UNSOL_THERMAL_ALARM_IND*)malloc(
            sizeof(sOEM_HOOK_RAW_UNSOL_THERMAL_ALARM_IND));
    if (NULL == pData)
    {
        RIL_LOG_CRITICAL("CSilo_MISC::ParseXDRVI() - Could not allocate memory for pData.\r\n");
        goto Error;
    }
    memset(pData, 0, sizeof(sOEM_HOOK_RAW_UNSOL_THERMAL_ALARM_IND));

    pData->nCommand = RIL_OEM_HOOK_RAW_UNSOL_THERMAL_ALARM_IND;
    pData->nSensorId = nSensorId;
    pData->nTemp = nTemp;

    pResponse->SetResultCode(RIL_UNSOL_OEM_HOOK_RAW);

    if (!pResponse->SetData((void*)pData, sizeof(sOEM_HOOK_RAW_UNSOL_THERMAL_ALARM_IND), FALSE))
    {
        goto Error;
    }

    fRet = TRUE;
Error:
    if (!fRet)
    {
        free(pData);
        pData = NULL;
    }

    RIL_LOG_VERBOSE("CSilo_MISC::ParseXDRVI() - Exit\r\n");
    return fRet;
}
Ejemplo n.º 16
0
//
// No complexity is needed to parse the URC received for Coexistence purpose (+XMETRIC/+XNRTCWS).
// The goal is just to extract the URC name/value and notify the up-layer (CWS Manager) about it.
//
BOOL CSilo_MISC::ParseCoexURC(CResponse* const pResponse, const char*& rszPointer,
                              const char* pUrcPrefix)
{
    RIL_LOG_VERBOSE("CSilo_MISC::ParseCoexURC() - Enter\r\n");

    BOOL fRet = FALSE;
    char szExtInfo[MAX_BUFFER_SIZE] = {0};
    sOEM_HOOK_RAW_UNSOL_COEX_INFO* pData = NULL;

    if (NULL == pResponse)
    {
        RIL_LOG_CRITICAL("CSilo_MISC::ParseCoexURC() - pResponse is NULL.\r\n");
        goto Error;
    }

    pResponse->SetUnsolicitedFlag(TRUE);

    // Performing a backup of the URC string (rszPointer) into szExtInfo, to not modify rszPointer
    ExtractUnquotedString(rszPointer, '\r', szExtInfo, MAX_BUFFER_SIZE, rszPointer);

    RIL_LOG_VERBOSE("CSilo_MISC::ParseCoexURC() - URC prefix=[%s] URC value=[%s]\r\n",
            pUrcPrefix, szExtInfo);

    // Creating the response
    pData = (sOEM_HOOK_RAW_UNSOL_COEX_INFO*)malloc(
            sizeof(sOEM_HOOK_RAW_UNSOL_COEX_INFO));
    if (NULL == pData)
    {
        RIL_LOG_CRITICAL("CSilo_MISC::ParseCoexURC() -"
                " Could not allocate memory for pData.\r\n");
        goto Error;
    }

    memset(pData, 0, sizeof(sOEM_HOOK_RAW_UNSOL_COEX_INFO));

    // pData.response will contain the final result (URC name + URC value)
    // Adding the prefix of the URC (+XMETRIC or +XNRTCWS) to pData->response
    if (!CopyStringNullTerminate(pData->response, pUrcPrefix, COEX_INFO_BUFFER_SIZE))
    {
        RIL_LOG_CRITICAL("CSilo_MISC:ParseCoexURC - Copy of URC prefix failed\r\n");
        goto Error;
    }

    // Adding the value of the URC to pData->response
    if (!ConcatenateStringNullTerminate(pData->response, sizeof(pData->response), szExtInfo))
    {
        RIL_LOG_CRITICAL("CSilo_MISC::ParseCoexURC() : Failed to concat the URC "
                "prefix to its value!\r\n");
        goto Error;
    }

    RIL_LOG_INFO("CSilo_MISC::ParseCoexURC() - Final Response=[%s]\r\n", pData->response);

    pData->command = RIL_OEM_HOOK_RAW_UNSOL_COEX_INFO;
    pData->responseSize = strnlen(pData->response, COEX_INFO_BUFFER_SIZE);

    pResponse->SetResultCode(RIL_UNSOL_OEM_HOOK_RAW);

    if (!pResponse->SetData((void*)pData,
            sizeof(sOEM_HOOK_RAW_UNSOL_COEX_INFO), FALSE))
    {
        goto Error;
    }

    fRet = TRUE;
Error:
    if (!fRet)
    {
        free(pData);
        pData = NULL;
    }

    RIL_LOG_VERBOSE("CSilo_MISC::ParseCoexURC() - Exit\r\n");
    return fRet;
}
void CRequestInfoTable::GetRequestInfo(int requestID, REQ_INFO& rReqInfo)
{
    RIL_LOG_VERBOSE("CRequestInfoTable::GetRequestInfo() - Enter\r\n");

    // Set defaults if we can't find the request id
    rReqInfo.uiTimeout = CTE::GetTE().GetTimeoutAPIDefault();

    if (m_rgpRequestInfos == NULL)
    {
        RIL_LOG_INFO("CRequestInfoTable::GetRequestInfo() - m_rgpRequestInfos is NULL\r\n");
        goto Error;
    }
    else if (REQ_ID_NONE == requestID)
    {
        RIL_LOG_INFO("CRequestInfoTable::GetRequestInfo() - Request ID NONE given; assigning"
                " default values.\r\n");
        goto Error;
    }
    else if ((requestID >= REQ_ID_TOTAL && requestID < INTERNAL_REQ_ID_START) || (requestID < 0))
    {
        RIL_LOG_CRITICAL("CRequestInfoTable::GetRequestInfo() - Invalid request ID [0x%x]\r\n",
                requestID);
        goto Error;
    }

    // Internal request
    if (requestID >= INTERNAL_REQ_ID_START)
    {
        int index = requestID - INTERNAL_REQ_ID_START;

        CRepository repository;
        int iTemp = 0;

        memset(&rReqInfo, 0, sizeof(rReqInfo));

        rReqInfo.uiTimeout = CTE::GetTE().GetTimeoutAPIDefault();

        if (index < INTERNAL_REQ_ID_TOTAL)
        {
            if (repository.Read(g_szGroupInternalRequestTimeouts,
                    g_ReqInternal[index].reqInfo.szName, iTemp))
            {
                rReqInfo.uiTimeout = (UINT32)iTemp;
            }
        }
    }
    // Request from ril
    else if (NULL == m_rgpRequestInfos[requestID])
    {
        CRepository repository;
        int iTemp = 0;

        memset(&rReqInfo, 0, sizeof(rReqInfo));

        if (repository.Read(g_szGroupRequestTimeouts, g_pReqInfo[requestID].szName, iTemp))
        {
            rReqInfo.uiTimeout = (UINT32)iTemp;
        }
        else
        {
            rReqInfo.uiTimeout = CTE::GetTE().GetTimeoutAPIDefault();
        }

        // Use WAIT_FOREVER timeout if given time was 0
        if (!rReqInfo.uiTimeout)
        {
            rReqInfo.uiTimeout = WAIT_FOREVER;
        }

        else if (CHardwareConfig::GetInstance().IsMultiSIM())
        {
            // Timeout values need to be extended for Multi SIM capable modems,
            // depending on type of command (ie. network/non-network)
            switch (requestID)
            {
                case RIL_REQUEST_SETUP_DATA_CALL: // +CGACT, +CGDATA, +CGDCONT, +CGPADDR, +XDNS
                case RIL_REQUEST_DEACTIVATE_DATA_CALL:
                    rReqInfo.uiTimeout = 2 * rReqInfo.uiTimeout + 50000;
                    break;

                // network commands
                case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: // +CCFC
                case RIL_REQUEST_SET_CALL_FORWARD:          // +CCFC
                case RIL_REQUEST_QUERY_CALL_WAITING:        // +CCWA
                case RIL_REQUEST_SET_CALL_WAITING:          // +CCWA
                case RIL_REQUEST_RADIO_POWER:               // +CFUN
                case RIL_REQUEST_DATA_CALL_LIST:            // +CGACT?
                case RIL_REQUEST_HANGUP:                    // +CHLD
                case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: // +CHLD
                case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: // +CHLD
                case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: // +CHLD
                case RIL_REQUEST_CONFERENCE:                // +CHLD
                case RIL_REQUEST_UDUB:                      // +CHLD
                case RIL_REQUEST_SEPARATE_CONNECTION:       // +CHLD
                case RIL_REQUEST_EXPLICIT_CALL_TRANSFER:    // +CHLD
                case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: // +CLCK
                case RIL_REQUEST_QUERY_FACILITY_LOCK:       // +CLCK
                case RIL_REQUEST_SET_FACILITY_LOCK:         // +CLCK
                case RIL_REQUEST_GET_CLIR:                  // +CLIR?
                case RIL_REQUEST_SET_CLIR:                  // +CLIR
                case RIL_REQUEST_SEND_SMS:                  // +CMGS
                case RIL_REQUEST_SMS_ACKNOWLEDGE:           // +CNMA
                case RIL_REQUEST_OPERATOR:                  // +XCOPS
                case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: // +COPS?
                case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS:  // +COPS=?
                case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: // +COPS
                case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: // +COPS
                case RIL_REQUEST_SEND_USSD:                 // +CUSD
                case RIL_REQUEST_CANCEL_USSD:               // +CUSD
                case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: // +SATD
                case RIL_REQUEST_DTMF_START:                // +XVTS
                case RIL_REQUEST_DTMF_STOP:                 // +XVTS
                case RIL_REQUEST_DIAL:                      // ATD
                // non-network cmds requiring response
                case RIL_REQUEST_DELETE_SMS_ON_SIM:         // +CMGD
                case RIL_REQUEST_SEND_SMS_EXPECT_MORE:      // +CMMS, +CMGS
                case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG: // +CSCB?
                case RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION: // +CSCB
                case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS:  // +XCELLINFO
                case RIL_REQUEST_GET_CELL_INFO_LIST:        // +XCELLINFO
                case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS:  // +XTESM
                    rReqInfo.uiTimeout = 2 * rReqInfo.uiTimeout + 10000;
                    break;
            }
        }

        // Cache the data we just read (taking the cache access lock)
        if (m_pCacheAccessMutex)
        {
            CMutex::Lock(m_pCacheAccessMutex);
        }
        // Recheck if the cache is still empty
        if (NULL == m_rgpRequestInfos[requestID])
        {
            REQ_INFO* pNewReqInfo = new REQ_INFO;
            if (NULL != pNewReqInfo)
            {
                *pNewReqInfo = rReqInfo;
                m_rgpRequestInfos[requestID] = pNewReqInfo;
            }
        }
        if (m_pCacheAccessMutex)
        {
            CMutex::Unlock(m_pCacheAccessMutex);
        }
    }
    else
    {
        rReqInfo = *m_rgpRequestInfos[requestID];
    }

Error:
    RIL_LOG_INFO("CRequestInfoTable::GetRequestInfo() - RequestID %d: Timeout [%u]\r\n",
            requestID, rReqInfo.uiTimeout);

    RIL_LOG_VERBOSE("CRequestInfoTable::GetRequestInfo() - Exit\r\n");
}
Ejemplo n.º 18
0
void ProfileProcess::run()
{
    RIL_LOG_VERBOSE("ProfileProcess::run() - Enter\r\n");
    bool isTeWriteNeeded = true;
    bool isMtWriteNeeded = true;
    // Char array that holds MT profile read in NVM
    char szReadMtProfile[UsatInitStateMachine::MAX_SIZE_PROFILE * 2 + 1] = {'\0'};
    // Char array that holds TE profile to write read from repository.txt
    char szDefaultTeProfile[UsatInitStateMachine::MAX_SIZE_PROFILE * 2 + 1] = {'\0'};
    // Char array that holds calculated TE profile to write
    char szTeCalculatedProfile[UsatInitStateMachine::MAX_SIZE_PROFILE * 2 + 1] = {'\0'};
    // Char array that holds calculated MT profile to write
    char szMtCalculatedProfile[UsatInitStateMachine::MAX_SIZE_PROFILE * 2 + 1] = {'\0'};
    // Array of char array that holds all of the profiles read in NVM
    char** ppszProfiles = NULL;
    // Byte array that holds TE profile to write read in repository.txt
    const BYTE* achDefaultTeProfile;
    // Byte array that holds MT mask to apply read in repository.txt
    const BYTE* achDefaultMtMask;
    // Char array that holds TE profile read in NVM
    const char* pszReadTeProfile;
    // Char array that holds MT profile read in NVM
    const char* pszReadMtProfile;
    // Char array that holds MT only profile read in NVM
    const char* pszReadMtOnlyProfile;
    // Features that can be both supported by MT and TE : see 3GPP 31.111 Annex Q
    // Byte 3.8: REFRESH
    // Byte 5.1: SET_UP_EVENT_LIST
    // Byte 12.1: OPEN_CHANNEL
    // Byte 12.2: CLOSE_CHANNEL
    // Byte 12.3: RECEIVE_DATA
    // Byte 12.4: SEND_DATA
    // Byte 12.5: GET_CHANNEL_STATUS
    // Byte 12.6: SERVICE_SEARCH
    // Byte 12.7: GET_SERVICE_INFORMATION
    // Byte 12.8: DECLARE_SERVICE
    const char TE_MT_SUPPORTED[]
            = "0000800001000000000000FF0000000000000000000000000000000000000000";
    CCatProfile* pCatProfile = m_usatInitStateMachine.GetCatProfile();

    ppszProfiles = m_usatInitStateMachine.GetProfileArray();

    if (NULL == ppszProfiles)
    {
        RIL_LOG_CRITICAL("ProfileProcess::run() - Profile array is NULL\r\n");
        goto Out;
    }

    pszReadTeProfile = isValidString(ppszProfiles[TE_PROFILE_STORAGE])
            ? ppszProfiles[TE_PROFILE_STORAGE]
            : UsatInitStateMachine::DEFAULT_PROFILE;

    pszReadMtProfile = isValidString(ppszProfiles[MT_PROFILE_STORAGE])
            ? ppszProfiles[MT_PROFILE_STORAGE]
            : UsatInitStateMachine::DEFAULT_PROFILE;

    pszReadMtOnlyProfile = isValidString(ppszProfiles[MT_ONLY_PROFILE_STORAGE])
            ? ppszProfiles[MT_ONLY_PROFILE_STORAGE]
            : UsatInitStateMachine::DEFAULT_PROFILE;

    if (NULL == pCatProfile)
    {
        RIL_LOG_CRITICAL("ProfileProcess::run() - pCatProfile is NULL\r\n");
        goto Out;
    }

    // Set new TE profile to use to the value in NVM in case of an error
    pCatProfile->SetTeProfile(pszReadTeProfile, strlen(pszReadTeProfile));

    // Get TE profile read in repository.txt that should be written in NVM
    achDefaultTeProfile = pCatProfile->GetTeDefaultProfile();

    if (NULL == achDefaultTeProfile)
    {
        RIL_LOG_CRITICAL("ProfileProcess::run() - TE profile read is NULL\r\n");
        goto Out;
    }

    // Get MT mask read in repository.txt that should be apply to MT profile to disable
    // some modem features
    achDefaultMtMask = pCatProfile->GetMtMask();

    if (NULL == achDefaultMtMask)
    {
        RIL_LOG_CRITICAL("ProfileProcess::run() - MT mask read is NULL\r\n");
        goto Out;
    }

    if (!convertByteArrayIntoString(achDefaultTeProfile, UsatInitStateMachine::MAX_SIZE_PROFILE,
            szDefaultTeProfile))
    {
        RIL_LOG_CRITICAL("ProfileProcess::run() - Could not convert TE into string\r\n");
        goto Out;
    }

    // compare if TE read is equal to TE to write read in repository.txt
    if (CompareProfiles(pszReadTeProfile, szDefaultTeProfile))
    {
        RIL_LOG_VERBOSE("ProfileProcess::run() - Same TE\r\n");
        isTeWriteNeeded = false;
        // copy read TE to calculated TE
        memcpy(szTeCalculatedProfile, szDefaultTeProfile, strlen(szDefaultTeProfile) + 1);
    }
    else
    {
        // calculate new TE profile by doing Te = TeRepository AND NOT MtOnly
        if (!CalculateTeProfile(szDefaultTeProfile, pszReadMtOnlyProfile, szTeCalculatedProfile))
        {
            RIL_LOG_CRITICAL("ProfileProcess::run() - Cannot calculate TE profile\r\n");
            goto Out;
        }

        // Check if TE writing is needed by comparing calculated TE to the modem TE
        isTeWriteNeeded = !CompareProfiles(szTeCalculatedProfile, pszReadTeProfile);

        // Set new calculated TE profile
        pCatProfile->SetTeProfile(szTeCalculatedProfile, strlen(szTeCalculatedProfile));
    }

    // Calculate new MT profile by doing Mt = MtModem AND NOT Te
    // then the MT mask is applied to remove some modem features
    if (!CalculateMtProfile(pszReadMtProfile, szTeCalculatedProfile, TE_MT_SUPPORTED,
            achDefaultMtMask, szMtCalculatedProfile))
    {
        RIL_LOG_CRITICAL("ProfileProcess::run() - Cannot calculate MT profile\r\n");
        goto Out;
    }

    // Check if writing MT is needed by comparing it to MT read in NVM
    isMtWriteNeeded = !CompareProfiles(szMtCalculatedProfile, pszReadMtProfile);

    if (!isMtWriteNeeded && !isTeWriteNeeded)
    {
        RIL_LOG_INFO("ProfileProcess::run() - No need to write profiles\r\n");
        goto Out;
    }

    // Write profiles
    CTE::GetTE().WriteUsatProfiles(szTeCalculatedProfile, isTeWriteNeeded, szMtCalculatedProfile,
            isMtWriteNeeded);
    return;

Out:
    if (m_usatInitStateMachine.GetReadyToActivate()
            && m_usatInitStateMachine.GetUiccState() == UsatInitStateMachine::UICC_ACTIVE)
    {
        m_usatInitStateMachine.PassToNextEvent(UsatInitStateMachine::SIM_READY_TO_ACTIVATE);
    }
}
Ejemplo n.º 19
0
void UsatState::SimReadyToActivate()
{
    RIL_LOG_INFO("UsatState::SimReadyToActivate() - Nothing to do\r\n");
}
Ejemplo n.º 20
0
void UsatState::SimReadyForReset()
{
    RIL_LOG_INFO("UsatState::SimReadyForReset() - Nothing to do\r\n");
}
Ejemplo n.º 21
0
void UsatState::SimUnavailable()
{
    RIL_LOG_INFO("UsatState::SimUnavailable() - Nothing to do\r\n");
}
Ejemplo n.º 22
0
void UsatState::ProfileRead()
{
    RIL_LOG_INFO("UsatState::ProfileRead() - Nothing to do\r\n");
}
Ejemplo n.º 23
0
//
// IMS-Register notification
//
BOOL CSilo_IMS::ParseCIREGU(CResponse* const pResponse, const char*& rszPointer)
{
    RIL_LOG_VERBOSE("CSilo_IMS::ParseCIREGU() - Enter\r\n");

    BOOL   fRet     = FALSE;
    UINT32 uiRegInfo = 0;
    char   szExtInfo[MAX_BUFFER_SIZE];
    char   szAlpha[MAX_BUFFER_SIZE];
    int pos = 0;
    sOEM_HOOK_RAW_UNSOL_IMS_REG_STATUS data;

    if (NULL == pResponse)
    {
        RIL_LOG_CRITICAL("CSilo_IMS::ParseCIREGU() - pResponse is NULL.\r\n");
        goto Error;
    }

    pResponse->SetUnsolicitedFlag(TRUE);

    // Throw out the alpha chars if there are any
    (void)ExtractQuotedString(rszPointer, szAlpha, MAX_BUFFER_SIZE, rszPointer);

    // Parse "<reg_info>"
    if (!ExtractUInt32(rszPointer, uiRegInfo, rszPointer))
    {
        RIL_LOG_CRITICAL("CSilo_IMS::ParseCIREGU() - Could not parse IMS registration"
                "status indication\r\n");
        goto Error;
    }

    // Parse ",<ext_info>" if any. Debug purpose only.
    if (SkipString(rszPointer, ",", rszPointer)
            && ExtractUnquotedString(rszPointer, m_cTerminator, szExtInfo,
                    MAX_BUFFER_SIZE, rszPointer))
    {
        RIL_LOG_INFO("CSilo_IMS::ParseCIREGU() - IMS capabilities: %s", szExtInfo);
    }

    data.command = RIL_OEM_HOOK_RAW_UNSOL_IMS_REG_STATUS;
    data.status = uiRegInfo;

    CTE::GetTE().SetImsRegistrationStatus(uiRegInfo);

    RIL_LOG_VERBOSE("CSilo_IMS::ParseCIREGU() - CIREGU=[%d]\r\n", uiRegInfo);

    pResponse->SetResultCode(RIL_UNSOL_OEM_HOOK_RAW);

    if (!pResponse->SetData((void*)&data,
            sizeof(sOEM_HOOK_RAW_UNSOL_IMS_REG_STATUS), TRUE))
    {
        goto Error;
    }

    /*
     * When the IMS registration status change force the framework to query the data
     * registration state by completing RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED.
     */
    RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED, NULL, 0);

    fRet = TRUE;
Error:
    RIL_LOG_VERBOSE("CSilo_IMS::ParseCIREGU() - Exit\r\n");
    return fRet;
}
Ejemplo n.º 24
0
void triggerCellInfoList(void* param)
{
    // querying cell information when radio request pending or not registered
    // results in no response from modem.
    if (NULL == param || CTE::GetTE().IsRadioRequestPending() || !CTE::GetTE().IsRegistered())
    {
        CTE::GetTE().SetCellInfoTimerRunning(FALSE);
        return;
    }

    // Get the CellInfo rate and compare.
    // if the newly set rate is less or equal,continue reading cellinfo from modem
    // if it is more, then start a new timed call back with the difference in timeout
    RIL_LOG_VERBOSE("triggerCellInfoList- Enter\r\n");
    int storedRate = CTE::GetTE().GetCellInfoListRate();
    int requestedRate = (int)param;
    RIL_LOG_INFO("triggerCellInfoList- StoredRate %d Rate with callback %d\r\n",
            storedRate, requestedRate);
    if (requestedRate >= storedRate || requestedRate <= 0)
    {
        REQUEST_DATA rReqData;

        memset(&rReqData, 0, sizeof(REQUEST_DATA));
        if (!CopyStringNullTerminate(rReqData.szCmd1, CTE::GetTE().GetReadCellInfoString(),
                sizeof(rReqData.szCmd1)))
        {
            RIL_LOG_CRITICAL("triggerCellInfoList() - Unable to create cellinfo command!\r\n");
            return;
        }

        rReqData.pContextData = (void*)requestedRate;

        // The rate setting has not changed while waiting for time out
        // read the cell information and report to framework
        CCommand* pCmd = new CCommand(g_pReqInfo[RIL_REQUEST_GET_CELL_INFO_LIST].uiChannel,
                NULL, RIL_REQUEST_GET_CELL_INFO_LIST, rReqData,
                &CTE::ParseUnsolCellInfoListRate, &CTE::PostUnsolCellInfoListRate);

        if (pCmd)
        {
            if (!CCommand::AddCmdToQueue(pCmd))
            {
                RIL_LOG_CRITICAL("triggerCellInfoList() - Unable to queue command!\r\n");
                delete pCmd;
                pCmd = NULL;
            }
        }
        else
        {
            RIL_LOG_CRITICAL("triggerCellInfoList() - "
                    "Unable to allocate memory for new command!\r\n");
        }

        /*
         * requestedRate <= 0 means that the cell information query is triggered on
         * cell information change. Stop the timer only if the query is due to
         * timer expiry.
         */
        if (requestedRate > 0)
        {
            CTE::GetTE().SetCellInfoTimerRunning(FALSE);
        }
    }
    // the settings have changed to not to report CELLINFO
    else if (INT_MAX == storedRate)
    {
        CTE::GetTE().SetCellInfoTimerRunning(FALSE);
        RIL_LOG_INFO("triggerCellInfoList- Unsol cell info disabled: %d\r\n", storedRate);
    }
    else
    {
         // A new rate setting, re run the timer for the difference
         if (storedRate > requestedRate)
         {
             RIL_requestTimedCallback(triggerCellInfoList,
                   (void*)storedRate, ((storedRate - requestedRate) / 1000), 0);
         }
    }
    RIL_LOG_VERBOSE("triggerCellInfoList- Exit\r\n");
}
//
// No complexity is needed to parse the URC received for Coexistence purpose (+XMETRIC/+XNRTCWS).
// The goal is just to extract the URC name/value and notify the up-layer (CWS Manager) about it.
//
BOOL CSilo_rfcoexistence::ParseCoexReportURC(CResponse* const pResponse, const char*& rszPointer,
                              const char* pUrcPrefix)
{
    RIL_LOG_VERBOSE("CSilo_rfcoexistence::ParseCoexReportURC() - Enter\r\n");

    BOOL bRet = FALSE;
    // prefix can be "+XMETRIC: " or "+XNRTCWSI: "
    const int MAX_PREFIX_SIZE = 12;
    // KW fix, total size of pData->response is COEX_INFO_BUFFER_SIZE
    // pData->response is made by pUrcPrefix + szExtInfo
    char szExtInfo[COEX_INFO_BUFFER_SIZE - MAX_PREFIX_SIZE] = {0};
    sOEM_HOOK_RAW_UNSOL_COEX_REPORT* pData = NULL;

    if (NULL == pResponse)
    {
        RIL_LOG_CRITICAL("CSilo_rfcoexistence::ParseCoexReportURC() - pResponse is NULL.\r\n");
        goto Error;
    }

    pResponse->SetUnsolicitedFlag(TRUE);

    // Extract the URC string (rszPointer) into szExtInfo, to not modify rszPointer
    ExtractUnquotedString(rszPointer, '\r', szExtInfo,
                             (COEX_INFO_BUFFER_SIZE - MAX_PREFIX_SIZE), rszPointer);

    RIL_LOG_VERBOSE("CSilo_rfcoexistence::ParseCoexReportURC()- URC prefix=[%s] URC value=[%s]\r\n",
            pUrcPrefix, szExtInfo);

    // Creating the response
    pData = (sOEM_HOOK_RAW_UNSOL_COEX_REPORT*) malloc(sizeof(sOEM_HOOK_RAW_UNSOL_COEX_REPORT));
    if (NULL == pData)
    {
        RIL_LOG_CRITICAL("CSilo_rfcoexistence::ParseCoexReportURC() -"
                " Could not allocate memory for pData.\r\n");
        goto Error;
    }

    memset(pData, 0, sizeof(sOEM_HOOK_RAW_UNSOL_COEX_REPORT));

    // pData.response will contain the final result (URC name + URC value)
    // Adding the prefix of the URC (+XMETRIC or +XNRTCWS) to pData->response
    if (!CopyStringNullTerminate(pData->response, pUrcPrefix, MAX_PREFIX_SIZE))
    {
        RIL_LOG_CRITICAL("CSilo_rfcoexistence:ParseCoexReportURC - Copy of URC prefix failed\r\n");
        goto Error;
    }

    // Adding the value of the URC to pData->response
    if (!ConcatenateStringNullTerminate(pData->response, sizeof(pData->response), szExtInfo))
    {
        RIL_LOG_CRITICAL("CSilo_rfcoexistence::ParseCoexReportURC() : Failed to concat the URC "
                "prefix to its value!\r\n");
        goto Error;
    }

    RIL_LOG_INFO("CSilo_rfcoexistence::ParseCoexReportURC() - Final Response=[%s]\r\n",
            pData->response);

    pData->commandId = RIL_OEM_HOOK_RAW_UNSOL_COEX_REPORT;
    pData->responseSize = strlen(pData->response);

    pResponse->SetResultCode(RIL_UNSOL_OEM_HOOK_RAW);

    if (!pResponse->SetData(pData, sizeof(sOEM_HOOK_RAW_UNSOL_COEX_REPORT), FALSE))
    {
        goto Error;
    }

    bRet = TRUE;
Error:
    if (!bRet)
    {
        free(pData);
        pData = NULL;
    }

    RIL_LOG_VERBOSE("CSilo_rfcoexistence::ParseCoexReportURC() - Exit\r\n");
    return bRet;
}
Ejemplo n.º 26
0
void UsatState::ProfileToActivate()
{
    RIL_LOG_INFO("UsatState::ProfileToActivate() - Nothing to do\r\n");
}
Ejemplo n.º 27
0
void UsatState::run()
{
    RIL_LOG_INFO("UsatState::run() - Nothing to do\r\n");
}
Ejemplo n.º 28
0
// Helper function to convert IP addresses to Android-readable format.
// szIpIn [IN] - The IP string to be converted
// szIpOut [OUT] - The converted IPv4 address in Android-readable format if there is an IPv4 address.
// uiIpOutSize [IN] - The size of the szIpOut buffer
// szIpOut2 [OUT] - The converted IPv6 address in Android-readable format if there is an IPv6 address.
// uiIpOutSize [IN] - The size of szIpOut2 buffer
//
// If IPv4 format a1.a2.a3.a4, then szIpIn is copied to szIpOut.
// If Ipv6 format:
// Convert a1.a2.a3.a4.a5. ... .a15.a16 to XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX IPv6 format
// output is copied to szIpOut2
// If Ipv4v6 format:
// Convert a1.a2.a3.a4.a5. ... .a19.a20 to
// a1.a2.a3.a4 to szIpOut
// XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX (a5-a20) to szIpOut2
// If szIpOut2 is NULL, then this parameter is ignored
BOOL ConvertIPAddressToAndroidReadable(char* szIpIn,
                                       char* szIpOut,
                                       UINT32 uiIpOutSize,
                                       char* szIpOut2,
                                       UINT32 uiIpOutSize2)
{
    RIL_LOG_VERBOSE("ConvertIPAddressToAndroidReadable() - Enter\r\n");
    BOOL bRet = FALSE;
    const int MAX_AIPV4_INDEX = 4;      // Number of 'a' values read from modem for IPv4 case
    const int MAX_AIPV6_INDEX = 16;     // Number of 'a' values read from modem for IPv6 case
    const int MAX_AIPV4V6_INDEX = 20;   // Number of 'a' values read from modem for IPv4v6 case

    //  Sanity checks
    if ( (NULL == szIpIn) || (NULL == szIpOut) || (0 == uiIpOutSize))
    {
        RIL_LOG_CRITICAL("ConvertIPAddressToAndroidReadable() : Invalid inputs!\r\n");
        return FALSE;
    }

    //  Count number of '.'
    int nDotCount = 0;
    for (UINT32 i = 0; szIpIn[i] != '\0'; i++)
    {
        if ('.' == szIpIn[i])
        {
            //  Found a '.'
            nDotCount++;
        }
    }

    //  If 3 dots, IPv4. If 15 dots, IPv6. If 19 dots, then IPv4v6.
    switch(nDotCount)
    {
        case 3:
        {
            //  Extract a1...a4 into uiIP.
            //  Then convert aAddress to szIpOut.
            UINT32 uiIP[MAX_AIPV4_INDEX] = {'\0'};
            if (EOF == sscanf(szIpIn, "%u.%u.%u.%u",
                    &uiIP[0], &uiIP[1], &uiIP[2], &uiIP[3]))
            {
                RIL_LOG_CRITICAL("ConvertIPAddressToAndroidReadable() -"
                        " cannot sscanf into ipv4 format\r\n");
                goto Error;
            }

            if (0 == uiIP[0] && 0 == uiIP[0] && 0 == uiIP[0] && 0 == uiIP[0])
            {
                RIL_LOG_INFO("ConvertIPAddressToAndroidReadable() -"
                        "Invalid address - ignore\r\n");
            }
            else
            {
                if (snprintf(szIpOut, uiIpOutSize,
                        "%u.%u.%u.%u", uiIP[0], uiIP[1], uiIP[2], uiIP[3]) <= 0)
                {
                    RIL_LOG_CRITICAL("ConvertIPAddressToAndroidReadable() -"
                            " error with snprintf() ipv4 part\r\n");
                    goto Error;
                }
            }
        }
        break;

        case 15:
        {
            //  IPv6 format.  Need to re-format this to Android IPv6 format.

            //  Extract a1...a16 into aIP.
            //  Then convert aAddress to szIpOut.
            UINT32 aIP[MAX_AIPV6_INDEX] = {0};
            unsigned char acIP[MAX_AIPV6_INDEX] = {0};
            if (EOF == sscanf(szIpIn, "%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u",
                    &aIP[0], &aIP[1], &aIP[2], &aIP[3], &aIP[4], &aIP[5], &aIP[6], &aIP[7],
                    &aIP[8], &aIP[9], &aIP[10], &aIP[11], &aIP[12], &aIP[13], &aIP[14], &aIP[15]))
            {
                RIL_LOG_CRITICAL("ConvertIPAddressToAndroidReadable() -"
                        " cannot sscanf into aIP[]! ipv6\r\n");
                goto Error;
            }

            //  Loop through array, check values from modem is from 0-255.
            for (int i=0; i<MAX_AIPV6_INDEX; i++)
            {
                if (aIP[i] > 255)
                {
                    //  Value is not between 0-255.
                    RIL_LOG_CRITICAL("ConvertIPAddressToAndroidReadable() -"
                            " ipv6 aIP[%d] not in range 0-255. val=%u\r\n", i, aIP[i]);
                    goto Error;
                }
            }

            //  Convert unsigned int to unsigned char (for inet_ntop)
            //  The value read in should be in range 0-255.
            for (int i=0; i<MAX_AIPV6_INDEX; i++)
            {
                acIP[i] = (unsigned char)(aIP[i]);
            }

            if (NULL != szIpOut2 && 0 != uiIpOutSize2)
            {

                if (inet_ntop(AF_INET6, (void*)acIP, szIpOut2, uiIpOutSize2) <= 0)
                {
                    RIL_LOG_CRITICAL("ConvertIPAddressToAndroidReadable() -"
                            " cannot inet_ntop ipv6\r\n");
                    goto Error;
                }
            }
        }
        break;

        case 19:
        {
            //  IPv4v6 format.  Grab a1.a2.a3.a4 and that's the IPv4 part.  The rest is IPv6.
            //  Extract a1...a20 into aIP.
            //  Then IPv4 part is extracted into szIpOut.
            //  IPV6 part is extracted into szIpOut2.
            UINT32 aIP[MAX_AIPV4V6_INDEX] = {0};
            if (EOF == sscanf(szIpIn, "%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u."
                    "%u.%u.%u.%u.%u.%u", &aIP[0], &aIP[1], &aIP[2], &aIP[3],
                    &aIP[4], &aIP[5], &aIP[6], &aIP[7], &aIP[8], &aIP[9], &aIP[10], &aIP[11],
                    &aIP[12], &aIP[13], &aIP[14], &aIP[15], &aIP[16], &aIP[17], &aIP[18], &aIP[19]
                    ))
            {
                RIL_LOG_CRITICAL("ConvertIPAddressToAndroidReadable() -"
                        " cannot sscanf into aIP[]! ipv4v6\r\n");
                goto Error;
            }

            //  Loop through array, check values from modem is from 0-255.
            for (int i=0; i<MAX_AIPV4V6_INDEX; i++)
            {
                if (aIP[i] > 255)
                {
                    //  Value is not between 0-255.
                    RIL_LOG_CRITICAL("ConvertIPAddressToAndroidReadable() -"
                            " ipv4v6 aIP[%d] not in range 0-255. val=%u\r\n", i, aIP[i]);
                    goto Error;
                }
            }

            if (snprintf(szIpOut, uiIpOutSize,
                    "%u.%u.%u.%u",
                    aIP[0], aIP[1], aIP[2], aIP[3]) <= 0)
            {
                RIL_LOG_CRITICAL("ConvertIPAddressToAndroidReadable() -"
                        " error with snprintf()! ipv4v6 v4 part\r\n");
                goto Error;
            }

            if (NULL != szIpOut2 && 0 != uiIpOutSize2)
            {
                unsigned char acIP[MAX_AIPV6_INDEX] = {0};

                //  Convert unsigned int to unsigned char (for inet_ntop)
                //  The value read in should be in range 0-255, from check done above.
                for (int i=0; i<MAX_AIPV6_INDEX; i++)
                {
                    acIP[i] = (unsigned char)(aIP[i+4]);
                }

                if (inet_ntop(AF_INET6, (void*)acIP, szIpOut2, uiIpOutSize2) <= 0)
                {
                    RIL_LOG_CRITICAL("ConvertIPAddressToAndroidReadable() -"
                            " cannot inet_ntop ipv4v6\r\n");
                    goto Error;
                }
            }
        }
        break;

        default:
            RIL_LOG_CRITICAL("ConvertIPAddressToAndroidReadable() -"
                    " Unknown address format nDotCount=[%d]\r\n", nDotCount);
            goto Error;
    }

    bRet = TRUE;

Error:
    RIL_LOG_VERBOSE("ConvertIPAddressToAndroidReadable() - Exit\r\n");
    return bRet;
}