Permalink
Browse files

Merge pull request #6899 from fabi1cazenave/bt-pair

Bug 818230 - Pairing does not stop when cancelled from bluetooth pairing page
r=kaze
  • Loading branch information...
2 parents 46baef6 + fd57fb8 commit b9c807e72f721b980db0e88376c8534b201b9695 @fabi1cazenave fabi1cazenave committed Dec 7, 2012
Showing with 11 additions and 6 deletions.
  1. +9 −5 apps/settings/js/bluetooth.js
  2. +2 −1 apps/settings/js/onpair.js
View
14 apps/settings/js/bluetooth.js
@@ -247,6 +247,7 @@ onLocalized(function bluetoothSettings() {
var childWindow = null;
var pairingMode = 'active';
+ var userCanceledPairing = false;
var pairingAddress = null;
var connectingAddress = null;
var connectedAddress = null;
@@ -427,11 +428,13 @@ onLocalized(function bluetoothSettings() {
// if the attention screen still open, close it
if (childWindow)
childWindow.close();
- // show pair process fail.
- var msg = _('error-pair-title') + '\n' + _('error-pair-pincode');
// display failure only when active request
- if (pairingMode === 'active')
+ if (pairingMode === 'active' && !userCanceledPairing) {
+ // show pair process fail.
+ var msg = _('error-pair-title') + '\n' + _('error-pair-pincode');
window.alert(msg);
+ }
+ userCanceledPairing = false;
// rollback device status
if (openList.index[pairingAddress]) {
var item = openList.index[pairingAddress][1];
@@ -561,10 +564,11 @@ onLocalized(function bluetoothSettings() {
discoverTimeout = null;
}
- function setConfirmation(address) {
+ function setConfirmation(address, confirmed) {
if (!defaultAdapter)
return;
- var req = defaultAdapter.setPairingConfirmation(address, true);
+ userCanceledPairing = !confirmed;
+ var req = defaultAdapter.setPairingConfirmation(address, confirmed);
}
function setPinCode(address, pincode) {
View
3 apps/settings/js/onpair.js
@@ -99,7 +99,7 @@ var PairView = {
this.closeButton.disabled = true;
switch (this._pairMethod) {
case 'confirmation':
- window.opener.gDeviceList.setConfirmation(this._device.address);
+ window.opener.gDeviceList.setConfirmation(this._device.address, true);
break;
case 'pincode':
var value = this.pinInput.value;
@@ -114,6 +114,7 @@ var PairView = {
break;
case 'button-close':
+ window.opener.gDeviceList.setConfirmation(this._device.address, false);
window.close();
break;
}

0 comments on commit b9c807e

Please sign in to comment.