B2G telephony: need to reset audio state when phone call ends

VERIFIED FIXED in mozilla15

Status

()

Core
DOM: Device Interfaces
VERIFIED FIXED
5 years ago
5 years ago

People

(Reporter: philikon, Assigned: hsinyi)

Tracking

Trunk
mozilla15
ARM
Gonk (Firefox OS)
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

Apparently enabling/disabling the loud speaker or muting a call continues to have an effect on the audio system after the phone call ends. See https://github.com/andreasgal/gaia/issues/1281#issuecomment-5371389 for the original report.

I suspect we need to reset gAudioManager.microphoneMuted as well as gAudioManager.setForceForUse(...) when the last call ends.
Hey Hsinyi, would you mind taking a look at this? Thanks!
Assignee: nobody → htsai
(Assignee)

Comment 2

5 years ago
Sure, I would investigate this.
(Assignee)

Comment 3

5 years ago
Created attachment 620218 [details] [diff] [review]
Patch

When there's no activeCall, we set 'gAudioManager.phoneState = nsIAudioManger.PHONE_STATE_NORMAL'. And no problem with the current setting when a call ends. 

However, when 'dialer' receives 'disconnected', the dialer will 'toggleMute()' to unmute or disable speaker if user has muted or enabled during the call. In |RadioInterfaceLayer.js| the setter of 'microphoneMuted' and 'speakerEnabled' set gAudioManager.phoneState as IN_CALL or IN_COMMUNICATION first to successfully mute or enable speaker. I.e, 'gAudioManager.phoneState = nsIAudioManger.PHONE_STATE_NORMAL' is overriden. So, this patch resets gAudioManager.phoneState before the setters end. Then video player works fine!
Attachment #620218 - Flags: review?(philipp)
(Assignee)

Comment 4

5 years ago
(In reply to Hsin-Yi Tsai [:hsinyi] from comment #3)
> Created attachment 620218 [details] [diff] [review]
> Patch
> 
> When there's no activeCall, we set 'gAudioManager.phoneState =
> nsIAudioManger.PHONE_STATE_NORMAL'. And no problem with the current setting
> when a call ends. 
> 
> However, when 'dialer' receives 'disconnected', the dialer will
> 'toggleMute()' to unmute or disable speaker if user has muted or enabled
> during the call. In |RadioInterfaceLayer.js| the setter of 'microphoneMuted'
> and 'speakerEnabled' set gAudioManager.phoneState as IN_CALL or
> IN_COMMUNICATION first to successfully mute or enable speaker. I.e,
> 'gAudioManager.phoneState = nsIAudioManger.PHONE_STATE_NORMAL' is overriden.
> So, this patch resets gAudioManager.phoneState before the setters end. Then
> video player works fine!
B.t.w. I still don't know why XXX in the setters is needed. But without XXX, the setters don't work correctly. That's why I repeat the assignment for 'gAudioManager.phoneState' at the end of the setters.
Android implementation:

http://androidxref.com/source/xref/frameworks/base/telephony/java/com/android/internal/telephony/CallManager.java#370

It seems audio mode needs to be synced with the phone state.

And how they do mute:

http://androidxref.com/source/xref/frameworks/base/telephony/java/com/android/internal/telephony/CallManager.java#871
(Assignee)

Comment 6

5 years ago
Kan-Ru, thanks for sharing. Yes, audio system should be synced with phone/call state. And our design considers this as well.
Comment on attachment 620218 [details] [diff] [review]
Patch

Review of attachment 620218 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/system/gonk/RadioInterfaceLayer.js
@@ +740,5 @@
>      gAudioManager.microphoneMuted = value;
> +
> +    if (!this._activeCall) {
> +      gAudioManager.phoneState = nsIAudioManager.PHONE_STATE_NORMAL;
> +    }

Why set `phoneState` twice? Wouldn't an if/else clause make more sense.

Also, this seems to be missing the actual fixes to `updateCallAudioState`. That said, https://github.com/andreasgal/gaia/issues/1281#issuecomment-5425901 reports the issue to be gone. Can you still reproduce it?
Attachment #620218 - Flags: review?(philipp)
(Assignee)

Comment 8

5 years ago
(In reply to Philipp von Weitershausen [:philikon] from comment #7)
> Comment on attachment 620218 [details] [diff] [review]
> Patch
> 
> Review of attachment 620218 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: dom/system/gonk/RadioInterfaceLayer.js
> @@ +740,5 @@
> >      gAudioManager.microphoneMuted = value;
> > +
> > +    if (!this._activeCall) {
> > +      gAudioManager.phoneState = nsIAudioManager.PHONE_STATE_NORMAL;
> > +    }
> 
> Why set `phoneState` twice? Wouldn't an if/else clause make more sense.
> 
We need to set 'phoneState' IN_CALL or IN_COMMUNICATION right before setting 'microphoneMuted', not matter which phoneState and call state we are in. Otherwise, we cannot set 'microphoneMuted' as expected.

So, after we mute the microphone and when there's no active call, we need to reset the phoneState to release the audio system for other functionalities, like video. That's why I need to set 'phoneState' twice.

> Also, this seems to be missing the actual fixes to `updateCallAudioState`.
> That said,
> https://github.com/andreasgal/gaia/issues/1281#issuecomment-5425901 reports
> the issue to be gone. Can you still reproduce it?
Yes, I can. I added a comment there, 
https://github.com/andreasgal/gaia/issues/1281#issuecomment-5425901
(Assignee)

Comment 9

5 years ago
(In reply to Hsin-Yi Tsai [:hsinyi] from comment #8)
> So, after we mute the microphone and when there's no active call, we need to

Sorry, should be 'after we *unmute* the microphone and ....

> reset the phoneState to release the audio system for other functionalities,
> like video. That's why I need to set 'phoneState' twice.
(In reply to Hsin-Yi Tsai [:hsinyi] from comment #8)
> > ::: dom/system/gonk/RadioInterfaceLayer.js
> > @@ +740,5 @@
> > >      gAudioManager.microphoneMuted = value;
> > > +
> > > +    if (!this._activeCall) {
> > > +      gAudioManager.phoneState = nsIAudioManager.PHONE_STATE_NORMAL;
> > > +    }
> > 
> > Why set `phoneState` twice? Wouldn't an if/else clause make more sense.
> > 
> We need to set 'phoneState' IN_CALL or IN_COMMUNICATION right before setting
> 'microphoneMuted', not matter which phoneState and call state we are in.
> Otherwise, we cannot set 'microphoneMuted' as expected.
> 
> So, after we mute the microphone and when there's no active call, we need to
> reset the phoneState to release the audio system for other functionalities,
> like video. That's why I need to set 'phoneState' twice.

Oh, good point!
(Reporter)

Updated

5 years ago
Attachment #620218 - Flags: review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/b351bb34089f
Target Milestone: --- → mozilla15
https://hg.mozilla.org/mozilla-central/rev/b351bb34089f
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED

Comment 13

5 years ago
https://github.com/mozilla-b2g/gaia/issues/1281 - tested on Otoro build from tip from 7/18/2012 and it works.
Resolution: FIXED → WORKSFORME
John, please don't change the resolution to WORKSFORME when there was a patch that landed. Resolutions have a *very specific* meaning (INVALID = not a valid bug, WORKSFORME = can't reproduce it, FIXED = there was a bug and we fixed it, WONTFIX = there is a bug but we won't fix it).

I think you mean VERIFIED FIXED, so I'm changing it to that.
Status: RESOLVED → VERIFIED
Resolution: WORKSFORME → FIXED
You need to log in before you can comment on or make changes to this bug.