Skip to content

Location updates continue after leaving cell #6

@mvglasow

Description

@mvglasow

I have noticed that the location provider continues sending the last known location in situations in which it shoud really stop sending updates.

To reproduce:

  • Use a phone that returns only the serving cell. (Nexus S or Galaxy Nexus with Cyanogenmod should work, YMMV with others. To find out, get SatStat and look at the network page – you should see only one GSM cell.)
  • Stop all applications which might query the network location provider.
  • Use an application which receives and displays location updates from GSMLocationBackend. (I used a build of SatStat's satstat-location branch, with some debug code inserted to log every location update.)
  • Find out which cells around you are in the database (giving you a location) and which are not.
  • Make sure you are served by a cell which is in the database.
  • Then either:
    • Switch to airplane mode, or
    • Move into a cell which is not in the database. (In my tests I stayed within the same LAC, but this may be unrelated.)

You will observe the following:

  • If at startup (i.e. the time the application registers with the location provider) the serving cell is not in the database, you will not receive any location updates. This behavior is correct.
  • Location updates will start as soon as you are served by a cell which is in the database, with a location update sent approximately every 1.5 seconds – still correct.
  • When moving into a cell that is not in the database or switching to airplane mode, the location provider will continue sending updates at the same rate, with the previous coordinates.

The latter is not correct:

  • When the network becomes unavailable, we can no longer reliably establish our location using the network. This means we should stop sending updates, so that applications can react accordingly – by using other location providers, or by marking the last known location as stale after some time.
  • When moving into a cell that is not in the database, it is equally incorrect to keep sending the old location. The simple approach here would be to stop sending updates.

A somewhat more advanced approach when the cell is not in the DB would be to drop the cell ID and look just for the same MCC/MNC/LAC combination. Bigger cities have multiple LACs, thus the radius of a LAC should be somewhere in the 2–3 km range. The actual accuracy is best inferred from the database (half the longest distance between any two cells having that LAC, plus the average coverage radius of a cell). If the MCC/MNC/LAC combination still does not yield a result, try by MCC/MNC and finally just by MCC. (In some places, such as in the US, carriers use different MNCs in different regions, hence MCC/MNC may allow for a narrower radius than the MCC alone.)

Of course, accuracy will decrease dramatically if we don't have a cell ID. However, even an inaccurate location will still be useful for some purposes: MCC/MNC/LAC would result in a radius of 2–3 km, which is fully sufficient to get the local weather forecast or a list of nearby events. In small countries (such as Andorra or San Marino) even the MCC would be sufficient for that purpose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions