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.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.location.Criteria; | 8 import android.location.Criteria; |
9 import android.location.Location; | 9 import android.location.Location; |
10 import android.location.LocationListener; | 10 import android.location.LocationListener; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 ensureLocationManagerCreated(); | 143 ensureLocationManagerCreated(); |
144 if (usePassiveOneShotLocation()) return; | 144 if (usePassiveOneShotLocation()) return; |
145 | 145 |
146 assert !mIsRunning; | 146 assert !mIsRunning; |
147 mIsRunning = true; | 147 mIsRunning = true; |
148 | 148 |
149 // We're running on the main thread. The C++ side is responsible to | 149 // We're running on the main thread. The C++ side is responsible to |
150 // bounce notifications to the Geolocation thread as they arrive in
the mainLooper. | 150 // bounce notifications to the Geolocation thread as they arrive in
the mainLooper. |
151 try { | 151 try { |
152 Criteria criteria = new Criteria(); | 152 Criteria criteria = new Criteria(); |
| 153 if (isGpsEnabled) criteria.setAccuracy(Criteria.ACCURACY_FINE); |
153 mLocationManager.requestLocationUpdates(0, 0, criteria, this, | 154 mLocationManager.requestLocationUpdates(0, 0, criteria, this, |
154 ThreadUtils.getUiThreadLooper()); | 155 ThreadUtils.getUiThreadLooper()); |
155 if (isGpsEnabled) { | |
156 criteria.setAccuracy(Criteria.ACCURACY_FINE); | |
157 mLocationManager.requestLocationUpdates(0, 0, criteria, this
, | |
158 ThreadUtils.getUiThreadLooper()); | |
159 } | |
160 } catch (SecurityException e) { | 156 } catch (SecurityException e) { |
161 Log.e(TAG, "Caught security exception registering for location u
pdates from " + | 157 Log.e(TAG, "Caught security exception registering for location u
pdates from " + |
162 "system. This should only happen in DumpRenderTree."); | 158 "system. This should only happen in DumpRenderTree."); |
163 } catch (IllegalArgumentException e) { | 159 } catch (IllegalArgumentException e) { |
164 Log.e(TAG, "Caught IllegalArgumentException registering for loca
tion updates."); | 160 Log.e(TAG, "Caught IllegalArgumentException registering for loca
tion updates."); |
165 } | 161 } |
166 } | 162 } |
167 | 163 |
168 /** | 164 /** |
169 * Unregisters this object from the location service. | 165 * Unregisters this object from the location service. |
(...skipping 30 matching lines...) Expand all Loading... |
200 */ | 196 */ |
201 private boolean isOnlyPassiveLocationProviderEnabled() { | 197 private boolean isOnlyPassiveLocationProviderEnabled() { |
202 List<String> providers = mLocationManager.getProviders(true); | 198 List<String> providers = mLocationManager.getProviders(true); |
203 return providers != null && providers.size() == 1 | 199 return providers != null && providers.size() == 1 |
204 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER)
; | 200 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER)
; |
205 } | 201 } |
206 } | 202 } |
207 } | 203 } |
208 | 204 |
209 | 205 |
OLD | NEW |