Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1155411 - merge pull request #29887 from daleharvey:1155411 to mo…
Browse files Browse the repository at this point in the history
…zilla-b2g:master
  • Loading branch information
mozilla-autolander-deprecated committed May 6, 2015
2 parents b9f6aa0 + c2fd547 commit 426fe64
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 37 deletions.
4 changes: 2 additions & 2 deletions apps/system/js/devtools/logshake.js
Expand Up @@ -35,7 +35,7 @@
*/
start: function() {
Service.request('handleSystemMessageNotification', 'logshake', this);
window.addEventListener('volumeup+sleep', this);
window.addEventListener('volumeup+volumedown', this);
this.startCaptureLogsListener();
},

Expand Down Expand Up @@ -68,7 +68,7 @@
handleEvent: function(event) {
debug('handling event ' + event.type);
switch(event.type) {
case 'volumeup+sleep':
case 'volumeup+volumedown':
this.requestSystemLogs();
break;
case 'capture-logs-start':
Expand Down
54 changes: 22 additions & 32 deletions apps/system/js/hardware_buttons.js
Expand Up @@ -49,21 +49,21 @@
* that are not cancelable and do not bubble. They are dispatched at the
* window object. The type property is set to one of these:
*
* | Event Type | Meaning |
* |-------------|-----------------------------------------------------------|
* | home | short press and release of home button |
* | holdhome | long press and hold of home button |
* | sleep | short press and release of sleep button |
* | wake | sleep or home pressed while sleeping |
* | holdsleep | long press and hold of sleep button |
* | volumeup | volume up pressed and released or autorepeated |
* | volumedown | volume down pressed and released or autorepeated |
* | volumedown | volume down and sleep pressed at same time (used for |
* | + sleep | screenshots) |
* | volumeup | volume up and sleep pressed at same time (used for |
* | + sleep | systemlog capture) |
* | camera | short press and release of camera button |
* | holdcamera | long press and hold of camera button |
* | Event Type | Meaning |
* |--------------|----------------------------------------------------------|
* | home | short press and release of home button |
* | holdhome | long press and hold of home button |
* | sleep | short press and release of sleep button |
* | wake | sleep or home pressed while sleeping |
* | holdsleep | long press and hold of sleep button |
* | volumeup | volume up pressed and released or autorepeated |
* | volumedown | volume down pressed and released or autorepeated |
* | volumedown | volume down and sleep pressed at same time (used for |
* | + sleep | screenshots) |
* | volumedown | volume up and sleep pressed at same time (used for |
* | + volumeup | systemlog capture) |
* | camera | short press and release of camera button |
* | holdcamera | long press and hold of camera button |
*
* Because these events are fired at the window object, they cannot be
* captured. Many modules listen for the home event. Those that want
Expand Down Expand Up @@ -438,13 +438,6 @@
*/
this.hardwareButtons.setState('screenshot', type);
return;
case 'volume-up-button-press':
/**
* When the user presses Volume Up button, before HOLD_INTERVAL,
* while holding the Sleep button.
*/
this.hardwareButtons.setState('systemlog', type);
return;
case 'home-button-press':
this.hardwareButtons.setState('base', type);
return;
Expand Down Expand Up @@ -532,16 +525,13 @@
*/
this.hardwareButtons.setState('screenshot', type);
return;
} else if (this.direction === 'volume-up-button-press') {
/**
* When the user presses Sleep button, before HOLD_INTERVAL,
* while holding the Volume Up button.
*/
this.hardwareButtons.setState('systemlog', type);
return;
}
this.hardwareButtons.setState('sleep', type);
return;
case 'volume-down-button-press':
case 'volume-up-button-press':
this.hardwareButtons.setState('systemlog', type);
return;
case 'volume-up-button-release':
if (this.direction === 'volume-up-button-press') {
if (!this.repeating) {
Expand Down Expand Up @@ -714,11 +704,11 @@
HardwareButtonsSystemLogState.prototype.enter = function() {
this.timer = setTimeout(function() {
/**
* When the user holds Volume Up and Power button
* When the user holds Volume Up and Volume Down button
* more than HOLD_INTERVAL.
* @event HardwareButtonsHomeState#volumeup+sleep
* @event HardwareButtonsHomeState#volumeup+volumedown
*/
this.hardwareButtons.publish('volumeup+sleep');
this.hardwareButtons.publish('volumeup+volumedown');
this.hardwareButtons.setState('base');
}.bind(this), this.hardwareButtons.HOLD_INTERVAL);
};
Expand Down
9 changes: 6 additions & 3 deletions apps/system/test/unit/hardware_buttons_test.js
Expand Up @@ -201,18 +201,21 @@ suite('system/HardwareButtons', function() {
bubbles: false }));
});

test('hold volume-up and press sleep (screen enabled)', function() {
fireHardwareKeyEvent('mozbrowserbeforekeydown', 'Power', false);
test('hold volume-down and press volume-up (screen enabled)', function() {
fireHardwareKeyEvent('mozbrowserafterkeydown', 'VolumeDown', false);
fireHardwareKeyEvent('mozbrowserafterkeydown', 'VolumeUp', false);

// hold timeout was cancelled, capture timeout called
assert.isTrue(stubClearTimeout.calledOnce);
assert.isTrue(stubSetTimeout.calledTwice);

fireHardwareKeyEvent('mozbrowserbeforekeyup', 'VolumeUp', false);
fireHardwareKeyEvent('mozbrowserafterkeyup', 'VolumeDown', false);

// Fire the capturelog timeout
stubSetTimeout.getCall(1).args[0].call(window);
assert.isTrue(stubDispatchEvent.calledOnce);
assert.isTrue(stubDispatchEvent.calledWith({ type: 'volumeup+sleep',
assert.isTrue(stubDispatchEvent.calledWith({ type: 'volumeup+volumedown',
bubbles: false }));
});

Expand Down

0 comments on commit 426fe64

Please sign in to comment.