EONS.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:38k
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*******************************************************************************
- *
- * Filename:
- * ---------
- * EONS.c
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- * This file is created for EONS support (3GPP 51.11 EF OPL/PNN)
- *
- * Author:
- * -------
- * -------
- *
- *==============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *==============================================================================
- *******************************************************************************/
- #include "MMI_features.h"
- #include "StdC.h"
- #include "L4Dr.h"
- #include "L4Dr1.h"
- #include "ProtocolEvents.h"
- #include "PixtelDataTypes.h"
- #include "EventsGprot.h"
- #include "SimDetectionDef.h"
- #include "QueueGProt.h"
- #include "GSM7BitDefaultAlphabet.h"
- #include "sim_common_enums.h"
- #include "DebugInitDef.h"
- #include "NVRAMType.h"
- #include "NVRAMProt.h"
- #include "NVRAMEnum.h"
- #include "IdleAppDef.h" /* for g_idle_context */
- #include "SimDetectionGexdcl.h" /* for g_pwr_context */
- /**************************************************************************
- Pre-definition
- **************************************************************************/
- #if ( (defined __MMI_EONS_SUPPORT__) && (defined MMI_ON_HARDWARE_P) )
- /**************************************************************************
- Definitions
- **************************************************************************/
- #define MAX_MCC_MNC_LENGTH 3 /* Do not modify this definition */
- #define MAX_OPN_PNN_RECORD 24 /* Modify this definition to support more records in EF OPL/PNN */
- /* If this value is larger than 24, NVRAM size should also be modified */
- /**************************************************************************
- Structure
- **************************************************************************/
- typedef struct _eons_plmn_info
- {
- S8 pnn_plmn_num[MAX_MCC_MNC_LENGTH + 1];
- U8 pnn_identifier;
- } EONSPLMNINFO;
- /**************************************************************************
- Global variables
- **************************************************************************/
- static U8 opl_record_number = 0; /* total records read from EF OPL */
- static U8 opl_record_count = 1; /* count for how many records which have been read */
- static MMI_BOOL opl_read_finish = MMI_FALSE;
- static EONSPLMNINFO g_eons_plmn_info[MAX_OPN_PNN_RECORD];
- /* diamond, 2006/06/01 Prevent from sending this message twice before get the response */
- static U8 eons_got_read_pnn_rsp = 1;
- extern U8 gNWProviderName[MAX_LENGTH_DISPLAY_NAME * ENCODING_LENGTH]; /* in SimDetection.c */
- extern U8 gPLMN[MAX_PLMN_LEN_MMI];
- extern S8 gHomePLMNNum[MAX_PLMN_LEN_MMI + 1];
- extern S8 gOperatorName[MAX_LENGTH_OPERATOR_NAME * ENCODING_LENGTH];
- extern U8 gOpNameValid;
- /**************************************************************************
- Function Prototypes
- **************************************************************************/
- extern void smsal_gsm7_unpack(
- kal_uint8 *old_data_ptr,
- kal_uint8 *new_data_ptr,
- kal_uint16 data_len,
- kal_uint16 offset);
- extern kal_uint16 smsal_msg_len_in_character(kal_uint8 dcs, kal_uint16 len, kal_uint8 last_byte);
- extern kal_bool is_sim_replaced(void);
- extern ChangeRoamingState(void);
- extern void EntryIdleScreen(void);
- extern void RefreshNwProviderName(U8 *);
- void eons_convert_plmn_bcd_format_to_string(U8 *, U8 *);
- void eons_get_opl_record_req(U8);
- void eons_write_opn_to_nvram(void);
- void eons_reset_nvram(void);
- U8 eons_check_if_plmn_present(U8 *);
- /**************************************************************************
- Get records of PNN:
- void eons_retrieve_name_from_table(U8 *data)
- void eons_retrieve_name_from_pnn(U16 length, U8 *data)
- void eons_get_pnn_record_rsp(void *msgPtr)
- void eons_get_pnn_record_req(U8 recordNo)
- void eons_replace_opn_by_pnn_for_hplmn_rsp(void *msgPtr)
- void eons_replace_opn_by_pnn_for_hplmn_req(void)
- **************************************************************************/
- /*****************************************************************************
- * FUNCTION
- * eons_retrieve_name_from_table
- * DESCRIPTION
- *
- * PARAMETERS
- * buffer [?]
- * RETURNS
- * void
- *****************************************************************************/
- void eons_retrieve_name_from_table(U8 *buffer)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /*
- * U16 count;
- * for(count = 0; count < MAX_PLMN_NO_LIST_LENGTH; ++count)
- * {
- * if(memcmp(sPlmnsToDisplayName[count],gPLMN,strlen((PS8) sPlmnsToDisplayName[count])) == 0)
- * break;
- * }
- * if(count < MAX_PLMN_NO_LIST_LENGTH)
- * memcpy((S8*)gNWProviderName,GetCurrentPLMNName((S8*)sPlmnsToDisplayName[count]),MAX_LENGTH_DISPLAY_NAME * ENCODING_LENGTH);
- * else
- * AnsiiToUnicodeString((S8*)gNWProviderName,(S8*)gPLMN);
- */
- *buffer = 0; /* null string */
- }
- /*****************************************************************************
- * FUNCTION
- * eons_retrieve_name_from_pnn
- * DESCRIPTION
- *
- * PARAMETERS
- * length [IN]
- * data [?]
- * buffer [?]
- * RETURNS
- * void
- *****************************************************************************/
- void eons_retrieve_name_from_pnn(U16 length, U8 *data, U8 *buffer)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /* data[0]: Network IEI */
- /* data[1]: Length */
- /* data[2]-[n]: Name */
- U8 coding_scheme;
- U8 pnnDecode[MAX_LENGTH_DISPLAY_NAME];
- U8 pnnBuffer[MAX_LENGTH_DISPLAY_NAME];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- //U8* pnnDecode = OslMalloc(data[1]*8/7 +1);
- //U8* pnnBuffer = OslMalloc(data[1]);
- memcpy(pnnBuffer, data + 3, data[1] - 1);
- *(pnnBuffer + data[1] - 1) = 0; /* set null-terminated char */
- coding_scheme = (data[2] & 0x70) >> 4;
- if (coding_scheme == 0)
- {
- /* Octets (packed GSM 7-bit default alphabet) in EF PNN */
- /* smsal_gsm7_unpack(pnnBuffer, pnnDecode, data[1], 0); */
- smsal_gsm7_unpack(pnnBuffer, pnnDecode, smsal_msg_len_in_character(0, data[1], pnnBuffer[data[1]]), 0);
- /* Unicode in display buffer */
- AnsiiToUnicodeString((PS8) buffer, (PS8) pnnDecode);
- }
- else if (coding_scheme == 1)
- {
- /* Octets (UCS2) in EF PNN */
- U8 *convertedData = NULL;
- U8 dcs;
- switch (*pnnBuffer)
- {
- case 0x80:
- dcs = MMI_UCS2_DCS;
- break;
- case 0x81:
- dcs = MMI_UCS2_81;
- break;
- case 0x82:
- dcs = MMI_UCS2_82;
- break;
- default:
- dcs = 0;
- break;
- }
- if (dcs == 0)
- {
- eons_retrieve_name_from_table(buffer);
- }
- else
- {
- convertedData = CovertStringForPlatform(pnnBuffer + 1, data[1] - 2, dcs, NULL);
- pfnUnicodeStrcpy((PS8) buffer, (PS8) convertedData);
- OslMfree(convertedData);
- }
- }
- else
- {
- /* unknown format */
- eons_retrieve_name_from_table(buffer);
- }
- PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "[EONS] PNN: %s", pnnDecode));
- //OslMfree(pnnDecode);
- //OslMfree(pnnBuffer);
- }
- /*****************************************************************************
- * FUNCTION
- * eons_replace_opn_by_pnn_for_hplmn_rsp
- * DESCRIPTION
- *
- * PARAMETERS
- * msgPtr [?]
- * RETURNS
- * void
- *****************************************************************************/
- void eons_replace_opn_by_pnn_for_hplmn_rsp(void *msgPtr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_smu_read_sim_rsp_struct *pnnReadSimRes;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pnnReadSimRes = (mmi_smu_read_sim_rsp_struct*) msgPtr;
- ClearProtocolEventHandler(PRT_MMI_SMU_READ_SIM_RSP);
- /* EONS: Get the PLMN name string successfully, and save it to display buffer */
- if (pnnReadSimRes->result.flag == 0)
- {
- eons_retrieve_name_from_pnn(pnnReadSimRes->length, pnnReadSimRes->data, (PU8) gOperatorName);
- }
- /* EONS: To prevent from too many OPL records will delay the time of update NW provider name */
- if (is_sim_replaced() && g_idle_context.IsOnIdleScreen)
- {
- RefreshNwProviderName(gPLMN);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * eons_replace_opn_by_pnn_for_hplmn_req
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void eons_replace_opn_by_pnn_for_hplmn_req(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /* U8 recordnum = eons_check_if_plmn_present(gPLMN); */
- U8 homePLMN[MAX_PLMN_LEN_MMI + 1];
- U8 recordnum5digit, recordnum6digit;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(homePLMN, 0, MAX_PLMN_LEN_MMI + 1);
- memcpy(homePLMN, gHomePLMNNum, MAX_PLMN_LEN_MMI - 1);
- recordnum5digit = eons_check_if_plmn_present(homePLMN);
- memcpy(homePLMN, gHomePLMNNum, MAX_PLMN_LEN_MMI);
- recordnum6digit = eons_check_if_plmn_present(homePLMN);
- /* if(gOpNameValid && recordnum) */
- if (gOpNameValid == 1 && (recordnum5digit != 0 || recordnum6digit != 0))
- {
- /* EONS: Get the record of EF PNN for Home PLMN */
- MYQUEUE Message;
- mmi_smu_read_sim_req_struct *dataPtr;
- SetProtocolEventHandler(eons_replace_opn_by_pnn_for_hplmn_rsp, PRT_MMI_SMU_READ_SIM_RSP);
- Message.oslSrcId = MOD_MMI;
- Message.oslDestId = MOD_L4C;
- Message.oslMsgId = PRT_MMI_SMU_READ_SIM_REQ;
- dataPtr = (mmi_smu_read_sim_req_struct*) OslConstructDataPtr(sizeof(mmi_smu_read_sim_req_struct));
- dataPtr->file_idx = (U8) FILE_PNN_IDX; /* PNN...FILE_PNN_IDX */
- /* dataPtr->para=recordnum; */
- dataPtr->para = (recordnum5digit == 0) ? recordnum6digit : recordnum5digit;
- dataPtr->length = MAX_LENGTH_DISPLAY_NAME + 2;
- Message.oslDataPtr = (oslParaType*) dataPtr;
- Message.oslPeerBuffPtr = NULL;
- OslMsgSendExtQueue(&Message);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * eons_get_pnn_record_rsp
- * DESCRIPTION
- *
- * PARAMETERS
- * msgPtr [?]
- * RETURNS
- * void
- *****************************************************************************/
- void eons_get_pnn_record_rsp(void *msgPtr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_smu_read_sim_rsp_struct *pnnReadSimRes;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pnnReadSimRes = (mmi_smu_read_sim_rsp_struct*) msgPtr;
- ClearProtocolEventHandler(PRT_MMI_SMU_READ_SIM_RSP);
- eons_got_read_pnn_rsp = 1;
- /* EONS: Get the PLMN name string successfully, and save it to display buffer */
- if (pnnReadSimRes->result.flag == 0)
- {
- memset(gNWProviderName, 0, MAX_LENGTH_DISPLAY_NAME * ENCODING_LENGTH);
- eons_retrieve_name_from_pnn(pnnReadSimRes->length, pnnReadSimRes->data, (PU8) gNWProviderName);
- ChangeRoamingState();
- if (g_idle_context.IsOnIdleScreen && g_pwr_context.testRoaming == 3)
- {
- EntryIdleScreen();
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * eons_get_pnn_record_req
- * DESCRIPTION
- *
- * PARAMETERS
- * recordNo [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void eons_get_pnn_record_req(U8 recordNo)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /* EONS: Get the record of EF PNN for camp on PLMN */
- MYQUEUE Message;
- mmi_smu_read_sim_req_struct *dataPtr;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (eons_got_read_pnn_rsp == 0)
- {
- /* diamond, 2006/06/01 Prevent from sending this message twice before get the response */
- return;
- }
- SetProtocolEventHandler(eons_get_pnn_record_rsp, PRT_MMI_SMU_READ_SIM_RSP);
- eons_got_read_pnn_rsp = 0;
- Message.oslSrcId = MOD_MMI;
- Message.oslDestId = MOD_L4C;
- Message.oslMsgId = PRT_MMI_SMU_READ_SIM_REQ;
- dataPtr = (mmi_smu_read_sim_req_struct*) OslConstructDataPtr(sizeof(mmi_smu_read_sim_req_struct));
- dataPtr->file_idx = (U8) FILE_PNN_IDX; /* PNN...FILE_PNN_IDX */
- dataPtr->para = (U8) recordNo;
- dataPtr->length = MAX_LENGTH_DISPLAY_NAME + 2;
- Message.oslDataPtr = (oslParaType*) dataPtr;
- Message.oslPeerBuffPtr = NULL;
- OslMsgSendExtQueue(&Message);
- }
- /**************************************************************************
- Get records of OPL:
- void eons_retrieve_plmn_from_opl(U16 length, U8 *data)
- void eons_get_opl_record_rsp(void *msgPtr)
- void eons_get_opl_record_req(U8 recordNo)
- **************************************************************************/
- /*****************************************************************************
- * FUNCTION
- * eons_retrieve_plmn_from_opl
- * DESCRIPTION
- *
- * PARAMETERS
- * length [IN]
- * data [?]
- * RETURNS
- * void
- *****************************************************************************/
- void eons_retrieve_plmn_from_opl(U16 length, U8 *data)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 PnnPlmn[MAX_MCC_MNC_LENGTH * 2 + 1];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (data[7] == 0)
- {
- /* The name shall be taken from other sources, like the list in ME */
- /* Ignore this record and read next */
- opl_record_count--;
- opl_record_number--;
- return;
- }
- /* data[0]-[6]: Location Area Identity (3-byte PLMN + 2-byte LAC * 2) */
- /* data[7]: PLMN Network Name Record Identifier (use this id to search the name in EF PNN */
- g_eons_plmn_info[opl_record_count - 1].pnn_plmn_num[0] = data[0];
- g_eons_plmn_info[opl_record_count - 1].pnn_plmn_num[1] = data[1];
- g_eons_plmn_info[opl_record_count - 1].pnn_plmn_num[2] = data[2];
- /* data[3]-[6] not necessary for MMI */
- g_eons_plmn_info[opl_record_count - 1].pnn_identifier = data[7];
- eons_convert_plmn_bcd_format_to_string((U8*) g_eons_plmn_info[opl_record_count - 1].pnn_plmn_num, PnnPlmn);
- PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "[EONS] OPL %02d: %s", opl_record_count, PnnPlmn));
- }
- /*****************************************************************************
- * FUNCTION
- * eons_get_opl_record_rsp
- * DESCRIPTION
- *
- * PARAMETERS
- * msgPtr [?]
- * RETURNS
- * void
- *****************************************************************************/
- void eons_get_opl_record_rsp(void *msgPtr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_smu_read_sim_rsp_struct *oplReadSimRes;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- oplReadSimRes = (mmi_smu_read_sim_rsp_struct*) msgPtr;
- ClearProtocolEventHandler(PRT_MMI_SMU_READ_SIM_RSP);
- if (oplReadSimRes->data[0] != 0xFF && opl_record_count < opl_record_number)
- {
- /* EONS: Get the BCD-formated PLMN successfully, and save it to memory */
- if (oplReadSimRes->result.flag == 0)
- {
- eons_retrieve_plmn_from_opl(oplReadSimRes->length, oplReadSimRes->data);
- }
- /* EONS: Get next one */
- eons_get_opl_record_req(++opl_record_count);
- }
- else
- {
- /* EONS: following records are invalid */
- opl_read_finish = MMI_TRUE;
- if (oplReadSimRes->data[0] == 0xFF)
- {
- opl_record_count--; /* invalid one */
- }
- if (opl_record_count == opl_record_number && oplReadSimRes->result.flag == 0)
- {
- eons_retrieve_plmn_from_opl(oplReadSimRes->length, oplReadSimRes->data); /* the max supported record */
- }
- eons_write_opn_to_nvram();
- if (is_sim_replaced())
- {
- eons_replace_opn_by_pnn_for_hplmn_req(); /* replace opn string */
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * eons_get_opl_record_req
- * DESCRIPTION
- *
- * PARAMETERS
- * recordNo [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void eons_get_opl_record_req(U8 recordNo)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /* EONS: Get the record of EF OPL */
- MYQUEUE Message;
- mmi_smu_read_sim_req_struct *dataPtr;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetProtocolEventHandler(eons_get_opl_record_rsp, PRT_MMI_SMU_READ_SIM_RSP);
- Message.oslSrcId = MOD_MMI;
- Message.oslDestId = MOD_L4C;
- Message.oslMsgId = PRT_MMI_SMU_READ_SIM_REQ;
- dataPtr = (mmi_smu_read_sim_req_struct*) OslConstructDataPtr(sizeof(mmi_smu_read_sim_req_struct));
- dataPtr->file_idx = (U8) FILE_OPL_IDX; /* OPL...FILE_OPL_IDX */
- dataPtr->para = (U8) recordNo;
- dataPtr->length = 8;
- Message.oslDataPtr = (oslParaType*) dataPtr;
- Message.oslPeerBuffPtr = NULL;
- OslMsgSendExtQueue(&Message);
- }
- /**************************************************************************
- Get File Info of PNN and OPL:
- void eons_get_pnn_file_info_rsp(void *info)
- void eons_get_pnn_file_info_req(void)
- void eons_get_opl_file_info_rsp(void *info)
- void eons_get_opl_file_info_req(void)
- **************************************************************************/
- /*****************************************************************************
- * FUNCTION
- * eons_get_pnn_file_info_rsp
- * DESCRIPTION
- *
- * PARAMETERS
- * info [?]
- * RETURNS
- * void
- *****************************************************************************/
- void eons_get_pnn_file_info_rsp(void *info)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /* EONS: If PNN is also present, then try to get OPN first record */
- mmi_smu_read_file_info_rsp_struct *resp;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- resp = (mmi_smu_read_file_info_rsp_struct*) (info);
- ClearProtocolEventHandler(PRT_MMI_SMU_READ_FILE_INFO_RSP);
- if (resp->result.flag == 0)
- {
- eons_get_opl_record_req(opl_record_count);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * eons_get_pnn_file_info_req
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void eons_get_pnn_file_info_req(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /* EONS: Get the file info of EF PNN */
- MYQUEUE msgStruct;
- mmi_smu_read_file_info_req_struct *pnnstatus;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetProtocolEventHandler(eons_get_pnn_file_info_rsp, PRT_MMI_SMU_READ_FILE_INFO_RSP);
- pnnstatus = OslConstructDataPtr(sizeof(mmi_smu_read_file_info_req_struct));
- pnnstatus->file_idx = (U8) FILE_PNN_IDX; /* PNN...FILE_PNN_IDX */
- msgStruct.oslSrcId = MOD_MMI;
- msgStruct.oslDestId = MOD_L4C;
- msgStruct.oslMsgId = PRT_MMI_SMU_READ_FILE_INFO_REQ;
- msgStruct.oslSapId = INVALID_SAP;
- msgStruct.oslDataPtr = (oslParaType*) pnnstatus;
- msgStruct.oslPeerBuffPtr = NULL;
- OslMsgSendExtQueue(&msgStruct);
- }
- /*****************************************************************************
- * FUNCTION
- * eons_get_opn_file_info_rsp
- * DESCRIPTION
- *
- * PARAMETERS
- * info [?]
- * RETURNS
- * void
- *****************************************************************************/
- void eons_get_opn_file_info_rsp(void *info)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /* EONS: If OPL is present, then try to get PNN */
- mmi_smu_read_file_info_rsp_struct *resp;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- resp = (mmi_smu_read_file_info_rsp_struct*) (info);
- ClearProtocolEventHandler(PRT_MMI_SMU_READ_FILE_INFO_RSP);
- if (resp->result.flag == 0)
- {
- opl_record_number = (resp->num_of_rec < MAX_OPN_PNN_RECORD) ? resp->num_of_rec : MAX_OPN_PNN_RECORD;
- eons_get_pnn_file_info_req();
- }
- else
- {
- if (is_sim_replaced())
- {
- eons_reset_nvram();
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * eons_get_opn_file_info_req
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void eons_get_opn_file_info_req(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /* EONS: Get the file info of EF OPL */
- MYQUEUE msgStruct;
- mmi_smu_read_file_info_req_struct *oplstatus;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetProtocolEventHandler(eons_get_opn_file_info_rsp, PRT_MMI_SMU_READ_FILE_INFO_RSP);
- oplstatus = OslConstructDataPtr(sizeof(mmi_smu_read_file_info_req_struct));
- oplstatus->file_idx = (U8) FILE_OPL_IDX; /* OPL...FILE_OPL_IDX */
- msgStruct.oslSrcId = MOD_MMI;
- msgStruct.oslDestId = MOD_L4C;
- msgStruct.oslMsgId = PRT_MMI_SMU_READ_FILE_INFO_REQ;
- msgStruct.oslSapId = INVALID_SAP;
- msgStruct.oslDataPtr = (oslParaType*) oplstatus;
- msgStruct.oslPeerBuffPtr = NULL;
- OslMsgSendExtQueue(&msgStruct);
- }
- /**************************************************************************
- Check if camp on PLMN is the same as anyone in OPL:
- void eons_convert_plmn_bcd_format_to_string(U8* PlmnBcd, U8* PlmnString)
- U8 eons_check_if_plmn_present(U8 *UpdatePlmn)
- **************************************************************************/
- /*****************************************************************************
- * FUNCTION
- * eons_convert_plmn_bcd_format_to_string
- * DESCRIPTION
- *
- * PARAMETERS
- * PlmnBcd [?]
- * PlmnString [?]
- * RETURNS
- * void
- *****************************************************************************/
- void eons_convert_plmn_bcd_format_to_string(U8 *PlmnBcd, U8 *PlmnString)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PlmnString[0] = 0x30 + (PlmnBcd[0] & 0x0F);
- PlmnString[1] = 0x30 + ((PlmnBcd[0] & 0xF0) >> 4);
- PlmnString[2] = 0x30 + (PlmnBcd[1] & 0x0F);
- PlmnString[3] = 0x30 + (PlmnBcd[2] & 0x0F);
- PlmnString[4] = 0x30 + ((PlmnBcd[2] & 0xF0) >> 4);
- if ((PlmnBcd[1] & 0xF0) == 0xF0) /* 5-digit MCC/MNC */
- {
- PlmnString[5] = 0;
- }
- else /* 6-digit MCC/MNC */
- {
- PlmnString[5] = 0x30 + ((PlmnBcd[1] & 0xF0) >> 4);
- PlmnString[6] = 0;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * eons_check_if_plmn_present
- * DESCRIPTION
- *
- * PARAMETERS
- * UpdatePlmn [?]
- * RETURNS
- *
- *****************************************************************************/
- U8 eons_check_if_plmn_present(U8 *UpdatePlmn)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 i = 0, rtn = 0;
- U8 PnnPlmn[MAX_MCC_MNC_LENGTH * 2 + 1];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (strlen((PS8) UpdatePlmn) == 0)
- {
- return rtn;
- }
- for (i = 0; i < MAX_OPN_PNN_RECORD; i++)
- {
- eons_convert_plmn_bcd_format_to_string((U8*) g_eons_plmn_info[i].pnn_plmn_num, PnnPlmn);
- /* Compare camp on PLMN with PLMN in OPL, need to notice that the first parameter is camp on PLMN */
- if (strncmp((PS8) UpdatePlmn, (PS8) PnnPlmn, strlen((PS8) UpdatePlmn)) == 0)
- {
- /* return which record in opl */
- rtn = g_eons_plmn_info[i].pnn_identifier;
- break;
- }
- }
- return rtn;
- }
- /**************************************************************************
- Update OPL to NVRAM:
- void eons_write_opn_to_nvram(void)
- void eons_read_opn_to_nvram(void)
- void eons_reset_nvram(void)
- **************************************************************************/
- /*****************************************************************************
- * FUNCTION
- * eons_write_opn_to_nvram
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void eons_write_opn_to_nvram(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 nvram_buf[NVRAM_EF_EONS_INFO_SIZE];
- U8 i;
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(nvram_buf, 0xFF, NVRAM_EF_EONS_INFO_SIZE);
- for (i = 0; i < opl_record_count; i++)
- {
- nvram_buf[i * 4] = g_eons_plmn_info[i].pnn_plmn_num[0];
- nvram_buf[i * 4 + 1] = g_eons_plmn_info[i].pnn_plmn_num[1];
- nvram_buf[i * 4 + 2] = g_eons_plmn_info[i].pnn_plmn_num[2];
- nvram_buf[i * 4 + 3] = g_eons_plmn_info[i].pnn_identifier;
- }
- WriteRecord(NVRAM_EF_EONS_INFO_LID, 1, (void*)nvram_buf, NVRAM_EF_EONS_INFO_SIZE, &error);
- }
- /*****************************************************************************
- * FUNCTION
- * eons_read_opn_from_nvram
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void eons_read_opn_from_nvram(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 nvram_buf[NVRAM_EF_EONS_INFO_SIZE];
- U8 PnnPlmn[MAX_MCC_MNC_LENGTH * 2 + 1];
- U8 i;
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ReadRecord(NVRAM_EF_EONS_INFO_LID, 1, (void*)nvram_buf, NVRAM_EF_EONS_INFO_SIZE, &error);
- for (i = 0; i < MAX_OPN_PNN_RECORD; i++)
- {
- g_eons_plmn_info[i].pnn_plmn_num[0] = nvram_buf[i * 4];
- g_eons_plmn_info[i].pnn_plmn_num[1] = nvram_buf[i * 4 + 1];
- g_eons_plmn_info[i].pnn_plmn_num[2] = nvram_buf[i * 4 + 2];
- g_eons_plmn_info[i].pnn_identifier = nvram_buf[i * 4 + 3];
- eons_convert_plmn_bcd_format_to_string((U8*) g_eons_plmn_info[i].pnn_plmn_num, PnnPlmn);
- PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "[EONS] OPL %02d: %s", i + 1, PnnPlmn));
- }
- }
- /*****************************************************************************
- * FUNCTION
- * eons_reset_nvram
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void eons_reset_nvram(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 nvram_buf[NVRAM_EF_EONS_INFO_SIZE];
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(nvram_buf, 0xFF, NVRAM_EF_EONS_INFO_SIZE);
- WriteRecord(NVRAM_EF_EONS_INFO_LID, 1, (void*)nvram_buf, NVRAM_EF_EONS_INFO_SIZE, &error);
- }
- /**************************************************************************
- Utility:
- MMI_BOOL eons_check_roaming(void)
- MMI_BOOL eons_check_opl_read(void)
- **************************************************************************/
- /*****************************************************************************
- * FUNCTION
- * eons_check_roaming
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL eons_check_roaming(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 rtn1, rtn2;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- rtn1 = eons_check_if_plmn_present(gPLMN);
- rtn2 = eons_check_if_plmn_present((PU8) gHomePLMNNum);
- if (rtn1 == 0 && rtn2 == 0)
- {
- return MMI_FALSE;
- }
- else if (rtn1 != rtn2)
- {
- return MMI_FALSE;
- }
- else /* rtn1=rtn2: the same name string for camp on PLMN and home PLMN */
- {
- return MMI_TRUE;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * eons_check_opl_read
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL eons_check_opl_read(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return opl_read_finish;
- }
- /**************************************************************************
- Pre-definition
- **************************************************************************/
- #endif /* ( (defined __MMI_EONS_SUPPORT__) && (defined MMI_ON_HARDWARE_P) ) */