Skip to content

Commit c4d93ba

Browse files
Steve BlockBart Sears
authored andcommitted
Cherry-pick DeviceMotionService CL from master [do not merge]
In DeviceMotionService, handle the fact that we may receive updates from SensorManager after unregistering. cherry-pick of Change: d09001f Bug: 5110230 Change-Id: Id1d1f51b445ce4a14bfcdfad8f173922e01b6563
1 parent 1a23088 commit c4d93ba

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)