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) { | |
jdduke (slow)
2014/09/05 15:32:05
Nit: This branch can fit on a single line without
| |
154 criteria.setAccuracy(Criteria.ACCURACY_FINE); | |
155 } | |
153 mLocationManager.requestLocationUpdates(0, 0, criteria, this, | 156 mLocationManager.requestLocationUpdates(0, 0, criteria, this, |
154 ThreadUtils.getUiThreadLooper()); | 157 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) { | 158 } catch (SecurityException e) { |
161 Log.e(TAG, "Caught security exception registering for location u pdates from " + | 159 Log.e(TAG, "Caught security exception registering for location u pdates from " + |
162 "system. This should only happen in DumpRenderTree."); | 160 "system. This should only happen in DumpRenderTree."); |
163 } catch (IllegalArgumentException e) { | 161 } catch (IllegalArgumentException e) { |
164 Log.e(TAG, "Caught IllegalArgumentException registering for loca tion updates."); | 162 Log.e(TAG, "Caught IllegalArgumentException registering for loca tion updates."); |
165 } | 163 } |
166 } | 164 } |
167 | 165 |
168 /** | 166 /** |
169 * Unregisters this object from the location service. | 167 * Unregisters this object from the location service. |
(...skipping 30 matching lines...) Expand all Loading... | |
200 */ | 198 */ |
201 private boolean isOnlyPassiveLocationProviderEnabled() { | 199 private boolean isOnlyPassiveLocationProviderEnabled() { |
202 List<String> providers = mLocationManager.getProviders(true); | 200 List<String> providers = mLocationManager.getProviders(true); |
203 return providers != null && providers.size() == 1 | 201 return providers != null && providers.size() == 1 |
204 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER) ; | 202 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER) ; |
205 } | 203 } |
206 } | 204 } |
207 } | 205 } |
208 | 206 |
209 | 207 |
OLD | NEW |