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() {
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.
* @private
......@@ -65,30 +81,35 @@ login.createScreen('HIDDetectionScreen', 'hid-detection', function() {
/**
* Sets a device-block css class to reflect device state of searching,
* connected, pairing or paired (for BT devices).
* @param {blockId} id one of 'hid-mouse-block' or 'hid-keyboard-block'.
* @param {state} one of 'searching', 'connected', 'pairing', 'paired',
* @param {blockId} id one of keys of this.BLOCK dict.
* @param {state} one of keys of this.CONNECTION dict.
* @private
*/
setDeviceBlockState_: function(blockId, state) {
if (state == 'update')
return;
var deviceBlock = $(blockId);
var states = ['searching', 'connected', 'pairing', 'paired'];
for (var i = 0; i < states.length; ++i) {
if (states[i] != state)
deviceBlock.classList.remove(states[i]);
for (var stateCase in this.CONNECTION)
deviceBlock.classList.toggle(stateCase, stateCase == state);
// '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.
* @param {state} one of 'searching', 'connected', 'paired'.
* @param {state} one of keys of this.CONNECTION dict.
*/
setPointingDeviceState: function(state) {
if (state === undefined)
return;
this.setDeviceBlockState_('hid-mouse-block', state);
this.setDeviceBlockState_(this.BLOCK.MOUSE, state);
},
/**
......@@ -120,10 +141,10 @@ login.createScreen('HIDDetectionScreen', 'hid-detection', function() {
if (data === undefined || !('state' in data))
return;
var state = data['state'];
this.setDeviceBlockState_('hid-keyboard-block', state);
if (state == 'paired')
this.setDeviceBlockState_(this.BLOCK.KEYBOARD, state);
if (state == this.CONNECTION.PAIRED)
$('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'];
if (data['pairing-state'] == this.PAIRING.REMOTE_PIN_CODE ||
data['pairing-state'] == this.PAIRING.REMOTE_PASSKEY) {
......@@ -136,21 +157,11 @@ login.createScreen('HIDDetectionScreen', 'hid-detection', function() {
data['keyboard-label'] + ' ' + data['pincode'] + ' ' +
loadTimeData.getString('hidDetectionBTEnterKey'));
}
} else if (state == 'update') {
} else if (state == this.CONNECTION.UPDATE) {
if ('keysEntered' in data) {
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";
const char kRemotePinCode[] = "bluetoothRemotePinCode";
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 kUSBConnectedState[] = "connected";
const char kBTPairedState[] = "paired";
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";
// Names of possible arguments used for ui update.
......@@ -61,6 +62,10 @@ bool DeviceIsKeyboard(device::BluetoothDevice::DeviceType device_type) {
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 chromeos {
......@@ -123,10 +128,8 @@ void HIDDetectionScreenHandler::Show() {
num_of_times_dialog_was_shown + 1);
ShowScreen(OobeUI::kScreenHIDDetection, NULL);
if (!pointing_device_id_.empty())
SendPointingDeviceNotification();
if (!keyboard_device_id_.empty())
SendKeyboardDeviceNotification(NULL);
SendPointingDeviceNotification();
SendKeyboardDeviceNotification(NULL);
}
void HIDDetectionScreenHandler::Hide() {
......@@ -369,7 +372,7 @@ void HIDDetectionScreenHandler::OnInputDeviceAdded(
pointing_device_connect_type_ = info.type;
SendPointingDeviceNotification();
}
if (keyboard_device_id_.empty() && info.is_keyboard) {
if (keyboard_device_id_.empty() && DeviceIsKeyboard(info)) {
keyboard_device_id_ = info.id;
keyboard_device_name_ = info.name;
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