зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1006380
- Set phone in PHONE_STATE_IN_COMMUNICATION audio state when telephony audio channel is in use. r=mchen
This commit is contained in:
Родитель
e109c7cd41
Коммит
b1de933084
|
@ -432,6 +432,13 @@ AudioChannelService::ContentOrNormalChannelIsActive()
|
|||
!mChannelCounters[AUDIO_CHANNEL_INT_NORMAL].IsEmpty();
|
||||
}
|
||||
|
||||
bool
|
||||
AudioChannelService::TelephonyChannelIsActive()
|
||||
{
|
||||
return !mChannelCounters[AUDIO_CHANNEL_INT_TELEPHONY].IsEmpty() ||
|
||||
!mChannelCounters[AUDIO_CHANNEL_INT_TELEPHONY_HIDDEN].IsEmpty();
|
||||
}
|
||||
|
||||
bool
|
||||
AudioChannelService::ProcessContentOrNormalChannelIsActive(uint64_t aChildID)
|
||||
{
|
||||
|
|
|
@ -74,6 +74,12 @@ public:
|
|||
*/
|
||||
virtual bool ContentOrNormalChannelIsActive();
|
||||
|
||||
/**
|
||||
* Return true if there is a telephony channel active in this process
|
||||
* or one of its subprocesses.
|
||||
*/
|
||||
virtual bool TelephonyChannelIsActive();
|
||||
|
||||
/**
|
||||
* Return true if a normal or content channel is active for the given
|
||||
* process ID.
|
||||
|
|
|
@ -47,12 +47,13 @@ using namespace mozilla::dom::bluetooth;
|
|||
|
||||
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "AudioManager" , ## args)
|
||||
|
||||
#define HEADPHONES_STATUS_HEADSET MOZ_UTF16("headset")
|
||||
#define HEADPHONES_STATUS_HEADPHONE MOZ_UTF16("headphone")
|
||||
#define HEADPHONES_STATUS_OFF MOZ_UTF16("off")
|
||||
#define HEADPHONES_STATUS_UNKNOWN MOZ_UTF16("unknown")
|
||||
#define HEADPHONES_STATUS_CHANGED "headphones-status-changed"
|
||||
#define MOZ_SETTINGS_CHANGE_ID "mozsettings-changed"
|
||||
#define HEADPHONES_STATUS_HEADSET MOZ_UTF16("headset")
|
||||
#define HEADPHONES_STATUS_HEADPHONE MOZ_UTF16("headphone")
|
||||
#define HEADPHONES_STATUS_OFF MOZ_UTF16("off")
|
||||
#define HEADPHONES_STATUS_UNKNOWN MOZ_UTF16("unknown")
|
||||
#define HEADPHONES_STATUS_CHANGED "headphones-status-changed"
|
||||
#define MOZ_SETTINGS_CHANGE_ID "mozsettings-changed"
|
||||
#define AUDIO_CHANNEL_PROCESS_CHANGED "audio-channel-process-changed"
|
||||
|
||||
static void BinderDeadCallback(status_t aErr);
|
||||
static void InternalSetAudioRoutes(SwitchState aState);
|
||||
|
@ -280,6 +281,32 @@ AudioManager::HandleBluetoothStatusChanged(nsISupports* aSubject,
|
|||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
AudioManager::HandleAudioChannelProcessChanged()
|
||||
{
|
||||
// Note: If the user answers a VoIP call (e.g. WebRTC calls) during the
|
||||
// telephony call (GSM/CDMA calls) the audio manager won't set the
|
||||
// PHONE_STATE_IN_COMMUNICATION audio state. Once the telephony call finishes
|
||||
// the RIL plumbing sets the PHONE_STATE_NORMAL audio state. This seems to be
|
||||
// an issue for the VoIP call but it is not. Once the RIL plumbing sets the
|
||||
// the PHONE_STATE_NORMAL audio state the AudioManager::mPhoneAudioAgent
|
||||
// member will call the StopPlaying() method causing that this function will
|
||||
// be called again and therefore the audio manager sets the
|
||||
// PHONE_STATE_IN_COMMUNICATION audio state.
|
||||
|
||||
if ((mPhoneState == PHONE_STATE_IN_CALL) ||
|
||||
(mPhoneState == PHONE_STATE_RINGTONE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
AudioChannelService *service = AudioChannelService::GetAudioChannelService();
|
||||
NS_ENSURE_TRUE_VOID(service);
|
||||
|
||||
bool telephonyChannelIsActive = service->TelephonyChannelIsActive();
|
||||
telephonyChannelIsActive ? SetPhoneState(PHONE_STATE_IN_COMMUNICATION) :
|
||||
SetPhoneState(PHONE_STATE_NORMAL);
|
||||
}
|
||||
|
||||
nsresult
|
||||
AudioManager::Observe(nsISupports* aSubject,
|
||||
const char* aTopic,
|
||||
|
@ -298,6 +325,11 @@ AudioManager::Observe(nsISupports* aSubject,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
else if (!strcmp(aTopic, AUDIO_CHANNEL_PROCESS_CHANGED)) {
|
||||
HandleAudioChannelProcessChanged();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// To process the volume control on each audio channel according to
|
||||
// change of settings
|
||||
else if (!strcmp(aTopic, MOZ_SETTINGS_CHANGE_ID)) {
|
||||
|
@ -429,6 +461,9 @@ AudioManager::AudioManager()
|
|||
if (NS_FAILED(obs->AddObserver(this, MOZ_SETTINGS_CHANGE_ID, false))) {
|
||||
NS_WARNING("Failed to add mozsettings-changed observer!");
|
||||
}
|
||||
if (NS_FAILED(obs->AddObserver(this, AUDIO_CHANNEL_PROCESS_CHANGED, false))) {
|
||||
NS_WARNING("Failed to add audio-channel-process-changed observer!");
|
||||
}
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
char value[PROPERTY_VALUE_MAX];
|
||||
|
@ -456,6 +491,9 @@ AudioManager::~AudioManager() {
|
|||
if (NS_FAILED(obs->RemoveObserver(this, MOZ_SETTINGS_CHANGE_ID))) {
|
||||
NS_WARNING("Failed to remove mozsettings-changed observer!");
|
||||
}
|
||||
if (NS_FAILED(obs->RemoveObserver(this, AUDIO_CHANNEL_PROCESS_CHANGED))) {
|
||||
NS_WARNING("Failed to remove audio-channel-process-changed!");
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -73,6 +73,7 @@ private:
|
|||
void HandleBluetoothStatusChanged(nsISupports* aSubject,
|
||||
const char* aTopic,
|
||||
const nsCString aAddress);
|
||||
void HandleAudioChannelProcessChanged();
|
||||
};
|
||||
|
||||
} /* namespace gonk */
|
||||
|
|
Загрузка…
Ссылка в новой задаче