From df04ea4684753d3b4a1cf858fc813dcd08a1aa33 Mon Sep 17 00:00:00 2001 From: Marco Chen Date: Wed, 17 Jul 2013 14:21:00 +0800 Subject: [PATCH] Bug 889730 - Switch states of Headphone are not only On/Off but Headset/Headphone. r=baku --- dom/system/gonk/AudioChannelManager.cpp | 8 +------- dom/system/gonk/AudioChannelManager.h | 3 ++- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/dom/system/gonk/AudioChannelManager.cpp b/dom/system/gonk/AudioChannelManager.cpp index fcbb3c36f350..9be9834ff9a6 100644 --- a/dom/system/gonk/AudioChannelManager.cpp +++ b/dom/system/gonk/AudioChannelManager.cpp @@ -41,13 +41,7 @@ AudioChannelManager::WrapObject(JSContext* aCx, JS::Handle aScope) void AudioChannelManager::Notify(const SwitchEvent& aEvent) { - if (aEvent.status() == SWITCH_STATE_ON || - aEvent.status() == SWITCH_STATE_HEADSET || - aEvent.status() == SWITCH_STATE_HEADPHONE) { - mState = SWITCH_STATE_ON; - } else { - mState = SWITCH_STATE_OFF; - } + mState = aEvent.status(); DispatchTrustedEvent(NS_LITERAL_STRING("headphoneschange")); } diff --git a/dom/system/gonk/AudioChannelManager.h b/dom/system/gonk/AudioChannelManager.h index 947be8c07027..91aac3c23b31 100644 --- a/dom/system/gonk/AudioChannelManager.h +++ b/dom/system/gonk/AudioChannelManager.h @@ -43,7 +43,8 @@ public: bool Headphones() const { - return mState == hal::SWITCH_STATE_ON; + MOZ_ASSERT(mState != hal::SWITCH_STATE_UNKNOWN); + return mState != hal::SWITCH_STATE_OFF; } IMPL_EVENT_HANDLER(headphoneschange)