Commit ce6a9e9d authored by merkulova's avatar merkulova Committed by Commit bot

HID fix for device info check.

BUG=436912

Review URL: https://codereview.chromium.org/770563003

Cr-Commit-Position: refs/heads/master@{#315295}
parent 0e8f7d83
...@@ -29,6 +29,22 @@ login.createScreen('HIDDetectionScreen', 'hid-detection', function() { ...@@ -29,6 +29,22 @@ login.createScreen('HIDDetectionScreen', 'hid-detection', function() {
DISMISSED: 'bluetoothPairingDismissed' DISMISSED: 'bluetoothPairingDismissed'
}, },
// Enumeration of possible connection states of a device.
CONNECTION: {
SEARCHING: 'searching',
CONNECTED: 'connected',
PAIRING: 'pairing',
PAIRED: 'paired',
// Special info state.
UPDATE: 'update'
},
// Possible ids of device blocks.
BLOCK: {
MOUSE: 'hid-mouse-block',
KEYBOARD: 'hid-keyboard-block'
},
/** /**
* Button to move to usual OOBE flow after detection. * Button to move to usual OOBE flow after detection.
* @private * @private
...@@ -65,30 +81,35 @@ login.createScreen('HIDDetectionScreen', 'hid-detection', function() { ...@@ -65,30 +81,35 @@ login.createScreen('HIDDetectionScreen', 'hid-detection', function() {
/** /**
* Sets a device-block css class to reflect device state of searching, * Sets a device-block css class to reflect device state of searching,
* connected, pairing or paired (for BT devices). * connected, pairing or paired (for BT devices).
* @param {blockId} id one of 'hid-mouse-block' or 'hid-keyboard-block'. * @param {blockId} id one of keys of this.BLOCK dict.
* @param {state} one of 'searching', 'connected', 'pairing', 'paired', * @param {state} one of keys of this.CONNECTION dict.
* @private * @private
*/ */
setDeviceBlockState_: function(blockId, state) { setDeviceBlockState_: function(blockId, state) {
if (state == 'update') if (state == 'update')
return; return;
var deviceBlock = $(blockId); var deviceBlock = $(blockId);
var states = ['searching', 'connected', 'pairing', 'paired']; for (var stateCase in this.CONNECTION)
for (var i = 0; i < states.length; ++i) { deviceBlock.classList.toggle(stateCase, stateCase == state);
if (states[i] != state)
deviceBlock.classList.remove(states[i]); // 'Continue' button available iff at least one device is connected,
if ((blockId in this.BLOCK) &&
(state == this.CONNECTION.CONNECTED ||
state == this.CONNECTION.PAIRED)) {
$('hid-continue-button').disabled = false;
} else {
$('hid-continue-button').disabled = true;
} }
deviceBlock.classList.add(state);
}, },
/** /**
* Sets state for mouse-block. * Sets state for mouse-block.
* @param {state} one of 'searching', 'connected', 'paired'. * @param {state} one of keys of this.CONNECTION dict.
*/ */
setPointingDeviceState: function(state) { setPointingDeviceState: function(state) {
if (state === undefined) if (state === undefined)
return; return;
this.setDeviceBlockState_('hid-mouse-block', state); this.setDeviceBlockState_(this.BLOCK.MOUSE, state);
}, },
/** /**
...@@ -120,10 +141,10 @@ login.createScreen('HIDDetectionScreen', 'hid-detection', function() { ...@@ -120,10 +141,10 @@ login.createScreen('HIDDetectionScreen', 'hid-detection', function() {
if (data === undefined || !('state' in data)) if (data === undefined || !('state' in data))
return; return;
var state = data['state']; var state = data['state'];
this.setDeviceBlockState_('hid-keyboard-block', state); this.setDeviceBlockState_(this.BLOCK.KEYBOARD, state);
if (state == 'paired') if (state == this.CONNECTION.PAIRED)
$('hid-keyboard-label-paired').textContent = data['keyboard-label']; $('hid-keyboard-label-paired').textContent = data['keyboard-label'];
else if (state == 'pairing') { else if (state == this.CONNECTION.PAIRING) {
$('hid-keyboard-label-pairing').textContent = data['keyboard-label']; $('hid-keyboard-label-pairing').textContent = data['keyboard-label'];
if (data['pairing-state'] == this.PAIRING.REMOTE_PIN_CODE || if (data['pairing-state'] == this.PAIRING.REMOTE_PIN_CODE ||
data['pairing-state'] == this.PAIRING.REMOTE_PASSKEY) { data['pairing-state'] == this.PAIRING.REMOTE_PASSKEY) {
...@@ -136,21 +157,11 @@ login.createScreen('HIDDetectionScreen', 'hid-detection', function() { ...@@ -136,21 +157,11 @@ login.createScreen('HIDDetectionScreen', 'hid-detection', function() {
data['keyboard-label'] + ' ' + data['pincode'] + ' ' + data['keyboard-label'] + ' ' + data['pincode'] + ' ' +
loadTimeData.getString('hidDetectionBTEnterKey')); loadTimeData.getString('hidDetectionBTEnterKey'));
} }
} else if (state == 'update') { } else if (state == this.CONNECTION.UPDATE) {
if ('keysEntered' in data) { if ('keysEntered' in data) {
this.setPincodeKeysState_(data['keysEntered']); this.setPincodeKeysState_(data['keysEntered']);
} }
} }
}, },
/**
* Event handler that is invoked just before the screen in shown.
* @param {Object} data Screen init payload.
*/
onBeforeShow: function(data) {
$('hid-continue-button').disabled = true;
this.setDeviceBlockState_('hid-mouse-block', 'searching');
this.setDeviceBlockState_('hid-keyboard-block', 'searching');
},
}; };
}); });
...@@ -29,12 +29,13 @@ const char kJsScreenPath[] = "login.HIDDetectionScreen"; ...@@ -29,12 +29,13 @@ const char kJsScreenPath[] = "login.HIDDetectionScreen";
const char kRemotePinCode[] = "bluetoothRemotePinCode"; const char kRemotePinCode[] = "bluetoothRemotePinCode";
const char kRemotePasskey[] = "bluetoothRemotePasskey"; const char kRemotePasskey[] = "bluetoothRemotePasskey";
// Possible ui-states for device-blocks. // Possible ui-states for device-blocks. Same as CONNECTION dict of
// HIDDetectionScreen
const char kSearchingState[] = "searching"; const char kSearchingState[] = "searching";
const char kUSBConnectedState[] = "connected"; const char kUSBConnectedState[] = "connected";
const char kBTPairedState[] = "paired"; const char kBTPairedState[] = "paired";
const char kBTPairingState[] = "pairing"; const char kBTPairingState[] = "pairing";
// Special state for notifications that don't switch ui-state, but add info. // Special state for notifications that doesn't switch ui-state, but adds info.
const char kBTUpdateState[] = "update"; const char kBTUpdateState[] = "update";
// Names of possible arguments used for ui update. // Names of possible arguments used for ui update.
...@@ -61,6 +62,10 @@ bool DeviceIsKeyboard(device::BluetoothDevice::DeviceType device_type) { ...@@ -61,6 +62,10 @@ bool DeviceIsKeyboard(device::BluetoothDevice::DeviceType device_type) {
device_type == device::BluetoothDevice::DEVICE_KEYBOARD_MOUSE_COMBO; device_type == device::BluetoothDevice::DEVICE_KEYBOARD_MOUSE_COMBO;
} }
bool DeviceIsKeyboard(const device::InputServiceLinux::InputDeviceInfo& info) {
return info.is_keyboard || info.is_touchscreen || info.is_tablet;
}
} // namespace } // namespace
namespace chromeos { namespace chromeos {
...@@ -123,9 +128,7 @@ void HIDDetectionScreenHandler::Show() { ...@@ -123,9 +128,7 @@ void HIDDetectionScreenHandler::Show() {
num_of_times_dialog_was_shown + 1); num_of_times_dialog_was_shown + 1);
ShowScreen(OobeUI::kScreenHIDDetection, NULL); ShowScreen(OobeUI::kScreenHIDDetection, NULL);
if (!pointing_device_id_.empty())
SendPointingDeviceNotification(); SendPointingDeviceNotification();
if (!keyboard_device_id_.empty())
SendKeyboardDeviceNotification(NULL); SendKeyboardDeviceNotification(NULL);
} }
...@@ -369,7 +372,7 @@ void HIDDetectionScreenHandler::OnInputDeviceAdded( ...@@ -369,7 +372,7 @@ void HIDDetectionScreenHandler::OnInputDeviceAdded(
pointing_device_connect_type_ = info.type; pointing_device_connect_type_ = info.type;
SendPointingDeviceNotification(); SendPointingDeviceNotification();
} }
if (keyboard_device_id_.empty() && info.is_keyboard) { if (keyboard_device_id_.empty() && DeviceIsKeyboard(info)) {
keyboard_device_id_ = info.id; keyboard_device_id_ = info.id;
keyboard_device_name_ = info.name; keyboard_device_name_ = info.name;
keyboard_device_connect_type_ = info.type; keyboard_device_connect_type_ = info.type;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment