| <link rel="stylesheet" href="../style.css" /> |
| |
| [TOC] |
| # fuchsia.power.systemmode |
| |
| <div class="fidl-version-div"><span class="fidl-attribute fidl-version">Added: 7</span></div> |
| |
| |
| ## **PROTOCOLS** |
| |
| ## ClientConfigurator {#ClientConfigurator} |
| *Defined in [fuchsia.power.systemmode/systemmode.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.power.systemmode/systemmode.fidl;l=110)* |
| <p>A protocol that can be used to update the power configuration for a given |
| <a class='link' href='#ClientType'>ClientType</a>.</p> |
| |
| |
| ### Get {#ClientConfigurator.Get} |
| |
| <p>Gets the power configuration for the given <a class='link' href='#ClientType'>ClientType</a>.</p> |
| <p>If there is no power configuration for <code>client_type</code> then the returned |
| value will be absent.</p> |
| <ul> |
| <li><code>client_type</code> specifies which <a class='link' href='#ClientType'>ClientType</a> <a class='link' href='#ClientConfig'>ClientConfig</a> to get</li> |
| </ul> |
| <ul> |
| <li><code>config</code> is the returned client-specific configuration, or an absent |
| value if <code>client_type</code> does not have an existing configuration</li> |
| </ul> |
| |
| |
| |
| #### Request {#ClientConfigurator.Get_Request} |
| |
| <table> |
| <tr><th>Name</th><th>Type</th></tr> |
| <tr> |
| <td><code>client_type</code></td> |
| <td> |
| <code><a class='link' href='../fuchsia.power.clientlevel/'>fuchsia.power.clientlevel</a>/<a class='link' href='../fuchsia.power.clientlevel/#ClientType'>ClientType</a></code> |
| </td> |
| </tr> |
| </table> |
| |
| |
| #### Response {#ClientConfigurator.Get_Response} |
| |
| <table> |
| <tr><th>Name</th><th>Type</th></tr> |
| <tr> |
| <td><code>config</code></td> |
| <td> |
| <code><a class='link' href='#ClientConfig'>ClientConfig</a>?</code> |
| </td> |
| </tr> |
| </table> |
| |
| ### Set {#ClientConfigurator.Set} |
| |
| <p>Sets the power configuration for the given <a class='link' href='#ClientType'>ClientType</a>.</p> |
| <p>This method should be used in tandem with <a class='link' href='#GetConfig'>GetConfig</a> in order to |
| update the existing power configuration for a given <a class='link' href='#ClientType'>ClientType</a> |
| without fully overwriting it.</p> |
| <p>When the power configuration for a given <a class='link' href='#ClientType'>ClientType</a> is changed, the |
| Power Manager will reevaluate current power level of that <a class='link' href='#ClientType'>ClientType</a> |
| according to the new configuration. This reevaluation may result in a |
| new power level being sent to the connected client.</p> |
| <p>The call returns immediately after the new config has been received and |
| validated. Actual system changes to be applied as a result of changing a |
| client's configuration will occur after the call has returned. |
| Therefore, any errors that occur while updating clients according to the |
| new system power mode are not propagated back to the caller. Instead, |
| client updates are applied on a "best effort" basis.</p> |
| <p>If the provided <code>config</code> is not valid, then no changes will be applied |
| and the channel will be closed. Validation will fail if a given |
| <code>SystemMode</code> is repeated across multiple <code>mode_match</code> entries contained |
| by the <code>ClientConfig</code>.</p> |
| <ul> |
| <li><code>client_type</code> specifies which <a class='link' href='#ClientType'>ClientType</a>'s <a class='link' href='#ClientConfig'>ClientConfig</a> to set</li> |
| <li><code>config</code> is the <a class='link' href='#ClientConfig'>ClientConfig</a> that will be set for <a class='link' href='#client_type'>client_type</a></li> |
| </ul> |
| |
| |
| |
| #### Request {#ClientConfigurator.Set_Request} |
| |
| <table> |
| <tr><th>Name</th><th>Type</th></tr> |
| <tr> |
| <td><code>client_type</code></td> |
| <td> |
| <code><a class='link' href='../fuchsia.power.clientlevel/'>fuchsia.power.clientlevel</a>/<a class='link' href='../fuchsia.power.clientlevel/#ClientType'>ClientType</a></code> |
| </td> |
| </tr> |
| <tr> |
| <td><code>config</code></td> |
| <td> |
| <code><a class='link' href='#ClientConfig'>ClientConfig</a></code> |
| </td> |
| </tr> |
| </table> |
| |
| |
| #### Response {#ClientConfigurator.Set_Response} |
| |
| <EMPTY> |
| |
| ## Requester {#Requester} |
| *Defined in [fuchsia.power.systemmode/systemmode.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.power.systemmode/systemmode.fidl;l=33)* |
| <p>A protocol that can be used to request a change to the currently active |
| system power modes.</p> |
| |
| |
| ### Request {#Requester.Request} |
| |
| <p>Requests to set or clear a system power mode.</p> |
| <p>The call returns immediately after the request has been received, |
| validated, and accepted. Actual system changes to be applied as a result |
| of this request will occur after the call has returned. Therefore, any |
| errors that occur while updating clients according to the new system |
| power mode are not propagated back to the caller. Instead, client |
| updates are applied on a "best effort" basis.</p> |
| <p>An error returned by this method means the request itself is not valid |
| and was rejected. Details of the specific rejection reason are reflected |
| by the error value. In the event of an error, the channel will remain |
| open.</p> |
| <p>A client can use this method to set or clear system power mode variants |
| independently. For example:</p> |
| <p>// battery is below the "low" threshold |
| Request(LOW_BATTERY, true);</p> |
| <p>// device is now plugged into the wall |
| Request(ON_AC_POWER, true);</p> |
| <p>// battery is now above the "low" threshold |
| Request(LOW_BATTERY, false);</p> |
| <ul> |
| <li><code>mode</code> is the <code>SystemMode</code> to request to be set or cleared</li> |
| <li><code>set</code> should be true to request to set <code>mode</code>, or false to clear it</li> |
| </ul> |
| <ul> |
| <li>error a <a class='link' href='#ModeRequestError'>ModeRequestError</a> value indicating why the request was |
| rejected.</li> |
| </ul> |
| |
| |
| |
| #### Request {#Requester.Request_Request} |
| |
| <table> |
| <tr><th>Name</th><th>Type</th></tr> |
| <tr> |
| <td><code>mode</code></td> |
| <td> |
| <code><a class='link' href='#SystemMode'>SystemMode</a></code> |
| </td> |
| </tr> |
| <tr> |
| <td><code>set</code></td> |
| <td> |
| <code>bool</code> |
| </td> |
| </tr> |
| </table> |
| |
| |
| #### Response {#Requester.Request_Response} |
| |
| <table> |
| <tr><th>Name</th><th>Type</th></tr> |
| <tr> |
| <td><code>result</code></td> |
| <td> |
| <code><a class='link' href='#Requester_Request_Result'>Requester_Request_Result</a></code> |
| </td> |
| </tr> |
| </table> |
| |
| |
| ## **STRUCTS** |
| |
| ### ClientConfig {#ClientConfig data-text="ClientConfig"} |
| *Defined in [fuchsia.power.systemmode/systemmode.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.power.systemmode/systemmode.fidl;l=91)* |
| <p>Defines the power configuration for a <a class='link' href='#ClientType'>ClientType</a>.</p> |
| <p>For a client connected with a given <a class='link' href='#ClientType'>ClientType</a>, the PowerManager will |
| use the configured <a class='link' href='#ClientConfig'>ClientConfig</a> for that <a class='link' href='#ClientType'>ClientType</a> to choose the |
| appropriate power level based on the currently active system power modes. |
| The power level selection process is as follows for a given <a class='link' href='#ClientType'>ClientType</a>:</p> |
| <ol> |
| <li>Iterate through the <a class='link' href='#ClientConfig.mode_matches'>ClientConfig.mode_matches</a> entries. If the |
| <code>mode</code> value specified by an entry is contained in the currently active |
| system power modes, then the corresponding <code>power_level</code> from that entry |
| will be selected as this client’s current power level, and iteration for |
| this client will stop.</li> |
| <li>If no entry in <code>mode_matches</code> was matched, then <code>default_level</code> will be |
| selected as the client's current power level.</li> |
| </ol> |
| |
| <table> |
| <tr><th>Field</th><th>Type</th><th>Description</th><th>Default</th></tr> |
| <tr id="ClientConfig.mode_matches"> |
| <td><code>mode_matches</code></td> |
| <td> |
| <code>vector<<a class='link' href='#ModeMatch'>ModeMatch</a>></code> |
| </td> |
| <td></td> |
| <td>No default</td> |
| </tr> |
| <tr id="ClientConfig.default_level"> |
| <td><code>default_level</code></td> |
| <td> |
| <code>uint64</code> |
| </td> |
| <td></td> |
| <td>No default</td> |
| </tr> |
| </table> |
| |
| ### ModeMatch {#ModeMatch data-text="ModeMatch"} |
| *Defined in [fuchsia.power.systemmode/systemmode.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.power.systemmode/systemmode.fidl;l=102)* |
| <p>Defines the mode-based match criterion for selecting a power level.</p> |
| <p>The power configuration for a given <a class='link' href='#ClientType'>ClientType</a> is made up of a |
| collection of these <code>ModeMatch</code> entries. If an entry's specified <code>mode</code> is |
| contained in the currently active system power modes, then its <code>power_level</code> |
| will be selected as the client's power level.</p> |
| |
| <table> |
| <tr><th>Field</th><th>Type</th><th>Description</th><th>Default</th></tr> |
| <tr id="ModeMatch.mode"> |
| <td><code>mode</code></td> |
| <td> |
| <code><a class='link' href='#SystemMode'>SystemMode</a></code> |
| </td> |
| <td></td> |
| <td>No default</td> |
| </tr> |
| <tr id="ModeMatch.power_level"> |
| <td><code>power_level</code></td> |
| <td> |
| <code>uint64</code> |
| </td> |
| <td></td> |
| <td>No default</td> |
| </tr> |
| </table> |
| |
| ### Requester_Request_Response {#Requester_Request_Response data-text="Requester_Request_Response"} |
| *Defined in [fuchsia.power.systemmode/systemmode.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.power.systemmode/systemmode.fidl;l=67)* |
| |
| <EMPTY> |
| |
| |
| ## **ENUMS** |
| |
| ### ModeRequestError [flexible](/fuchsia-src/reference/fidl/language/language.md#strict-vs-flexible){:.fidl-attribute} {#ModeRequestError data-text="ModeRequestError"} |
| Type: <code>uint32</code> |
| |
| *Defined in [fuchsia.power.systemmode/systemmode.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.power.systemmode/systemmode.fidl;l=25)* |
| <p>Possible error values returned by <a class='link' href='#Requester.Request'>Requester.Request</a>.</p> |
| |
| <table> |
| <tr><th>Name</th><th>Value</th><th>Description</th></tr> |
| <tr id="ModeRequestError.GENERIC"> |
| <td><h3 id="ModeRequestError.GENERIC" class="add-link hide-from-toc">GENERIC</h3></td> |
| <td><code>1</code></td> |
| <td><p>A generic error has occurred.</p> |
| </td> |
| </tr> |
| </table> |
| |
| ### SystemMode [flexible](/fuchsia-src/reference/fidl/language/language.md#strict-vs-flexible){:.fidl-attribute} {#SystemMode data-text="SystemMode"} |
| Type: <code>uint32</code> |
| |
| *Defined in [fuchsia.power.systemmode/systemmode.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.power.systemmode/systemmode.fidl;l=22)* |
| <p>Enumerates the supported system power modes.</p> |
| <p>Power modes in the system are non-exclusive -- more than one could be active |
| at any given time. They typically define a system-wide low-power state or |
| power goal, like "battery-saver mode". See the |
| <a href="/src/power/power-manager/system_power_mode_config/README.md">README.md</a> for |
| more details.</p> |
| <p>Note when adding a new variant: update <a class='link' href='#MAX_MODE_MATCHES_PER_CLIENT'>MAX_MODE_MATCHES_PER_CLIENT</a> to be |
| equal to the number of <code>SystemMode</code> variants to support the "worst case" |
| client configuration.</p> |
| |
| <table> |
| <tr><th>Name</th><th>Value</th><th>Description</th></tr> |
| </table> |
| |
| |
| |
| ## **UNIONS** |
| |
| ### Requester_Request_Result [strict](/fuchsia-src/reference/fidl/language/language.md#strict-vs-flexible){:.fidl-attribute} {#Requester_Request_Result data-text="Requester_Request_Result"} |
| *Defined in [fuchsia.power.systemmode/systemmode.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.power.systemmode/systemmode.fidl;l=67)* |
| <table> |
| <tr><th>Ordinal</th><th>Variant</th><th>Type</th><th>Description</th></tr> |
| <tr id="Requester_Request_Result.response"> |
| <td><h3 id="Requester_Request_Result.response" class="add-link hide-from-toc">1</h3></td> |
| <td><code>response</code></td> |
| <td> |
| <code><a class='link' href='#Requester_Request_Response'>Requester_Request_Response</a></code> |
| </td> |
| <td></td> |
| </tr> |
| <tr id="Requester_Request_Result.err"> |
| <td><h3 id="Requester_Request_Result.err" class="add-link hide-from-toc">2</h3></td> |
| <td><code>err</code></td> |
| <td> |
| <code><a class='link' href='#ModeRequestError'>ModeRequestError</a></code> |
| </td> |
| <td></td> |
| </tr> |
| </table> |
| |
| |
| |
| ## **CONSTANTS** |
| |
| <table> |
| <tr><th>Name</th><th>Value</th><th>Type</th><th>Description</th></tr> |
| <tr id="MAX_MODE_MATCHES_PER_CLIENT"> |
| <td><a href="https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.power.systemmode/systemmode.fidl;l=76">MAX_MODE_MATCHES_PER_CLIENT</a></td> |
| <td> |
| <code>0</code> |
| </td> |
| <td><code>uint32</code></td> |
| <td><p>Maximum number of <a class='link' href='#ModeMatch'>ModeMatch</a> entries that a <a class='link' href='#ClientConfig'>ClientConfig</a> may contain.</p> |
| <p>This value should be set equal to the number of <a class='link' href='#SystemMode'>SystemMode</a> variants, as |
| that is the number of entries required to support the "worst case" client |
| configuration ("worst case" means a configuration where a mode match entry |
| is needed for each of the supported power modes).</p> |
| </td> |
| </tr> |
| </table> |