<div dir="ltr"><div><div><div><div><div>Thank you Lorn,<br><br></div>then WakeupWatcher works as expected.<br><br></div>The only problem I now have is that the timer used to monitor the state wheter the Android service is running or not keeps running forever.<br>

</div>Even if I set the Timer's running property to false when the screen is closed the timer keeps on running.<br><br></div>Any idea why this happens?<br><br></div>Here is my timer code:<br><br><span style="color:rgb(128,0,128)">Timer</span><span style="color:rgb(192,192,192)"> </span>{
<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(128,0,0)">id</span>:<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,0)">alienTimer</span></pre>


<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(128,0,0)">running</span>:<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,128)">WakeupWatcher</span>.isScreenOn();</pre>


<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(128,0,0)">interval</span>:<span style="color:rgb(192,192,192)"> </span>1000;</pre>
<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(128,0,0)">repeat</span>:<span style="color:rgb(192,192,192)"> </span>true;</pre>
<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(128,0,0)">onTriggered</span>:<span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">            </span><span style="font-style:italic;color:rgb(0,0,128)">isAlienRunning</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,128)">Alien</span>.isRunning();</pre>


<pre style="margin:0px;text-indent:0px"><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)">            </span><span style="color:rgb(0,128,0)">isAlienTimerRunning</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">WakeupWatcher.isScreenOn();</span></pre>


<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">            </span><span style="font-style:italic;color:rgb(0,0,128)">alienStatus</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,128)">isAlienRunning</span><span style="color:rgb(192,192,192)"> </span>?<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"running"</span><span style="color:rgb(192,192,192)"> </span>:<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"not</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">running"</span>;</pre>


<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">            </span><span style="font-style:italic;color:rgb(0,0,0)">btnStopAlien</span>.enabled<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,128)">Alien</span>.isAlienInstalled()<span style="color:rgb(192,192,192)"> </span>&&<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,128)">isAlienRunning</span><span style="color:rgb(192,192,192)"> </span>&&<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,128)">isPasswordSet</span><span style="color:rgb(192,192,192)"> </span>&&<span style="color:rgb(192,192,192)"> </span>!<span style="font-style:italic;color:rgb(0,0,128)">isStop</span><span style="color:rgb(192,192,192)"> </span>&&<span style="color:rgb(192,192,192)"> </span>!<span style="font-style:italic;color:rgb(0,0,128)">isRestart</span>;</pre>


<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">            </span><span style="font-style:italic;color:rgb(0,85,175)">console</span>.debug(<span style="color:rgb(0,128,0)">"alienTimer</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">is</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"</span><span style="color:rgb(192,192,192)"> </span>+<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,128)">isAlienTimerRunning</span>);</pre>


<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">        </span>}</pre>
<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">    </span>}<br><br></pre><pre style="margin:0px;text-indent:0px">The WakeupWatcher.isScreenOn returns true if screen is on and false if it's not.<br>

</pre><pre style="margin:0px;text-indent:0px">I don't understand why the timer does not stop and start when that property is changed.<br><br></pre><pre style="margin:0px;text-indent:0px">Here is some output from the application:<br>

<br><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">[D] QWaylandEglIntegration::QWaylandEglIntegration:58 - Using Wayland-EGL </span></pre>
<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">[W] QQmlImportDatabase::importPlugin:1697 - Module 'Sailfish.Silica' does not contain a module identifier directive - it cannot be protected from external registrations.</span></p>


<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">[D] MLocalThemeDaemonClient::MLocalThemeDaemonClient:81 - MLocalThemeDaemonClient::MLocalThemeDaemonClient(const QString&, QObject*) Theme:  "jolla-ambient" </span></p>


<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">[D] MLocalThemeDaemonClient::MLocalThemeDaemonClient:112 - LocalThemeDaemonClient: Looking for assets in ("/usr/share/themes/blanco/meegotouch", "/usr/share/themes/jolla-ambient/meegotouch") </span></p>


<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">DeclarativeCoverWindow: I have a default alpha buffer</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">alienTimer is true</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">alienTimer is true</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">alienTimer is true</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">alienTimer is true</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">alienTimer is true</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">alienTimer is true</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">alienTimer is true</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">[D] WakeupWatcher::mceDisplayStateChanged:62 - --> currentDisplayState =  "on" , screenOn =  true </span></p>


<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">alienTimer is true</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">alienTimer is true</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">alienTimer is true</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">alienTimer is true</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">[D] WakeupWatcher::mceDisplayStateChanged:62 - --> currentDisplayState =  "off" , screenOn =  false </span></p>


<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">alienTimer is true</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">alienTimer is true</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">alienTimer is true</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:'Courier';font-size:10pt;color:rgb(170,0,0)">alienTimer is true</span></p><pre style="margin:0px;text-indent:0px"><br></pre><br></div><div class="gmail_extra">

<br clear="all"><div><br>// Peter Pykäläinen</div>
<br><br><div class="gmail_quote">On 29 April 2014 07:00, Peter Pykäläinen <span dir="ltr"><<a href="mailto:peter.pykalainen@gmail.com" target="_blank">peter.pykalainen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<p dir="ltr">Thank you so much.<br>
I will give this a try.</p>
<p dir="ltr">// Peter Pykäläinen</p>
<div class="gmail_quote">29.4.2014 6.43 kirjoitti "Lorn Potter" <<a href="mailto:lorn.potter@jolla.com" target="_blank">lorn.potter@jolla.com</a>>:<div><div class="h5"><br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<br>
On 29 Apr 2014, at 5:09 am, Peter Pykäläinen <<a href="mailto:peter.pykalainen@gmail.com" target="_blank">peter.pykalainen@gmail.com</a>> wrote:<br>
<br>
> Hi,<br>
><br>
> any idea on how to use QML DeviceInfo on Sailfish?<br>
> I have been searching for a solution to get the event when device screen is<br>
> locked (onLockStatusChanged), but apparently the imports are not working /<br>
> not allowed.<br>
<br>
DeviceInfo no longer has that functionality in Qt 5.<br>
<br>
Try something like this:<br>
<a href="https://github.com/nemomobile/connectionagent/blob/master/connd/wakeupwatcher.cpp" target="_blank">https://github.com/nemomobile/connectionagent/blob/master/connd/wakeupwatcher.cpp</a><br>
<a href="https://github.com/nemomobile/connectionagent/blob/master/connd/wakeupwatcher.h" target="_blank">https://github.com/nemomobile/connectionagent/blob/master/connd/wakeupwatcher.h</a><br>
<br>
<br>
_______________________________________________<br>
SailfishOS.org Devel mailing list<br>
</blockquote></div></div></div>
</blockquote></div><br></div>