Commit 8242c9ca authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

Revert TabletModeController refactoring cls.

The refacotring CLs exposed an underlying issue that caused b/117075672.
I need to revert all the refactoring for now, and fix the underlying issue
first and then reland these refactoring cls.

Basically the assumption of "--enable-touchview" USE flag is not longer true,
thus Chrome can't reply on this flag to decide whether a device is capable of
entering tablet mode. We need to find other ways to do so.

Since it's a pure revert, TBR xiyuan@.

Revert "TabletModeController refactoring II."

This reverts commit 43b3f48d.

Revert "TabletModeController refactoring III."

This reverts commit 95f93d44.

Revert "Fix the regression caused by the refactoring."

This reverts commit 5b0a138d.

Bug:887042, b/117075672
TBR=xiyuan@chromium.org

Change-Id: I494a8d05be1fb07bea404cd714b0b1d9689e46d4
Reviewed-on: https://chromium-review.googlesource.com/c/1265996Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597356}
parent 3a375f95
...@@ -357,7 +357,7 @@ TEST_F(VirtualKeyboardControllerAutoTest, EnabledDuringTabletMode) { ...@@ -357,7 +357,7 @@ TEST_F(VirtualKeyboardControllerAutoTest, EnabledDuringTabletMode) {
TabletModeControllerTestApi().EnterTabletMode(); TabletModeControllerTestApi().EnterTabletMode();
ASSERT_TRUE(keyboard::IsKeyboardEnabled()); ASSERT_TRUE(keyboard::IsKeyboardEnabled());
// Toggle tablet mode off. // Toggle tablet mode off.
TabletModeControllerTestApi().LeaveTabletMode(); TabletModeControllerTestApi().LeaveTabletMode(false);
ASSERT_FALSE(keyboard::IsKeyboardEnabled()); ASSERT_FALSE(keyboard::IsKeyboardEnabled());
} }
...@@ -400,7 +400,7 @@ TEST_F(VirtualKeyboardControllerAutoTest, SuppressedInTabletMode) { ...@@ -400,7 +400,7 @@ TEST_F(VirtualKeyboardControllerAutoTest, SuppressedInTabletMode) {
ASSERT_TRUE(notified()); ASSERT_TRUE(notified());
ASSERT_FALSE(IsVirtualKeyboardSuppressed()); ASSERT_FALSE(IsVirtualKeyboardSuppressed());
// Toggle tablet mode oFF. // Toggle tablet mode oFF.
TabletModeControllerTestApi().LeaveTabletMode(); TabletModeControllerTestApi().LeaveTabletMode(false);
ASSERT_FALSE(keyboard::IsKeyboardEnabled()); ASSERT_FALSE(keyboard::IsKeyboardEnabled());
} }
......
...@@ -112,7 +112,7 @@ TEST_F(OverviewButtonTrayTest, TabletModeObserverOnTabletModeToggled) { ...@@ -112,7 +112,7 @@ TEST_F(OverviewButtonTrayTest, TabletModeObserverOnTabletModeToggled) {
TabletModeControllerTestApi().EnterTabletMode(); TabletModeControllerTestApi().EnterTabletMode();
EXPECT_TRUE(GetTray()->visible()); EXPECT_TRUE(GetTray()->visible());
TabletModeControllerTestApi().LeaveTabletMode(); TabletModeControllerTestApi().LeaveTabletMode(false);
EXPECT_FALSE(GetTray()->visible()); EXPECT_FALSE(GetTray()->visible());
} }
...@@ -302,7 +302,7 @@ TEST_F(OverviewButtonTrayTest, VisibilityChangesForSystemModalWindow) { ...@@ -302,7 +302,7 @@ TEST_F(OverviewButtonTrayTest, VisibilityChangesForSystemModalWindow) {
ASSERT_TRUE(Shell::IsSystemModalWindowOpen()); ASSERT_TRUE(Shell::IsSystemModalWindowOpen());
TabletModeControllerTestApi().EnterTabletMode(); TabletModeControllerTestApi().EnterTabletMode();
EXPECT_TRUE(GetTray()->visible()); EXPECT_TRUE(GetTray()->visible());
TabletModeControllerTestApi().LeaveTabletMode(); TabletModeControllerTestApi().LeaveTabletMode(false);
EXPECT_FALSE(GetTray()->visible()); EXPECT_FALSE(GetTray()->visible());
} }
......
...@@ -164,12 +164,17 @@ class ASH_EXPORT TabletModeController ...@@ -164,12 +164,17 @@ class ASH_EXPORT TabletModeController
// a certain range of time before using unstable angle. // a certain range of time before using unstable angle.
bool CanUseUnstableLidAngle() const; bool CanUseUnstableLidAngle() const;
// Attempts to enter tablet mode and update the internal keyboard and // True if it is possible to enter tablet mode in the current
// touchpad. // configuration. If this returns false, it should never be the case that
// tablet mode becomes enabled.
bool CanEnterTabletMode();
// Attempts to enter tablet mode and locks the internal keyboard and touchpad.
void AttemptEnterTabletMode(); void AttemptEnterTabletMode();
// Attempts to exit tablet mode and update the internal keyboard and touchpad. // Attempts to exit tablet mode and unlocks the internal keyboard and touchpad
void AttemptLeaveTabletMode(); // if |called_by_device_update| is false.
void AttemptLeaveTabletMode(bool called_by_device_update);
// Record UMA stats tracking TabletMode usage. If |type| is // Record UMA stats tracking TabletMode usage. If |type| is
// TABLET_MODE_INTERVAL_INACTIVE, then record that TabletMode has been // TABLET_MODE_INTERVAL_INACTIVE, then record that TabletMode has been
...@@ -198,17 +203,6 @@ class ASH_EXPORT TabletModeController ...@@ -198,17 +203,6 @@ class ASH_EXPORT TabletModeController
// sent from device manager. This will exit tablet mode if needed. // sent from device manager. This will exit tablet mode if needed.
void HandleMouseAddedOrRemoved(); void HandleMouseAddedOrRemoved();
// Update the internal mouse and keyboard event blocker |event_blocker_|
// according to current configuration. The internal input events should be
// blocked if 1) we are currently in tablet mode or 2) we are currently in
// laptop mode but the lid is flipped over (i.e., we are in laptop mode
// because of an external attached mouse).
void UpdateInternalMouseAndKeyboardEventBlocker();
// Returns true if the current lid angle can be detected and is in tablet mode
// angle range.
bool LidAngleIsInTabletModeRange();
// Callback function for |bluetooth_devices_observer_|. Called when |device| // Callback function for |bluetooth_devices_observer_|. Called when |device|
// changes. // changes.
void UpdateBluetoothDevice(device::BluetoothDevice* device); void UpdateBluetoothDevice(device::BluetoothDevice* device);
...@@ -220,6 +214,9 @@ class ASH_EXPORT TabletModeController ...@@ -220,6 +214,9 @@ class ASH_EXPORT TabletModeController
// internal keyboard and touchpad. // internal keyboard and touchpad.
std::unique_ptr<ScopedDisableInternalMouseAndKeyboard> event_blocker_; std::unique_ptr<ScopedDisableInternalMouseAndKeyboard> event_blocker_;
// Whether we have ever seen accelerometer data.
bool have_seen_accelerometer_data_ = false;
// Whether the lid angle can be detected. If it's true, the device is a // Whether the lid angle can be detected. If it's true, the device is a
// convertible device (both screen acclerometer and keyboard acclerometer are // convertible device (both screen acclerometer and keyboard acclerometer are
// available, thus lid angle is detectable). And if it's false, the device is // available, thus lid angle is detectable). And if it's false, the device is
......
...@@ -21,8 +21,9 @@ void TabletModeControllerTestApi::EnterTabletMode() { ...@@ -21,8 +21,9 @@ void TabletModeControllerTestApi::EnterTabletMode() {
tablet_mode_controller_->AttemptEnterTabletMode(); tablet_mode_controller_->AttemptEnterTabletMode();
} }
void TabletModeControllerTestApi::LeaveTabletMode() { void TabletModeControllerTestApi::LeaveTabletMode(
tablet_mode_controller_->AttemptLeaveTabletMode(); bool called_by_device_update) {
tablet_mode_controller_->AttemptLeaveTabletMode(called_by_device_update);
} }
void TabletModeControllerTestApi::AttachExternalMouse() { void TabletModeControllerTestApi::AttachExternalMouse() {
......
...@@ -26,9 +26,10 @@ class TabletModeControllerTestApi { ...@@ -26,9 +26,10 @@ class TabletModeControllerTestApi {
TabletModeControllerTestApi(); TabletModeControllerTestApi();
~TabletModeControllerTestApi(); ~TabletModeControllerTestApi();
// Enters or exits tablet mode. // Enters or exits tablet mode. Use these instead when stuff such as tray
// visibilty depends on the event blocker instead of the actual tablet mode.
void EnterTabletMode(); void EnterTabletMode();
void LeaveTabletMode(); void LeaveTabletMode(bool called_by_device_update);
// Called to attach an external mouse. If we're currently in tablet mode, // Called to attach an external mouse. If we're currently in tablet mode,
// tablet mode will be ended because of this. // tablet mode will be ended because of this.
......
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