Skip to content

Commit c0347aa

Browse files
author
Jeff Brown
committed
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
1 parent 745f1e3 commit c0347aa

5 files changed

Lines changed: 304 additions & 321 deletions

File tree

core/java/android/view/WindowManagerPolicy.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,13 @@ interface OnKeyguardExitResult {
875875
*/
876876
public boolean rotationHasCompatibleMetricsLw(int orientation, int rotation);
877877

878+
/**
879+
* Called by the window manager when the rotation changes.
880+
*
881+
* @param rotation The new rotation.
882+
*/
883+
public void setRotationLw(int rotation);
884+
878885
/**
879886
* Called when the system is mostly done booting to determine whether
880887
* the system should go into safe mode.

0 commit comments

Comments
 (0)