IOPMDeclareNetworkClientActivity

Function IOPMDeclareNetworkClientActivity 

Source
pub unsafe extern "C-unwind" fn IOPMDeclareNetworkClientActivity(
    assertion_name: Option<&CFString>,
    assertion_id: *mut IOPMAssertionID,
) -> IOReturn
Available on crate feature pwr_mgt only.
Expand description

A convenience function for handling remote network clients; this is a wrapper for holding

 kIOPMAssertNetworkClientActive

Call this whenever you detect activity from your remote network clients. This call generates an IPC call, and may block.

On the first invocation, this will populate parameter AssertionID with a new assertion ID. You should pass in this returned assertion ID on every access.

When system is on AC power, every call to IOPMDeclareNetworkClientActivity prevents system from idle sleeping and from demand sleeping for the duration of system sleep timer. When system is on Battery power, every call to IOPMDeclareNetworkClientActivity prevents system from idle sleeping for the duration of system sleep timer.

Assertion created by this interface is valid only for the duration of system sleep timer from the last call. IOKit will disable AssertionID after that duration.

If you detect that your remote client is no longer active, please immediately call

 IOPMAssertionRelease
. Do not wait for the timeout.

If your process can detect when remote clients are active and idle, you can skip this API and directly create

 kIOPMAssertNetworkClientActive
yourself.

If your remote clients require access to the framebuffer or the GPU, then this isn’t the appropriate call for you. Please see

 IOPMAssertionDeclareUserActivity
and pass in argument
 kIOPMUserActiveRemote
.

Parameter AssertionName: A string that describes the name of the caller and the activity being handled by this assertion (e.g. “Serving a podcast”). The name must be less than 128 characters. *

Parameter AssertionID: On Success, unique id will be returned in this parameter. Caller may call this function again with the unique id retured previously to report additional user activity. The unique id returned by this function may change on each call depending on how frequently this function call is repeated and the current system sleep timer value. If you make this call more than once, track the returned value for assertionID, and pass it in as an argument on each call.

Returns: Returns kIOReturnSuccess on success, any other return indicates PM could not successfully activate the specified assertion.

§Safety

  • assertion_name might not allow None.
  • assertion_id must be a valid pointer.