~thomas-voss/location-service/fix-1354092

« back to all changes in this revision

Viewing changes to src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp

  • Committer: thomas-voss
  • Date: 2014-10-06 08:25:45 UTC
  • mfrom: (105.1.5 location-service)
  • Revision ID: thomas.voss@canonical.com-20141006082545-c67ispeh4aeesc12
[ thomas-voss ]
* Implement heuristic to invalidate 3G cells after 60 seconds. (LP:
  #1371514)
[ thomas-voss ]
* Expose remote::Interface and respective stub/skeleton for using and
  exposing remote location providers.
* Add a standalone daemon for executing providers out of process.

Show diffs side-by-side

added added

removed removed

Lines of Context:
108
108
void impl::OfonoNmConnectivityManager::enumerate_connected_radio_cells(const std::function<void(const connectivity::RadioCell::Ptr&)>& f) const
109
109
{
110
110
    std::lock_guard<std::mutex> lg(d.cached.guard);
 
111
    // We only report currently valid cells.
111
112
    for (const auto& cell : d.cached.cells)
112
 
        f(cell.second);
 
113
        if (cell.second->is_valid().get())
 
114
            f(cell.second);
113
115
}
114
116
 
115
117
const core::Property<connectivity::Characteristics>& impl::OfonoNmConnectivityManager::active_connection_characteristics() const
216
218
    });
217
219
 
218
220
    // And update our cache of modems and registered cells.
219
 
    auto cell = std::make_shared<detail::CachedRadioCell>(modem);
 
221
    auto cell = std::make_shared<detail::CachedRadioCell>(modem, dispatcher.service);
 
222
 
 
223
    // We do not keep the cell alive.
 
224
    std::weak_ptr<detail::CachedRadioCell> wp{cell};
 
225
 
 
226
    // We account for a cell becoming invalid and report it as report.
 
227
    cell->is_valid().changed().connect([this, wp](bool valid)
 
228
    {
 
229
        VLOG(10) << "Validity of cell changed: " << std::boolalpha << valid << std::endl;
 
230
 
 
231
        auto sp = wp.lock();
 
232
 
 
233
        if (not sp)
 
234
            return;
 
235
 
 
236
        if (valid)
 
237
            signals.connected_cell_added(sp);
 
238
        else
 
239
            signals.connected_cell_removed(sp);
 
240
    });
 
241
 
220
242
    {
221
243
        std::lock_guard<std::mutex> lg(cached.guard);
222
244
        cached.modems.insert(std::make_pair(modem.object->path(), modem));
289
311
    {
290
312
        // A new network registration is coming in and we have to create
291
313
        // a corresponding cell instance.
292
 
        auto cell = std::make_shared<detail::CachedRadioCell>(itm->second);
 
314
        auto cell = std::make_shared<detail::CachedRadioCell>(itm->second, dispatcher.service);
 
315
 
 
316
        // We do not keep the cell alive.
 
317
        std::weak_ptr<detail::CachedRadioCell> wp{cell};
 
318
 
 
319
        // We account for a cell becoming invalid and report it as report.
 
320
        cell->is_valid().changed().connect([this, wp](bool valid)
 
321
        {
 
322
            VLOG(10) << "Validity of cell changed: " << std::boolalpha << valid << std::endl;
 
323
 
 
324
            auto sp = wp.lock();
 
325
 
 
326
            if (not sp)
 
327
                return;
 
328
 
 
329
            if (valid)
 
330
                signals.connected_cell_added(sp);
 
331
            else
 
332
                signals.connected_cell_removed(sp);
 
333
        });
 
334
 
293
335
        cached.cells.insert(std::make_pair(path,cell));
294
336
        // Cache is up to date now and we announce the new cell to
295
337
        // API customers, with the lock on the cache not being held.