Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…le pairing
  • Loading branch information...
commit c33a69f1c35de391c7c3250a077894dde5c97017 1 parent efa7bc1
Arthur Chen authored crh0716 committed

Showing 2 changed files with 66 additions and 38 deletions. Show diff stats Hide diff stats

  1. +28 15 apps/settings/js/bluetooth.js
  2. +38 23 apps/settings/js/onpair.js
43 apps/settings/js/bluetooth.js
@@ -530,23 +530,36 @@ onLocalized(function bluetoothSettings() {
530 530 }
531 531
532 532 function onRequestPairing(evt, method) {
533   - var device = {
534   - address: evt.address,
535   - name: evt.name || _('unnamed-device'),
536   - icon: evt.icon || 'bluetooth-default'
  533 + var showPairView = function bt_showPairView() {
  534 + var device = {
  535 + address: evt.address,
  536 + name: evt.name || _('unnamed-device'),
  537 + icon: evt.icon || 'bluetooth-default'
  538 + };
  539 +
  540 + if (device.address !== pairingAddress) {
  541 + pairingAddress = device.address;
  542 + pairingMode = 'passive';
  543 + }
  544 + var passkey = evt.passkey || null;
  545 + var protocol = window.location.protocol;
  546 + var host = window.location.host;
  547 + childWindow = window.open(protocol + '//' + host + '/onpair.html',
  548 + 'pair_screen', 'attention');
  549 + childWindow.onload = function childWindowLoaded() {
  550 + childWindow.PairView.init(pairingMode, method, device, passkey);
  551 + };
537 552 };
538 553
539   - if (device.address !== pairingAddress) {
540   - pairingAddress = device.address;
541   - pairingMode = 'passive';
542   - }
543   - var passkey = evt.passkey || null;
544   - var protocol = window.location.protocol;
545   - var host = window.location.host;
546   - childWindow = window.open(protocol + '//' + host + '/onpair.html',
547   - 'pair_screen', 'attention');
548   - childWindow.onload = function childWindowLoaded() {
549   - childWindow.PairView.init(pairingMode, method, device, passkey);
  554 + var req = navigator.mozSettings.createLock().get('lockscreen.locked');
  555 + req.onsuccess = function bt_onGetLocksuccess() {
  556 + if (!req.result['lockscreen.locked']) {
  557 + showPairView();
  558 + }
  559 + };
  560 + req.onerror = function bt_onGetLockError() {
  561 + // fallback to default value 'unlocked'
  562 + showPairView();
550 563 };
551 564 }
552 565
61 apps/settings/js/onpair.js
@@ -39,6 +39,7 @@ var PairView = {
39 39 var _ = navigator.mozL10n.get;
40 40 this.pairButton.addEventListener('click', this);
41 41 this.closeButton.addEventListener('click', this);
  42 + window.addEventListener('resize', this);
42 43
43 44 this.nameLabel.textContent = this._device.name;
44 45 this.deviceInfo.className = this._device.icon;
@@ -86,37 +87,51 @@ var PairView = {
86 87 onLocalized(PairView.show.bind(PairView));
87 88 },
88 89
  90 + close: function() {
  91 + window.opener.gDeviceList.setConfirmation(this._device.address, false);
  92 + window.close();
  93 + },
  94 +
89 95 handleEvent: function pv_handleEvent(evt) {
90 96 var _ = navigator.mozL10n.get;
91   - if (evt.type !== 'click' || !evt.target)
  97 + if (!evt.target)
92 98 return;
93 99
94   - evt.preventDefault();
95   - switch (evt.target.id) {
96   - case 'button-pair':
97   - this.pairDescription.textContent = _('device-status-waiting');
98   - this.pairButton.disabled = true;
99   - this.closeButton.disabled = true;
100   - switch (this._pairMethod) {
101   - case 'confirmation':
102   - window.opener.gDeviceList.
103   - setConfirmation(this._device.address, true);
104   - break;
105   - case 'pincode':
106   - var value = this.pinInput.value;
107   - window.opener.gDeviceList.setPinCode(this._device.address, value);
  100 + switch (evt.type) {
  101 + case 'click':
  102 + evt.preventDefault();
  103 + switch (evt.target.id) {
  104 + case 'button-pair':
  105 + this.pairDescription.textContent = _('device-status-waiting');
  106 + this.pairButton.disabled = true;
  107 + this.closeButton.disabled = true;
  108 + switch (this._pairMethod) {
  109 + case 'confirmation':
  110 + window.opener.gDeviceList.
  111 + setConfirmation(this._device.address, true);
  112 + break;
  113 + case 'pincode':
  114 + var value = this.pinInput.value;
  115 + window.opener.gDeviceList.setPinCode(this._device.address,
  116 + value);
  117 + break;
  118 + case 'passkey':
  119 + var value = this.passkeyInput.value;
  120 + window.opener.gDeviceList.setPasskey(this._device.address,
  121 + value);
  122 + break;
  123 + }
  124 + window.close();
108 125 break;
109   - case 'passkey':
110   - var value = this.passkeyInput.value;
111   - window.opener.gDeviceList.setPasskey(this._device.address, value);
  126 + case 'button-close':
  127 + this.close();
112 128 break;
113 129 }
114   - window.close();
115 130 break;
116   -
117   - case 'button-close':
118   - window.opener.gDeviceList.setConfirmation(this._device.address, false);
119   - window.close();
  131 + case 'resize':
  132 + this.close();
  133 + break;
  134 + default:
120 135 break;
121 136 }
122 137 }

0 comments on commit c33a69f

Please sign in to comment.
Something went wrong with that request. Please try again.