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.location.Location; | |
8 import android.os.Handler; | 7 import android.os.Handler; |
9 import android.os.HandlerThread; | 8 import android.os.HandlerThread; |
10 import android.os.Message; | 9 import android.os.Message; |
11 | 10 |
12 /** | 11 /** |
13 * 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 |
14 * 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 |
15 * 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. |
16 */ | 15 */ |
17 public class MockLocationProvider implements LocationProviderFactory.LocationPro
vider { | 16 public class MockLocationProvider implements LocationProviderFactory.LocationPro
vider { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 if (msg.what == UPDATE_LOCATION_MSG) { | 70 if (msg.what == UPDATE_LOCATION_MSG) { |
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 Location location = new Location("MockLocationProvider"); | 80 LocationProviderAdapter.newLocationAvailable( |
82 location.setTime(System.currentTimeMillis()); | 81 0, 0, System.currentTimeMillis() / 1000.0, false, 0, true, 0.5,
false, 0, false, 0); |
83 location.setAccuracy(0.5f); | |
84 LocationProviderAdapter.onNewLocationAvailable(location); | |
85 } | 82 } |
86 }; | 83 }; |
OLD | NEW |