Closed Bug 1162426 Opened 9 years ago Closed 9 years ago

B2G RIL: need a way to know current telephony state

Categories

(Firefox OS Graveyard :: RIL, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(tracking-b2g:backlog, firefox41 fixed)

RESOLVED FIXED
2.2 S14 (12june)
tracking-b2g backlog
Tracking Status
firefox41 --- fixed

People

(Reporter: jessica, Assigned: aknow)

References

Details

Attachments

(2 files, 3 obsolete files)

For bug 1156231 and bug 931670, we'd like to have an easy way to know the current telephony state, e.g. whether there is an active call. A simple way may be to be notified about call state changes, e.g. any call started / all calls ended, and we can track the state ourselves. The design is up to you :)
Blocks: 931670, 1156231
Assignee: nobody → szchen
Attached patch (WIP) Provide TelephonyUtils (obsolete) — Splinter Review
My idea is to provide a TelephonyUtils that wrap the underlying TelephonyService.
Currently, 3 APIs in my mind:

- boolean TelephonyUtils.isActive([optional] aClientId)
- boolean TelephonyUtils.hasNoCalls([optional] aClientId)
- Promise TelephonyUtils.waitForNoCalls([optional] aClientId)

Without passing aClientId, the action works on the entire system, i.e., the union of sim1, sim2, ...

Any ideas for the APIs?  What utilities we want?  Naming?  Architecture?
You may refer to attachment 8603182 [details] [diff] [review] which contains the implementation and an xpcshell test for demonstration.
(In reply to Szu-Yu Chen [:aknow] from comment #2)
> My idea is to provide a TelephonyUtils that wrap the underlying
> TelephonyService.
> Currently, 3 APIs in my mind:
> 
> - boolean TelephonyUtils.isActive([optional] aClientId)
> - boolean TelephonyUtils.hasNoCalls([optional] aClientId)
> - Promise TelephonyUtils.waitForNoCalls([optional] aClientId)
> 
> Without passing aClientId, the action works on the entire system, i.e., the
> union of sim1, sim2, ...
> 
> Any ideas for the APIs?  What utilities we want?  Naming?  Architecture?
> You may refer to attachment 8603182 [details] [diff] [review] which contains
> the implementation and an xpcshell test for demonstration.

Thanks Aknow for the quick patch, the APIs work for me, just a comment about the naming.
'isActive' sounds a little vague to me, will 'isAnyActiveCall' be better? or any other suggestion?
Attached patch Part 1: Provide TelephonyUtils (obsolete) — Splinter Review
APIs in this version:
- boolean TelephonyUtils.hasAnyCalls([optional] aClientId)
- boolean TelephonyUtils.hasConnectedCalls([optional] aClientId)
- Promise TelephonyUtils.waitForNoCalls([optional] aClientId)
Attachment #8604011 - Flags: review?(htsai)
Attached patch Part 2: Test case (obsolete) — Splinter Review
Attachment #8604012 - Flags: review?(htsai)
Attachment #8603182 - Attachment is obsolete: true
[Tracking Requested - why for this release]:
Comment on attachment 8604012 [details] [diff] [review]
Part 2: Test case

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

The fundamental structure looks good but we have some failures to fix.

::: dom/telephony/test/xpcshell/test_TelephonyUtils.js
@@ +49,5 @@
> +  // Hold the call.
> +
> +  TelephonyService.notifyCurrentCalls(0, {
> +    0: {
> +      state: RIL.CALL_STATE_HELD,

Should be CALL_STATE_HOLDING

@@ +69,5 @@
> +  let p = TelephonyUtils.waitForNoCalls();
> +  p.then(() => run_next_test(), () => ok(false, "promise should not reject"));
> +
> +  // Override _sendToRilWorker to avoid calling into RadioInterfaceLayer.
> +  TelephonyService._sendToRilWorker = function(aClientId, message, options,

This doesn't work.  I got the error 

 5:32.21 LOG: Thread-1 ERROR NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN: Cannot modify properties of a WrappedNative
test_oneCall@test_TelephonyUtils.js:73:3
_run_next_test@/data/local/tests/xpcshell/head.js:1447:11
do_execute_soon/<.run@/data/local/tests/xpcshell/head.js:653:9
_do_main@/data/local/tests/xpcshell/head.js:207:5
_execute_test@/data/local/tests/xpcshell/head.js:513:5
@-e:1:1
Attachment #8604012 - Flags: review?(htsai) → review-
Comment on attachment 8604011 [details] [diff] [review]
Part 1: Provide TelephonyUtils

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

Looks pretty good!
Attachment #8604011 - Flags: review?(htsai) → review+
> @@ +69,5 @@
> > +  let p = TelephonyUtils.waitForNoCalls();
> > +  p.then(() => run_next_test(), () => ok(false, "promise should not reject"));
> > +
> > +  // Override _sendToRilWorker to avoid calling into RadioInterfaceLayer.
> > +  TelephonyService._sendToRilWorker = function(aClientId, message, options,
> 
> This doesn't work.  I got the error 
> 
>  5:32.21 LOG: Thread-1 ERROR NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN: Cannot
> modify properties of a WrappedNative
> test_oneCall@test_TelephonyUtils.js:73:3
> _run_next_test@/data/local/tests/xpcshell/head.js:1447:11
> do_execute_soon/<.run@/data/local/tests/xpcshell/head.js:653:9
> _do_main@/data/local/tests/xpcshell/head.js:207:5
> _execute_test@/data/local/tests/xpcshell/head.js:513:5
> @-e:1:1

Hsinyi,

I didn't get this error when I ran the xpcshell-test on emulator.
Please let me know your test step and environment. I'd like to reproduce it.
Flags: needinfo?(htsai)
(In reply to Szu-Yu Chen [:aknow] from comment #9)
> > @@ +69,5 @@
> > > +  let p = TelephonyUtils.waitForNoCalls();
> > > +  p.then(() => run_next_test(), () => ok(false, "promise should not reject"));
> > > +
> > > +  // Override _sendToRilWorker to avoid calling into RadioInterfaceLayer.
> > > +  TelephonyService._sendToRilWorker = function(aClientId, message, options,
> > 
> > This doesn't work.  I got the error 
> > 
> >  5:32.21 LOG: Thread-1 ERROR NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN: Cannot
> > modify properties of a WrappedNative
> > test_oneCall@test_TelephonyUtils.js:73:3
> > _run_next_test@/data/local/tests/xpcshell/head.js:1447:11
> > do_execute_soon/<.run@/data/local/tests/xpcshell/head.js:653:9
> > _do_main@/data/local/tests/xpcshell/head.js:207:5
> > _execute_test@/data/local/tests/xpcshell/head.js:513:5
> > @-e:1:1
> 
> Hsinyi,
> 
> I didn't get this error when I ran the xpcshell-test on emulator.
> Please let me know your test step and environment. I'd like to reproduce it.

I was running on emu-kk build with gecko a week older (I thought I have used the latest one...). 
I'll try it again upon the newest build.
(In reply to Hsin-Yi Tsai [:hsinyi] from comment #10)
> (In reply to Szu-Yu Chen [:aknow] from comment #9)
> > > @@ +69,5 @@
> > > > +  let p = TelephonyUtils.waitForNoCalls();
> > > > +  p.then(() => run_next_test(), () => ok(false, "promise should not reject"));
> > > > +
> > > > +  // Override _sendToRilWorker to avoid calling into RadioInterfaceLayer.
> > > > +  TelephonyService._sendToRilWorker = function(aClientId, message, options,
> > > 
> > > This doesn't work.  I got the error 
> > > 
> > >  5:32.21 LOG: Thread-1 ERROR NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN: Cannot
> > > modify properties of a WrappedNative
> > > test_oneCall@test_TelephonyUtils.js:73:3
> > > _run_next_test@/data/local/tests/xpcshell/head.js:1447:11
> > > do_execute_soon/<.run@/data/local/tests/xpcshell/head.js:653:9
> > > _do_main@/data/local/tests/xpcshell/head.js:207:5
> > > _execute_test@/data/local/tests/xpcshell/head.js:513:5
> > > @-e:1:1
> > 
> > Hsinyi,
> > 
> > I didn't get this error when I ran the xpcshell-test on emulator.
> > Please let me know your test step and environment. I'd like to reproduce it.
> 
> I was running on emu-kk build with gecko a week older (I thought I have used
> the latest one...). 
> I'll try it again upon the newest build.

The command I use is "./mach xpchsell-test dom/telephony/tests/xpcshell/test_TelephonyUtils.js
Flags: needinfo?(htsai)
Found a wrong |this|. Request review again.
Attachment #8608640 - Flags: review?(htsai)
For some reason, I change it to a marionette test. So it's totally different from previous version.
Attachment #8604011 - Attachment is obsolete: true
Attachment #8604012 - Attachment is obsolete: true
Attachment #8608642 - Flags: review?(htsai)
Attachment #8608640 - Flags: review?(htsai) → review+
Comment on attachment 8608642 [details] [diff] [review]
Part 2#2: Test case

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

Thank you.
Attachment #8608642 - Flags: review?(htsai) → review+
https://hg.mozilla.org/mozilla-central/rev/22504f6f9c78
https://hg.mozilla.org/mozilla-central/rev/15c06e854079
Status: NEW → RESOLVED
Closed: 9 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → 2.2 S14 (12june)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: