Allow apps to keep the screen on

Bug #1462489 reported by Pat McGowan
86
This bug affects 16 people
Affects Status Importance Assigned to Milestone
Canonical Click Reviewers tools (obsolete)
Fix Released
High
Jamie Strandboge
Canonical System Image
Fix Released
High
Pat McGowan
Ubuntu Developer Portal
Fix Released
Undecided
David Callé
apparmor-easyprof-ubuntu (Ubuntu)
Fix Released
High
Jamie Strandboge
qtsystems-opensource-src (Ubuntu)
Fix Released
High
Timo Jyrinki
qtsystems-opensource-src (Ubuntu RTM)
Fix Released
High
Timo Jyrinki
qtubuntu (Ubuntu)
Confirmed
Undecided
Unassigned
ubuntu-system-settings (Ubuntu)
Confirmed
Wishlist
Unassigned
ubuntu-ui-toolkit (Ubuntu)
Invalid
Undecided
Unassigned
unity-system-compositor (Ubuntu)
Fix Released
High
Michael Zanetti
unity8 (Ubuntu)
Fix Released
Wishlist
Unassigned

Bug Description

Support an interface in QML and HTML to allow an app to keep the screen on while the app is active. This has come up in several scenarios, such as an ebook reader, a clock in night mode.

First step is to hook up QtSystemInfo screenSaverEnabled

One solution to inhibit the screen blanking:

Add a new dbus rule to the default template
Provide a mediator (unity8) to control this, so it can restore the screen blanking when the app is not active or has been closed
Prompt the user for confirmation the first time the app accesses it
use the trust store to avoid prompts each time
add to the System settings Other app access panel an entry for Screen or Display so the setting could be revoked

Changed in unity8 (Ubuntu):
importance: Undecided → Wishlist
tags: added: application-confinement
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in apparmor-easyprof-ubuntu (Ubuntu):
status: New → Confirmed
Changed in ubuntu-system-settings (Ubuntu):
status: New → Confirmed
Changed in ubuntu-ui-toolkit (Ubuntu):
status: New → Confirmed
Changed in unity8 (Ubuntu):
status: New → Confirmed
Changed in ubuntu-system-settings (Ubuntu):
importance: Undecided → Wishlist
Revision history for this message
rds (r-schroll) wrote :

As the author of an ebook reader, I wouldn't want to disable the screensaver completely. But I might want to increase the timeout when the reader has focus. Is that within the ambit of this bug, or should I open another one?

Revision history for this message
Sebastien Bacher (seb128) wrote :

do we really need a permission for that? is there any issue to let the focussed application control the screen?

Revision history for this message
costales (costales) wrote : [Bug 1462489] Re: Allow apps to keep the screen on

I made GPS Navigation app. I need to config the idle screen for use this
app each time :(
I'd need to set the screen = ON always.

I'm receiving bad user reviews too in the Store because of this (for
example, review of Jun 6 or 4, 2015)
https://uappexplorer.com/app/navigator.costales
" The only minor flaw so far is that it lets the screen dim even if screen
lock is off - it would be nice to be able to disable that."
"screem auto dims even if I change Bq phone settings."
"has no option for always on screen wich goes dark after 1 min "
" the screen turns almost down even if I set the never sleep option up"

For a video apps it would be useful too.

Best regards!

On Mon, Jun 8, 2015 at 2:43 PM, Sebastien Bacher <email address hidden> wrote:
>
> do we really need a permission for that? is there any issue to let the
> focussed application control the screen?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1462489
>
> Title:
> Allow apps to keep the screen on
>
> To manage notifications about this bug go to:
>
https://bugs.launchpad.net/ubuntu/+source/apparmor-easyprof-ubuntu/+bug/1462489/+subscriptions

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

On 06/08/2015 12:17 PM, costales wrote:
> I made GPS Navigation app. I need to config the idle screen for use this
> app each time :(
> I'd need to set the screen = ON always.
>
FYI, the suggested implementation in the bug is to ask the user the first time
the app tries to inhibit the screen turning off if it is ok to do this-- after
that the answer will be remembered (and thereafter adjustable in system
settings). I don't know if this will be the actual implementation, but the idea
is to solve your issue when it is implemented.

...

> For a video apps it would be useful too.
>
Video apps should be using media-hub which already has the ability to inhibit
the screen turning off. Webapps needing this are waiting for work that is in
progress to make media-hub work with oxide, but that is coming.

--
Jamie Strandboge | http://www.ubuntu.com

Revision history for this message
costales (costales) wrote :

THanks Jamie,
It's OK the user question :)

This is a QML container for a web, then should I to add the media-hub for
this kind of app? Is it just that?

Thanks in advance!

On Monday, June 8, 2015, Jamie Strandboge <email address hidden> wrote:
> On 06/08/2015 12:17 PM, costales wrote:
>> I made GPS Navigation app. I need to config the idle screen for use this
>> app each time :(
>> I'd need to set the screen = ON always.
>>
> FYI, the suggested implementation in the bug is to ask the user the first
time
> the app tries to inhibit the screen turning off if it is ok to do this--
after
> that the answer will be remembered (and thereafter adjustable in system
> settings). I don't know if this will be the actual implementation, but
the idea
> is to solve your issue when it is implemented.
>
> ...
>
>> For a video apps it would be useful too.
>>
> Video apps should be using media-hub which already has the ability to
inhibit
> the screen turning off. Webapps needing this are waiting for work that is
in
> progress to make media-hub work with oxide, but that is coming.
>
> --
> Jamie Strandboge | http://www.ubuntu.com
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1462489
>
> Title:
> Allow apps to keep the screen on
>
> To manage notifications about this bug go to:
>
https://bugs.launchpad.net/ubuntu/+source/apparmor-easyprof-ubuntu/+bug/1462489/+subscriptions
>

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

On 06/08/2015 01:37 PM, costales wrote:
> THanks Jamie,
> It's OK the user question :)
>
> This is a QML container for a web, then should I to add the media-hub for
> this kind of app? Is it just that?
>
As a developer, I think it is all supposed to be transparent-- ie, you use
regular QML, an UbuntuWebview or Oxide Webview and under the hood media-hub is
used. Today, that should work fine for Audio{}/etc it is just that with the
UbuntuWebview and Oxide Webview that under the hood work is in progress.

> Thanks in advance!
>
>
> On Monday, June 8, 2015, Jamie Strandboge <email address hidden> wrote:
>> On 06/08/2015 12:17 PM, costales wrote:
>>> I made GPS Navigation app. I need to config the idle screen for use this
>>> app each time :(
>>> I'd need to set the screen = ON always.
>>>
>> FYI, the suggested implementation in the bug is to ask the user the first
> time
>> the app tries to inhibit the screen turning off if it is ok to do this--
> after
>> that the answer will be remembered (and thereafter adjustable in system
>> settings). I don't know if this will be the actual implementation, but
> the idea
>> is to solve your issue when it is implemented.
>>
>> ...
>>
>>> For a video apps it would be useful too.
>>>
>> Video apps should be using media-hub which already has the ability to
> inhibit
>> the screen turning off. Webapps needing this are waiting for work that is
> in
>> progress to make media-hub work with oxide, but that is coming.
>>
>> --
>> Jamie Strandboge | http://www.ubuntu.com
>>
>> --
>> You received this bug notification because you are subscribed to the bug
>> report.
>> https://bugs.launchpad.net/bugs/1462489
>>
>> Title:
>> Allow apps to keep the screen on
>>
>> To manage notifications about this bug go to:
>>
> https://bugs.launchpad.net/ubuntu/+source/apparmor-easyprof-ubuntu/+bug/1462489/+subscriptions
>>
>

--
Jamie Strandboge | http://www.ubuntu.com

Revision history for this message
costales (costales) wrote :

I was looking into the apparmor and I didn't find any 'media'...
I found a "media-hub" into the video module. Then I added that to the
project, but it didn't work.
I'm a bit lost, I didn't find documentation about media-hub. Please,
could you put me in the right way? :) Thanks in advance!
Costales

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

On 06/08/2015 04:42 PM, costales wrote:
> I was looking into the apparmor and I didn't find any 'media'...
> I found a "media-hub" into the video module. Then I added that to the
> project, but it didn't work.
> I'm a bit lost, I didn't find documentation about media-hub. Please,
> could you put me in the right way? :) Thanks in advance!
> Costales
>
This doesn't really have anything to do with apparmor. If you were wondering
about which security policy groups to use, just use 'audio' or 'video' and
that's it. You just use normal QML like Audio{} and Video{} and you don't have
to worry about media-hub yourself.

--
Jamie Strandboge | http://www.ubuntu.com

Revision history for this message
costales (costales) wrote :

The project is this: lp:~unav

I added 'video' & 'audio' into the policy_groups.

I added then this both tags
<http://doc.qt.io/qt-5/qml-qtmultimedia-audio.html> into the QML:
    Audio {
    }
    Video
    }

But the screen is setting OFF after 1' :(

Revision history for this message
Pat McGowan (pat-mcgowan) wrote :

The screen only stays on if playback is active

Revision history for this message
costales (costales) wrote :

Thanks Pat ;)
Then, I can't use it, because I have indicator voices and I'm not playing then all the time :(
Thanks anyway!

Revision history for this message
Albert Astals Cid (aacid) wrote :

FWIW the QtSystemInfo has a ScreenSaver item that has a screenSaverEnabled property that we could/should implement to do exactly this

https://bugs.launchpad.net/ubuntu/+source/qtubuntu/+bug/1462665

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in qtubuntu (Ubuntu):
status: New → Confirmed
Revision history for this message
Michael Zanetti (mzanetti) wrote :

I agree with Albert, we really should make the existing API work instead of coming up with a new one and keep the existing one broken.

Revision history for this message
FransSchreuder (fransschreuder1) wrote :

Yes Michael, I second that. for unconfined apps it's now possible to use dbus in order to achieve this, but for some apps (I created OSMScout) we need this feature to be fixed for general store apps.
Having the ScreenSaver qml keyword implemented (and allowed) would perfectly do the job.

Changed in canonical-devices-system-image:
assignee: nobody → Pat McGowan (pat-mcgowan)
importance: Undecided → High
milestone: none → ww28-2015
status: New → Confirmed
description: updated
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

The ScreenSaver QML element uses XGetScreenSaver/XSetScreenSaver and is only functional on X11. I guess we might want to add an implementation for Mir.

Cf. http://code.qt.io/cgit/qt/qtsystems.git/tree/src/systeminfo/linux/qscreensaver_linux.cpp

Revision history for this message
Pat McGowan (pat-mcgowan) wrote :

We have a patch for QScreenSaver. The way it will work is that apps can use this from QML:

import QtSystemInfo 5.0
ScreenSaver { screenSaverEnabled: false }

or its pendant from C++. Unity-System-Compositor will watch the
application. As soon as the application is closed, the request will be
dropped and the screensaver will be enabled again, even if the app
didn't explicitly release the resource before quitting.

We need apparmor to allow apps to call the methods:
* keepDisplayOn
* removeDisplayOnRequest
on interface:
com.canonical.Unity.Screen
and path:
/com/canonical/Unity/Screen
on the *system* bus.

Changed in apparmor-easyprof-ubuntu (Ubuntu):
assignee: nobody → Jamie Strandboge (jdstrand)
importance: Undecided → High
Revision history for this message
Pat McGowan (pat-mcgowan) wrote :

@tyler can you help with this

Changed in apparmor-easyprof-ubuntu (Ubuntu):
assignee: Jamie Strandboge (jdstrand) → Tyler Hicks (tyhicks)
Changed in unity-system-compositor (Ubuntu):
assignee: nobody → Michael Zanetti (mzanetti)
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Back from holidays, integrating Michael's patch into qtsystems-opensource-src.

Changed in qtsystems-opensource-src (Ubuntu):
assignee: nobody → Timo Jyrinki (timo-jyrinki)
importance: Undecided → High
status: New → In Progress
Changed in qtsystems-opensource-src (Ubuntu RTM):
importance: Undecided → High
assignee: nobody → Timo Jyrinki (timo-jyrinki)
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

What templates should this be for? Seems at least ubuntu-sdk and ubuntu-webapp. Should scopes also have this ability?

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

We discussed this on irc. This a) should not include scopes and b) should not require a trust prompt since it will be clear that the foreground app is inhibiting the screen. If this is extended to scopes in the futures, we should revisit the trust prompt discussion.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Per Pat, this is for both wily and stable-phone-overlay.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

This will be implemented by added a new policy group, 'keep-display-on' that apps can start using. As such, app policy will not have to be regenerated on OTA upgrade for this change (since no apps are using this new policy group). This requires updating the review tools due to comment #25 (trust prompt won't be implemented at this time, so limit the use of this policy group to only apps specifying the ubuntu-sdk or ubuntu-webapp templates). The addition of the policy group also requires a documentation change.

Changed in click-reviewers-tools (Ubuntu):
assignee: nobody → Jamie Strandboge (jdstrand)
status: New → Triaged
importance: Undecided → High
Changed in apparmor-easyprof-ubuntu (Ubuntu):
assignee: Tyler Hicks (tyhicks) → Jamie Strandboge (jdstrand)
status: Confirmed → Triaged
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Adding lp:developer-ubuntu-com task to update https://developer.ubuntu.com/en/start/platform/guides/app-confinement/. I'll add suggested text once the implementation is going to land.

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

(in QA signoff queue)

Changed in qtsystems-opensource-src (Ubuntu RTM):
status: New → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package qtsystems-opensource-src - 5.0~git20141206~44f70d99-0ubuntu4

---------------
qtsystems-opensource-src (5.0~git20141206~44f70d99-0ubuntu4) wily; urgency=medium

  [ Michael Zanetti ]
  * debian/patches/unity-screen.diff:
    - Allow apps to keep the screen on (LP: #1462489)

 -- Timo Jyrinki <email address hidden> Mon, 06 Jul 2015 09:02:12 +0000

Changed in qtsystems-opensource-src (Ubuntu):
status: In Progress → Fix Released
Changed in canonical-devices-system-image:
status: Confirmed → Fix Committed
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

This bug was fixed in the package qtsystems-opensource-src 5.0~git20141206~44f70d99-0ubuntu2.1 in https://launchpad.net/~ci-train-ppa-service/+archive/ubuntu/stable-phone-overlay

---------------

qtsystems-opensource-src (5.0~git20141206~44f70d99-0ubuntu2.1) vivid; urgency=medium

  [ Michael Zanetti ]
  * debian/patches/unity-screen.diff:
    - Allow apps to keep the screen on (LP: #1462489)

 -- Timo Jyrinki <email address hidden> Mon, 06 Jul 2015 09:03:16 +0000

Changed in qtsystems-opensource-src (Ubuntu RTM):
status: In Progress → Fix Released
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

FYI, the apparmor-easyprof-ubuntu part of the task has not landed yet so I'm not sure Fix Committed is correct for canonical-devices-system-image. This will land this week.

Changed in apparmor-easyprof-ubuntu (Ubuntu):
status: Triaged → In Progress
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Thanks to mzanetti, here is a test snap

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

To verify the snap work, tap the button multiple times. You should see no denials. Then tap the button until the text string says 'disabled'-- then leave the device alone and observe the screen dimming/locking is inhibited. (Requires latest rc-proposed and apparmor-easyprof-ubuntu 1.3.13 from silo 17).

Changed in click-reviewers-tools (Ubuntu):
status: Triaged → In Progress
no longer affects: click-reviewers-tools (Ubuntu)
Revision history for this message
costales (costales) wrote :

Thanks a lot!
@Jamie: For testing it, when will your install .click work in the stable
channel? With the next OTA5?

Changed in click-reviewers-tools:
assignee: nobody → Jamie Strandboge (jdstrand)
importance: Undecided → High
status: New → Fix Released
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

That is the plan, yes. The QA team is testing it for OTA-5 as I type this.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apparmor-easyprof-ubuntu - 15.10.6

---------------
apparmor-easyprof-ubuntu (15.10.6) wily; urgency=medium

  * add ubuntu/keep-display-on for using the Unity screen DBus API
    - LP: #1462489
  * adjust autopkgtests for keep-display-on

 -- Jamie Strandboge <email address hidden> Wed, 08 Jul 2015 09:11:56 -0500

Changed in apparmor-easyprof-ubuntu (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Ok, apparmor-easyprof-ubuntu 1.3.13 is in https://launchpad.net/~ci-train-ppa-service/+archive/ubuntu/stable-phone-overlay/+packages now.

For the developer documentation changes to https://developer.ubuntu.com/en/start/platform/guides/app-confinement/:
1. add 'keep-display-on' to the 'Policy groups' section (ie, the output of 'aa-easyprof --policy-vendor=ubuntu --policy-version=1.2 --list-policy-groups')
2. under Usage/common, add:
  keep-display-on: Can request keeping the screen on

    QML: qtdeclarative5-systeminfo-plugin
    import QtSystemInfo <version>

Revision history for this message
costales (costales) wrote :

Hi! I implemented in GPS Navigation after update to OTA5 and all it's
working perfect.
Thanks a lot for your support!!
Costales

Revision history for this message
costales (costales) wrote :

I found one wrong behaviour.
If I disable the screensaver into the application, the screensaver will
be disable on the entire system when the app goes to the background.

Revision history for this message
Michael Zanetti (mzanetti) wrote :

Well, currently, as long as the application process is running, the request for keeping the display list is respected. When the app is closed (or killed by OOM) the request is deleted.

I agree the long term solution should be to drop it when the app is unfocused (although we should consider how that works with convergence and windowed mode before we make a decision).

On a side note, I would also argue that most applications should even keep the display list all the time. For example, BigMovingText should not request the display to be kept lit while being in the settings menu, but only when it actually is displaying the big moving text. In order to create good quality apps, be clever and set screensaverEnabled to something meaningful instead of just "false". For example:

screenSaverEnabled: !(Qt.application.active && doingStuffThatReallyRequiresIt)

Revision history for this message
costales (costales) wrote :

Then is working perfect :) yes, if I kill it the screensaver will apply.
Thanks for the explanation!

Revision history for this message
Laurie Bradshaw (lauriebradshaw) wrote :

So how would I request the display stays lit without qt?

Revision history for this message
Laurie Bradshaw (lauriebradshaw) wrote :

Ah, nevermind, send dbus message, got it.

Changed in canonical-devices-system-image:
status: Fix Committed → Fix Released
Revision history for this message
costales (costales) wrote :

Hi. One question please, was this released for the Nexus deviced too?
I'm asking because a few Nexus 5/7 users are rating the app as Not Working.
Thanks in advance.

Revision history for this message
Pat McGowan (pat-mcgowan) wrote :

It should be working on Nexus 4, 7 and 10
Not sure when Nexus 5 build was updated as thats community driven

Revision history for this message
costales (costales) wrote :

Thanks a lot for the answer :)

On Thursday, August 6, 2015, Pat McGowan <email address hidden> wrote:
> It should be working on Nexus 4, 7 and 10
> Not sure when Nexus 5 build was updated as thats community driven
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1462489
>
> Title:
> Allow apps to keep the screen on
>
> To manage notifications about this bug go to:
>
https://bugs.launchpad.net/canonical-devices-system-image/+bug/1462489/+subscriptions
>

Revision history for this message
Robert Schroll (rschroll) wrote :

> It should be working on Nexus 4, 7 and 10

It's not working on my Nexus 7, but presumably that's because the flo devel channel hasn't seen an update since April. Has it been abandoned again?

Changed in unity-system-compositor (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Albert Astals Cid (aacid) wrote :

I'm going to set this as fix released for unity8 since it's already working for apps and i don't see what could be missing from unity8.

Changed in unity8 (Ubuntu):
status: Confirmed → Fix Released
David Callé (davidc3)
Changed in developer-ubuntu-com:
assignee: nobody → David Callé (davidc3)
status: New → Fix Released
Gerry Boland (gerboland)
tags: added: unity8
Cris Dywan (kalikiana)
Changed in ubuntu-ui-toolkit (Ubuntu):
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.