Allow apps to keep the screen on

Bug #1462489 reported by Pat McGowan on 2015-06-05
86
This bug affects 16 people
Affects Status Importance Assigned to Milestone
Canonical Click Reviewers tools
High
Jamie Strandboge
Canonical System Image
High
Pat McGowan
Ubuntu Developer Portal
Undecided
David Callé
apparmor-easyprof-ubuntu (Ubuntu)
High
Jamie Strandboge
qtsystems-opensource-src (Ubuntu)
High
Timo Jyrinki
qtsystems-opensource-src (Ubuntu RTM)
High
Timo Jyrinki
qtubuntu (Ubuntu)
Undecided
Unassigned
ubuntu-system-settings (Ubuntu)
Wishlist
Unassigned
ubuntu-ui-toolkit (Ubuntu)
Undecided
Unassigned
unity-system-compositor (Ubuntu)
High
Michael Zanetti
unity8 (Ubuntu)
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
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
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?

Sebastien Bacher (seb128) wrote :

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

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

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

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
>

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

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

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

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' :(

Pat McGowan (pat-mcgowan) wrote :

The screen only stays on if playback is active

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!

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

Launchpad Janitor (janitor) wrote :

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

Changed in qtubuntu (Ubuntu):
status: New → Confirmed
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.

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
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

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
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
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)
Jamie Strandboge (jdstrand) wrote :

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

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.

Jamie Strandboge (jdstrand) wrote :

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

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
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.

Timo Jyrinki (timo-jyrinki) wrote :

(in QA signoff queue)

Changed in qtsystems-opensource-src (Ubuntu RTM):
status: New → In Progress
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
Ł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
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
Jamie Strandboge (jdstrand) wrote :

Thanks to mzanetti, here is a test snap

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)
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
Jamie Strandboge (jdstrand) wrote :

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

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
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>

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

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.

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)

costales (costales) wrote :

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

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

Ah, nevermind, send dbus message, got it.

Changed in canonical-devices-system-image:
status: Fix Committed → Fix Released
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.

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

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
>

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
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) on 2015-09-10
Changed in developer-ubuntu-com:
assignee: nobody → David Callé (davidc3)
status: New → Fix Released
Gerry Boland (gerboland) on 2017-01-06
tags: added: unity8
Changed in ubuntu-ui-toolkit (Ubuntu):
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers