powerd

Revision 18 as of 2013-07-11 17:19:20

Clear message

powerd

powerd is a system daemon that helps manage power states on the phone by providing a DBUS API (to be documented). This API is used by system services, not apps, to change the state of the system power and display. powerd also manages some things internally, like the activity timeout, although that code will be moving to Unity.

Bugs

Please report any bugs you find with powerd. If you have issues, you need to enable debug messages, which as of July 11 are disabled by default. In order to do that you need to edit /etc/init/powerd.conf and remove the comment (the # character) on the line that says "env POWERD_DEBUG=1". After doing that you can reboot the phone and reproduce your issue. Once the issue comes back, please attach the contents of /var/log/syslog to the bug. If you want you can filter that log to only have powerd entries using grep.

The current powerd bug list can be found Here.

Testing

PowerD Test Plan

Test Description

Command

Pass/Fail

Test Display On, Brightness Dim

powerd-cli display on dim

Test Display On, Brightness Bright

powerd-cli display on bright

Test Display On, Brightness Dim, Proximity On

powerd-cli display on dim proximity

Test Display On, Brightness Bright, Proximity On

powerd-cli display on bright proximity

Test Display On, Don't Care about Brightness Level

powerd-cli display on dc

Test Display On, Don't Care about Brightness Level with Proximity

powerd-cli display on dc proximity

Test Display On upon receiving a phone call

powerd-cli listen

Test Display On upon receiving a SMS text

powerd-cli listen

Test Display On upon receiving a MMS text

powerd-cli listen

Test Feature powerd-cli

powerd-cli test

Test that power button overrides any requested screen state via powerd

Disable screen via power button , followed by powerd-cli display on bright

Test that the activity timer dims the screen after 45 seconds

powerd-cli listen

Test that the activity timer shuts off the screen after 60 seconds

powerd-cli listen

Ensure that when 2 display activities are sent, dim and bright. The bright activity always overrides the dim

Open 2 terminals,
In the 1st terminal issue: powerd-cli display on dim
In the 2nd terminal issue: powerd-cli display on bright

Ensure that the display switches from Dim to Bright

Open 2 terminals,
In the 1st terminal issue: powerd-cli display on bright
In the 2nd terminal issue: powerd-cli display on dim

Ensure that the display remains bright and dim is ignored

Ensure that stopping powerd kills all pending activity requests

Open 3 terminals,
In the 1st terminal issue: powerd-cli display on dim
In the 2nd terminal issue: powerd-cli display on bright

In the 3rd terminal Issue: sudo initctl restart powerd
Verify the existing activities have been cancelled
: powerd-cli list


The following table displays the tested devices, percentage of pass/fail test case ratio.

Tested Devices

Nexus4

Nexus7

API

The documentation below is for the dbus API, it is documented as if these are C-style function calls, but currently there is no library to use. This API is still very fluid and will change without warning. The code in powerd-cli.c provides good examples for calling into this API from C.

  • System States
    • string requestSysState(int state)
      • state: may be one of:
        • 0 - Requesting this state will prevent the device from suspending. There are no other valid states
      • Return Value: Returns a string cookie
    • void clearSysState(string cookie)
      • provided a valid cookie, this will clear a state request. If this is the last active state request, the phone will suspend immediately.
  • Display States
    • string requestDisplayState(int state, int brightness, unsigned int flags)
      • state: may be one of
        • 0 - callers will use this when they do not care about whether the screen is on, but instead need to modify flags or brightness settings. For example, a call to enable the Proximity Sensor's control of the screen would set this value.
        • 1 - will turn the screen on, overriding DONT_CARE requests
      • brightness: may be one of
        • 0 - callers will use this when the don't care what the brightness is, for example if they want the screen on, but don't care at what brightness it is set. This allows for other callers to control brightness (like the screen dim on inactivity).
        • 1 - screen should be dim. Note that if other callers request Bright, this will be overridden.
        • 2 - screen should be bright
      • flags: may any of (or'd together)
        • 1 - allow the proximity sensor to turn the screen on and off
        • 2 - disable auto-brightness which is based on ambient light
    • void clearSysState(string cookie)
      • provided a valid cookie, this will clear a state request. If this is the last request to keep the screen on, it will turn off.