Comment 8 for bug 1481240

Revision history for this message
Kyle Nitzsche (knitzsche) wrote :

If I have a proper precise (GPS based) location (lat&long) in a scope from SearchMetadata.location().latitude()|longitude(), and then disable Location indicator > Location detection OR GPS, then reenable it and refresh the scope, I never get a precise location back. I am stuck with geo IP derived location.

To demo this, I wrote a simple scope that merely gets the lat and long and logs it, or a message if ! has_location().

Here's the relevant code:

void Query::run(us::SearchReplyProxy const& reply)
{
    if (!metadata_.has_location())
    {
        qDebug() << "LOCTEST: no location: " + QDateTime::currentDateTime().toString();
        return;
    }
    try{
        auto lat = metadata_.location().latitude();
        auto lng = metadata_.location().longitude();
        qDebug() << "LOCTEST: lat long: " + QString::number(lat) + " " + QString::number(lng) + " " + QDateTime::currentDateTime().toString();
    } catch(unity::scopes::NotFoundException &e) {
        qWarning() << "==== Warning: Could not get location.";
    }
}

Query::Query(const us::CannedQuery &query, const us::SearchMetadata & metadata, const QVariant accessToken, QString const& cacheDir_) :
    SearchQueryBase(query, metadata),
    metadata_(metadata),
    cannedQuery(query),
    query_(query.query_string()),
    accessToken_(accessToken),
    cacheDir_(cacheDir_)
{

}

Here are the results from scope-registry log grepped with LOCTEST. COMMENTs and ACTIONs added:

COMMENT: starting lat/long are precise (GPS)

"LOCTEST: lat long: 42.4062 -71.6038 Mon Nov 30 23:32:46 2015"
"LOCTEST: lat long: 42.4062 -71.6038 Mon Nov 30 23:32:48 2015"

ACTION: disable indicator Location > Location detection

"LOCTEST: lat long: 42.4062 -71.6038 Mon Nov 30 23:33:24 2015"
"LOCTEST: lat long: 42.4062 -71.6038 Mon Nov 30 23:33:34 2015"
"LOCTEST: lat long: 42.4062 -71.6038 Mon Nov 30 23:33:36 2015"
"LOCTEST: lat long: 42.4062 -71.6038 Mon Nov 30 23:33:37 2015"

COMMENT: Why am I still seeing a precise location? Normally for me geo IP based location is the next town over.

ACTION restart unity8-dash

"LOCTEST: lat long: 42.5244 -71.7657 Mon Nov 30 23:33:59 2015"

COMMENT: That ^ is the geo IP based vague location, as expected.

"LOCTEST: no location: Mon Nov 30 23:34:07 2015"

COMMENT: why do I get no location?

"LOCTEST: lat long: 42.5244 -71.7657 Mon Nov 30 23:34:24 2015"

ACTION: indicator Location > Location detection enabled

"LOCTEST: lat long: 42.5244 -71.7657 Mon Nov 30 23:35:58 2015"
"LOCTEST: lat long: 42.5244 -71.7657 Mon Nov 30 23:36:03 2015"
"LOCTEST: lat long: 42.5244 -71.7657 Mon Nov 30 23:36:10 2015"
"LOCTEST: lat long: 42.5244 -71.7657 Mon Nov 30 23:36:13 2015"
"LOCTEST: lat long: 42.5244 -71.7657 Mon Nov 30 23:36:16 2015"
"LOCTEST: lat long: 42.5244 -71.7657 Mon Nov 30 23:36:54 2015"
"LOCTEST: lat long: 42.5244 -71.7657 Mon Nov 30 23:36:56 2015"
"LOCTEST: lat long: 42.5244 -71.7657 Mon Nov 30 23:37:02 2015"
"LOCTEST: lat long: 42.5244 -71.7657 Mon Nov 30 23:37:04 2015"
"LOCTEST: lat long: 42.5244 -71.7657 Mon Nov 30 23:37:11 2015"
"LOCTEST: lat long: 42.5244 -71.7657 Mon Nov 30 23:37:15 2015"

COMMENT: Several minutes have passed. Why do I still see vague geo IP based location? I expected GPS precision.

ACTION: restart unity8-dash

"LOCTEST: lat long: 42.5244 -71.7657 Mon Nov 30 23:37:40 2015"
"LOCTEST: lat long: 42.5244 -71.7657 Mon Nov 30 23:37:53 2015"
"LOCTEST: lat long: 42.5244 -71.7657 Mon Nov 30 23:38:01 2015"
"LOCTEST: lat long: 42.5244 -71.7657 Mon Nov 30 23:38:03 2015"
"LOCTEST: lat long: 42.5244 -71.7657 Mon Nov 30 23:38:05 2015"

COMMENT: still geo ip based.

ACTION: Wait a while

"LOCTEST: lat long: 42.5244 -71.7657 Mon Nov 30 23:49:18 2015"

COMMENT: still geo IP based. So, all location indicator settings are on, location is enabled in scope, but still: geo IP.

I don't know whether this is a problem with the scope framework using a stale location in this case or if it is an underlying problem with the location service not understanding that it was re enabled, getting a new location, and refreshing unity...