pdestefanis / Ushahidi_Android

Ushahidi is a web and mobile platform that allows you to create, visualize and share stories on a map. It allows individuals to share their stories on their own terms using the tools they already have. Ushahidi is free and open source software, so anyone can get involved by visiting http://community.ushahidi.com. Sync with any Ushahidi deployment. Send reports with images and location data as well as receive alerts from others who have sent in reports to the site. Works in offline mode.
http://www.ushahidi.com
GNU Lesser General Public License v3.0
6 stars 3 forks source link

Location being reset in the map #28

Closed pdestefanis closed 12 years ago

pdestefanis commented 12 years ago

THIS IS A CRITICAL BUG

In a new report, when the user selects a location manually and proceeds to enter additional data, the system resets the selected location to the detected location after a short period of time.

How to reproduce: Turn off GPS Go to "Add new incident" (the system will provide the current location through NETWORK_PROVIDER) Tap another location and wait The system resets the location to the auto-detected location

This was observed in the log:

[ first tap somewhere in the map] 03-08 11:48:08.176: I/MapMarker(25316): 110, 193 >> 35.889171, -79.123480

[ then then system does this - see time difference ] 03-08 11:48:28.005: D/dalvikvm(281): GC_EXPLICIT freed 1193K, 38% free 9459K/15175K, external 2178K/2719K, paused 185ms 03-08 11:48:28.015: D/WifiService(281): acquireWifiLockLocked: WifiLock{NetworkLocationProvider type=2 binder=android.os.BinderProxy@40aa1c60} 03-08 11:48:28.556: D/IncidentAdd(25316): doReverseGeocode 03-08 11:48:28.566: I/ReverseGeocoderTask(25316): doInBackground [35.906085059999995, -78.8639028] 03-08 11:48:29.486: I/ReverseGeocoderTask(25316): onPostExecute 3040, E Cornwallis Rd, Durham, United States 03-08 11:48:33.070: D/WifiService(281): releaseWifiLockLocked: WifiLock{NetworkLocationProvider type=2 binder=android.os.BinderProxy@40aa1c60}

Desired behavior:

Once the user manually selects a location in the map, any type of auto-location, (GPS, network, etc) is suspended for the duration of the data entry for this event. The user selection is persistent for that event, and takes precedence. Likewise, the system needs to allow for setting the location even during the period when the GPS is looking for a signal. If the users does so, the GPS-based location is no longer necessary. Currently, the user is not allowed to select a location while the GPS is trying to get a fix, for the duration of the timeout period

pdestefanis commented 12 years ago

Note:

I see that the map keeps calling the reverse geocode procedure, with the address detected initially:

03-08 14:21:30.065: D/IncidentAdd(26343): doReverseGeocode 03-08 14:21:30.075: I/ReverseGeocoderTask(26343): doInBackground [35.906085059999995, -78.8639028] 03-08 14:21:32.117: I/ReverseGeocoderTask(26343): onPostExecute 3040, E Cornwallis Rd, Durham, United States

"3040, E Cornwallis Rd, Durham, United States" is my current location. Even if I clear the "location" field, the call will still be made with that location"

I have also observed in the debug log that the GPS timeout counter keeps reactivating. During that time I was able to select a new location.

At some point while I was selecting a location, I saw this error in the log, and the map window went white. I had to kill the application to continue (the phone was responsive)

03-08 14:23:56.888: I/MapMarker(26343): 56, 92 >> 35.929916, -79.280627 03-08 14:23:58.670: E/PixelConverter(26343): Setting singular matrix Matrix{[0.0, 0.0, 115.0][0.0, 0.0, 210.0][0.0, 0.0, 1.0]}

Below is a sample of how the GPS keeps trying to acquire a location:

03-08 14:28:23.418: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 3908 03-08 14:28:23.418: D/Ushahidi/MapUserLocation(26385): didFindLocation: true 03-08 14:28:24.419: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 2906 03-08 14:28:24.419: D/Ushahidi/MapUserLocation(26385): didFindLocation: true 03-08 14:28:25.410: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 1904 03-08 14:28:25.410: D/Ushahidi/MapUserLocation(26385): didFindLocation: true 03-08 14:28:31.996: D/IncidentAdd(26385): Title: Pasional Index: 5 03-08 14:28:31.996: D/IncidentAdd(26385): Title: Trusted Reports Index: 4 03-08 14:28:31.996: D/IncidentAdd(26385): Title: Otros Index: 3 03-08 14:28:31.996: D/IncidentAdd(26385): Title: Criminal Index: 2 03-08 14:28:31.996: D/IncidentAdd(26385): Title: Municipal Index: 1 03-08 14:28:32.056: D/Ushahidi/MapUserLocation(26385): setDeviceLocation 03-08 14:28:32.056: D/Ushahidi/MapUserLocation(26385): useGPSProvider 03-08 14:28:32.056: D/Ushahidi/MapUserLocation(26385): gpsAvailable: true 03-08 14:28:32.056: D/Ushahidi/MapUserLocation(26385): startTimer 03-08 14:28:32.056: D/Ushahidi/MapUserLocation(26385): gpsTimeout: 60 03-08 14:28:32.127: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 59935 03-08 14:28:32.127: D/Ushahidi/MapUserLocation(26385): didFindLocation: true 03-08 14:28:32.127: D/Ushahidi/MapUserLocation(26385): locationManager.removeUpdates 03-08 14:28:32.127: I/MapActivity(26385): Handling network change notification:CONNECTED 03-08 14:28:32.127: W/IdleConnectionHandler(26385): Removing a connection that never existed! 03-08 14:28:32.127: W/IdleConnectionHandler(26385): Removing a connection that never existed! 03-08 14:28:33.128: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 58935 03-08 14:28:33.128: D/Ushahidi/MapUserLocation(26385): didFindLocation: true 03-08 14:28:34.129: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 57935 03-08 14:28:34.129: D/Ushahidi/MapUserLocation(26385): didFindLocation: true 03-08 14:28:35.119: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 56934 03-08 14:28:35.119: D/Ushahidi/MapUserLocation(26385): didFindLocation: true 03-08 14:28:36.130: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 55934 03-08 14:28:36.130: D/Ushahidi/MapUserLocation(26385): didFindLocation: true 03-08 14:28:37.131: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 54934 03-08 14:28:37.131: D/Ushahidi/MapUserLocation(26385): didFindLocation: true 03-08 14:28:38.122: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 53934 03-08 14:28:38.122: D/Ushahidi/MapUserLocation(26385): didFindLocation: true 03-08 14:28:39.123: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 52934 03-08 14:28:39.123: D/Ushahidi/MapUserLocation(26385): didFindLocation: true 03-08 14:28:40.124: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 51933 03-08 14:28:40.124: D/Ushahidi/MapUserLocation(26385): didFindLocation: true 03-08 14:28:41.125: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 50933 03-08 14:28:41.125: D/Ushahidi/MapUserLocation(26385): didFindLocation: true 03-08 14:28:42.126: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 49932 03-08 14:28:42.126: D/Ushahidi/MapUserLocation(26385): didFindLocation: true 03-08 14:28:43.127: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 48932 03-08 14:28:43.127: D/Ushahidi/MapUserLocation(26385): didFindLocation: true 03-08 14:28:44.128: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 47929 03-08 14:28:44.128: D/Ushahidi/MapUserLocation(26385): didFindLocation: true 03-08 14:28:45.129: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 46928 03-08 14:28:45.129: D/Ushahidi/MapUserLocation(26385): didFindLocation: true 03-08 14:28:46.130: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 45928 03-08 14:28:46.130: D/Ushahidi/MapUserLocation(26385): didFindLocation: true 03-08 14:28:47.131: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 44927 03-08 14:28:47.131: D/Ushahidi/MapUserLocation(26385): didFindLocation: true 03-08 14:28:48.122: D/Ushahidi/MapUserLocation(26385): millisUntilFinished: 43927 03-08 14:28:48.122: D/Ushahidi/MapUserLocation(26385): didFindLocation: true

03-08 14:23:56.888: I/MapMarker(26343): 56, 92 >> 35.929916, -79.280627 03-08 14:23:58.670: E/PixelConverter(26343): Setting singular matrix Matrix{[0.0, 0.0, 115.0][0.0, 0.0, 210.0][0.0, 0.0, 1.0]}

pdestefanis commented 12 years ago

To help you with this, I've revised and (hopefully) clarified the logic on #13, please see:

You can use any names for the functions. This is just pseudocode, and it’s not meant to tell you how to code, just show you the logic

  # For now, this is only called when the user enters the "add event" screen. 
  # In the future, we will add a button to call the function again, ie to retry the autolocation
  # Please not there is no reverse geocoding involved, just get lat/lon

  GetLocation()

  #Variables in settings file:
  Timeout (default 60 seconds)
  Default_Latitude (default -89.2216)
  Default_Longitude (default 13.69947)
  Tolerance = 2

  Use_GPS()
    If isProviderEnabled(GPS_PROVIDER)
        While T < TIMEOUT
          getLastKnownLocation(GPS_PROVIDER) // only wait for TIMEOUT seconds. If timeout expires, the call Use_Network()

          # Allow the user to enter a location during this period.
          # If the user selects a location during this period, take that location and abort the GPS lookup

          If found() or manually_entered() // we cancel the search for GPS coordinates when the unit gets a fix, or the user selects a location
             Return (Latitude, Longitude)
          endif
        endwhile
    else
        Use_Network()
    endif

  Use_Network()
    If ! isProviderEnabled(NETWORK_PROVIDER)
        Default_Location()
    Else
        getLastKnownLocation(NETWORK_PROVIDER) // this loads Latitude and Longitude variables (your names may vary)
    endif

    If ! (Latitude - Default_Latitude > Tolerance) OR (Longitude - Default_Longitude > Tolerance)
        Default_Location()
    endif
  Return (Latitude, Longitude)

  Default_Location()
    message("cannot determine location, using default value")
    Latitude = Default_Latitude
    Longitude = Default_Longitud