Commit 9490c8af authored by Gwendal Grignou's avatar Gwendal Grignou Committed by Commit Bot

Revert "Do not use the accelerometer device file when it's failed to read"

This reverts commit 42f6f938.

Reason for revert: 
1- We need to trigger event before reading
2- Reading one byte will make next reading unaligned.
3- The error was due to invalid group setting, fixed since.

Original change's description:
> Do not use the accelerometer device file when it's failed to read
>
> On some system / device configuration, the accelerometer device
> file exists but can't be read by the browser process. When this
> happens, it generates error log repeatedly, which is not great.
>
> This CL tries to address this issue in a way. On initializing
> accelerometer configuration, it tries to read the device file
> at that time, and when it fails to read, it just stops the
> initialization and reports an error message. This happens once,
> and does not generate repeated logs.
>
> Also, when an error happens, now it can obtain the errno and
> print it as a part of the log, so it would be more understandable
> why it fails. On my case, it is just permission denied, for some
> reasons.
>
> Bug: 1134527
> Test: manually with nautilus device in the lab
> Change-Id: Ib9823631a70fc54d3e3abc35067aff56a7d7ee50
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2454840
> Reviewed-by: Min Chen <minch@chromium.org>
> Reviewed-by: James Cook <jamescook@chromium.org>
> Commit-Queue: Jun Mukai <mukai@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#814780}

TBR=jamescook@chromium.org,mukai@chromium.org,minch@chromium.org,chenghaoyang@chromium.org

Change-Id: Icd2a780a14bd4e12358053f150a37bd3d7f46f75
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1134527,1133429
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2461648Reviewed-by: default avatarJun Mukai <mukai@chromium.org>
Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
Auto-Submit: Gwendal Grignou <gwendal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815187}
parent 50c7b900
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "base/files/file_enumerator.h" #include "base/files/file_enumerator.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/location.h" #include "base/location.h"
#include "base/logging.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/numerics/math_constants.h" #include "base/numerics/math_constants.h"
#include "base/observer_list_threadsafe.h" #include "base/observer_list_threadsafe.h"
...@@ -616,21 +615,12 @@ bool AccelerometerFileReader::InitializeAccelerometer( ...@@ -616,21 +615,12 @@ bool AccelerometerFileReader::InitializeAccelerometer(
} }
configuration_.scale[config_index][i] = scale; configuration_.scale[config_index][i] = scale;
} }
base::FilePath path =
base::FilePath(kAccelerometerDevicePath).Append(name.BaseName());
char try_reading;
if (base::ReadFile(path, &try_reading, 1) < 0) {
logging::SystemErrorCode err_code = logging::GetLastSystemErrorCode();
LOG(ERROR) << "Failed to read " << path
<< " error: " << logging::SystemErrorCodeToString(err_code);
return false;
}
configuration_.has[config_index] = true; configuration_.has[config_index] = true;
configuration_.count++; configuration_.count++;
ReadingData reading_data; ReadingData reading_data;
reading_data.path = path; reading_data.path =
base::FilePath(kAccelerometerDevicePath).Append(name.BaseName());
reading_data.sources.push_back( reading_data.sources.push_back(
static_cast<AccelerometerSource>(config_index)); static_cast<AccelerometerSource>(config_index));
...@@ -711,11 +701,9 @@ void AccelerometerFileReader::ReadFileAndNotify() { ...@@ -711,11 +701,9 @@ void AccelerometerFileReader::ReadFileAndNotify() {
char reading[reading_size]; char reading[reading_size];
int bytes_read = base::ReadFile(reading_data.path, reading, reading_size); int bytes_read = base::ReadFile(reading_data.path, reading, reading_size);
if (bytes_read < reading_size) { if (bytes_read < reading_size) {
logging::SystemErrorCode err_code = logging::GetLastSystemErrorCode();
LOG(ERROR) << "Accelerometer Read " << bytes_read << " byte(s), expected " LOG(ERROR) << "Accelerometer Read " << bytes_read << " byte(s), expected "
<< reading_size << " bytes from accelerometer " << reading_size << " bytes from accelerometer "
<< reading_data.path.MaybeAsASCII() << reading_data.path.MaybeAsASCII();
<< " error: " << logging::SystemErrorCodeToString(err_code);
return; return;
} }
for (AccelerometerSource source : reading_data.sources) { for (AccelerometerSource source : reading_data.sources) {
......
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