Commit 8a2f3aa1 authored by felixe's avatar felixe Committed by Commit Bot

Revert of Remove confusing keyboard test & focus on input device (patchset #9...

Revert of Remove confusing keyboard test & focus on input device (patchset #9 id:160001 of https://codereview.chromium.org/2964823002/ )

Reason for revert:
A follow up fix for a race condition on cold boot was reverted in https://chromium-review.googlesource.com/c/574731/. With only this patch the functionality is broken in the user facing scenario.

The code state without either this cl or the follow up is better than with only this cl.

Original issue's description:
> Remove confusing keyboard test & inspect input device
>
> In order to make the decision for when to trigger the OOBE display
> chooser less confusing for end users I'm removing the keyboard check.
> Instead an explicit remora requisition check is used to limit the
> effects.
>
> BUG=738885
>
> Review-Url: https://codereview.chromium.org/2964823002
> Cr-Commit-Position: refs/heads/master@{#485019}
> Committed: https://chromium.googlesource.com/chromium/src/+/c923b817665a649b4e18243116c31c68404af7dd

TBR=jdufault@chromium.org,oshima@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=738885

Review-Url: https://codereview.chromium.org/2977293002
Cr-Commit-Position: refs/heads/master@{#487262}
parent 14329d06
...@@ -4,17 +4,13 @@ ...@@ -4,17 +4,13 @@
#include "chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h" #include "chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h"
#include <stdint.h>
#include "ash/display/window_tree_host_manager.h" #include "ash/display/window_tree_host_manager.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "base/stl_util.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "ui/display/display.h" #include "ui/display/display.h"
#include "ui/display/display_layout.h"
#include "ui/display/manager/display_manager.h" #include "ui/display/manager/display_manager.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
#include "ui/events/devices/device_data_manager.h"
#include "ui/events/devices/touchscreen_device.h"
using content::BrowserThread; using content::BrowserThread;
...@@ -27,9 +23,6 @@ bool TouchSupportAvailable(const display::Display& display) { ...@@ -27,9 +23,6 @@ bool TouchSupportAvailable(const display::Display& display) {
display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE; display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE;
} }
// TODO(felixe): More context at crbug.com/738885
const uint16_t kDeviceIds[] = {0x0457, 0x266e};
} // namespace } // namespace
OobeDisplayChooser::OobeDisplayChooser() : weak_ptr_factory_(this) {} OobeDisplayChooser::OobeDisplayChooser() : weak_ptr_factory_(this) {}
...@@ -58,21 +51,18 @@ void OobeDisplayChooser::TryToPlaceUiOnTouchDisplay() { ...@@ -58,21 +51,18 @@ void OobeDisplayChooser::TryToPlaceUiOnTouchDisplay() {
void OobeDisplayChooser::MoveToTouchDisplay() { void OobeDisplayChooser::MoveToTouchDisplay() {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
const ui::DeviceDataManager* device_manager = const display::Displays& displays =
ui::DeviceDataManager::GetInstance(); ash::Shell::Get()->display_manager()->active_only_display_list();
for (const ui::TouchscreenDevice& device :
device_manager->GetTouchscreenDevices()) { if (displays.size() <= 1)
if (!base::ContainsValue(kDeviceIds, device.vendor_id)) return;
continue;
for (const display::Display& display : displays) {
int64_t display_id = if (TouchSupportAvailable(display)) {
device_manager->GetTargetDisplayForTouchDevice(device.id); ash::Shell::Get()->window_tree_host_manager()->SetPrimaryDisplayId(
if (display_id == display::kInvalidDisplayId) display.id());
continue; break;
}
ash::Shell::Get()->window_tree_host_manager()->SetPrimaryDisplayId(
display_id);
break;
} }
} }
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h" #include "chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h"
#include <memory> #include <memory>
#include <vector>
#include "ash/display/display_configuration_controller.h" #include "ash/display/display_configuration_controller.h"
#include "ash/shell.h" #include "ash/shell.h"
...@@ -14,12 +13,9 @@ ...@@ -14,12 +13,9 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/display/display.h" #include "ui/display/display.h"
#include "ui/display/display_observer.h" #include "ui/display/display_observer.h"
#include "ui/display/manager/chromeos/touchscreen_util.h"
#include "ui/display/manager/display_manager.h" #include "ui/display/manager/display_manager.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
#include "ui/display/test/display_manager_test_api.h" #include "ui/display/test/display_manager_test_api.h"
#include "ui/events/devices/device_data_manager.h"
#include "ui/events/devices/touchscreen_device.h"
namespace chromeos { namespace chromeos {
...@@ -29,93 +25,63 @@ class OobeDisplayChooserTest : public ash::test::AshTestBase { ...@@ -29,93 +25,63 @@ class OobeDisplayChooserTest : public ash::test::AshTestBase {
public: public:
OobeDisplayChooserTest() : ash::test::AshTestBase() {} OobeDisplayChooserTest() : ash::test::AshTestBase() {}
int64_t GetPrimaryDisplay() { void SetUp() override {
return display::Screen::GetScreen()->GetPrimaryDisplay().id(); ash::test::AshTestBase::SetUp();
display_manager_test_api_.reset(
new display::test::DisplayManagerTestApi(display_manager()));
} }
void UpdateTouchscreenDevices(const ui::TouchscreenDevice& touchscreen) { void EnableTouch(int64_t id) {
std::vector<ui::TouchscreenDevice> devices{touchscreen}; display_manager_test_api_->SetTouchSupport(
id, display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE);
}
ui::DeviceHotplugEventObserver* manager = void DisableTouch(int64_t id) {
ui::DeviceDataManager::GetInstance(); display_manager_test_api_->SetTouchSupport(
manager->OnTouchscreenDevicesUpdated(devices); id, display::Display::TouchSupport::TOUCH_SUPPORT_UNAVAILABLE);
}
int64_t GetPrimaryDisplay() {
return display::Screen::GetScreen()->GetPrimaryDisplay().id();
} }
private: private:
std::unique_ptr<display::test::DisplayManagerTestApi>
display_manager_test_api_;
DISALLOW_COPY_AND_ASSIGN(OobeDisplayChooserTest); DISALLOW_COPY_AND_ASSIGN(OobeDisplayChooserTest);
}; };
const uint16_t kWhitelistedId = 0x266e;
} // namespace } // namespace
TEST_F(OobeDisplayChooserTest, PreferTouchAsPrimary) { TEST_F(OobeDisplayChooserTest, PreferTouchAsPrimary) {
// Setup 2 displays, second one is intended to be a touch display OobeDisplayChooser display_chooser;
std::vector<display::ManagedDisplayInfo> display_info;
display_info.push_back(
display::ManagedDisplayInfo::CreateFromSpecWithID("0+0-3000x2000", 1));
display_info.push_back(
display::ManagedDisplayInfo::CreateFromSpecWithID("3000+0-800x600", 2));
display_manager()->OnNativeDisplaysChanged(display_info);
base::RunLoop().RunUntilIdle();
// Make sure the non-touch display is primary
ash::Shell::Get()->window_tree_host_manager()->SetPrimaryDisplayId(1);
// Setup corresponding TouchscreenDevice object
ui::TouchscreenDevice touchscreen =
ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
"Touchscreen", gfx::Size(800, 600), 1);
touchscreen.vendor_id = kWhitelistedId;
UpdateTouchscreenDevices(touchscreen);
base::RunLoop().RunUntilIdle();
// Associate touchscreen device with display UpdateDisplay("3000x2000,800x600");
display_info[1].AddInputDevice(touchscreen.id); display::DisplayIdList ids = display_manager()->GetCurrentDisplayIdList();
display_info[1].set_touch_support(display::Display::TOUCH_SUPPORT_AVAILABLE); DisableTouch(ids[0]);
display_manager()->OnNativeDisplaysChanged(display_info); EnableTouch(ids[1]);
base::RunLoop().RunUntilIdle();
OobeDisplayChooser display_chooser; EXPECT_EQ(ids[0], GetPrimaryDisplay());
EXPECT_EQ(1, GetPrimaryDisplay());
display_chooser.TryToPlaceUiOnTouchDisplay(); display_chooser.TryToPlaceUiOnTouchDisplay();
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_EQ(2, GetPrimaryDisplay());
}
TEST_F(OobeDisplayChooserTest, DontSwitchFromTouch) {
// Setup 2 displays, second one is intended to be a touch display
std::vector<display::ManagedDisplayInfo> display_info;
display_info.push_back(
display::ManagedDisplayInfo::CreateFromSpecWithID("0+0-3000x2000", 1));
display_info.push_back(
display::ManagedDisplayInfo::CreateFromSpecWithID("3000+0-800x600", 2));
display_info[0].set_touch_support(display::Display::TOUCH_SUPPORT_AVAILABLE);
display_manager()->OnNativeDisplaysChanged(display_info);
base::RunLoop().RunUntilIdle();
// Make sure the non-touch display is primary EXPECT_EQ(ids[1], GetPrimaryDisplay());
ash::Shell::Get()->window_tree_host_manager()->SetPrimaryDisplayId(1); }
// Setup corresponding TouchscreenDevice object TEST_F(OobeDisplayChooserTest, AddingSecondTouchDisplayShouldbeNOP) {
ui::TouchscreenDevice touchscreen = OobeDisplayChooser display_chooser;
ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
"Touchscreen", gfx::Size(800, 600), 1);
touchscreen.vendor_id = kWhitelistedId;
UpdateTouchscreenDevices(touchscreen);
base::RunLoop().RunUntilIdle();
// Associate touchscreen device with display UpdateDisplay("3000x2000,800x600");
display_info[1].AddInputDevice(touchscreen.id); display::DisplayIdList ids = display_manager()->GetCurrentDisplayIdList();
display_info[1].set_touch_support(display::Display::TOUCH_SUPPORT_AVAILABLE); EnableTouch(ids[0]);
display_manager()->OnNativeDisplaysChanged(display_info); EnableTouch(ids[1]);
base::RunLoop().RunUntilIdle();
OobeDisplayChooser display_chooser; EXPECT_EQ(ids[0], GetPrimaryDisplay());
EXPECT_EQ(1, GetPrimaryDisplay());
display_chooser.TryToPlaceUiOnTouchDisplay(); display_chooser.TryToPlaceUiOnTouchDisplay();
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_EQ(1, GetPrimaryDisplay());
EXPECT_EQ(ids[0], GetPrimaryDisplay());
} }
} // namespace chromeos } // namespace chromeos
...@@ -226,12 +226,17 @@ std::string GetDisplayType(const GURL& url) { ...@@ -226,12 +226,17 @@ std::string GetDisplayType(const GURL& url) {
return path; return path;
} }
bool IsRemoraRequisitioned() { bool IsKeyboardConnected() {
policy::DeviceCloudPolicyManagerChromeOS* policy_manager = const std::vector<ui::InputDevice>& keyboards =
g_browser_process->platform_part() ui::InputDeviceManager::GetInstance()->GetKeyboardDevices();
->browser_policy_connector_chromeos() for (const ui::InputDevice& keyboard : keyboards) {
->GetDeviceCloudPolicyManager(); if (keyboard.type == ui::INPUT_DEVICE_INTERNAL ||
return policy_manager && policy_manager->IsRemoraRequisition(); keyboard.type == ui::INPUT_DEVICE_EXTERNAL) {
return true;
}
}
return false;
} }
} // namespace } // namespace
...@@ -371,7 +376,7 @@ OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url) ...@@ -371,7 +376,7 @@ OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
// TODO(felixe): Display iteration and primary display selection not supported // TODO(felixe): Display iteration and primary display selection not supported
// in Mash. See http://crbug.com/720917. // in Mash. See http://crbug.com/720917.
if (!ash_util::IsRunningInMash() && IsRemoraRequisitioned()) if (!ash_util::IsRunningInMash() && !IsKeyboardConnected())
oobe_display_chooser_ = base::MakeUnique<OobeDisplayChooser>(); oobe_display_chooser_ = base::MakeUnique<OobeDisplayChooser>();
} }
......
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