зеркало из https://github.com/mozilla/gecko-dev.git
Bug 830672 - audio-channel-changed is properly when an audio channel is visible, r=mchen
This commit is contained in:
Родитель
84609c4505
Коммит
c881379fed
|
@ -228,7 +228,7 @@ AudioChannelService::SendAudioChannelChangedNotification()
|
|||
// Calculating the most important active channel.
|
||||
AudioChannelType higher = AUDIO_CHANNEL_LAST;
|
||||
|
||||
// Top-Down in the hierarchy.
|
||||
// Top-Down in the hierarchy for visible elements
|
||||
if (!mChannelCounters[AUDIO_CHANNEL_INT_PUBLICNOTIFICATION].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_PUBLICNOTIFICATION;
|
||||
}
|
||||
|
@ -249,18 +249,41 @@ AudioChannelService::SendAudioChannelChangedNotification()
|
|||
higher = AUDIO_CHANNEL_NOTIFICATION;
|
||||
}
|
||||
|
||||
// Only 1 content channel hidden or a visible one.
|
||||
else if ((!mChannelCounters[AUDIO_CHANNEL_INT_CONTENT_HIDDEN].IsEmpty() &&
|
||||
!HasMoreThanOneContentChannelHidden()) ||
|
||||
!mChannelCounters[AUDIO_CHANNEL_INT_CONTENT].IsEmpty()) {
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_CONTENT].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_CONTENT;
|
||||
}
|
||||
|
||||
// At least 1 visible normal channel.
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_NORMAL].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_NORMAL;
|
||||
}
|
||||
|
||||
// Top-Down in the hierarchy for non-visible elements
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_PUBLICNOTIFICATION_HIDDEN].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_PUBLICNOTIFICATION;
|
||||
}
|
||||
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_RINGER_HIDDEN].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_RINGER;
|
||||
}
|
||||
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_TELEPHONY_HIDDEN].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_TELEPHONY;
|
||||
}
|
||||
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_ALARM_HIDDEN].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_ALARM;
|
||||
}
|
||||
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_NOTIFICATION_HIDDEN].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_NOTIFICATION;
|
||||
}
|
||||
|
||||
// Content channels play in background if just one is active.
|
||||
else if ((!mChannelCounters[AUDIO_CHANNEL_INT_CONTENT_HIDDEN].IsEmpty() &&
|
||||
!HasMoreThanOneContentChannelHidden())) {
|
||||
higher = AUDIO_CHANNEL_CONTENT;
|
||||
}
|
||||
|
||||
if (higher != mCurrentHigherChannel) {
|
||||
mCurrentHigherChannel = higher;
|
||||
|
||||
|
@ -304,7 +327,7 @@ AudioChannelService::Notify()
|
|||
bool
|
||||
AudioChannelService::ChannelsActiveWithHigherPriorityThan(AudioChannelInternalType aType)
|
||||
{
|
||||
for (int i = AUDIO_CHANNEL_INT_PUBLICNOTIFICATION;
|
||||
for (int i = AUDIO_CHANNEL_INT_LAST - 1;
|
||||
i != AUDIO_CHANNEL_INT_CONTENT_HIDDEN; --i) {
|
||||
if (i == aType) {
|
||||
return false;
|
||||
|
@ -389,26 +412,38 @@ AudioChannelService::GetInternalType(AudioChannelType aType,
|
|||
switch (aType) {
|
||||
case AUDIO_CHANNEL_NORMAL:
|
||||
return aElementHidden
|
||||
? AUDIO_CHANNEL_INT_NORMAL_HIDDEN : AUDIO_CHANNEL_INT_NORMAL;
|
||||
? AUDIO_CHANNEL_INT_NORMAL_HIDDEN
|
||||
: AUDIO_CHANNEL_INT_NORMAL;
|
||||
|
||||
case AUDIO_CHANNEL_CONTENT:
|
||||
return aElementHidden
|
||||
? AUDIO_CHANNEL_INT_CONTENT_HIDDEN : AUDIO_CHANNEL_INT_CONTENT;
|
||||
? AUDIO_CHANNEL_INT_CONTENT_HIDDEN
|
||||
: AUDIO_CHANNEL_INT_CONTENT;
|
||||
|
||||
case AUDIO_CHANNEL_NOTIFICATION:
|
||||
return AUDIO_CHANNEL_INT_NOTIFICATION;
|
||||
return aElementHidden
|
||||
? AUDIO_CHANNEL_INT_NOTIFICATION_HIDDEN
|
||||
: AUDIO_CHANNEL_INT_NOTIFICATION;
|
||||
|
||||
case AUDIO_CHANNEL_ALARM:
|
||||
return AUDIO_CHANNEL_INT_ALARM;
|
||||
return aElementHidden
|
||||
? AUDIO_CHANNEL_INT_ALARM_HIDDEN
|
||||
: AUDIO_CHANNEL_INT_ALARM;
|
||||
|
||||
case AUDIO_CHANNEL_TELEPHONY:
|
||||
return AUDIO_CHANNEL_INT_TELEPHONY;
|
||||
return aElementHidden
|
||||
? AUDIO_CHANNEL_INT_TELEPHONY_HIDDEN
|
||||
: AUDIO_CHANNEL_INT_TELEPHONY;
|
||||
|
||||
case AUDIO_CHANNEL_RINGER:
|
||||
return AUDIO_CHANNEL_INT_RINGER;
|
||||
return aElementHidden
|
||||
? AUDIO_CHANNEL_INT_RINGER_HIDDEN
|
||||
: AUDIO_CHANNEL_INT_RINGER;
|
||||
|
||||
case AUDIO_CHANNEL_PUBLICNOTIFICATION:
|
||||
return AUDIO_CHANNEL_INT_PUBLICNOTIFICATION;
|
||||
return aElementHidden
|
||||
? AUDIO_CHANNEL_INT_PUBLICNOTIFICATION_HIDDEN
|
||||
: AUDIO_CHANNEL_INT_PUBLICNOTIFICATION;
|
||||
|
||||
case AUDIO_CHANNEL_LAST:
|
||||
default:
|
||||
|
|
|
@ -84,10 +84,15 @@ protected:
|
|||
AUDIO_CHANNEL_INT_CONTENT,
|
||||
AUDIO_CHANNEL_INT_CONTENT_HIDDEN,
|
||||
AUDIO_CHANNEL_INT_NOTIFICATION,
|
||||
AUDIO_CHANNEL_INT_NOTIFICATION_HIDDEN,
|
||||
AUDIO_CHANNEL_INT_ALARM,
|
||||
AUDIO_CHANNEL_INT_ALARM_HIDDEN,
|
||||
AUDIO_CHANNEL_INT_TELEPHONY,
|
||||
AUDIO_CHANNEL_INT_TELEPHONY_HIDDEN,
|
||||
AUDIO_CHANNEL_INT_RINGER,
|
||||
AUDIO_CHANNEL_INT_RINGER_HIDDEN,
|
||||
AUDIO_CHANNEL_INT_PUBLICNOTIFICATION,
|
||||
AUDIO_CHANNEL_INT_PUBLICNOTIFICATION_HIDDEN,
|
||||
AUDIO_CHANNEL_INT_LAST
|
||||
};
|
||||
|
||||
|
|
|
@ -278,6 +278,69 @@ TestPriorities()
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
TEST_ENSURE_BASE(!playing, "Test4: A ringer channel unvisible agent should not be playing when a public notification is playing");
|
||||
|
||||
// Settings visible the normal channel.
|
||||
rv = normalAgent.mAgent->SetVisibilityState(true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Normal should be playing because visible.
|
||||
rv = normalAgent.StartPlaying(&playing);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
TEST_ENSURE_BASE(playing, "Test4: A normal channel visible agent should be playing");
|
||||
|
||||
// Settings visible the content channel.
|
||||
rv = contentAgent.mAgent->SetVisibilityState(true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Content should be playing because visible.
|
||||
rv = contentAgent.StartPlaying(&playing);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
TEST_ENSURE_BASE(playing, "Test4: A content channel visible agent should be playing");
|
||||
|
||||
// Settings visible the notification channel.
|
||||
rv = notificationAgent.mAgent->SetVisibilityState(true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Notification should be playing because visible.
|
||||
rv = notificationAgent.StartPlaying(&playing);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
TEST_ENSURE_BASE(playing, "Test4: A notification channel visible agent should be playing");
|
||||
|
||||
// Settings visible the alarm channel.
|
||||
rv = alarmAgent.mAgent->SetVisibilityState(true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Alarm should be playing because visible.
|
||||
rv = alarmAgent.StartPlaying(&playing);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
TEST_ENSURE_BASE(playing, "Test4: A alarm channel visible agent should be playing");
|
||||
|
||||
// Settings visible the telephony channel.
|
||||
rv = telephonyAgent.mAgent->SetVisibilityState(true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Telephony should be playing because visible.
|
||||
rv = telephonyAgent.StartPlaying(&playing);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
TEST_ENSURE_BASE(playing, "Test4: A telephony channel visible agent should be playing");
|
||||
|
||||
// Settings visible the ringer channel.
|
||||
rv = ringerAgent.mAgent->SetVisibilityState(true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Ringer should be playing because visible.
|
||||
rv = ringerAgent.StartPlaying(&playing);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
TEST_ENSURE_BASE(playing, "Test4: A ringer channel visible agent should be playing");
|
||||
|
||||
// Settings visible the pNotification channel.
|
||||
rv = pNotificationAgent.mAgent->SetVisibilityState(true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// pNotification should be playing because visible.
|
||||
rv = pNotificationAgent.StartPlaying(&playing);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
TEST_ENSURE_BASE(playing, "Test4: A pNotification channel visible agent should be playing");
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче