7 Commits

Author SHA1 Message Date
Jeff Brown
e97c9a244b Configure auto-rotation tilt tolerance in config.xml.
This allows for the thresholds to be tuned differently for different
products as needed.

Bug: 18276856
Change-Id: I6c87e683dea6a17cf606203a894c8419e20d3658
2015-06-11 18:53:14 -07:00
Adam Lesinski
282e181b58 Revert "Move frameworks/base/tools/ to frameworks/tools/"
This reverts commit 9f6a119c8aa276432ece4fe2118bd8a3c9b1067e.
2014-01-27 10:31:04 -08:00
Mike Lockwood
9f6a119c8a Move frameworks/base/tools/ to frameworks/tools/
Change-Id: I3ffafdab27cc4aca256c3a5806b630795b75d5c8
2013-08-28 09:44:17 -07:00
Jeff Brown
daf5d894ef Small tweaks to orientation.
Improved threshold for detecting external acceleration.

Bug: 5976859
Change-Id: Iaf2298fba8eda72d1cacbb2f3aea72f460a9262f
2012-05-07 18:30:18 -07:00
Jeff Brown
5aa73ae58f Improve heuristics for orientation detection.
1. Except as otherwise indicated, orientation change happens once
   the predicted rotation has been stable for 40ms.  Noise is
   suppressed by a low-pass filter with a 200ms time constant which
   seems to be about as small as is practical given the quality
   of the sensor data.

2. If the magnitude exceeds a threshold (excessive noise or freefall),
   resets the predicted orientation.
   Doesn't happen very often even when shaking the device.
   This heuristic mainly protects the detector from spurious tilt due
   to inaccurate determination of the gravity vector.

3. If the device was previously in a flat posture (on a table for at
   least 1000ms), then it must move out of that posture for at least
   500ms before the next orientation change will happen.
   This heuristic suppresses most spurious rotations that happen while
   picking up the device.

4. If the device is tilted away from the user by 20 degrees within
   a span of 300ms, the device is said to be swinging and at least
   300ms must elapse after the device stops swinging before the
   next orientation change will happen.
   This heuristic suppresses some but not all spurious rotations that
   happen while putting down a device.  Unfortunately, this heuristic
   sometimes triggers a false positive when turning the device very
   rapidly due to accelerometer noise.  The 300ms pause is a compromise
   so that occasional mispredicted swings don't significantly delay
   the rotation.

Bug: 5796249
Change-Id: Id7b36c4c563e35b70d6a7ac36d04f3c3d6ea5811
2012-01-17 17:07:10 -08:00
Jeff Brown
c0347aa19f Prevent unintended rotations.
Bug: 4981385

Changed the orientation listener to notify the policy whenever
its proposed orientation changes, and changes the window manager
to notify the orientation listener when the actual orientation
changes.  This allows us to better handle the case where the
policy has rejected a given proposal at one time (because the
current application forced orientation) but might choose
to accept the same proposal at another time.

It's important that the proposal always be up to date.  A proposal
becomes irrelevant as soon as the phone posture changes such
that we can no longer determine the orientation with confidence
(such as when a device is placed flat on a table).

Simplified the orientation filtering.  Now we just wait 200ms
for the device to be still before issuing a proposal.  The idea
is that if the device is moving around a lot, we assume that
the device is being picked up or put down or otherwise in
the process of being moved.  We don't want to change the rotation
until that's all settled down.  However, we do want to tolerate
a certain amount of environmental noise.

(The previous confidence algorithm was also designed along
these lines but it was less direct about waiting for things
to settle.  Instead it simply made orientation changes take
longer than usual while unsettled, but the extra delay was often
too much or too little.  This one should be easier to tune.)

Change-Id: I09e6befea1f0994b6b15d424f3182859c0d9a530
2011-09-23 17:26:09 -07:00
Jeff Brown
4519f07e9c New orientation listener.
The objective in this listener is to be more careful about the
signal processing to prevent spurious orientation changes
and to make all of the tweakable factors physically meaningful.

The calibration is defined in terms of time constants and
does not assume a particular discrete sampling rate.  This is
useful because it allows us to change the accelerometer sampling
interval if desired without having to change the calibration.
Moreover, the accelerometer sampling interval can vary +/- 20ms
from one sample to the next even in normal circumstances.

Proposed orientation changes are weighted by confidence factors
that vary exponentially in relation to how close the device
is to the ideal orientation change posture (screen is vertical,
angle is exactly at the midpoint of the orientation quadrant,
and no external acceleration beside gravity).  When not in an ideal
posture, the device takes proportionally longer to settle into a
new orientation state.

Added a little tool to plot the log output of the
WindowOrientationListener.  Check the README for more information
about how to use it.

Change-Id: I787f02d03582ff26367df65eda8d9ce85c5cb343
2011-01-24 13:46:57 -08:00