Commit da7e4828 authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

Speculative fix for a device wrongly enters tablet mode when reopen lid

I cannot repro on my eve or caroline device, but according to comment#4
in bug 1050195, and comment#9 in bug 1050330, it seems theoretically it
can be caused by aync reading of the lid angle driver
"cros-ec-lid-angle". So when the device first starts or comes out from
sleep, the driver "cros-ec-lid-angle" is not present yet, so Chrome is
doing its own lid angle calculation, and later when the reading result
comes back and"cros-ec-lid-angle" flag is properly set, Chrome does not
do the lid angle calculation anymore, but the old lid angle is not reset
to 0.f, so it might interfere with the tablet state calculation.

Bug: 1050195, 1050330
Change-Id: I9c650ee2becbabfb20101a192ebfa5eeb7b677dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2153899
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760553}
parent 92e350db
......@@ -554,6 +554,12 @@ void TabletModeController::OnAccelerometerUpdated(
if (update->HasLidAngleDriver(ACCELEROMETER_SOURCE_SCREEN) ||
update->HasLidAngleDriver(ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD)) {
ec_lid_angle_driver_present_ = true;
// Reset lid angle that might be calculated before lid angle driver is
// read.
lid_angle_ = 0.f;
can_detect_lid_angle_ = false;
if (record_lid_angle_timer_.IsRunning())
record_lid_angle_timer_.Stop();
AccelerometerReader::GetInstance()->RemoveObserver(this);
return;
}
......@@ -1154,10 +1160,10 @@ bool TabletModeController::CalculateIsInTabletPhysicalState() const {
if (tablet_mode_switch_is_on_)
return true;
if (!can_detect_lid_angle_)
if (lid_is_closed_)
return false;
if (lid_is_closed_)
if (!can_detect_lid_angle_)
return false;
// Toggle tablet mode on or off when corresponding thresholds are passed.
......
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