SettingProf.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:199k
源码类别:
MTK
开发平台:
C/C++
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #endif /* 0 */
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* PMT SHARIQ DLT_PATCH 20060814 END */
- }
- /*****************************************************************************
- * FUNCTION
- * ThemeManagerResetAlarmTone
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ThemeManagerResetAlarmTone(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 flag = 0, i;
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (i = 0; i < MAX_ELEMENTS; ++i)
- {
- if (gprofiles[i].toneSetup.alarmTone == CURRENT_THEME_ALARM_EXPIRY_TONE)
- {
- flag = 1;
- gprofiles[i].toneSetup.alarmTone = MIDI_2;
- }
- }
- #ifdef __MMI_ALM_AUDIO_OPTIONS__
- for (i = 0; i < NUM_OF_ALM; ++i)
- {
- if (g_alm_cntx.AlmList[i].AudioOptionValue == CURRENT_THEME_ALARM_EXPIRY_TONE)
- {
- g_alm_cntx.AlmList[i].AudioOption = ALM_AUDIO_OPTIONS_TONE;
- g_alm_cntx.AlmList[i].AudioOptionValue = (U16) (gstartMidiId + 1);
- }
- }
- AlmWriteToNvram();
- #endif /* __MMI_ALM_AUDIO_OPTIONS__ */
- if (flag)
- {
- WriteRecord(NVRAM_EF_PROFILES_LID, 1, &gprofiles[0], NVRAM_PROFILES_RECORD_SIZE, &error);
- memcpy(&gcurrentprofile, &gprofiles[gactivatedprofile], sizeof(PROFILE));
- }
- }
- #endif /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */
- /*****************************************************************************
- * FUNCTION
- * set_lcdbacklighttimer
- * DESCRIPTION
- * Setting lcdbacklight timer value
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- U8 set_lcdbacklighttimer(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error = 0;
- U16 j = 1;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- gprofiles[gprofileId].light.timer.setsec = gSec;
- if (WriteRecord(
- NVRAM_EF_PROFILES_LID,
- j,
- &gprofiles[0],
- NVRAM_PROFILES_RECORD_SIZE,
- &error) < NVRAM_PROFILES_RECORD_SIZE)
- {
- PRINT_INFORMATION(("## ERROR: set_lcdbacklighttimer: WriteRecord " "to NVRAM failed (ecode%d)n", (int)error));
- return ((U8) error);
- }
- if (gactivatedprofile == gprofileId)
- {
- memcpy(&gcurrentprofile, &gprofiles[gprofileId], sizeof(PROFILE));
- }
- return gSec;
- }
- /*****************************************************************************
- * FUNCTION
- * SetProfileDefault
- * DESCRIPTION
- * SetProfileDefault
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- pBOOL SetProfileDefault(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (gprofileheadset != 1)
- {
- PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "=== SetProfileDefault(): Headset mode. ===n"));
- ReadRecord(
- NVRAM_EF_PROFILES_LID,
- 2,
- &gprofiles[0],
- MAX_ELEMENTS * sizeof(PROFILE) /* NVRAM_PROFILES_RECORD_SIZE */ ,
- &error);
- gactivatedprofile = 0;
- memcpy(&gcurrentprofile, &gprofiles[gactivatedprofile], sizeof(PROFILE));
- showAlertStatusIcons(); /* function to show status icon on ilde screen */
- WriteRecord(NVRAM_EF_PROFILES_LID, 1, &gprofiles[0], NVRAM_PROFILES_RECORD_SIZE, &error);
- WriteValue(NVRAM_PROFILES_ACTIVATED, &gactivatedprofile, DS_BYTE, &error);
- /*
- * #ifdef __MMI_AUDIO_PLAYER__
- * mmi_audply_save_volume( gactivatedprofile );
- * #endif // __MMI_AUDIO_PLAYER__
- *
- * SetRingerVolume(GetRingVolumeLevel());
- */
- mdi_audio_set_volume_no_apply(MDI_VOLUME_MEDIA, GetRingVolumeLevel());
- SetKeyPadVolume(GetKeypadVolumeLevel());
- change_font();
- if (error == NVRAM_WRITE_SUCCESS)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- else
- {
- PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "=== SetProfileDefault(): Not Headset mode. ===n"));
- ReadRecord(
- NVRAM_EF_PROFILES_LID,
- 2,
- &gprofiles[0],
- MAX_ELEMENTS * sizeof(PROFILE) /* NVRAM_PROFILES_RECORD_SIZE */ ,
- &error);
- memcpy(&gcurrentprofile, &gprofiles[gactivatedprofile], sizeof(PROFILE));
- showAlertStatusIcons(); /* function to show status icon on ilde screen */
- WriteRecord(NVRAM_EF_PROFILES_LID, 1, &gprofiles[0], NVRAM_PROFILES_RECORD_SIZE, &error);
- WriteValue(NVRAM_PROFILES_ACTIVATED, &gactivatedprofile, DS_BYTE, &error);
- /*
- * #ifdef __MMI_AUDIO_PLAYER__
- * mmi_audply_save_volume( gactivatedprofile );
- * #endif // __MMI_AUDIO_PLAYER__
- *
- * SetRingerVolume(GetRingVolumeLevel());
- */
- mdi_audio_set_volume_no_apply(MDI_VOLUME_MEDIA, GetRingVolumeLevel());
- SetKeyPadVolume(GetKeypadVolumeLevel());
- change_font();
- if (error == NVRAM_WRITE_SUCCESS)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * SetExtraTone
- * DESCRIPTION
- *
- * PARAMETERS
- * extraTone [IN]
- * RETURNS
- * void
- *****************************************************************************/
- S16 SetExtraTone(EXTRA_TONE extraTone)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error = 0;
- U16 j = 1;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- gprofiles[gprofileId].extraTone.warningTone = extraTone.warningTone;
- gprofiles[gprofileId].extraTone.errorTone = extraTone.errorTone;
- #ifndef __MMI_CONNECT_NOTICE__
- gprofiles[gprofileId].extraTone.connectTone = extraTone.connectTone;
- #endif
- gprofiles[gprofileId].extraTone.campOnTone = extraTone.campOnTone;
- if (WriteRecord(
- NVRAM_EF_PROFILES_LID,
- j,
- &gprofiles[0],
- NVRAM_PROFILES_RECORD_SIZE,
- &error) < NVRAM_PROFILES_RECORD_SIZE)
- {
- PRINT_INFORMATION(("## ERROR: SetWarningToneType: WriteRecord " "to NVRAM failed (ecode%d)n", (int)error));
- return error;
- }
- if (gactivatedprofile == gprofileId)
- {
- memcpy(&gcurrentprofile, &gprofiles[gprofileId], sizeof(PROFILE));
- }
- return 0;
- }
- /*****************************************************************************
- * FUNCTION
- * playRequestedTone
- * DESCRIPTION
- * API to all applications to play tone.
- * PARAMETERS
- * playtone [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void playRequestedTone(ALL_TONE_ENUM playtone)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- BOOL done = FALSE;
- BOOL DataCallOnly = FALSE;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (playtone)
- {
- case CONGESTION_TONE:
- AudioPlayReq(TONE_CONGESTION_GSM, DEVICE_AUDIO_PLAY_ONCE);
- done = TRUE;
- break;
- case AUTH_FAIL_TONE:
- AudioPlayReq(TONE_AUTH_ERROR, DEVICE_AUDIO_PLAY_ONCE);
- done = TRUE;
- break;
- case NUM_UNOBTAIN_TONE:
- AudioPlayReq(TONE_NUM_UNOBTAIN, DEVICE_AUDIO_PLAY_ONCE);
- done = TRUE;
- break;
- case CALL_DROP_TONE:
- AudioPlayReq(TONE_RADIO_NA, DEVICE_AUDIO_PLAY_ONCE);
- done = TRUE;
- break;
- }
- if (done)
- {
- SetPlayReqToneFlag(TRUE);
- return;
- }
- if (IsWapCallPresent() && GetTotalCallCount()==1)
- {
- DataCallOnly = TRUE ;
- }
- if (!isInCall() || DataCallOnly)
- {
- SetPlayReqToneFlag(TRUE);
- switch (playtone)
- {
- case ERROR_TONE:
- if (gcurrentprofile.extraTone.errorTone == 1)
- {
- AudioPlayReq(TONE_ERROR1, DEVICE_AUDIO_PLAY_ONCE);
- }
- break;
- case CONNECT_TONE:
- #ifndef __MMI_CONNECT_NOTICE__
- if (gcurrentprofile.extraTone.connectTone == 1)
- #endif
- AudioPlayReq(TONE_CALL_CONNECT, DEVICE_AUDIO_PLAY_ONCE);
- break;
- case CAMP_ON_TONE:
- if (gcurrentprofile.extraTone.campOnTone == 1)
- {
- AudioPlayReq(SOUND_3, DEVICE_AUDIO_PLAY_ONCE);
- }
- break;
- case WARNING_TONE:
- if (gcurrentprofile.extraTone.warningTone == 1)
- {
- AudioPlayReq(TONE_WARNING1, DEVICE_AUDIO_PLAY_ONCE);
- }
- break;
- /**************************************************************************************/
- /***** Shall not come to here, Play ring tone in StartRingTone() use AudioPlayToneWithCallBack() *****/
- case INCOMING_CALL_TONE:
- if (gactivatedprofile != MMI_PROFILE_SILENT)
- {
- AudioPlayReq(gcurrentprofile.toneSetup.ringTone, (U8) GetRingTypeEnum());
- }
- break;
- /**************************************************************************************/
- case ALARM_TONE:
- /* PMT PANKAJ START: Added for providing support for FM Radio as alarm audio. */
- #ifdef __MMI_ALM_CUSTOMIZE_TONE__
- if (g_alm_frm_cntx.CurrAlmIndex >= ALM_ALM_START && g_alm_frm_cntx.CurrAlmIndex < ALM_SPOF_START)
- {
- AudioPlayToneWithCallBack(
- g_alm_cntx.AlmList[g_alm_frm_cntx.CurrAlmIndex - ALM_ALM_START].AudioOptionValue,
- DEVICE_AUDIO_PLAY_CRESCENDO,
- ALARM_TONE);
- }
- else
- {
- AudioPlayToneWithCallBack(
- gcurrentprofile.toneSetup.alarmTone,
- DEVICE_AUDIO_PLAY_CRESCENDO,
- ALARM_TONE);
- }
- #else /* __MMI_ALM_CUSTOMIZE_TONE__ */
- AudioPlayToneWithCallBack(gcurrentprofile.toneSetup.alarmTone, DEVICE_AUDIO_PLAY_CRESCENDO, ALARM_TONE);
- #endif /* __MMI_ALM_CUSTOMIZE_TONE__ */
- /* PMT PANKAJ END */
- break;
- case POWER_ON_TONE:
- if (gcurrentprofile.toneSetup.powerOnTone != POWERON_SILENT)
- {
- //KP Jerry modify for changing the style of message tone list on 2007-4-10 start
- #ifdef __MMI_TONE_LIST_STYLE_CHANGED__
- AudioPlayToneWithCallBack(
- gcurrentprofile.toneSetup.powerOnTone,
- DEVICE_AUDIO_PLAY_ONCE,
- POWER_ON_TONE);
- #else
- AudioPlayReq(gcurrentprofile.toneSetup.powerOnTone, DEVICE_AUDIO_PLAY_ONCE);
- #endif
- //KP Jerry modify for changing the style of message tone list on 2007-4-10 end
- }
- break;
- case POWER_OFF_TONE:
- if (gcurrentprofile.toneSetup.powerOffTone != POWEROFF_SILENT)
- {
- //KP Jerry modify for changing the style of message tone list on 2007-4-10 start
- #ifdef __MMI_TONE_LIST_STYLE_CHANGED__
- AudioPlayToneWithCallBack(
- gcurrentprofile.toneSetup.powerOffTone,
- DEVICE_AUDIO_PLAY_ONCE,
- POWER_OFF_TONE);
- #else
- AudioPlayReq(gcurrentprofile.toneSetup.powerOffTone, DEVICE_AUDIO_PLAY_ONCE);
- #endif
- //KP Jerry modify for changing the style of message tone list on 2007-4-10 end
- }
- break;
- #ifdef __MMI_CLAMSHELL__
- case COVER_OPEN_TONE:
- if (gcurrentprofile.toneSetup.coverOpenTone != COVER_OPEN_SILENT)
- {
- //KP Jerry modify for changing the style of message tone list on 2007-4-10 start
- #ifdef __MMI_TONE_LIST_STYLE_CHANGED__
- AudioPlayToneWithCallBack(
- gcurrentprofile.toneSetup.coverOpenTone,
- DEVICE_AUDIO_PLAY_ONCE,
- COVER_OPEN_TONE);
- #else
- AudioPlayReq(gcurrentprofile.toneSetup.coverOpenTone, DEVICE_AUDIO_PLAY_ONCE);
- #endif
- //KP Jerry modify for changing the style of message tone list on 2007-4-10 end
- }
- break;
- case COVER_CLOSE_TONE:
- if (gcurrentprofile.toneSetup.coverCloseTone != COVER_CLOSE_SILENT)
- {
- //KP Jerry modify for changing the style of message tone list on 2007-4-10 start
- #ifdef __MMI_TONE_LIST_STYLE_CHANGED__
- AudioPlayToneWithCallBack(
- gcurrentprofile.toneSetup.coverCloseTone,
- DEVICE_AUDIO_PLAY_ONCE,
- COVER_CLOSE_TONE);
- #else
- AudioPlayReq(gcurrentprofile.toneSetup.coverCloseTone, DEVICE_AUDIO_PLAY_ONCE);
- #endif
- //KP Jerry modify for changing the style of message tone list on 2007-4-10 end
- }
- break;
- #endif /* __MMI_CLAMSHELL__ */
- case MESSAGE_TONE:
- if (gcurrentprofile.toneSetup.messageTone != MESSAGE_SILENT)
- {
- /* AudioPlayReq(gcurrentprofile.toneSetup.messageTone,DEVICE_AUDIO_PLAY_ONCE); */
- //KP Jerry add for changing the style of message tone list on 2007-4-10 start
- #ifdef __MMI_TONE_LIST_STYLE_CHANGED__
- AudioPlayToneWithCallBack(
- gcurrentprofile.toneSetup.messageTone,
- DEVICE_AUDIO_PLAY_ONCE,
- MESSAGE_TONE);
- #else
- AudioPlayToneWithCallBack(
- gcurrentprofile.toneSetup.messageTone,
- DEVICE_AUDIO_PLAY_ONCE,
- ALARM_TONE);
- #endif
- //KP Jerry add for changing the style of message tone list on 2007-4-10 end
- }
- break;
- case SUCCESS_TONE:
- break;
- case SAVE_TONE:
- //MTK Brian added for disable save tone */
- //AudioPlayReq( TONE_GENERAL_BEEP,DEVICE_AUDIO_PLAY_ONCE);
- break;
- case EMPTY_LIST_TONE:
- /* AudioPlayReq( TONE_GENERAL_BEEP,DEVICE_AUDIO_PLAY_ONCE); */
- if (gcurrentprofile.extraTone.warningTone == 1)
- {
- AudioPlayReq(TONE_WARNING1, DEVICE_AUDIO_PLAY_ONCE);
- }
- break;
- case GENERAL_TONE:
- if (gcurrentprofile.extraTone.warningTone == 1)
- {
- AudioPlayReq(TONE_GENERAL_BEEP, DEVICE_AUDIO_PLAY_ONCE);
- }
- break;
- case AUX_TONE:
- if (gcurrentprofile.extraTone.warningTone == 1)
- {
- AudioPlayReq(TONE_AUX_IND, DEVICE_AUDIO_PLAY_ONCE);
- }
- break;
- /* Brian added for battery indication, 2003/11/17 */
- case BATTERY_LOW_TONE:
- if (gcurrentprofile.extraTone.warningTone == 1)
- {
- AudioPlayReq(TONE_BATTERY_LOW, DEVICE_AUDIO_PLAY_ONCE);
- }
- break;
- case BATTERY_WARNING_TONE:
- if (gcurrentprofile.extraTone.warningTone == 1)
- {
- AudioPlayReq(TONE_BATTERY_WARNING, DEVICE_AUDIO_PLAY_ONCE);
- }
- break;
- case WARNING_TONE_IN_CALL:
- if (gcurrentprofile.extraTone.warningTone == 1)
- {
- AudioPlayReq(TONE_WARNING2, DEVICE_AUDIO_PLAY_ONCE);
- }
- break;
- case ERROR_TONE_IN_CALL:
- if (gcurrentprofile.extraTone.errorTone == 1)
- {
- AudioPlayReq(TONE_ERROR2, DEVICE_AUDIO_PLAY_ONCE);
- }
- break;
- }
- }
- else /* No active call, No on hold call */
- {
- switch (playtone)
- {
- /* Robin 0719 */
- /* Shall play power off tone no matter in call or not */
- /* See CANNON+ SCR 3573, CSD connection, long press END key won't will power off first, then drop call */
- case POWER_OFF_TONE:
- {
- if (gcurrentprofile.toneSetup.powerOffTone != POWEROFF_SILENT)
- {
- AudioPlayReq(gcurrentprofile.toneSetup.powerOffTone, DEVICE_AUDIO_PLAY_ONCE);
- }
- break;
- }
- case SMS_IN_CALL_TONE:
- {
- if (gcurrentprofile.toneSetup.messageTone != MESSAGE_SILENT)
- {
- SetPlayReqToneFlag(TRUE);
- AudioPlayReq(TONE_MT_SMS_IN_CALL, DEVICE_AUDIO_PLAY_ONCE);
- }
- break;
- }
- case WARNING_TONE_IN_CALL:
- {
- if (gcurrentprofile.extraTone.warningTone == 1)
- {
- AudioPlayReq(TONE_WARNING2, DEVICE_AUDIO_PLAY_ONCE);
- }
- break;
- }
- case ERROR_TONE_IN_CALL:
- {
- if (gcurrentprofile.extraTone.errorTone == 1)
- {
- AudioPlayReq(TONE_ERROR2, DEVICE_AUDIO_PLAY_ONCE);
- }
- break;
- }
- case CONNECT_TONE_IN_CALL:
- {
- /* MTK Brian added for AUX TONE and Connect tone, 2003/11/19 */
- if (gcurrentprofile.extraTone.connectTone == 1)
- {
- AudioPlayReq(TONE_CALL_CONNECT, DEVICE_AUDIO_PLAY_ONCE);
- }
- break;
- }
- case SUCCESS_TONE_IN_CALL:
- {
- break;
- }
- /* MTK Brian added for battery indication, 2003/11/17 */
- case BATTERY_LOW_TONE:
- {
- if (gcurrentprofile.extraTone.warningTone == 1)
- {
- AudioPlayReq(TONE_WARNING2, DEVICE_AUDIO_PLAY_ONCE);
- }
- break;
- }
- case BATTERY_WARNING_TONE:
- {
- if (gcurrentprofile.extraTone.warningTone == 1)
- {
- AudioPlayReq(TONE_WARNING2, DEVICE_AUDIO_PLAY_ONCE);
- }
- break;
- }
- /* MTK Brian added for AUX TONE and Connect tone, 2003/11/19 */
- case AUX_TONE:
- {
- if (gcurrentprofile.extraTone.warningTone == 1)
- {
- AudioPlayReq(TONE_WARNING2, DEVICE_AUDIO_PLAY_ONCE);
- }
- break;
- }
- case CONNECT_TONE:
- {
- #ifndef __MMI_CONNECT_NOTICE__
- if (gcurrentprofile.extraTone.connectTone == 1)
- #endif
- AudioPlayReq(TONE_CALL_CONNECT, DEVICE_AUDIO_PLAY_ONCE);
- break;
- }
- case CALL_REMINDER_TONE:
- case CCBS_TONE:
- {
- AudioPlayReq(TONE_WARNING2, DEVICE_AUDIO_PLAY_ONCE);
- break;
- }
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * stopRequestedTone
- * DESCRIPTION
- * eneral API to all applications to stop tone.
- * PARAMETERS
- * playtone [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void stopRequestedTone(ALL_TONE_ENUM playtone)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- //if (GetPlayReqToneFlag() == TRUE) //KP disable for avoid clam-open tone can not stop on 2007-4-28
- {
- SetPlayReqToneFlag(FALSE);
- switch (playtone)
- {
- case ERROR_TONE:
- if (gcurrentprofile.extraTone.errorTone == 1)
- {
- AudioStopReq(TONE_ERROR1);
- }
- break;
- case CONNECT_TONE:
- if (gcurrentprofile.extraTone.connectTone == 1)
- {
- AudioStopReq(TONE_CALL_CONNECT);
- }
- break;
- case CAMP_ON_TONE:
- if (gcurrentprofile.extraTone.campOnTone == 1)
- {
- AudioStopReq(SOUND_3);
- }
- break;
- case WARNING_TONE:
- if (gcurrentprofile.extraTone.warningTone == 1)
- {
- AudioStopReq(TONE_WARNING1);
- }
- break;
- case INCOMING_CALL_TONE:
- if (gactivatedprofile != MMI_PROFILE_SILENT)
- {
- AudioStopReq(gcurrentprofile.toneSetup.ringTone);
- }
- break;
- case ALARM_TONE:
- //MTK Brian modified to play alarm tone in all profiels, 2003/11/16
- //if(!IsSilentModeActivated())
- //AudioStopReq( gcurrentprofile.toneSetup.alarmTone);
- mdi_audio_stop_all();
- break;
- case POWER_ON_TONE:
- if (gcurrentprofile.toneSetup.powerOnTone != POWERON_SILENT)
- {
- AudioStopReq(gcurrentprofile.toneSetup.powerOnTone);
- }
- break;
- case POWER_OFF_TONE:
- if (gcurrentprofile.toneSetup.powerOffTone != POWEROFF_SILENT)
- {
- AudioStopReq(gcurrentprofile.toneSetup.powerOffTone);
- }
- break;
- /* MTK brian added to wrap cover open/close tone setup, 2003/10/18 */
- #ifdef __MMI_CLAMSHELL__
- case COVER_OPEN_TONE:
- if (gcurrentprofile.toneSetup.coverOpenTone != COVER_OPEN_SILENT)
- {
- AudioStopReq(gcurrentprofile.toneSetup.coverOpenTone);
- }
- break;
- case COVER_CLOSE_TONE:
- if (gcurrentprofile.toneSetup.coverCloseTone != COVER_CLOSE_SILENT)
- {
- AudioStopReq(gcurrentprofile.toneSetup.coverCloseTone);
- }
- break;
- #endif /* __MMI_CLAMSHELL__ */
- /* MTK end */
- case MESSAGE_TONE:
- if (gcurrentprofile.toneSetup.messageTone != MESSAGE_SILENT)
- {
- AudioStopReq(gcurrentprofile.toneSetup.messageTone);
- }
- break;
- case SUCCESS_TONE:
- break;
- case SAVE_TONE:
- if (gactivatedprofile != MMI_PROFILE_SILENT)
- {
- AudioStopReq(TONE_GENERAL_BEEP);
- }
- break;
- case EMPTY_LIST_TONE:
- if (gcurrentprofile.extraTone.warningTone == 1)
- {
- AudioStopReq(TONE_WARNING1);
- }
- break;
- case GENERAL_TONE:
- if (gactivatedprofile != MMI_PROFILE_SILENT)
- {
- AudioStopReq(TONE_GENERAL_BEEP);
- }
- break;
- case SMS_IN_CALL_TONE:
- AudioStopReq(TONE_MT_SMS_IN_CALL);
- break;
- /* MTK Brian added for battery indication, 2003/11/17 */
- case BATTERY_LOW_TONE:
- AudioStopReq(TONE_BATTERY_LOW);
- break;
- case BATTERY_WARNING_TONE:
- AudioStopReq(TONE_BATTERY_WARNING);
- break;
- case CONGESTION_TONE:
- AudioStopReq(TONE_CONGESTION_GSM);
- break;
- case AUTH_FAIL_TONE:
- AudioStopReq(TONE_AUTH_ERROR);
- break;
- case NUM_UNOBTAIN_TONE:
- AudioStopReq(TONE_NUM_UNOBTAIN);
- break;
- case CALL_DROP_TONE:
- AudioStopReq(TONE_RADIO_NA);
- break;
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * SetPlayReqToneFlag
- * DESCRIPTION
- *
- * PARAMETERS
- * flag [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void SetPlayReqToneFlag(pBOOL flag)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- gPlayReqToneFlag = flag;
- }
- /*****************************************************************************
- * FUNCTION
- * GetPlayReqToneFlag
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- pBOOL GetPlayReqToneFlag(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return gPlayReqToneFlag;
- }
- /*****************************************************************************
- * FUNCTION
- * UpdateDeleteDownloadedRingTone
- * DESCRIPTION
- * set default tone when selected downloaded Ring tone is deleted.
- * PARAMETERS
- * ToneId [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void UpdateDeleteDownloadedRingTone(U16 ToneId)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (gcurrentprofile.toneSetup.ringTone == ToneId)
- {
- SetRingToneID(gstartMidiId);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * UpdateDeleteExtMldToneSetup
- * DESCRIPTION
- * set default tone when selected extented Melody Ring tone is deleted.
- * PARAMETERS
- * ToneId [IN]
- * RETURNS
- * void
- *****************************************************************************/
- #ifdef __MMI_PROFILE_EXTMELODY_SUPPORT__
- void UpdateDeleteExtMldToneSetup(U16 ToneId)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 i, dirtyFlag = 0;
- S16 error = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* Update alarm ring tone list */
- #if defined(__MMI_ALM_AUDIO_OPTIONS__) && defined(__MMI_ALM_CUSTOMIZE_TONE__)
- mmi_alm_tone_setup_delete_ext_melody(ToneId);
- #endif
- for (i = 0; i < MAX_ELEMENTS; i++)
- {
- if (gprofiles[i].toneSetup.ringTone == ToneId)
- {
- gprofiles[i].toneSetup.ringTone = gstartMidiId;
- dirtyFlag = 1;
- }
- if (gprofiles[i].toneSetup.alarmTone == ToneId)
- {
- gprofiles[i].toneSetup.alarmTone = gstartMidiId + 1;
- dirtyFlag = 1;
- }
- }
- if (dirtyFlag == 1)
- if (WriteRecord(
- NVRAM_EF_PROFILES_LID,
- 1,
- &gprofiles[0],
- NVRAM_PROFILES_RECORD_SIZE,
- &error) < NVRAM_PROFILES_RECORD_SIZE)
- {
- PRINT_INFORMATION(("## ERROR: SetRingToneID: WriteRecord " "to NVRAM failed (ecode%d)n", (int)error));
- return;
- }
- if (gactivatedprofile == gprofileId)
- {
- memcpy(&gcurrentprofile, &gprofiles[gprofileId], sizeof(PROFILE));
- }
- }
- //KP Jerry add for changing the style of message tone list on 2007-4-10 start
- #ifdef __MMI_TONE_LIST_STYLE_CHANGED__
- /*****************************************************************************
- * FUNCTION
- * UpdateDeleteExtMldToneSetup
- * DESCRIPTION
- * set default tone when selected extented Melody MS tone is deleted.
- * PARAMETERS
- * ToneId [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void UpdateDeleteExtMSMldToneSetup(U16 ToneId)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 i, dirtyFlag = 0;
- S16 error = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* Update alarm ring tone list */
- for (i = 0; i < MAX_ELEMENTS; i++)
- {
- if(gprofiles[i].toneSetup.messageTone == ToneId) //(gprofiles[i].toneSetup.messageTone < gstartMiscToneId || gprofiles[i].toneSetup.messageTone >(gstartMiscToneId + 10 )) //Old: (gprofiles[i].toneSetup.messageTone == ToneId) #KP Joey modified on 2007-04-09
- {
- gprofiles[i].toneSetup.messageTone = gstartMiscToneId + 4;//Joey added for returning to silence on 2007-4-07 ;
- dirtyFlag = 1;
- }
- if (gprofiles[i].toneSetup.powerOffTone == ToneId)
- {
- gprofiles[i].toneSetup.powerOffTone = gstartGeneralToneId + 1;
- dirtyFlag = 1;
- }
- if (gprofiles[i].toneSetup.powerOnTone == ToneId)
- {
- gprofiles[i].toneSetup.powerOnTone = gstartGeneralToneId;
- dirtyFlag = 1;
- }
- if (gprofiles[i].toneSetup.coverOpenTone== ToneId)
- {
- gprofiles[i].toneSetup.coverOpenTone = gstartGeneralToneId + 2;
- dirtyFlag = 1;
- }
- if (gprofiles[i].toneSetup.coverCloseTone== ToneId)
- {
- gprofiles[i].toneSetup.coverCloseTone = gstartGeneralToneId + 3;
- dirtyFlag = 1;
- }
- }
- if (dirtyFlag == 1)
- if (WriteRecord(
- NVRAM_EF_PROFILES_LID,
- 1,
- &gprofiles[0],
- NVRAM_PROFILES_RECORD_SIZE,
- &error) < NVRAM_PROFILES_RECORD_SIZE)
- {
- PRINT_INFORMATION(("## ERROR: SetRingToneID: WriteRecord " "to NVRAM failed (ecode%d)n", (int)error));
- return;
- }
- if (gactivatedprofile == gprofileId)
- {
- memcpy(&gcurrentprofile, &gprofiles[gprofileId], sizeof(PROFILE));
- }
- }
- #endif
- //KP Jerry add for changing the style of message tone list on 2007-4-10 end
- #endif /* __MMI_PROFILE_EXTMELODY_SUPPORT__ */
- /*****************************************************************************
- * FUNCTION
- * UpdateDeleteDownloadedAlarmTone
- * DESCRIPTION
- * set default tone when selected downloaded alarm tone is deleted.
- * PARAMETERS
- * ToneId [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void UpdateDeleteDownloadedAlarmTone(U16 ToneId)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (gcurrentprofile.toneSetup.alarmTone == ToneId)
- {
- TONE_SETUP tonesetup;
- tonesetup.alarmTone = gstartMidiId + 1;
- SetAlarmToneID(tonesetup.alarmTone);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * SetCurrentProfileAsActivatedProfile
- * DESCRIPTION
- * Sets Current Profile As Activated Profile
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void SetCurrentProfileAsActivatedProfile(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- gprofileId = gactivatedprofile;
- }
- /*****************************************************************************
- * FUNCTION
- * IsHeadsetModeActivated
- * DESCRIPTION
- * Tells if headset mode is activated
- * PARAMETERS
- * void
- * RETURNS
- * BOOL
- *****************************************************************************/
- BOOL IsHeadsetModeActivated(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (gactivatedprofile == MMI_PROFILE_HEADSET)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * IsSilentModeActivated
- * DESCRIPTION
- * Tells if silent mode is activated
- * PARAMETERS
- * void
- * RETURNS
- * pBOOL
- *****************************************************************************/
- pBOOL IsSilentModeActivated(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (gactivatedprofile == MMI_PROFILE_SILENT)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * IsMeetingModeActivated
- * DESCRIPTION
- * Tells if meeting mode is activated
- * PARAMETERS
- * void
- * RETURNS
- * BOOL
- *
- *****************************************************************************/
- BOOL IsMeetingModeActivated(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (gactivatedprofile == MMI_PROFILE_MEETING)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- /* MTK robin 1119, AT command set wallpaper and profile */
- /*****************************************************************************
- * FUNCTION
- * AtSetProfileTone
- * DESCRIPTION
- *
- * PARAMETERS
- * profileID [IN]
- * tone_type [IN]
- * tone_idx [IN]
- * RETURNS
- *
- *****************************************************************************/
- BOOL AtSetProfileTone(U8 profileID, PROFILE_TONE_TYPE_ENUM tone_type, U8 tone_idx)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error = 0;
- U16 j = 1;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (profileID >= MAX_PROFILE_NUM || tone_type >= TONE_MAX_TONE_TYPE || tone_idx > 10)
- {
- return MMI_FALSE;
- }
- switch (tone_type)
- {
- case TONE_POWERONTONE:
- if (tone_idx == 0)
- {
- gprofiles[profileID].toneSetup.powerOnTone = POWERON_SILENT;
- }
- else
- {
- gprofiles[profileID].toneSetup.powerOnTone = gstartGeneralToneId + tone_idx - 1;
- }
- break;
- default:
- return MMI_FALSE;
- }
- if (WriteRecord(NVRAM_EF_PROFILES_LID, j, &gprofiles[0], NVRAM_PROFILES_RECORD_SIZE, &error) <
- NVRAM_PROFILES_RECORD_SIZE)
- {
- PRINT_INFORMATION(("## ERROR: SetPowerOnToneType: WriteRecord " "to NVRAM failed (ecode%d)n", (int)error));
- return MMI_FALSE;
- }
- if (gactivatedprofile == gprofileId)
- {
- memcpy(&gcurrentprofile, &gprofiles[gprofileId], sizeof(PROFILE));
- }
- return MMI_TRUE;
- }
- /* MTK end */
- //KP Jerry add on 2007-4-1 start
- #ifdef __MMI_PROFILE_POWER_SAVING__
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_power_saving_activate_profile
- * DESCRIPTION
- * Activating Headset profile
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_power_saving_activate_profile(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearKeyEvents();
- PRINT_INFORMATION(("mmi_profiles_power_saving_activate_profile: gactivatedprofile =%d, glastactivatedprofile = %dn",
- gactivatedprofile, glastactivatedprofile));
- /* MTK Modified, Robin 1017, prevent activated profile and last actived profile become same one */
- #ifdef __MMI_BT_PROFILE__
- if (gactivatedprofile != MMI_PROFILE_SILENT && gactivatedprofile != MMI_PROFILE_HEADSET &&
- gactivatedprofile != MMI_PROFILE_BT && gactivatedprofile != MMI_PROFILE_POWER_SAVING)
- #else /* __MMI_BT_PROFILE__ */
- if (gactivatedprofile != MMI_PROFILE_SILENT && gactivatedprofile != MMI_PROFILE_HEADSET &&
- gactivatedprofile != MMI_PROFILE_POWER_SAVING)
- #endif /* __MMI_BT_PROFILE__ */
- glastactivatedprofile = gactivatedprofile;
- gactivatedprofile = MMI_PROFILE_POWER_SAVING;
- memcpy(&gcurrentprofile, &gprofiles[gactivatedprofile], sizeof(PROFILE));
- WriteValue(NVRAM_PROFILES_LASTACTIVATED, &glastactivatedprofile, DS_BYTE, &error);
- WriteValue(NVRAM_PROFILES_ACTIVATED, &gactivatedprofile, DS_BYTE, &error);
- showAlertStatusIcons();
- change_font();
- /* SetRingerVolume(GetRingVolumeLevel()); */
- mdi_audio_set_volume_no_apply(MDI_VOLUME_MEDIA, GetRingVolumeLevel());
- SetKeyPadVolume(GetKeypadVolumeLevel());
- mdi_audio_set_mic_volume();
- ActivateProfile();
- DisplayPopup((U8*) GetString(STR_POWER_SAVING_ACTIVATE_MESSAGE), IMG_GLOBAL_ACTIVATED, 1, 2000, (U8) SUCCESS_TONE);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_power_saving_deactivate_profile
- * DESCRIPTION
- * Deactivate Headset profile
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_power_saving_deactivate_profile(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_headset_deactivate_profile: gactivatedprofile =%d, glastactivatedprofile = %dn",
- gactivatedprofile, glastactivatedprofile));
- ReadValue(NVRAM_PROFILES_LASTACTIVATED, &glastactivatedprofile, DS_BYTE, &error);
- #ifdef __MMI_BT_PROFILE__
- #endif
- gactivatedprofile = glastactivatedprofile;
- WriteValue(NVRAM_PROFILES_ACTIVATED, &gactivatedprofile, DS_BYTE, &error);
- //ReadValue(NVRAM_PROFILES_ACTIVATED, &gactivatedprofile, DS_BYTE, &error);
- memcpy(&gcurrentprofile, &gprofiles[gactivatedprofile], sizeof(PROFILE));
- showAlertStatusIcons();
- change_font();
- /* SetRingerVolume(GetRingVolumeLevel()); */
- mdi_audio_set_volume_no_apply(MDI_VOLUME_MEDIA, GetRingVolumeLevel());
- SetKeyPadVolume(GetKeypadVolumeLevel());
- mdi_audio_set_mic_volume();
- ActivateProfile();
- switch (gactivatedprofile)
- {
- case MMI_PROFILE_GENERAL:
- DisplayPopup(
- (U8*) GetString(STR_GENERAL_RESTORED_MESSAGE),
- IMG_GLOBAL_ACTIVATED,
- 1,
- 2000,
- (U8) SUCCESS_TONE);
- break;
- case MMI_PROFILE_MEETING:
- DisplayPopup(
- (U8*) GetString(STR_MEETING_RESTORED_MESSAGE),
- IMG_GLOBAL_ACTIVATED,
- 1,
- 2000,
- (U8) SUCCESS_TONE);
- break;
- case MMI_PROFILE_OUTDOOR:
- DisplayPopup(
- (U8*) GetString(STR_OUTDOOR_RESTORED_MESSAGE),
- IMG_GLOBAL_ACTIVATED,
- 1,
- 2000,
- (U8) SUCCESS_TONE);
- break;
- case MMI_PROFILE_INDOOR:
- DisplayPopup(
- (U8*) GetString(STR_INDOOR_RESTORED_MESSAGE),
- IMG_GLOBAL_ACTIVATED,
- 1,
- 2000,
- (U8) SUCCESS_TONE);
- break;
- case MMI_PROFILE_HEADSET:
- /* DisplayPopup((U8*)GetString(STR_HEADSET_RESTORED_MESSAGE),IMG_GLOBAL_ACTIVATED,1,2000,(U8)SUCCESS_TONE); */
- break;
- #ifdef __MMI_PROFILE_POWER_SAVING__
- case MMI_PROFILE_POWER_SAVING:
- DisplayPopup(
- (U8*) GetString(STR_POWER_SAVING_RESTORED_MESSAGE),
- IMG_GLOBAL_ACTIVATED,
- 1,
- 2000,
- (U8) SUCCESS_TONE);
- break;
- #endif
- #ifdef __MMI_BT_PROFILE__
- case MMI_PROFILE_BT:
- #endif
- break;
- }
- }
- #endif
- //KP Jerry add on 2007-4-1 end
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_headset_activate_profile
- * DESCRIPTION
- * Activating Headset profile
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_headset_activate_profile(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_headset_activate_profile: gactivatedprofile =%d, glastactivatedprofile = %dn",
- gactivatedprofile, glastactivatedprofile));
- gprofileheadset = 1;
- /* MTK Modified, Robin 1017, prevent activated profile and last actived profile become same one */
- //KP Jerry modify on 2007-4-3 start
- #ifdef __MMI_PROFILE_POWER_SAVING__
- #ifdef __MMI_BT_PROFILE__
- if (gactivatedprofile != MMI_PROFILE_SILENT && gactivatedprofile != MMI_PROFILE_HEADSET &&
- gactivatedprofile != MMI_PROFILE_BT && gactivatedprofile != MMI_PROFILE_POWER_SAVING)
- #else /* __MMI_BT_PROFILE__ */
- if (gactivatedprofile != MMI_PROFILE_SILENT && gactivatedprofile != MMI_PROFILE_HEADSET && gactivatedprofile != MMI_PROFILE_POWER_SAVING)
- #endif /* __MMI_BT_PROFILE__ */
- #else/*!__MMI_PROFILE_POWER_SAVING__*/
- #ifdef __MMI_BT_PROFILE__
- if (gactivatedprofile != MMI_PROFILE_SILENT && gactivatedprofile != MMI_PROFILE_HEADSET &&
- gactivatedprofile != MMI_PROFILE_BT)
- #else /* __MMI_BT_PROFILE__ */
- if (gactivatedprofile != MMI_PROFILE_SILENT && gactivatedprofile != MMI_PROFILE_HEADSET)
- #endif /* __MMI_BT_PROFILE__ */
- #endif/*__MMI_PROFILE_POWER_SAVING__*/
- //KP Jerry modify on 2007-4-3 end
- glastactivatedprofile = gactivatedprofile;
- gactivatedprofile = MMI_PROFILE_HEADSET;
- memcpy(&gcurrentprofile, &gprofiles[gactivatedprofile], sizeof(PROFILE));
- WriteValue(NVRAM_PROFILES_LASTACTIVATED, &glastactivatedprofile, DS_BYTE, &error);
- showAlertStatusIcons();
- change_font();
- /* SetRingerVolume(GetRingVolumeLevel()); */
- mdi_audio_set_volume_no_apply(MDI_VOLUME_MEDIA, GetRingVolumeLevel());
- SetKeyPadVolume(GetKeypadVolumeLevel());
- mdi_audio_set_mic_volume();
- if (gloudSpeaker == 1)
- {
- gloudSpeaker = 0;
- SetLSpkNowOff(TRUE);
- }
- //KP Jerry add on 2007-03-31 start
- #ifdef __MMI_PROFILE_POWER_SAVING__
- ProfileResetBackLightSetting();
- ProfilesResetKeyBacklight();
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
- #endif
- //KP Jerry add on 2007-03-31 end
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_headset_deactivate_profile
- * DESCRIPTION
- * Deactivate Headset profile
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_headset_deactivate_profile(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_headset_deactivate_profile: gactivatedprofile =%d, glastactivatedprofile = %dn",
- gactivatedprofile, glastactivatedprofile));
- gprofileheadset = 0;
- ReadValue(NVRAM_PROFILES_LASTACTIVATED, &glastactivatedprofile, DS_BYTE, &error);
- #ifdef __MMI_BT_PROFILE__
- #endif
- ReadValue(NVRAM_PROFILES_ACTIVATED, &gactivatedprofile, DS_BYTE, &error);
- memcpy(&gcurrentprofile, &gprofiles[gactivatedprofile], sizeof(PROFILE));
- showAlertStatusIcons();
- change_font();
- /* SetRingerVolume(GetRingVolumeLevel()); */
- mdi_audio_set_volume_no_apply(MDI_VOLUME_MEDIA, GetRingVolumeLevel());
- SetKeyPadVolume(GetKeypadVolumeLevel());
- mdi_audio_set_mic_volume();
- //KP Jerry add on 2007-03-31 start
- #ifdef __MMI_PROFILE_POWER_SAVING__
- ProfileResetBackLightSetting();
- ProfilesResetKeyBacklight();
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
- #endif
- //KP Jerry add on 2007-03-31 end
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_earphone_plug_in_callback
- * DESCRIPTION
- * invoke it when plug in earphone
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_earphone_plug_in_callback(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (mmi_bootup_is_in_power_on_period() == MMI_FALSE)
- {
- PRINT_INFORMATION(("mmi_profiles_earphone_plug_in_callback: gactivatedprofile =%dn", gactivatedprofile));
- mdi_audio_set_audio_mode(AUD_MODE_HEADSET);
- SetModeSpeechVolume();
- #ifdef __MMI_BT_PROFILE__
- if (gactivatedprofile == MMI_PROFILE_BT)
- {
- #ifdef __MMI_HFP_SUPPORT__
- mmi_profiles_bt_disconnect_req(MMI_PROFILES_BT_HFP_SCO);
- #endif
- #if defined(__MMI_BT_BCHS_SUPPORT__)&& defined(__MMI_A2DP_SUPPORT__)
- mdi_audio_bt_a2dp_turn_off();
- #endif
- }
- #endif /* __MMI_BT_PROFILE__ */
- mmi_profiles_headset_activate_profile();
- #if defined(__MMI_FM_RADIO__) && defined(__MMI_FM_RADIO_BIND_EARPHONE__)
- mmi_fmrdo_power_on_main_screen(TRUE);
- #endif
- }
- else
- {
- mdi_audio_set_audio_mode(AUD_MODE_HEADSET);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_earphone_plug_out_callback
- * DESCRIPTION
- * invoke it when plug out earphone
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_earphone_plug_out_callback(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (mmi_bootup_is_in_power_on_period() == MMI_FALSE)
- {
- PRINT_INFORMATION(("mmi_profiles_earphone_plug_out_callback: gactivatedprofile =%dn", gactivatedprofile));
- #if defined(__MMI_FM_RADIO__) && defined(__MMI_FM_RADIO_BIND_EARPHONE__)
- mmi_fmrdo_power_on(FALSE);
- #endif
- #ifdef __MMI_BT_PROFILE__
- #if 0 /* If in bluetooth profile, try to connect SCO back if in call */
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #endif
- #ifdef __MMI_HFP_SUPPORT__
- if (mmi_profiles_bt_is_connected(MMI_PROFILES_BT_HFP_ACL))
- {
- mmi_profiles_bt_activate_profile();
- /* Always connect if Audio via SCO is on */
- #if !defined(__MMI_BT_AUDIO_VIA_SCO__)
- if (g_mmi_profiles_bt_in_call && (g_mmi_profiles_bt_always_use_in_call || mmi_bt_is_aud2hf()))
- #endif
- {
- mmi_profiles_bt_connect_req(MMI_PROFILES_BT_HFP_SCO);
- }
- }
- #endif /* __MMI_HFP_SUPPORT__ */
- #if defined(__MMI_BT_BCHS_SUPPORT__) && defined(__MMI_A2DP_SUPPORT__)
- if (mmi_profiles_bt_is_connected(MMI_PROFILES_BT_A2DP_SIG))
- {
- if (gactivatedprofile != MMI_PROFILE_BT)
- {
- mmi_profiles_bt_activate_profile();
- }
- if (!g_mmi_profiles_bt_in_call)
- {
- mdi_audio_bt_a2dp_turn_on();
- #if defined(__MMI_AUDIO_PLAYER__) && defined(__MMI_AUDIO_SPECTRUM_DISPLAY__) && defined(__MMI_A2DP_PROHIBIT_AUDIO_SPECTRUM_DISPLAY__)
- mmi_audply_disable_spectrum_display();
- #endif
- }
- }
- #endif /* __MMI_BT_BCHS_SUPPORT__ && __MMI_A2DP_SUPPORT__ */
- #endif /* __MMI_BT_PROFILE__ */
- if (mdi_audio_get_audio_mode() != AUD_MODE_LOUDSPK)
- {
- mdi_audio_set_audio_mode(AUD_MODE_NORMAL);
- SetModeSpeechVolume();
- }
- if (gactivatedprofile == MMI_PROFILE_HEADSET)
- {
- mmi_profiles_headset_deactivate_profile();
- }
- }
- else
- {
- mdi_audio_set_audio_mode(AUD_MODE_NORMAL);
- }
- }
- #ifdef __MMI_BT_PROFILE__
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_allow_popup
- * DESCRIPTION
- * check is it allowed to popup
- * PARAMETERS
- * void
- * RETURNS
- * BOOL
- *****************************************************************************/
- BOOL mmi_profiles_bt_allow_popup(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return g_mmi_profiles_bt_in_call;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_connect_sco
- * DESCRIPTION
- * connect sco link
- * PARAMETERS
- * callback [IN] )(void)
- * RETURNS
- * BOOL
- *****************************************************************************/
- BOOL mmi_profiles_bt_connect_sco(void (*callback) (void))
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- BOOL connect = FALSE;
- S32 connect_id;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #ifdef __MMI_HFP_SUPPORT__
- PRINT_INFORMATION( ("mmi_profiles_bt_connect_sco: Allow SCO=[%d], BT Inquery=[%d]n", g_mmi_profiles_bt_allow_sco, g_mmi_profiles_bt_inquerying) );
- if(g_mmi_profiles_bt_allow_sco &&
- !g_mmi_profiles_bt_inquerying &&
- gactivatedprofile == MMI_PROFILE_BT )
- {
- if( mmi_bt_is_hs_connected() )
- {
- connect_id = mmi_bt_get_active_signal_connection_id( MMI_BT_HFG_PROFILE_UUID );
- ASSERT( connect_id >= 0 );
- connect = mdi_audio_bt_open_stream( BT_HFP, (U16)connect_id );
- if( connect )
- {
- mmi_profiles_bt_connect_sco_app_callback = callback;
- }
- #ifdef __MMI_BT_AUDIO_VIA_SCO__
- /* Already Connected, start a timeout timer */
- else if(g_mmi_profiles_bt_sco_timeout &&
- mmi_profiles_bt_is_connected(MMI_PROFILES_BT_HFP_SCO))
- {
- StartTimer(BT_SCO_CONNECT_TIMER, BT_SCO_CONNECT_TIMEOUT_DURATION, mmi_profiles_bt_sco_timeout);
- }
- #endif /* __MMI_BT_AUDIO_VIA_SCO__ */
- }
- g_mmi_profiles_bt_app_in_use = TRUE;
- }
- #endif /* __MMI_HFP_SUPPORT__ */
- return connect;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_disconnect_sco
- * DESCRIPTION
- * disconnect sco link
- * PARAMETERS
- * void
- * RETURNS
- * BOOL
- *****************************************************************************/
- BOOL mmi_profiles_bt_disconnect_sco(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- BOOL disconnect = FALSE;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #ifdef __MMI_HFP_SUPPORT__
- PRINT_INFORMATION( ("mmi_profiles_bt_disconnect_sco: in_call=%d, always_use=%d, aud2hf=%dn",
- g_mmi_profiles_bt_in_call,g_mmi_profiles_bt_always_use_in_call,mmi_bt_is_aud2hf()) );
- if (!g_mmi_profiles_bt_in_call || !(g_mmi_profiles_bt_always_use_in_call || mmi_bt_is_aud2hf()))
- {
- disconnect = mdi_audio_bt_is_stream_open(BT_HFP);
- mdi_audio_bt_close_stream(BT_HFP);
- mmi_profiles_bt_connect_sco_app_callback = NULL;
- }
- g_mmi_profiles_bt_app_in_use = FALSE;
- #endif /* __MMI_HFP_SUPPORT__ */
- return disconnect;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_deactivate_cnf_hdlr
- * DESCRIPTION
- * the cnf handler for bt a2dp deactivate req
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_bt_deactivate_cnf_hdlr(void)
- {
- if (g_mmi_profiles_bt_reset_pending != 0)
- {
- g_mmi_profiles_bt_reset_pending &= 0x0D;
- if (g_mmi_profiles_bt_reset_pending == 0)
- {
- mmi_bt_panic_ind_post_process();
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_reset
- * DESCRIPTION
- * to reset bt profile
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_bt_reset(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_bt_reset: reset_pending = %dn", g_mmi_profiles_bt_reset_pending));
- #if defined(__MMI_BT_BCHS_SUPPORT__) && defined(__MMI_A2DP_SUPPORT__)
- if (mmi_profiles_bt_is_connected(MMI_PROFILES_BT_A2DP_STR))
- {
- g_mmi_profiles_bt_reset_pending |= 2;
- mmi_profiles_bt_disconnect_req(MMI_PROFILES_BT_A2DP_STR);
- }
- #endif /* __MMI_BT_BCHS_SUPPORT__ && __MMI_A2DP_SUPPORT__ */
- #if defined(__BTMTK__) && defined(__MMI_A2DP_SUPPORT__) && defined(__MMI_AUDIO_PLAYER__)
- mmi_audply_bt_power_off_callback(TRUE);
- mmi_bt_a2dp_deactivate_req();
- g_mmi_profiles_bt_reset_pending |= 2;
- #endif
- #ifdef __MMI_HFP_SUPPORT__
- if (mmi_profiles_bt_is_connected(MMI_PROFILES_BT_HFP_SCO))
- {
- g_mmi_profiles_bt_reset_pending |= 1;
- mmi_profiles_bt_disconnect_req(MMI_PROFILES_BT_HFP_SCO);
- }
- mmi_profiles_bt_connect_sco_app_callback = NULL;
- #endif /* __MMI_HFP_SUPPORT__ */
- if (gactivatedprofile == MMI_PROFILE_BT)
- {
- if (mmi_gpio_is_earphone_plug_in())
- {
- mdi_audio_set_audio_mode(AUD_MODE_HEADSET);
- mmi_profiles_headset_activate_profile();
- }
- else
- {
- mmi_profiles_bt_deactivate_profile();
- }
- }
- if (g_mmi_profiles_bt_reset_pending == 0)
- {
- mmi_bt_panic_ind_post_process();
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_is_activated
- * DESCRIPTION
- * to check if bt profile is activated
- * PARAMETERS
- * void
- * RETURNS
- * BOOL
- *****************************************************************************/
- BOOL mmi_profiles_bt_is_activated(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return (gactivatedprofile == MMI_PROFILE_BT);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_open_stream_callback
- * DESCRIPTION
- * a callback function for open bt stream cnf
- * PARAMETERS
- * profile [IN]
- * result [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_bt_open_stream_callback(U8 profile, mdi_result result)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 res;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_bt_open_stream_callback: profile =%d, result = %dn", profile, result));
- if (result == MDI_AUDIO_SUCCESS)
- {
- res = MMI_PROFILES_BT_OK;
- }
- else if (result == MDI_AUDIO_BUSY)
- {
- res = MMI_PROFILES_BT_BUSY;
- }
- else
- {
- res = MMI_PROFILES_BT_FAIL;
- }
- switch (profile)
- {
- #ifdef __MMI_HFP_SUPPORT__
- case BT_HFP:
- mmi_profiles_bt_connect_callback(MMI_PROFILES_BT_HFP_SCO, MMI_PROFILES_BT_RSP, res);
- if( result == MDI_AUDIO_SUCCESS )
- {
- #ifdef __MMI_BT_MTK_SUPPORT__
- mmi_bth_sco_connect_ind_hdler(mmi_bt_get_active_signal_connection_id(MMI_BT_HFG_PROFILE_UUID));
- #else
- mmi_bchs_sco_connect_ind_hdler(mmi_bt_get_active_signal_connection_id(MMI_BT_HFG_PROFILE_UUID));
- #endif
- #ifdef __MMI_BT_AUDIO_VIA_SCO__
- PRINT_INFORMATION( ("Start SCO timer: flag = [%d]n",g_mmi_profiles_bt_sco_timeout) );
- if(g_mmi_profiles_bt_sco_timeout)
- {
- StopTimer(BT_SCO_CONNECT_TIMER);
- StartTimer(BT_SCO_CONNECT_TIMER, BT_SCO_CONNECT_TIMEOUT_DURATION, mmi_profiles_bt_sco_timeout);
- }
- #endif /* #ifdef __MMI_BT_AUDIO_VIA_SCO__ */
- }
- else
- {
- #ifdef __MMI_BT_MTK_SUPPORT__
- mmi_bth_sco_connect_cnf_hdler(1, mmi_bt_get_active_signal_connection_id(MMI_BT_HFG_PROFILE_UUID));
- #else
- mmi_bchs_sco_connect_cnf_hdler(1, mmi_bt_get_active_signal_connection_id(MMI_BT_HFG_PROFILE_UUID));
- #endif
- }
- if (mmi_profiles_bt_connect_sco_app_callback != NULL)
- {
- mmi_profiles_bt_connect_sco_app_callback();
- }
- break;
- #endif /* __MMI_HFP_SUPPORT__ */
- #if defined(__MMI_BT_BCHS_SUPPORT__) && defined(__MMI_A2DP_SUPPORT__)
- case BT_A2DP:
- mmi_profiles_bt_connect_callback(MMI_PROFILES_BT_A2DP_STR, MMI_PROFILES_BT_RSP, res);
- break;
- #endif /* __MMI_BT_BCHS_SUPPORT__ && __MMI_A2DP_SUPPORT__ */
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_close_stream_callback
- * DESCRIPTION
- * a callback function for close bt stream cnf
- * PARAMETERS
- * profile [IN]
- * result [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_bt_close_stream_callback(U8 profile, mdi_result result)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- #if defined(__MMI_BT_AUDIO_VIA_SCO__) || defined(__MMI_BT_FM_VIA_SCO__)
- void (*inquery_callback) (void);
- #endif
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_bt_close_stream_callback: profile =%d, result = %dn", profile, result));
- switch (profile)
- {
- #ifdef __MMI_HFP_SUPPORT__
- case BT_HFP:
- mmi_profiles_bt_disconnect_callback(MMI_PROFILES_BT_HFP_SCO, MMI_PROFILES_BT_RSP, MMI_PROFILES_BT_OK);
- #ifdef __MMI_BT_MTK_SUPPORT__
- mmi_bth_sco_disconnect_ind_hdler(mmi_bt_get_active_signal_connection_id(MMI_BT_HFG_PROFILE_UUID));
- #else
- mmi_bchs_sco_disconnect_ind_hdler(mmi_bt_get_active_signal_connection_id(MMI_BT_HFG_PROFILE_UUID));
- #endif
- #if defined(__MMI_BT_AUDIO_VIA_SCO__) || defined(__MMI_BT_FM_VIA_SCO__)
- /* Callback inquery function because the SCO disconnect is called by BT inquery */
- if(g_mmi_profiles_bt_inquery_callback)
- {
- inquery_callback = g_mmi_profiles_bt_inquery_callback;
- g_mmi_profiles_bt_inquery_callback = NULL;
- inquery_callback();
- }
- #endif
- break;
- #endif /* __MMI_HFP_SUPPORT__ */
- #if defined(__MMI_BT_BCHS_SUPPORT__) && defined(__MMI_A2DP_SUPPORT__)
- case BT_A2DP:
- mmi_profiles_bt_disconnect_callback(MMI_PROFILES_BT_A2DP_STR, MMI_PROFILES_BT_RSP, MMI_PROFILES_BT_OK);
- break;
- #endif /* __MMI_BT_BCHS_SUPPORT__ && __MMI_A2DP_SUPPORT__ */
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_is_connected
- * DESCRIPTION
- * to check if bt is connected
- * PARAMETERS
- * connect_type [IN]
- * RETURNS
- * BOOL
- *****************************************************************************/
- BOOL mmi_profiles_bt_is_connected(U8 connect_type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- BOOL bt_connect = FALSE;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (connect_type)
- {
- #ifdef __MMI_HFP_SUPPORT__
- case MMI_PROFILES_BT_HFP_ACL:
- bt_connect = (BOOL) mmi_bt_is_hs_connected();
- break;
- case MMI_PROFILES_BT_HFP_SCO:
- bt_connect = mdi_audio_bt_is_stream_open(BT_HFP);
- break;
- #endif /* __MMI_HFP_SUPPORT__ */
- #if defined(__MMI_BT_BCHS_SUPPORT__) && defined(__MMI_A2DP_SUPPORT__)
- case MMI_PROFILES_BT_A2DP_SIG:
- bt_connect = (mmi_bt_get_active_signal_connection_id(MMI_BT_ADVANCED_AUDIO_PROFILE_UUID) >= 0);
- break;
- case MMI_PROFILES_BT_A2DP_STR:
- bt_connect = mdi_audio_bt_is_stream_open(BT_A2DP);
- break;
- #endif /* __MMI_BT_BCHS_SUPPORT__ && __MMI_A2DP_SUPPORT__ */
- default:
- ASSERT(0);
- }
- PRINT_INFORMATION(("mmi_profiles_bt_is_connected: connect_type =%d, bt_connect = %dn", connect_type, bt_connect));
- return bt_connect;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_connect_req
- * DESCRIPTION
- * bt connect request
- * PARAMETERS
- * connect_type [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_bt_connect_req(U8 connect_type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 connect_id;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_bt_connect_req: connect_type =[%d], Allow SCO=[%d], BT Inquery=[%d]n",
- connect_type, g_mmi_profiles_bt_allow_sco, g_mmi_profiles_bt_inquerying));
- switch (connect_type)
- {
- #ifdef __MMI_HFP_SUPPORT__
- case MMI_PROFILES_BT_HFP_SCO:
- if(g_mmi_profiles_bt_allow_sco && !g_mmi_profiles_bt_inquerying)
- {
- connect_id = mmi_bt_get_active_signal_connection_id(MMI_BT_HFG_PROFILE_UUID);
- ASSERT(connect_id >= 0);
- mdi_audio_bt_open_stream(BT_HFP, (U16) connect_id);
- }
- break;
- #endif /* __MMI_HFP_SUPPORT__ */
- #if defined(__MMI_BT_BCHS_SUPPORT__) && defined(__MMI_A2DP_SUPPORT__)
- case MMI_PROFILES_BT_A2DP_STR:
- connect_id = mmi_bt_get_active_signal_connection_id(MMI_BT_ADVANCED_AUDIO_PROFILE_UUID);
- ASSERT(connect_id >= 0);
- mdi_audio_bt_open_stream(BT_A2DP, (U16) connect_id);
- break;
- #endif /* __MMI_BT_BCHS_SUPPORT__ && __MMI_A2DP_SUPPORT__ */
- default:
- ASSERT(0);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_disconnect_req
- * DESCRIPTION
- * bt disconnect request
- * PARAMETERS
- * connect_type [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_bt_disconnect_req(U8 connect_type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- #if defined(__MMI_BT_BCHS_SUPPORT__) && defined(__MMI_A2DP_SUPPORT__)
- S32 connect_id;
- #endif
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_bt_disconnect_req: connect_type =%dn", connect_type));
- switch (connect_type)
- {
- #ifdef __MMI_HFP_SUPPORT__
- case MMI_PROFILES_BT_HFP_SCO:
- mdi_audio_bt_close_stream(BT_HFP);
- mmi_profiles_bt_connect_sco_app_callback = NULL;
- break;
- #endif /* __MMI_HFP_SUPPORT__ */
- #if defined(__MMI_BT_BCHS_SUPPORT__) && defined(__MMI_A2DP_SUPPORT__)
- case MMI_PROFILES_BT_A2DP_SIG:
- connect_id = mmi_bt_get_active_signal_connection_id(MMI_BT_ADVANCED_AUDIO_PROFILE_UUID);
- if (connect_id >= 0)
- {
- if (a2dp_signal_disconnecting)
- return;
- a2dp_signal_disconnecting = TRUE;
- mmi_bchs_a2dp_disconnect_req( (U32)connect_id );
- }
- break;
- case MMI_PROFILES_BT_A2DP_STR:
- mdi_audio_bt_close_stream(BT_A2DP);
- break;
- #endif /* __MMI_BT_BCHS_SUPPORT__ && __MMI_A2DP_SUPPORT__ */
- default:
- ASSERT(0);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_call_start_callback
- * DESCRIPTION
- * the call back function for call start
- * PARAMETERS
- * void
- * BOOL(?) [IN] Turn on
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_bt_call_start_callback(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- BOOL speech_on = mdi_audio_is_speech_mode();
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_bt_call_start_callback: in_call=%d,speech_on=%dn", g_mmi_profiles_bt_in_call,
- speech_on));
- if (!g_mmi_profiles_bt_in_call)
- {
- if (gactivatedprofile == MMI_PROFILE_BT)
- {
- #if defined(__MMI_BT_BCHS_SUPPORT__) && defined(__MMI_A2DP_SUPPORT__)
- if (mmi_profiles_bt_is_connected(MMI_PROFILES_BT_A2DP_SIG))
- {
- mdi_audio_bt_a2dp_turn_off();
- }
- #endif /* __MMI_BT_BCHS_SUPPORT__ && __MMI_A2DP_SUPPORT__ */
- #ifdef __MMI_HFP_SUPPORT__
- if (mmi_profiles_bt_is_connected(MMI_PROFILES_BT_HFP_ACL))
- {
- if (g_mmi_profiles_bt_always_use_in_call || mmi_bt_is_aud2hf())
- {
- mmi_profiles_bt_connect_req(MMI_PROFILES_BT_HFP_SCO);
- #ifdef __MMI_BT_AUDIO_VIA_SCO__
- /* Stop SCO timeout timer during call */
- StopTimer(BT_SCO_CONNECT_TIMER);
- #endif /* #ifdef __MMI_BT_AUDIO_VIA_SCO__ */
- }
- }
- #endif /* __MMI_HFP_SUPPORT__ */
- }
- g_mmi_profiles_bt_in_call = TRUE;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_call_end_callback
- * DESCRIPTION
- * the call back function for call end
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_bt_call_end_callback(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- BOOL speech_on = mdi_audio_is_speech_mode();
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_bt_call_end_callback: in_call=%d, speech_on=%dn", g_mmi_profiles_bt_in_call,
- speech_on));
- if (g_mmi_profiles_bt_in_call)
- {
- if (gactivatedprofile == MMI_PROFILE_BT)
- {
- #ifdef __MMI_HFP_SUPPORT__
- if (mmi_profiles_bt_is_connected(MMI_PROFILES_BT_HFP_ACL))
- {
- /* Disconnect later if support audio via BT SCO */
- #ifdef __MMI_BT_AUDIO_VIA_SCO__
- if(g_mmi_profiles_bt_sco_timeout)
- {
- StartTimer(BT_SCO_CONNECT_TIMER, BT_SCO_CONNECT_TIMEOUT_DURATION, mmi_profiles_bt_sco_timeout);
- }
- #else
- mmi_profiles_bt_disconnect_req(MMI_PROFILES_BT_HFP_SCO);
- #endif
- }
- #endif /* __MMI_HFP_SUPPORT__ */
- #if defined(__MMI_BT_BCHS_SUPPORT__) && defined(__MMI_A2DP_SUPPORT__)
- if (mmi_profiles_bt_is_connected(MMI_PROFILES_BT_A2DP_SIG))
- {
- mdi_audio_bt_a2dp_turn_on();
- #if defined(__MMI_AUDIO_PLAYER__) && defined(__MMI_AUDIO_SPECTRUM_DISPLAY__) && defined(__MMI_A2DP_PROHIBIT_AUDIO_SPECTRUM_DISPLAY__)
- mmi_audply_disable_spectrum_display();
- #endif
- }
- #endif /* __MMI_BT_BCHS_SUPPORT__ && __MMI_A2DP_SUPPORT__ */
- }
- g_mmi_profiles_bt_in_call = FALSE;
- #ifdef __MMI_HFP_SUPPORT__
- g_mmi_profiles_bt_always_use_in_call = FALSE;
- #endif
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_connect_callback
- * DESCRIPTION
- * the call back function for bt connect indication
- * PARAMETERS
- * connect_type [IN]
- * callback_type [IN]
- * result [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_bt_connect_callback(U8 connect_type, U8 callback_type, U16 result)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_bt_connect_callback: connect_type =%d, callback_type = %d, result = %dn",
- connect_type, callback_type, result));
- switch (connect_type)
- {
- #ifdef __MMI_HFP_SUPPORT__
- case MMI_PROFILES_BT_HFP_ACL:
- if (callback_type == MMI_PROFILES_BT_IND || callback_type == MMI_PROFILES_BT_RSP)
- {
- if (result == MMI_PROFILES_BT_OK)
- {
- if (gactivatedprofile != MMI_PROFILE_BT)
- {
- #if defined(__MMI_BT_BCHS_SUPPORT__) && defined(__MMI_A2DP_SUPPORT__)
- if (mmi_profiles_bt_is_connected(MMI_PROFILES_BT_A2DP_SIG) && !g_mmi_profiles_bt_in_call)
- {
- mdi_audio_bt_a2dp_turn_on();
- #if defined(__MMI_AUDIO_PLAYER__) && defined(__MMI_AUDIO_SPECTRUM_DISPLAY__) && defined(__MMI_A2DP_PROHIBIT_AUDIO_SPECTRUM_DISPLAY__)
- mmi_audply_disable_spectrum_display();
- #endif
- }
- #endif /* __MMI_BT_BCHS_SUPPORT__ && __MMI_A2DP_SUPPORT__ */
- mmi_profiles_bt_activate_profile();
- }
- /* Always connect if Audio via SCO is on. But need to check FM radio if FM via SCO on */
- #if !defined(__MMI_BT_AUDIO_VIA_SCO__)
- #ifdef __MMI_BT_FM_VIA_SCO__
- if ( (g_mmi_profiles_bt_in_call && (g_mmi_profiles_bt_always_use_in_call || mmi_bt_is_aud2hf()))
- || mdi_audio_is_playing(MDI_AUDIO_PLAY_FM_RADIO) )
- #else
- if (g_mmi_profiles_bt_in_call && (g_mmi_profiles_bt_always_use_in_call || mmi_bt_is_aud2hf()))
- #endif
- #endif
- {
- mmi_profiles_bt_connect_req(MMI_PROFILES_BT_HFP_SCO);
- }
- }
- }
- break;
- case MMI_PROFILES_BT_HFP_SCO:
- if (callback_type == MMI_PROFILES_BT_IND || callback_type == MMI_PROFILES_BT_RSP)
- {
- if (result == MMI_PROFILES_BT_OK)
- {
- /* add a condition check for SCO, if it's not allowed, then disconnect it */
- #if !defined(__MMI_BT_AUDIO_VIA_SCO__)
- #ifdef __MMI_BT_FM_VIA_SCO__
- if( !g_mmi_profiles_bt_app_in_use && !g_mmi_profiles_bt_in_call && !mmi_bt_is_doing_far_end_loopback_test()
- && !mdi_audio_is_playing(MDI_AUDIO_PLAY_FM_RADIO) )
- #else
- if( !g_mmi_profiles_bt_app_in_use && !g_mmi_profiles_bt_in_call && !mmi_bt_is_doing_far_end_loopback_test())
- #endif
- {
- mmi_profiles_bt_disconnect_req( MMI_PROFILES_BT_HFP_SCO );
- return;
- }
- #endif /* #if !defined(__MMI_BT_AUDIO_VIA_SCO__) */
- if (gactivatedprofile != MMI_PROFILE_BT)
- mmi_profiles_bt_activate_profile();
- if (g_mmi_profiles_bt_in_call)
- {
- g_mmi_profiles_bt_always_use_in_call = TRUE;
- }
- }
- }
- break;
- #endif /* __MMI_HFP_SUPPORT__ */
- #if defined(__MMI_BT_BCHS_SUPPORT__) && defined(__MMI_A2DP_SUPPORT__)
- case MMI_PROFILES_BT_A2DP_SIG:
- if (callback_type == MMI_PROFILES_BT_IND || callback_type == MMI_PROFILES_BT_RSP)
- {
- if (result == MMI_PROFILES_BT_OK)
- {
- mmi_profiles_bt_connect_req(MMI_PROFILES_BT_A2DP_STR);
- }
- }
- break;
- case MMI_PROFILES_BT_A2DP_STR:
- if (callback_type == MMI_PROFILES_BT_IND || callback_type == MMI_PROFILES_BT_RSP)
- {
- if (result == MMI_PROFILES_BT_OK)
- {
- if (!g_mmi_profiles_bt_in_call)
- {
- mdi_audio_bt_a2dp_turn_on();
- #if defined(__MMI_AUDIO_PLAYER__) && defined(__MMI_AUDIO_SPECTRUM_DISPLAY__) && defined(__MMI_A2DP_PROHIBIT_AUDIO_SPECTRUM_DISPLAY__)
- mmi_audply_disable_spectrum_display();
- #endif
- }
- if (gactivatedprofile != MMI_PROFILE_BT)
- mmi_profiles_bt_activate_profile();
- }
- else if (result != MMI_PROFILES_BT_BUSY)
- {
- if (mmi_profiles_bt_is_connected(MMI_PROFILES_BT_A2DP_SIG))
- {
- mmi_profiles_bt_disconnect_req(MMI_PROFILES_BT_A2DP_SIG);
- }
- }
- }
- break;
- #endif /* __MMI_BT_BCHS_SUPPORT__ && __MMI_A2DP_SUPPORT__ */
- default:
- ASSERT(0);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_disconnect_callback
- * DESCRIPTION
- * the call back function for bt disconnect indication
- * PARAMETERS
- * connect_type [IN]
- * callback_type [IN]
- * result [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_bt_disconnect_callback(U8 connect_type, U8 callback_type, U16 result)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_bt_disconnect_callback: connect_type =%d, callback_type = %d, result = %dn",
- connect_type, callback_type, result));
- switch (connect_type)
- {
- #ifdef __MMI_HFP_SUPPORT__
- case MMI_PROFILES_BT_HFP_ACL:
- if (callback_type == MMI_PROFILES_BT_IND || callback_type == MMI_PROFILES_BT_RSP)
- {
- mmi_profiles_bt_disconnect_req(MMI_PROFILES_BT_HFP_SCO);
- if (gactivatedprofile == MMI_PROFILE_BT)
- {
- #if defined(__MMI_BT_BCHS_SUPPORT__) && defined(__MMI_A2DP_SUPPORT__)
- if (mmi_profiles_bt_is_connected(MMI_PROFILES_BT_A2DP_SIG))
- {
- return;
- }
- #endif /* __MMI_BT_BCHS_SUPPORT__ && __MMI_A2DP_SUPPORT__ */
- if (mmi_gpio_is_earphone_plug_in())
- {
- mdi_audio_set_audio_mode(AUD_MODE_HEADSET);
- mmi_profiles_headset_activate_profile();
- }
- else
- {
- mmi_profiles_bt_deactivate_profile();
- }
- }
- }
- break;
- case MMI_PROFILES_BT_HFP_SCO:
- if (callback_type == MMI_PROFILES_BT_IND || callback_type == MMI_PROFILES_BT_RSP)
- {
- if (g_mmi_profiles_bt_reset_pending != 0)
- {
- g_mmi_profiles_bt_reset_pending &= 0x0E;
- if (g_mmi_profiles_bt_reset_pending == 0)
- {
- mmi_bt_panic_ind_post_process();
- }
- }
- else
- {
- #if defined(__MMI_BT_BCHS_SUPPORT__) && defined(__MMI_A2DP_SUPPORT__)
- if( gactivatedprofile == MMI_PROFILE_BT )
- {
- if( mmi_profiles_bt_is_connected( MMI_PROFILES_BT_A2DP_SIG ) )
- {
- if( !g_mmi_profiles_bt_app_in_use && !g_mmi_profiles_bt_in_call )
- {
- mdi_audio_bt_a2dp_turn_on();
- #if defined( __MMI_AUDIO_PLAYER__ ) && defined( __MMI_AUDIO_SPECTRUM_DISPLAY__ ) && defined( __MMI_A2DP_PROHIBIT_AUDIO_SPECTRUM_DISPLAY__ )
- mmi_audply_disable_spectrum_display();
- #endif
- }
- }
- }
- #endif // __MMI_BT_BCHS_SUPPORT__ && __MMI_A2DP_SUPPORT__
- }
- }
- break;
- #endif /* __MMI_HFP_SUPPORT__ */
- #if defined(__MMI_BT_BCHS_SUPPORT__) && defined(__MMI_A2DP_SUPPORT__)
- case MMI_PROFILES_BT_A2DP_SIG:
- if (callback_type == MMI_PROFILES_BT_IND || callback_type == MMI_PROFILES_BT_RSP)
- {
- a2dp_signal_disconnecting = FALSE;
- mmi_profiles_bt_disconnect_req(MMI_PROFILES_BT_A2DP_STR);
- if (gactivatedprofile == MMI_PROFILE_BT)
- {
- #ifdef __MMI_HFP_SUPPORT__
- if (mmi_profiles_bt_is_connected(MMI_PROFILES_BT_HFP_ACL))
- {
- return;
- }
- #endif /* __MMI_HFP_SUPPORT__ */
- if (mmi_gpio_is_earphone_plug_in())
- {
- mdi_audio_set_audio_mode(AUD_MODE_HEADSET);
- mmi_profiles_headset_activate_profile();
- }
- else
- {
- mmi_profiles_bt_deactivate_profile();
- }
- }
- }
- break;
- case MMI_PROFILES_BT_A2DP_STR:
- if (callback_type == MMI_PROFILES_BT_IND || callback_type == MMI_PROFILES_BT_RSP)
- {
- if( mmi_profiles_bt_is_connected( MMI_PROFILES_BT_A2DP_SIG ) )
- {
- mmi_profiles_bt_disconnect_req( MMI_PROFILES_BT_A2DP_SIG );
- }
- if (gactivatedprofile == MMI_PROFILE_BT)
- {
- #ifdef __MMI_HFP_SUPPORT__
- if (!g_mmi_profiles_bt_in_call || !mmi_profiles_bt_is_connected(MMI_PROFILES_BT_HFP_SCO))
- #endif
- {
- if (mmi_gpio_is_earphone_plug_in())
- {
- mdi_audio_set_audio_mode(AUD_MODE_HEADSET);
- mmi_profiles_headset_activate_profile();
- }
- }
- mdi_audio_bt_a2dp_turn_off();
- }
- if (g_mmi_profiles_bt_reset_pending != 0)
- {
- g_mmi_profiles_bt_reset_pending &= 0x0D;
- if (g_mmi_profiles_bt_reset_pending == 0)
- {
- mmi_bt_panic_ind_post_process();
- }
- }
- else
- {
- mmi_bt_profile_callback_before_release_connection(
- 0,
- 0,
- 0,
- MMI_BT_ADVANCED_AUDIO_PROFILE_UUID,
- 0xFFFFFFFF);
- }
- }
- break;
- #endif /* __MMI_BT_BCHS_SUPPORT__ && __MMI_A2DP_SUPPORT__ */
- default:
- ASSERT(0);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_activate_profile
- * DESCRIPTION
- * activate BT profile
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_bt_activate_profile(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_bt_activate_profile: gactivatedprofile =%d, glastactivatedprofile = %dn",
- gactivatedprofile, glastactivatedprofile));
- gprofileheadset = 0;
- //KP Jerry modify on 2007-4-3 start
- #ifdef __MMI_PROFILE_POWER_SAVING__
- if (gactivatedprofile != MMI_PROFILE_SILENT && gactivatedprofile != MMI_PROFILE_HEADSET &&
- gactivatedprofile != MMI_PROFILE_BT && gactivatedprofile != MMI_PROFILE_POWER_SAVING)
- #else/*!__MMI_PROFILE_POWER_SAVING__*/
- if (gactivatedprofile != MMI_PROFILE_SILENT && gactivatedprofile != MMI_PROFILE_HEADSET &&
- gactivatedprofile != MMI_PROFILE_BT)
- #endif/*__MMI_PROFILE_POWER_SAVING__*/
- //KP Jerry modify on 2007-4-3 end
- {
- glastactivatedprofile = gactivatedprofile;
- }
- gactivatedprofile = MMI_PROFILE_BT;
- memcpy(&gcurrentprofile, &gprofiles[gactivatedprofile], sizeof(PROFILE));
- WriteValue(NVRAM_PROFILES_LASTACTIVATED, &glastactivatedprofile, DS_BYTE, &error);
- showAlertStatusIcons();
- change_font();
- mdi_audio_set_volume_no_apply(MDI_VOLUME_MEDIA, GetRingVolumeLevel());
- SetKeyPadVolume(GetKeypadVolumeLevel());
- mdi_audio_set_mic_volume();
- //KP Jerry add on 2007-03-31 start
- #ifdef __MMI_PROFILE_POWER_SAVING__
- ProfileResetBackLightSetting();
- ProfilesResetKeyBacklight();
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
- #endif
- //KP Jerry add on 2007-03-31 end
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_deactivate_profile
- * DESCRIPTION
- * deactivate BT profile
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_bt_deactivate_profile(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_bt_deactivate_profile: gactivatedprofile =%d, glastactivatedprofile = %dn",
- gactivatedprofile, glastactivatedprofile));
- ReadValue(NVRAM_PROFILES_ACTIVATED, &gactivatedprofile, DS_BYTE, &error);
- memcpy(&gcurrentprofile, &gprofiles[gactivatedprofile], sizeof(PROFILE));
- showAlertStatusIcons();
- change_font();
- mdi_audio_set_volume_no_apply(MDI_VOLUME_MEDIA, GetRingVolumeLevel());
- SetKeyPadVolume(GetKeypadVolumeLevel());
- mdi_audio_set_mic_volume();
- //KP Jerry add on 2007-03-31 start
- #ifdef __MMI_PROFILE_POWER_SAVING__
- ProfileResetBackLightSetting();
- ProfilesResetKeyBacklight();
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
- #endif
- //KP Jerry add on 2007-03-31 end
- }
- #if defined(__MMI_BT_AUDIO_VIA_SCO__) || defined(__MMI_BT_FM_VIA_SCO__)
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_disable_sco_timeout
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_bt_disable_sco_timeout(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_bt_disable_sco_timeoutn"));
- StopTimer(BT_SCO_CONNECT_TIMER);
- g_mmi_profiles_bt_sco_timeout = MMI_FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_enable_sco_timeout
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_bt_enable_sco_timeout(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_bt_enable_sco_timeoutn"));
- g_mmi_profiles_bt_sco_timeout = MMI_TRUE;
- if(mmi_profiles_bt_is_connected(MMI_PROFILES_BT_HFP_SCO))
- {
- StartTimer(BT_SCO_CONNECT_TIMER, BT_SCO_CONNECT_TIMEOUT_DURATION, mmi_profiles_bt_sco_timeout);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_disable_sco_connection
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_bt_disable_sco_connection(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_bt_disable_sco_connectionn"));
- StopTimer(BT_SCO_CONNECT_TIMER);
- //g_mmi_profiles_bt_sco_timeout = MMI_FALSE;
- g_mmi_profiles_bt_allow_sco = MMI_FALSE;
- mmi_profiles_bt_disconnect_sco();
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_enable_sco_connection
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_bt_enable_sco_connection(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_bt_enable_sco_timeoutn"));
- //g_mmi_profiles_bt_sco_timeout = MMI_TRUE;
- g_mmi_profiles_bt_allow_sco = MMI_TRUE;
- mmi_profiles_bt_connect_sco(NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_sco_timeout
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_bt_sco_timeout(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_bt_sco_timeout: SCO connected =%d, bt_in_call=%dn", mmi_profiles_bt_is_connected(MMI_PROFILES_BT_HFP_SCO), g_mmi_profiles_bt_in_call));
- if(mmi_profiles_bt_is_connected(MMI_PROFILES_BT_HFP_SCO))
- {
- /* If audio/video is not playing or not in call */
- if(!g_mmi_profiles_bt_in_call
- && mdi_audio_is_idle()
- && !mdi_video_is_playing()
- && !mdi_video_is_recording()
- #if defined(BGSND_ENABLE)
- && !mdi_audio_snd_is_playing()
- #endif
- )
- {
- mmi_profiles_bt_disconnect_sco();
- }
- /* still using audio resource, disconnect later */
- else if(g_mmi_profiles_bt_sco_timeout && !g_mmi_profiles_bt_in_call)
- {
- StartTimer(BT_SCO_CONNECT_TIMER, BT_SCO_CONNECT_TIMEOUT_DURATION, mmi_profiles_bt_sco_timeout);
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_inquery_start_callback
- * DESCRIPTION
- * Callback function for BT inquery
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_bt_inquery_start_callback(void (*callback) (void))
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 sco_status;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- sco_status = mdi_audio_bt_get_stream_status(BT_HFP);
- g_mmi_profiles_bt_inquery_callback = NULL;
- PRINT_INFORMATION(("mmi_profiles_bt_inquery_start_callback: SCO status = [%d]", sco_status));
- switch(sco_status)
- {
- case MDI_AUDIO_BT_STATE_IDLE:
- callback();
- break;
- case MDI_AUDIO_BT_STATE_WAIT_CLOSE:
- g_mmi_profiles_bt_inquery_callback = callback;
- break;
- case MDI_AUDIO_BT_STATE_OPEN:
- case MDI_AUDIO_BT_STATE_WAIT_OPEN:
- StopTimer(BT_SCO_CONNECT_TIMER);
- g_mmi_profiles_bt_inquery_callback = callback;
- g_mmi_profiles_bt_inquerying = MMI_TRUE;
- mdi_audio_suspend_background_play();
- mmi_profiles_bt_disconnect_sco();
- break;
- default:
- ASSERT(0);
- break;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_profiles_bt_inquery_stop_callback
- * DESCRIPTION
- * Callback function for BT inquery
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_profiles_bt_inquery_stop_callback(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("mmi_profiles_bt_inquery_stop_callback"));
- g_mmi_profiles_bt_inquery_callback = NULL;
- /* Connect SCO after background play resume */
- g_mmi_profiles_bt_inquerying = MMI_FALSE;
- mdi_audio_resume_background_play();
- }
- #endif /* #if defined(__MMI_BT_AUDIO_VIA_SCO__) || defined(__MMI_BT_FM_VIA_SCO__) */
- #endif /* __MMI_BT_PROFILE__ */