Commit 2e8c7c5a authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

Don't leave tablet mode on lid event if tablet mode switch is on

Leaving tablet mode on lid state changes is a workaround for the lid
being erroneously detected as fully open at small lid angles, which
could cause the device to be detected as in tablet mode while opening
the lid. This workaround should not override tablet mode state if
tablet mode switch is on - this is a reliable indicator that the
device actually is in tablet mode. Overriding this state could be
problematic on detachable devices if the keyboard is detached while
the lid is closed. In that case, the device could report lid as open
after entering the tablet mode, and subsequently, and unexpectedly
leave the tablet mode.

BUG=b/79327284

Change-Id: I31f2d31182122fc8a6a73e185360858e035118fe
Reviewed-on: https://chromium-review.googlesource.com/1054370Reviewed-by: default avatarJonathan Ross <jonross@chromium.org>
Reviewed-by: default avatarDan Erat <derat@chromium.org>
Commit-Queue: Toni Barzic <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557650}
parent e2201a45
......@@ -281,7 +281,9 @@ void TabletModeController::LidEventReceived(
const bool open = state == chromeos::PowerManagerClient::LidState::OPEN;
lid_is_closed_ = !open;
LeaveTabletMode(false);
if (!tablet_mode_switch_is_on_)
LeaveTabletMode(false);
}
void TabletModeController::TabletModeEventReceived(
......
......@@ -254,6 +254,27 @@ TEST_F(TabletModeControllerTest, OpenLidUnstableLidAngle) {
EXPECT_FALSE(IsTabletModeStarted());
}
// Verify that suppressing unstable lid angle while opening the lid does not
// override tablet mode switch on value - if tablet mode switch is on, device
// should remain in tablet mode.
TEST_F(TabletModeControllerTest, TabletModeSwitchOnWithOpenUnstableLidAngle) {
AttachTickClockForTest();
SetTabletMode(true /*on*/);
EXPECT_TRUE(IsTabletModeStarted());
OpenLid();
EXPECT_TRUE(IsTabletModeStarted());
// Simulate the correct accelerometer readings.
OpenLidToAngle(355.0f);
EXPECT_TRUE(IsTabletModeStarted());
// Simulate the erroneous accelerometer readings.
OpenLidToAngle(5.0f);
EXPECT_TRUE(IsTabletModeStarted());
}
// Verify the unstable lid angle is suppressed during closing the lid.
TEST_F(TabletModeControllerTest, CloseLidUnstableLidAngle) {
AttachTickClockForTest();
......@@ -275,6 +296,24 @@ TEST_F(TabletModeControllerTest, CloseLidUnstableLidAngle) {
EXPECT_FALSE(IsTabletModeStarted());
}
// Verify that suppressing unstable lid angle when the lid is closed does not
// override tablet mode switch on value - if tablet mode switch is on, device
// should remain in tablet mode.
TEST_F(TabletModeControllerTest, TabletModeSwitchOnWithCloseUnstableLidAngle) {
AttachTickClockForTest();
OpenLid();
SetTabletMode(true /*on*/);
EXPECT_TRUE(IsTabletModeStarted());
CloseLid();
EXPECT_TRUE(IsTabletModeStarted());
SetTabletMode(false /*on*/);
EXPECT_FALSE(IsTabletModeStarted());
}
TEST_F(TabletModeControllerTest, TabletModeTransition) {
OpenLidToAngle(90.0f);
EXPECT_FALSE(IsTabletModeStarted());
......
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