| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.device.geolocation; | 5 package org.chromium.device.geolocation; |
| 6 | 6 |
| 7 import android.os.Handler; | 7 import android.os.Handler; |
| 8 import android.os.HandlerThread; | 8 import android.os.HandlerThread; |
| 9 import android.os.Message; | 9 import android.os.Message; |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * A mock location provider. When started, runs a background thread that periodi
cally | 12 * A mock location provider. When started, runs a background thread that periodi
cally |
| 13 * posts location updates. This does not involve any system Location APIs and th
us | 13 * posts location updates. This does not involve any system Location APIs and th
us |
| 14 * does not require any special permissions in the test app or on the device. | 14 * does not require any special permissions in the test app or on the device. |
| 15 */ | 15 */ |
| 16 public class MockLocationProvider implements LocationProviderFactory.LocationPro
vider { | 16 public class MockLocationProvider implements LocationProviderFactory.LocationPro
vider { |
| 17 private boolean mIsRunning; | 17 private boolean mIsRunning; |
| 18 private Handler mHandler; | 18 private Handler mHandler; |
| 19 private HandlerThread mHandlerThread; | 19 private HandlerThread mHandlerThread; |
| 20 private final Object mLock = new Object(); | 20 private final Object mLock = new Object(); |
| 21 | 21 |
| 22 private static final int UPDATE_LOCATION_MSG = 100; | 22 private static final int UPDATE_LOCATION_MSG = 100; |
| 23 | 23 |
| 24 public MockLocationProvider() { | 24 public MockLocationProvider() {} |
| 25 } | |
| 26 | 25 |
| 27 public void stopUpdates() { | 26 public void stopUpdates() { |
| 28 if (mHandlerThread != null) { | 27 if (mHandlerThread != null) { |
| 29 mHandlerThread.quit(); | 28 mHandlerThread.quit(); |
| 30 } | 29 } |
| 31 } | 30 } |
| 32 | 31 |
| 33 @Override | 32 @Override |
| 34 public void start(boolean enableHighAccuracy) { | 33 public void start(boolean enableHighAccuracy) { |
| 35 if (mIsRunning) return; | 34 if (mIsRunning) return; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 newLocation(); | 71 newLocation(); |
| 73 sendEmptyMessageDelayed(UPDATE_LOCATION_MSG, 250); | 72 sendEmptyMessageDelayed(UPDATE_LOCATION_MSG, 250); |
| 74 } | 73 } |
| 75 } | 74 } |
| 76 } | 75 } |
| 77 }; | 76 }; |
| 78 } | 77 } |
| 79 | 78 |
| 80 private void newLocation() { | 79 private void newLocation() { |
| 81 LocationProviderAdapter.newLocationAvailable( | 80 LocationProviderAdapter.newLocationAvailable( |
| 82 0, 0, System.currentTimeMillis() / 1000.0, | 81 0, 0, System.currentTimeMillis() / 1000.0, false, 0, true, 0.5,
false, 0, false, 0); |
| 83 false, 0, | |
| 84 true, 0.5, | |
| 85 false, 0, | |
| 86 false, 0); | |
| 87 } | 82 } |
| 88 }; | 83 }; |
| 89 | |
| OLD | NEW |