~mir-team/qtmir/trunk

« back to all changes in this revision

Viewing changes to src/modules/Unity/Application/application.cpp

  • Committer: CI Train Bot
  • Author(s): Gerry Boland
  • Date: 2015-01-15 15:19:36 UTC
  • mfrom: (296.2.23 acquire-wakelock)
  • Revision ID: ci-train-bot@canonical.com-20150115151936-rrimwny1nz09h55l
Add Wakelock support - ensures device drops to deep-sleep mode only when all AppMan suspend tasks have completed

Implemented like so:
 - SharedWakelock manages a single wakelock instance, allowing multiple owners to keep the wakelock enabled, only releasing it when all owners have released it.
- Wakelock operates by communicating with PowerD
- the Application class decides whether a wakelock is necessary, based on the process' lifecycle state.
- added a mighty bunch of tests Fixes: #1309915
Approved by: Michael Zanetti, PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include "application_manager.h"
20
20
#include "desktopfilereader.h"
21
21
#include "session.h"
 
22
#include "sharedwakelock.h"
22
23
#include "taskcontroller.h"
23
24
 
24
25
// common
37
38
{
38
39
 
39
40
Application::Application(const QSharedPointer<TaskController>& taskController,
 
41
                         const QSharedPointer<SharedWakelock>& sharedWakelock,
40
42
                         DesktopFileReader *desktopFileReader,
41
43
                         State state,
42
44
                         const QStringList &arguments,
43
45
                         ApplicationManager *parent)
44
46
    : ApplicationInfoInterface(desktopFileReader->appId(), parent)
45
47
    , m_taskController(taskController)
 
48
    , m_sharedWakelock(sharedWakelock)
46
49
    , m_desktopData(desktopFileReader)
47
50
    , m_pid(0)
48
51
    , m_stage((m_desktopData->stageHint() == "SideStage") ? Application::SideStage : Application::MainStage)
316
319
void Application::setFocused(bool focused)
317
320
{
318
321
    qCDebug(QTMIR_APPLICATIONS) << "Application::setFocused - appId=" << appId() << "focused=" << focused;
 
322
    holdWakelock(true);
 
323
 
319
324
    if (m_focused != focused) {
320
325
        m_focused = focused;
321
326
        Q_EMIT focusedChanged(focused);
326
331
{
327
332
    qCDebug(QTMIR_APPLICATIONS) << "Application::onSessionSuspended - appId=" << appId();
328
333
    m_taskController->suspend(longAppId());
 
334
    holdWakelock(false);
329
335
}
330
336
 
331
337
void Application::onSessionResumed()
332
338
{
333
339
    qCDebug(QTMIR_APPLICATIONS) << "Application::onSessionResumed - appId=" << appId();
 
340
    holdWakelock(true);
334
341
    m_taskController->resume(longAppId());
335
342
}
336
343
 
337
344
void Application::respawn()
338
345
{
339
346
    qCDebug(QTMIR_APPLICATIONS) << "Application::respawn - appId=" << appId();
 
347
    holdWakelock(true);
340
348
    m_taskController->start(appId(), m_arguments);
341
349
}
342
350
 
355
363
    return m_session;
356
364
}
357
365
 
 
366
void Application::holdWakelock(bool enable) const
 
367
{
 
368
    if (appId() == "unity8-dash")
 
369
        return;
 
370
 
 
371
    if (enable) {
 
372
        m_sharedWakelock->acquire(this);
 
373
    } else {
 
374
        m_sharedWakelock->release(this);
 
375
    }
 
376
}
 
377
 
358
378
} // namespace qtmir