@@ -225,8 +225,7 @@ class LocationTracker extends Tracker
225225
226226 LocationManager m_location_manager ;
227227
228- LocationListener m_network_location_listener ;
229- LocationListener m_gps_location_listener ;
228+ LocationListener m_location_listener ;
230229
231230 public LocationTracker ()
232231 {
@@ -245,7 +244,7 @@ public LocationTracker()
245244 m_timestamp_offset = t_seconds_since_epoch - t_seconds_since_boot ;
246245
247246 m_location_manager = (LocationManager )m_engine .getContext ().getSystemService (Context .LOCATION_SERVICE );
248- m_network_location_listener = new LocationListener ()
247+ m_location_listener = new LocationListener ()
249248 {
250249 // LocationListener methods
251250 public void onLocationChanged (Location location )
@@ -255,26 +254,6 @@ public void onLocationChanged(Location location)
255254 LocationTracker .this .onLocationChanged (location );
256255 }
257256
258- public void onProviderDisabled (String provider )
259- {
260- }
261-
262- public void onProviderEnabled (String provider )
263- {
264- }
265-
266- public void onStatusChanged (String provider , int status , Bundle extras )
267- {
268- }
269- };
270-
271- m_gps_location_listener = new LocationListener ()
272- {
273- public void onLocationChanged (Location location )
274- {
275- LocationTracker .this .onLocationChanged (location );
276- }
277-
278257 public void onProviderDisabled (String provider )
279258 {
280259 m_gps_available = false ;
@@ -307,28 +286,22 @@ protected boolean register(boolean p_loosely)
307286 return true ;
308287
309288 m_use_gps = !p_loosely ;
289+
290+ Criteria t_criteria = new Criteria ();
291+ if (m_use_gps )
292+ t_criteria .setAccuracy (Criteria .ACCURACY_FINE );
293+ else
294+ t_criteria .setAccuracy (Criteria .ACCURACY_COARSE );
295+
310296 try
311297 {
312- m_location_manager .requestLocationUpdates (LocationManager . NETWORK_PROVIDER , 0 , 0 , m_network_location_listener );
298+ m_location_manager .requestLocationUpdates (0 , 0 , t_criteria , m_location_listener , null );
313299 m_registered = true ;
314300 }
315301 catch (SecurityException e )
316302 {
317303 }
318304
319-
320- if (m_use_gps )
321- {
322- try
323- {
324- m_location_manager .requestLocationUpdates (LocationManager .GPS_PROVIDER , 0 , 0 , m_gps_location_listener );
325- m_registered = true ;
326- }
327- catch (SecurityException e )
328- {
329- }
330- }
331-
332305 return m_registered ;
333306 }
334307
@@ -337,8 +310,7 @@ protected boolean unregister()
337310 if (!m_registered )
338311 return true ;
339312
340- m_location_manager .removeUpdates (m_network_location_listener );
341- m_location_manager .removeUpdates (m_gps_location_listener );
313+ m_location_manager .removeUpdates (m_location_listener );
342314 // MM-2011-03-13: [[ Bug 10077 ]] Make sure we flag as unregistered or else we will never be able to register again.5
343315 m_registered = false ;
344316 return true ;
0 commit comments