Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bug 824597 - Close the pair view when users press the home button whi…

…le pairing
  • Loading branch information...
commit 902f648e6f6fa24918568090a55b40bf5563766b 1 parent 485911d
Arthur Chen authored samjoch committed
Showing with 66 additions and 38 deletions.
  1. +28 −15 apps/settings/js/bluetooth.js
  2. +38 −23 apps/settings/js/onpair.js
View
43 apps/settings/js/bluetooth.js
@@ -530,23 +530,36 @@ onLocalized(function bluetoothSettings() {
}
function onRequestPairing(evt, method) {
- var device = {
- address: evt.address,
- name: evt.name || _('unnamed-device'),
- icon: evt.icon || 'bluetooth-default'
+ var showPairView = function bt_showPairView() {
+ var device = {
+ address: evt.address,
+ name: evt.name || _('unnamed-device'),
+ icon: evt.icon || 'bluetooth-default'
+ };
+
+ if (device.address !== pairingAddress) {
+ pairingAddress = device.address;
+ pairingMode = 'passive';
+ }
+ var passkey = evt.passkey || null;
+ var protocol = window.location.protocol;
+ var host = window.location.host;
+ childWindow = window.open(protocol + '//' + host + '/onpair.html',
+ 'pair_screen', 'attention');
+ childWindow.onload = function childWindowLoaded() {
+ childWindow.PairView.init(pairingMode, method, device, passkey);
+ };
};
- if (device.address !== pairingAddress) {
- pairingAddress = device.address;
- pairingMode = 'passive';
- }
- var passkey = evt.passkey || null;
- var protocol = window.location.protocol;
- var host = window.location.host;
- childWindow = window.open(protocol + '//' + host + '/onpair.html',
- 'pair_screen', 'attention');
- childWindow.onload = function childWindowLoaded() {
- childWindow.PairView.init(pairingMode, method, device, passkey);
+ var req = navigator.mozSettings.createLock().get('lockscreen.locked');
+ req.onsuccess = function bt_onGetLocksuccess() {
+ if (!req.result['lockscreen.locked']) {
+ showPairView();
+ }
+ };
+ req.onerror = function bt_onGetLockError() {
+ // fallback to default value 'unlocked'
+ showPairView();
};
}
View
61 apps/settings/js/onpair.js
@@ -39,6 +39,7 @@ var PairView = {
var _ = navigator.mozL10n.get;
this.pairButton.addEventListener('click', this);
this.closeButton.addEventListener('click', this);
+ window.addEventListener('resize', this);
this.nameLabel.textContent = this._device.name;
this.deviceInfo.className = this._device.icon;
@@ -86,37 +87,51 @@ var PairView = {
onLocalized(PairView.show.bind(PairView));
},
+ close: function() {
+ window.opener.gDeviceList.setConfirmation(this._device.address, false);
+ window.close();
+ },
+
handleEvent: function pv_handleEvent(evt) {
var _ = navigator.mozL10n.get;
- if (evt.type !== 'click' || !evt.target)
+ if (!evt.target)
return;
- evt.preventDefault();
- switch (evt.target.id) {
- case 'button-pair':
- this.pairDescription.textContent = _('device-status-waiting');
- this.pairButton.disabled = true;
- this.closeButton.disabled = true;
- switch (this._pairMethod) {
- case 'confirmation':
- window.opener.gDeviceList.
- setConfirmation(this._device.address, true);
- break;
- case 'pincode':
- var value = this.pinInput.value;
- window.opener.gDeviceList.setPinCode(this._device.address, value);
+ switch (evt.type) {
+ case 'click':
+ evt.preventDefault();
+ switch (evt.target.id) {
+ case 'button-pair':
+ this.pairDescription.textContent = _('device-status-waiting');
+ this.pairButton.disabled = true;
+ this.closeButton.disabled = true;
+ switch (this._pairMethod) {
+ case 'confirmation':
+ window.opener.gDeviceList.
+ setConfirmation(this._device.address, true);
+ break;
+ case 'pincode':
+ var value = this.pinInput.value;
+ window.opener.gDeviceList.setPinCode(this._device.address,
+ value);
+ break;
+ case 'passkey':
+ var value = this.passkeyInput.value;
+ window.opener.gDeviceList.setPasskey(this._device.address,
+ value);
+ break;
+ }
+ window.close();
break;
- case 'passkey':
- var value = this.passkeyInput.value;
- window.opener.gDeviceList.setPasskey(this._device.address, value);
+ case 'button-close':
+ this.close();
break;
}
- window.close();
break;
-
- case 'button-close':
- window.opener.gDeviceList.setConfirmation(this._device.address, false);
- window.close();
+ case 'resize':
+ this.close();
+ break;
+ default:
break;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.