Closed Bug 1127261 Opened 10 years ago Closed 10 years ago

[Bluetooth][Settings][API v2] It usually needs to trigger pair() twice. Then the pairing process is really starting.

Categories

(Firefox OS Graveyard :: Gaia::Settings, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: iliu, Assigned: iliu)

References

Details

(Whiteboard: [webbt-api])

Attachments

(3 files)

Since I'm working on implementation of pairing flow, I meet the problem that we have to call pair() twice. Then the pairing process is starting. STR: 1. Launch settings app and go into bluetooth app. 2. Start discovering device. 3. Tap a remote device to pair. Expect: The pairing process should be started. Then see the pairing dialog in screen. Actual: Nothing happened. PS: It's needed to tap twice(call pair() API). Then, the pairing process is starting.
Whiteboard: [webbt-api]
Jamin will take a look first. Assign owner to him.
Assignee: nobody → jaliu
I observed that there is a BondStateChanged Notification with state = BOND_STATE_NONE when I encounter this issue. There's a bug that gecko didn't reject the pair promise when the pair failed. I use a local patch for experiment, gecko will now reject the promise, but still no changes on gaia side. Might need to dig more and look gaia part also.
Jocelyn, If you confuse in too much log in from the `Debug` function, I put other console around the pair() function in Gaia side. My experiment is no resolve/reject while I clicked device to pair. Then, I click the same/different device to pair again. The pairing process will be trigger with pairing dialog. After both device confirmed to pair, I can receive the resovle() in Gaia side. Not sure it's helpful to debug the issue. Or something wrong in Gaia side. Please let me know you need any support. =============== diff for adding console in Gaia side =============== diff --git a/apps/settings/js/modules/bluetooth/bluetooth_context.js b/apps/settings/js/modules/bluetooth/bluetooth_context.js index d064776..0945c83 100644 --- a/apps/settings/js/modules/bluetooth/bluetooth_context.js +++ b/apps/settings/js/modules/bluetooth/bluetooth_context.js @@ -793,13 +793,17 @@ define(function(require) { * @returns {Promise} */ pair: function btc_pair(address) { + console.log('-->>> paired be called with address = ' + address); if (!this._defaultAdapter) { + console.log('-->>> in early return case!!!!'); return Promise.reject('default adapter is not existed!!'); } return this._defaultAdapter.pair(address).then(() => { + console.log('-->>> pair(): Resolved with void value!!!!'); Debug('pair(): Resolved with void value'); }, (reason) => { + console.log('-->>> Reject with this reason: ' + reason); Debug('pair(): Reject with this reason: ' + reason); return Promise.reject(reason); }); diff --git a/apps/settings/js/panels/bluetooth/panel.js b/apps/settings/js/panels/bluetooth/panel.js index ced8126..4f8f404 100644 --- a/apps/settings/js/panels/bluetooth/panel.js +++ b/apps/settings/js/panels/bluetooth/panel.js @@ -370,9 +370,12 @@ define(function(require) { // Update device pairing status first. deviceItem.paired = 'pairing'; // Pair with the remote device. + console.log('-->>> _onFoundDeviceItemClick(): call pair with deviceItem.address = ' + deviceItem.address); BtContext.pair(deviceItem.address).then(() => { + console.log('-->>> _onFoundDeviceItemClick(): pair successfully!!!'); Debug('_onFoundDeviceItemClick(): pair successfully'); }, (reason) => { + console.log('-->>> _onFoundDeviceItemClick(): pair failed!!!'); Debug('_onFoundDeviceItemClick(): pair failed, ' + 'reason = ' + reason); =============== logcat =============== I/Settings( 5322): Content JS LOG: -->>> pair(): Resolved with void value!!!! I/Settings( 5322): at btc_pair/< (app://settings.gaiamobile.org/js/modules/bluetooth/bluetooth_context.js:803:8) I/Settings( 5322): Content JS LOG: -->>> _onFoundDeviceItemClick(): pair successfully!!! I/Settings( 5322): at ctor_bluetooth/<._onFoundDeviceItemClick/< (app://settings.gaiamobile.org/js/panels/bluetooth/panel.js:375:10)
(In reply to jocelyn [:jocelyn] from comment #2) > I observed that there is a BondStateChanged Notification with state = > BOND_STATE_NONE when I encounter this issue. > There's a bug that gecko didn't reject the pair promise when the pair failed. > I use a local patch for experiment, gecko will now reject the promise, but > still no changes on gaia side. > Might need to dig more and look gaia part also. I also wonder why bluetooth1 didn't meet BOND_STATE_NONE + STATUS_FAIL on prior releases. Even promise is rejected |adapter.pair| still needs to call twice but bluetooth1 doesn't have such symptom.
(In reply to Ben Tian [:btian][2/18 ~ 2/23 CNY vacation] from comment #4) > I also wonder why bluetooth1 didn't meet BOND_STATE_NONE + STATUS_FAIL on > prior releases. Even promise is rejected |adapter.pair| still needs to call > twice but bluetooth1 doesn't have such symptom. Thanks Jocelyn. Discovery has to be stopped before pair (as APIv1). Attached tentative patch fixes the bug. Ian, can you help stop discovery before pair in gaia?
Flags: needinfo?(iliu)
(In reply to Ben Tian [:btian][2/18 ~ 2/23 CNY vacation] from comment #4) > (In reply to jocelyn [:jocelyn] from comment #2) > > I observed that there is a BondStateChanged Notification with state = > > BOND_STATE_NONE when I encounter this issue. > > There's a bug that gecko didn't reject the pair promise when the pair failed. > > I use a local patch for experiment, gecko will now reject the promise, but > > still no changes on gaia side. > > Might need to dig more and look gaia part also. We are missing a part that Gaia didn't refresh UI when gecko reject the promise. > > I also wonder why bluetooth1 didn't meet BOND_STATE_NONE + STATUS_FAIL on > prior releases. Even promise is rejected |adapter.pair| still needs to call > twice but bluetooth1 doesn't have such symptom. I think this should also be handled in v1, but the probability of this case might be low in v1. v2 encounter this mainly when issuing pair while discovering.
(In reply to Ben Tian [:btian][2/18 ~ 2/23 CNY vacation] from comment #5) > Thanks Jocelyn. Discovery has to be stopped before pair (as APIv1). Attached > tentative patch fixes the bug. The requirement results from bluedroid stack limitation. Stack would callback with pairing failure if discovery is not stopped. Updated on wiki [1] to inform gaia dev. [1] "Note on Bluedroid stack, discovery has to be stopped before pairing (i.e., call stopDiscovery() before pair()) otherwise stack callbacks with pairing failure." https://wiki.mozilla.org/B2G/Bluetooth/WebBluetooth-v2/BluetoothAdapter#pair.28DOMString_aDeviceAddress.29
Ian will help this bug per offline discussion and comment 5. Assign owner to him.
Assignee: jaliu → iliu
Flags: needinfo?(iliu)
Also modify component to Gaia::Settings.
Component: Bluetooth → Gaia::Settings
OS: Mac OS X → Gonk (Firefox OS)
Hardware: x86 → ARM
Comment on attachment 8572494 [details] [review] [gaia] ian-liu:bluetooth/bug1127261_stop_discovery_before_pair_with_device > mozilla-b2g:master Arthur, I revise pair() of BluetoothContext module. It will stopDiscovery() before we do pair(). Will need your review here. I will update the change to Bluetooth app if you feel the patch is okay. Thanks.
Attachment #8572494 - Flags: review?(arthur.chen)
Status: NEW → ASSIGNED
Summary: [Bluetooth][API v2] It usually needs to trigger pair() twice. Then the pairing process is really starting. → [Bluetooth][Settings][API v2] It usually needs to trigger pair() twice. Then the pairing process is really starting.
Comment on attachment 8572494 [details] [review] [gaia] ian-liu:bluetooth/bug1127261_stop_discovery_before_pair_with_device > mozilla-b2g:master Looks good to me. But it seems we should also make the same change to the files under the bluetooth app.
Attachment #8572494 - Flags: review?(arthur.chen)
Comment on attachment 8572494 [details] [review] [gaia] ian-liu:bluetooth/bug1127261_stop_discovery_before_pair_with_device > mozilla-b2g:master Also update the patch in Bluetooth app. Thanks.
Attachment #8572494 - Flags: review?(arthur.chen)
Comment on attachment 8572494 [details] [review] [gaia] ian-liu:bluetooth/bug1127261_stop_discovery_before_pair_with_device > mozilla-b2g:master r=me, thanks!
Attachment #8572494 - Flags: review?(arthur.chen) → review+
Thanks for Arthur's double check. Since the patch is landed, we can close the issue now. Gaia/master: https://github.com/mozilla-b2g/gaia/commit/a18b45797ac3999d80569cc68f2783762a122ae4
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: