Closed Bug 986395 Opened 10 years ago Closed 10 years ago

B2G RIL: Correct the API behavior of setPreferredNetworkType()

Categories

(Firefox OS Graveyard :: RIL, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(feature-b2g:2.0, tracking-b2g:backlog)

RESOLVED FIXED
2.0 S2 (23may)
feature-b2g 2.0
tracking-b2g backlog

People

(Reporter: edgar, Assigned: edgar)

Details

(Whiteboard: [p=1])

Attachments

(2 files, 1 obsolete file)

+++ This bug was initially created as a clone of Bug #974253 +++

For the radio off case, currently gecko will cache the last value which comes from setPreferredNetworkType() and set it again when radio is on. But in this case, gecko will dispatch an error event to gaia.

I think we should correct the behavior of this api:
1. If gecko already handle the radio off case and make sure the value will be correct set to modem, 
   this api should dispatch success event instead of an error one.
2. Should this api handle the radio off case like this? Other apis doesn't have this kind of behavior.
   So to consist with other apis, we should remove this behavior.

To me, I prefer second one. :)
(In reply to Edgar Chen [:edgar][:echen] from comment #0)
> +++ This bug was initially created as a clone of Bug #974253 +++
> 
> For the radio off case, currently gecko will cache the last value which
> comes from setPreferredNetworkType() and set it again when radio is on. But
> in this case, gecko will dispatch an error event to gaia.
> 
> I think we should correct the behavior of this api:
> 1. If gecko already handle the radio off case and make sure the value will
> be correct set to modem, 
>    this api should dispatch success event instead of an error one.
> 2. Should this api handle the radio off case like this? Other apis doesn't
> have this kind of behavior.
>    So to consist with other apis, we should remove this behavior.
> 
> To me, I prefer second one. :)

I think no matter gecko is trying to set preferredNetworkType again once radio is ready, the API should behave as one of the followings:
1) checking radio state, and fire error immediately if radio is off, even without querying REQUEST_SET_PREFERRED_NETWORK_TYPE.
2) we could consider checking radio state first (i.e. 1), but without the check, always fire result as modem responds
3) checking radio state first, if radio is off, we put the request into queue. Once radio is ready, we send the request to modem and respond success/error based on modem response. But this is problematic because what is radio is never on... we will need magic timeout. 

I think Edgar's comment is 1), plus gecko doesn't need to reset it again when radio becomes ready, right? If so, and if we have good communication with Gaia, it looks good to me.
(In reply to Hsin-Yi Tsai  [:hsinyi] from comment #1)
> (In reply to Edgar Chen [:edgar][:echen] from comment #0)
> > +++ This bug was initially created as a clone of Bug #974253 +++
> > 
> > For the radio off case, currently gecko will cache the last value which
> > comes from setPreferredNetworkType() and set it again when radio is on. But
> > in this case, gecko will dispatch an error event to gaia.
> > 
> > I think we should correct the behavior of this api:
> > 1. If gecko already handle the radio off case and make sure the value will
> > be correct set to modem, 
> >    this api should dispatch success event instead of an error one.
> > 2. Should this api handle the radio off case like this? Other apis doesn't
> > have this kind of behavior.
> >    So to consist with other apis, we should remove this behavior.
> > 
> > To me, I prefer second one. :)
> 
> I think no matter gecko is trying to set preferredNetworkType again once
> radio is ready, the API should behave as one of the followings:
> 1) checking radio state, and fire error immediately if radio is off, even
> without querying REQUEST_SET_PREFERRED_NETWORK_TYPE.
> 2) we could consider checking radio state first (i.e. 1), but without the
> check, always fire result as modem responds
> 3) checking radio state first, if radio is off, we put the request into
> queue. Once radio is ready, we send the request to modem and respond
> success/error based on modem response. But this is problematic because what
> is radio is never on... we will need magic timeout. 
> 
> I think Edgar's comment is 1), plus gecko doesn't need to reset it again
> when radio becomes ready, right? If so, and if we have good communication
> with Gaia, it looks good to me.

Sorry for doesn't make it clear enough.
My comment is more like 2) without check + gecko doesn't need to reset it again, because most of other api of mobileConnection doesn't check the radio state.
(In reply to Edgar Chen [:edgar][:echen] from comment #2)
> (In reply to Hsin-Yi Tsai  [:hsinyi] from comment #1)
> > (In reply to Edgar Chen [:edgar][:echen] from comment #0)
> > > +++ This bug was initially created as a clone of Bug #974253 +++
> > > 
> > > For the radio off case, currently gecko will cache the last value which
> > > comes from setPreferredNetworkType() and set it again when radio is on. But
> > > in this case, gecko will dispatch an error event to gaia.
> > > 
> > > I think we should correct the behavior of this api:
> > > 1. If gecko already handle the radio off case and make sure the value will
> > > be correct set to modem, 
> > >    this api should dispatch success event instead of an error one.
> > > 2. Should this api handle the radio off case like this? Other apis doesn't
> > > have this kind of behavior.
> > >    So to consist with other apis, we should remove this behavior.
> > > 
> > > To me, I prefer second one. :)
> > 
> > I think no matter gecko is trying to set preferredNetworkType again once
> > radio is ready, the API should behave as one of the followings:
> > 1) checking radio state, and fire error immediately if radio is off, even
> > without querying REQUEST_SET_PREFERRED_NETWORK_TYPE.
> > 2) we could consider checking radio state first (i.e. 1), but without the
> > check, always fire result as modem responds
> > 3) checking radio state first, if radio is off, we put the request into
> > queue. Once radio is ready, we send the request to modem and respond
> > success/error based on modem response. But this is problematic because what
> > is radio is never on... we will need magic timeout. 
> > 
> > I think Edgar's comment is 1), plus gecko doesn't need to reset it again
> > when radio becomes ready, right? If so, and if we have good communication
> > with Gaia, it looks good to me.
> 
> Sorry for doesn't make it clear enough.
> My comment is more like 2) without check + gecko doesn't need to reset it
> again, because most of other api of mobileConnection doesn't check the radio
> state.

Ha, I see. If radio state isn't a platform-independent assumption, then 2) should be fine as well.
Assignee: nobody → echen
If we are talking to gaia that they should wait till radio is ready, doesn't that imply gecko should simply return error when radio isn't ready, to have a more strict and consistent behaviour, even 2) looks no harm?
(In reply to Hsin-Yi Tsai  [:hsinyi] from comment #4)
> If we are talking to gaia that they should wait till radio is ready, doesn't
> that imply gecko should simply return error when radio isn't ready, to have
> a more strict and consistent behaviour, even 2) looks no harm?

Yup, agree with you.
If we do the radio check in gecko for setPreferredNetworkType(), should we do the same thing for other api of mobileConnection as well?
(In reply to Edgar Chen [:edgar][:echen] from comment #5)
> (In reply to Hsin-Yi Tsai  [:hsinyi] from comment #4)
> > If we are talking to gaia that they should wait till radio is ready, doesn't
> > that imply gecko should simply return error when radio isn't ready, to have
> > a more strict and consistent behaviour, even 2) looks no harm?
> 
> Yup, agree with you.
> If we do the radio check in gecko for setPreferredNetworkType(), should we
> do the same thing for other api of mobileConnection as well?

I think so, if the function call succeeds only after radio is ready. :)
Put this bug into backlog.
blocking-b2g: --- → backlog
Whiteboard: [p=1]
Target Milestone: --- → 2.0 S2 (23may)
Attached patch Part 1: RIL changes, v1 (obsolete) — Splinter Review
Attached patch Part 2: Test, v1Splinter Review
Comment on attachment 8421613 [details] [diff] [review]
Part 1: RIL changes, v1

1). Fire "RadioNotAvailable" error if radio is not enabled.
2). Don't reset preferred network type in ril_worker.
Attachment #8421613 - Flags: review?(htsai)
Comment on attachment 8421614 [details] [diff] [review]
Part 2: Test, v1

Add test for setting/getting preferred network type on radio off.
Attachment #8421614 - Flags: review?(htsai)
Comment on attachment 8421613 [details] [diff] [review]
Part 1: RIL changes, v1

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

Looks good, thanks :)

::: dom/system/gonk/ril_worker.js
@@ +1147,5 @@
>    /**
>     * Set the preferred network type.
>     *
>     * @param options An object contains a valid index of
>     *                RIL_PREFERRED_NETWORK_TYPE_TO_GECKO as its `networkType`

After this patch, |options| no longer has 'networkType', has 'options.type' instead. Please revise the comment appropriately.

@@ -6215,5 @@
>  RilObject.prototype[REQUEST_STK_SEND_TERMINAL_RESPONSE] = null;
>  RilObject.prototype[REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM] = null;
>  RilObject.prototype[REQUEST_EXPLICIT_CALL_TRANSFER] = null;
>  RilObject.prototype[REQUEST_SET_PREFERRED_NETWORK_TYPE] = function REQUEST_SET_PREFERRED_NETWORK_TYPE(length, options) {
> -  if (options.networkType == null) {

Nice cleanup!
Attachment #8421613 - Flags: review?(htsai) → review+
Comment on attachment 8421614 [details] [diff] [review]
Part 2: Test, v1

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

::: dom/mobileconnection/tests/marionette/test_mobile_clir_radio_off.js
@@ -31,5 @@
>      .then(() => testSetClirOnRadioOff(0))
>      .then(() => testGetClirOnRadioOff())
>      // Restore radio state.
>      .then(() => setRadioEnabledAndWait(true),
> -          () => setRadioEnabledAnWait(true));

Thanks for the catch :P
Attachment #8421614 - Flags: review?(htsai) → review+
Address review comment #12.
Attachment #8421613 - Attachment is obsolete: true
Attachment #8422895 - Flags: review+
feature-b2g: --- → 2.0
blocking-b2g: backlog → ---
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: