Bug 889730 - Switch states of Headphone are not only On/Off but Headset/Headphone. r=baku
☠☠ backed out by 1b93158f0bf7 ☠ ☠
authorMarco Chen <mchen@mozilla.com>
Tue, 16 Jul 2013 16:30:41 +0800
changeset 138710 129a238dbe1f3e2c47a768f4bfdd49a392426567
parent 138709 aa90caa3271c151b45463a2cde758eb8c759dec4
child 138711 ecc66980e9c8f07ba1b9cef658a00432df10fa98
push id24964
push userryanvm@gmail.com
push dateTue, 16 Jul 2013 20:04:09 +0000
treeherderautoland@fd10ead17ace [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs889730
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 889730 - Switch states of Headphone are not only On/Off but Headset/Headphone. r=baku
dom/system/gonk/AudioChannelManager.cpp
dom/system/gonk/AudioChannelManager.h
--- a/dom/system/gonk/AudioChannelManager.cpp
+++ b/dom/system/gonk/AudioChannelManager.cpp
@@ -36,22 +36,16 @@ JSObject*
 AudioChannelManager::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return AudioChannelManagerBinding::Wrap(aCx, aScope, this);
 }
 
 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"));
 }
 
 } // namespace system
 } // namespace dom
 } // namespace mozilla
--- a/dom/system/gonk/AudioChannelManager.h
+++ b/dom/system/gonk/AudioChannelManager.h
@@ -38,17 +38,18 @@ public:
      return GetOwner();
   }
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   bool Headphones() const
   {
-    return mState == hal::SWITCH_STATE_ON;
+    MOZ_ASSERT(mState != SWITCH_STATE_UNKNOWN);
+    return mState != hal::SWITCH_STATE_OFF;
   }
 
   IMPL_EVENT_HANDLER(headphoneschange)
 
 private:
   hal::SwitchState mState;
 };