Skip to content

Commit 03f8fcb

Browse files
Steve BlockAndroid Git Automerger
authored andcommitted
am c4d93ba: Cherry-pick DeviceMotionService CL from master [do not merge]
* commit 'c4d93ba55fbe905fa72ee7a068efd7c5fb4e8257': Cherry-pick DeviceMotionService CL from master [do not merge]
2 parents 845fdba + c4d93ba commit 03f8fcb

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

core/java/android/webkit/DeviceMotionService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ private void createHandler() {
9999
mUpdateRunnable = new Runnable() {
100100
@Override
101101
public void run() {
102+
assert mIsRunning;
102103
mManager.onMotionChange(new Double(mLastAcceleration[0]),
103104
new Double(mLastAcceleration[1]), new Double(mLastAcceleration[2]),
104105
INTERVAL_MILLIS);
@@ -157,6 +158,11 @@ public void onSensorChanged(SensorEvent event) {
157158
assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName());
158159
assert(event.sensor.getType() == Sensor.TYPE_ACCELEROMETER);
159160

161+
// We may get callbacks after the call to getSensorManager().unregisterListener() returns.
162+
if (!mIsRunning) {
163+
return;
164+
}
165+
160166
boolean firstData = mLastAcceleration == null;
161167
mLastAcceleration = event.values;
162168
if (firstData) {

core/java/android/webkit/DeviceOrientationService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ public void onSensorChanged(SensorEvent event) {
188188
assert(event.values.length == 3);
189189
assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName());
190190

191+
// We may get callbacks after the call to getSensorManager().unregisterListener() returns.
191192
if (!mIsRunning) {
192193
return;
193194
}

0 commit comments

Comments
 (0)