* commit '3d74e1f23c713414af1b6028d50ae24fa69d95d1': Update rotation without holding the WOL lock.
This commit is contained in:
@@ -217,6 +217,8 @@ public abstract class WindowOrientationListener {
|
|||||||
* It is called each time the orientation determination transitions from being
|
* It is called each time the orientation determination transitions from being
|
||||||
* uncertain to being certain again, even if it is the same orientation as before.
|
* uncertain to being certain again, even if it is the same orientation as before.
|
||||||
*
|
*
|
||||||
|
* This should only be called on the Handler thread.
|
||||||
|
*
|
||||||
* @param rotation The new orientation of the device, one of the Surface.ROTATION_* constants.
|
* @param rotation The new orientation of the device, one of the Surface.ROTATION_* constants.
|
||||||
* @see android.view.Surface
|
* @see android.view.Surface
|
||||||
*/
|
*/
|
||||||
@@ -995,9 +997,13 @@ public abstract class WindowOrientationListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSensorChanged(SensorEvent event) {
|
public void onSensorChanged(SensorEvent event) {
|
||||||
|
int newRotation;
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
mDesiredRotation = (int) event.values[0];
|
mDesiredRotation = (int) event.values[0];
|
||||||
evaluateRotationChangeLocked();
|
newRotation = evaluateRotationChangeLocked();
|
||||||
|
}
|
||||||
|
if (newRotation >=0) {
|
||||||
|
onProposedRotationChanged(newRotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1023,18 +1029,19 @@ public abstract class WindowOrientationListener {
|
|||||||
unscheduleRotationEvaluationLocked();
|
unscheduleRotationEvaluationLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void evaluateRotationChangeLocked() {
|
public int evaluateRotationChangeLocked() {
|
||||||
unscheduleRotationEvaluationLocked();
|
unscheduleRotationEvaluationLocked();
|
||||||
if (mDesiredRotation == mProposedRotation) {
|
if (mDesiredRotation == mProposedRotation) {
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
final long now = SystemClock.elapsedRealtimeNanos();
|
final long now = SystemClock.elapsedRealtimeNanos();
|
||||||
if (isDesiredRotationAcceptableLocked(now)) {
|
if (isDesiredRotationAcceptableLocked(now)) {
|
||||||
mProposedRotation = mDesiredRotation;
|
mProposedRotation = mDesiredRotation;
|
||||||
onProposedRotationChanged(mProposedRotation);
|
return mProposedRotation;
|
||||||
} else {
|
} else {
|
||||||
scheduleRotationEvaluationIfNecessaryLocked(now);
|
scheduleRotationEvaluationIfNecessaryLocked(now);
|
||||||
}
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDesiredRotationAcceptableLocked(long now) {
|
private boolean isDesiredRotationAcceptableLocked(long now) {
|
||||||
@@ -1090,9 +1097,13 @@ public abstract class WindowOrientationListener {
|
|||||||
private Runnable mRotationEvaluator = new Runnable() {
|
private Runnable mRotationEvaluator = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
int newRotation;
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
mRotationEvaluationScheduled = false;
|
mRotationEvaluationScheduled = false;
|
||||||
evaluateRotationChangeLocked();
|
newRotation = evaluateRotationChangeLocked();
|
||||||
|
}
|
||||||
|
if (newRotation >= 0) {
|
||||||
|
onProposedRotationChanged(newRotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user