Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify USSD and MMI promise behaviour #70

Closed
wants to merge 5 commits into from
Closed

Conversation

bchabod
Copy link
Contributor

@bchabod bchabod commented Aug 26, 2015

Background:
MMI code = any code you enter on your phone with * or #
USSD code = MMI code that doesn't only access the phone's hardware and requires a response from the operator

Here is how you currently send a MMI code from gaia:

      navigator.mozTelephony.dial(MMI_CODE, 0).then(obj => {
        return obj.result.then(function(result) {
          console.log('MMI response: ' + result);
        });
      }).catch(error => console.error(error));

It should be possible to do the same thing for a USSD code.
However, currently, the promise is resolved instantly with an empty result if the message is sent correctly, and the real response comes later, in a system message:

      navigator.mozSetMessageHandler('ussd-received', e => {
        console.log('USSD response: ' + e.message);
      });

Please note that USSD responses can also contain an object called USSDSession, that you can use to cancel or reply to a dialogue with the operator, which usually looks like a menu.

This PR tries to do the following:

  • Fix a critical bug that appeared in 2.5, preventing any USSD session from working because they were cancelled everytime: https://bugzilla.mozilla.org/show_bug.cgi?id=1191205
  • Silently cancel previous USSD sessions, so that there is no useless "Session expired" message : https://bugzilla.mozilla.org/show_bug.cgi?id=1198676
  • Unify USSD and MMI promise behaviour, so that USSDSession methods and mozTelephony.dial() promises for USSD codes are solved once the response is received, along with a USSDSession object if needed. Unsollicited messages should still go in a system message.

@hsinyi
Copy link
Contributor

hsinyi commented Aug 27, 2015

Hi Ben,
Thank you very much for the WIP!

Here's some context about the current USSD API design. We need to rely on an additional way to notify gaia "ussd responses" because the responses are coming from distinct unsolicited events per android ril.h[1]. Hence, it lacks a determined link b/w the response and a request. So App needs to rely on "ussd-received" notification. Previous discussion here [2].

[1] http://androidxref.com/5.1.1_r6/xref/hardware/ril/include/telephony/ril.h#2195
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=897773#c7

@bchabod bchabod force-pushed the USSD branch 4 times, most recently from 8bf12ad to 3d6d069 Compare August 31, 2015 09:18
A few errors had to be addressed :
- session.send() and session.cancel() promises have to be solved with MMICall and not void
- We should clear the current USSD callback before calling it
- session.send() and session.cancel() promises weren't binded correctly
- We should check for a errorMsg attribute on response object only if it's not null
@moz-hwine
Copy link

@moz-hwine moz-hwine closed this Oct 14, 2015
@mozilla mozilla locked and limited conversation to collaborators Oct 14, 2015
bvaughn pushed a commit to bvaughn/gecko-dev that referenced this pull request Apr 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants