am c4d93ba5: Cherry-pick DeviceMotionService CL from master [do not merge]

* commit 'c4d93ba55fbe905fa72ee7a068efd7c5fb4e8257':
  Cherry-pick DeviceMotionService CL from master [do not merge]
This commit is contained in:
Steve Block
2011-08-04 14:49:44 -07:00
committed by Android Git Automerger
2 changed files with 7 additions and 0 deletions

View File

@@ -99,6 +99,7 @@ final class DeviceMotionService implements SensorEventListener {
mUpdateRunnable = new Runnable() { mUpdateRunnable = new Runnable() {
@Override @Override
public void run() { public void run() {
assert mIsRunning;
mManager.onMotionChange(new Double(mLastAcceleration[0]), mManager.onMotionChange(new Double(mLastAcceleration[0]),
new Double(mLastAcceleration[1]), new Double(mLastAcceleration[2]), new Double(mLastAcceleration[1]), new Double(mLastAcceleration[2]),
INTERVAL_MILLIS); INTERVAL_MILLIS);
@@ -157,6 +158,11 @@ final class DeviceMotionService implements SensorEventListener {
assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName()); assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName());
assert(event.sensor.getType() == Sensor.TYPE_ACCELEROMETER); assert(event.sensor.getType() == Sensor.TYPE_ACCELEROMETER);
// We may get callbacks after the call to getSensorManager().unregisterListener() returns.
if (!mIsRunning) {
return;
}
boolean firstData = mLastAcceleration == null; boolean firstData = mLastAcceleration == null;
mLastAcceleration = event.values; mLastAcceleration = event.values;
if (firstData) { if (firstData) {

View File

@@ -188,6 +188,7 @@ final class DeviceOrientationService implements SensorEventListener {
assert(event.values.length == 3); assert(event.values.length == 3);
assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName()); assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName());
// We may get callbacks after the call to getSensorManager().unregisterListener() returns.
if (!mIsRunning) { if (!mIsRunning) {
return; return;
} }