com.webos.service.sleep

Note
This API has been available since API level 13.

API Summary

This service registers itself as com.webos.service.power and as com.webos.service.alarm and is provided by the sleep daemon (sleepd). It allows applications to interact with (e.g. defer or prevent) the system suspend/resume cycle.

Overview of the API

Shutdown Process:

The sleep daemon (sleepd) also transitions the system (and ultimately the device) from "On" to "Off". Clients that wish to be notified of this transition and optionally defer or prevent it must first register with sleepd using the "shutdown/shutdownApplicationsRegister" or "shutdown/ShutdownServicesRegister" method.

When sleepd receives a "shutdown/initiate" request, it will transition to the "ShutdownApplications" state.

In the "ShutdownApplications" state, sleepd will broadcast the "ShutdownApplications" signal to all clients which have registered for this signal using the "shutdown/shutdownApplicationsRegister" method, and will wait a maximum of 15 seconds for all responses. Each registered client should respond with an acknowledgement (ACK) using the "shutdown/shutdownApplicationsAck" method. As soon as all clients respond with an ACK, or the "ShutdownApplications" timeout expires, sleepd will transition to the "ShutdownServices" state.

In the "ShutdownServices" state, sleepd will broadcast the "ShutdownServices" signal to all clients which have registered for this signal using the "shutdown/shutdownServicesRegister" method, and will wait a maximum of 15 seconds for all responses. Each registered client should respond with an ACK using the "shutdown/shutdownServicesAck" method. As soon as all clients respond with an ACK, or the "ShutdownServices" timeout expires, sleepd will reply to the caller of the "shutdown/initiate" request.

After receiving the reply to the "shutdown/initiate" request, the caller should then call "shutdown/machineOff" or "shutdown/machineReboot" to forcefully shut down or reboot the device, respectively.

Methods

com/palm/power/TESTSuspend

ACG: sleep.management,sleep.operation
  • Added: API level 24

Description

Schedule the IdleCheck thread to check if the device can suspend.

Note: Used for developer testing purposes.

Parameters

None

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

returnValue is always true

Example

Example scenario

# luna-send -n 1 luna://com.webos.service.sleep/com/palm/power/TESTSuspend '{}'

Response:

{
    "returnValue":true
}

com/palm/power/activityEnd

ACG: sleep.management,sleep.operation
  • Added: API level 24

Description

Cancel a previous request (identified by "id") which was registered using activityStart.

Parameters

Name

Required

Type

Description

idRequiredString

ID of activity that needs to be ended.

This ID should be the same as one specified while calling activityStart method

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

If the activityEnd method succeeds, returnValue will contain true

If the activityEnd method fails, returnValue will contain false. The method may fail because of one the error conditions described in the Error Codes Reference table of this method. See the Error Code Reference table for more information.

errorTextOptionalString

ErrorText contains the error text if the method fails. The method will return errorText only if it fails.

See the Error Codes Reference of this method for more details.

errorCodeOptionalNumber

Return -1 In case of error

Error Codes Reference

Error Code

Error Text

Error Description

-1Malformed json

If the json object parsing fails

Example

Example scenario

# luna-send -n -f luna://com.webos.service.sleep/com/palm/power/activityEnd '{"id":"Diagnostics activity"}'

Response:

{
    "returnValue":true
}

com/palm/power/activityStart

ACG: sleep.management,sleep.operation
  • Added: API level 24

Description

An activity is a specified time duration for which you do not want the system to suspend. This method requests that the system create an activity for "duration" (in milliseconds) with an associated "id" (activity name).

Parameters

Name

Required

Type

Description

idRequiredString

ID of the activity , which can be any string as defined by the caller

duration_msRequirednumber

Duration of activity in milliseconds

This is the amount of time the caller does not want sleepd to suspend the system

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

If the activityStart method succeeds, returnValue will contain true

If the activityStart method fails, returnValue will contain false. The method may fail because of one the error conditions described in the Error Codes Reference table of this method. See the Error Code Reference table for more information.

errorTextOptionalString

ErrorText contains the error text if the method fails. The method will return errorText only if it fails.

See the Error Codes Reference of this method for more details.

errorCodeOptionalString

return errorCode as -1 if method call fails

Error Codes Reference

Error Code

Error Text

Error Description

NoneActivities frozen

This error indicates the system has decided to go to suspend and no new activities are accepted

-1Malformed json

If json object parsing fails

Example

Example scenario

# luna-send -n -f luna://com.webos.service.sleep/com/palm/power/activityStart '{"id":"Diagnostics activity", "duration_ms":100}'

Response:

{
    "returnValue":true
}

com/palm/power/clientCancelByName

ACG: sleep.management,sleep.operation
  • Added: API level 24

Description

Unregister the client by its name.

Parameters

Name

Required

Type

Description

clientNameRequiredString

Name of the client

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

If the clientCancelByName method succeeds, returnValue will contain true

If the clientCancelByName method fails, returnValue will contain false.

errorTextOptionalString

ErrorText contains the error text if the method fails. The method will return errorText only if it fails.

See the Error Codes Reference of this method for more details.

errorCodeOptionalString

return errorCode as -1 if method call fails

Error Codes Reference

Error Code

Error Text

Error Description

-1Invalid parameters

clientName is invalid

Example

Example scenario

# luna-send -n 1 luna://com.webos.service.sleep/com/palm/power/clientCancelByName '{"clientName":"rdxd"}'

Response:

{
    "returnValue":true
}

com/palm/power/forceSuspend

ACG: sleep.management,sleep.operation
  • Added: API level 24

Description

Force the device to go into suspend even with charger connected or any activity is still active.

Note: Used for developer testing purposes.

Parameters

None

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

returnValue is always true

Example

Example scenario

# luna-send -n 1 luna://com.webos.service.sleep/com/palm/power/forceSuspend '{}'

Response:

{
    "returnValue":true
}

com/palm/power/identify

ACG: sleep.management,sleep.operation
  • Added: API level 24

Description

Register a new client with the given name

Parameters

Name

Required

Type

Description

clientNameRequiredString

Name of the client

subscribeRequiredBoolean

Should be always set to true, since subscription is necessary for this method.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

If the method succeeds, returnValue will contain true.

If the method fails, returnValue will contain false. The method may fail because of one the error conditions described in the Error Codes Reference table of this method. See the Error Code Reference table for more information.

clientIdOptionalString

The new ID created for the client

subscribedOptionalBoolean

Always true

errorTextOptionalString

errorText contains the error text if the method fails. The method will return errorText only if it fails.

See the Error Codes Reference of this method for more details.

errorCodeOptionalNumber

Return -1 as errorCode

Error Codes Reference

Error Code

Error Text

Error Description

-1Malformed json

If the json object parsing fails

-1Invalid parameters

If client name is NULL or subscription is not set

-1Unknown error

Unknown error

Example

Example scenario

# luna-send -n 1 luna://com.webos.service.sleep/com/palm/power/identify '{"subscribe":true, "clientName":"rdxd"}'

Response:

{
    "subscribed":true,
    "clientId":"1HE7I2ej.4",
    "returnValue":true
}

com/palm/power/prepareSuspendAck

ACG: sleep.management,sleep.operation
  • Added: API level 24

Description

Used by a client to respond (ack or nack) to the "prepareSuspend" signal. Once the client sends ack to the "prepareSuspend" signal, the client does not do any more operations and prepare itself for the system suspend.

Parameters

Name

Required

Type

Description

clientIdRequiredString

ID of the client

ackRequiredBoolean

To ack for prepareSuspend cycle, set ack to true

To nack for prepareSuspend cycle, set ack to false

This parameter needs to be set, else the method will return an error

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

If prepareSuspendAck call succeeds, returnValue will contain true.

If prepareSuspendAck call fails, returnValue will contain false. The method may fail because of one the error conditions described in the Error Codes Reference table of this method. See the Error Code Reference table for more information.

errorTextOptionalString

ErrorText contains the error text if the method fails. The method will return errorText only if it fails.

See the Error Codes Reference of this method for more details.

errorCodeOptionalNumber

Return errorCode as -1 if method call fails

Error Codes Reference

Error Code

Error Text

Error Description

-1Invalid Parameters

ClientId is invalid or ack is not set

-1Malformed json

If the json object parsing fails

Example

Example scenario

# luna-send -n 1 luna://com.webos.service.sleep/com/palm/power/prepareSuspendAck '{"clientId":"VGb93LuP.2", "ack":true}'

Response:

{

"returnValue":true

}

 

com/palm/power/prepareSuspendRegister

ACG: sleep.management,sleep.operation
  • Added: API level 24

Description

Register a client (already registered with "identify" call) for "prepare suspend" signal. This will add to the counter "sNumPrepareSuspend" before every polling to make a decision to proceed with the suspend action or postpone it later.

Parameters

Name

Required

Type

Description

clientIdRequiredString

ID of the client as returned in the identify method call

registerRequiredBoolean

To register a vote in total count for "prepareSuspend" voting cycle, set register to true

To not register a vote in total count for "prepareSuspend" voting cycle, set register to false

This parameter needs to be set, else the method will return an error

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

If prepareSuspendRegister call succeeds, returnValue will contain true.

If prepareSuspendRegister call fails, returnValue will contain false. The method may fail because of one the error conditions described in the Error Codes Reference table of this method. See the Error Code Reference table for more information.

errorTextOptionalString

ErrorText contains the error text if the method fails. The method will return errorText only if it fails.

See the Error Codes Reference of this method for more details.

errorCodeOptionalNumber

Return errorCode -1 if method call fails

Error Codes Reference

Error Code

Error Text

Error Description

-1Invalid Parameters

clientId is invalid or register is not set

-1Malformed json

If the json object parsing fails

Example

Example scenario

# luna-send -n 1 luna://com.webos.service.sleep/com/palm/power/prepareSuspendRegister '{"clientId":"MRw5pw2V.2", "register":true}'

Response:

{

"returnValue":true

}

com/palm/power/suspendRequestAck

ACG: sleep.management,sleep.operation
  • Added: API level 24

Description

Add the client's count in the total number of ACKs received for the "suspend request" signal.

Parameters

Name

Required

Type

Description

clientIdRequiredString

ID of the client as returned in the identify method call

ackRequiredBoolean

To ack for suspendRequest cycle, set ack to true

To nack for suspendRequest cycle, set ack to false

This parameter needs to be set, else the method will return an error

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

If suspendRequestAck call succeeds, returnValue will contain true.

If suspendRequestAck call fails, returnValue will contain false. The method may fail because of one the error conditions described in the Error Codes Reference table of this method. See the Error Code Reference table for more information.

errorTextOptionalString

ErrorText contains the error text if the method fails. The method will return errorText only if it fails.

See the Error Codes Reference of this method for more details.

errorCodeOptionalString

return errorCode as -1 if method call fails

Error Codes Reference

Error Code

Error Text

Error Description

-1Invalid Parameters

ClientId is invalid or ack is not set

-1Malformed json

If the json object parsing fails

Example

Example scenario

# luna-send -n 1 luna://com.webos.service.sleep/com/palm/power/suspendRequestAck '{"clientId":"VVxhXwzw.2", "ack":true}'

Resposne:

{

"returnValue":true

}

com/palm/power/suspendRequestRegister

ACG: sleep.management,sleep.operation
  • Added: API level 24

Description

Register a client (already registered with "identify" call) for "suspend request" signal. This will add to the counter "sNumSuspendRequest" before every polling to make a decision to proceed with the suspend action or postpone it later.

Parameters

Name

Required

Type

Description

clientIdRequiredString

ID of the client as returned in the identify method call

registerRequiredBoolean

To register a vote in total count for "suspendRequest" voting cycle, set register to true

To not register a vote in total count for "suspendRequest" voting cycle, set register to false

This parameter needs to be set, else the method will return an error

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

If suspendRequestRegister call succeeds, returnValue will contain true.

If suspendRequestRegister call fails, returnValue will contain false. The method may fail because of one the error conditions described in the Error Codes Reference table of this method. See the Error Code Reference table for more information.

errorTextOptionalString

ErrorText contains the error text if the method fails. The method will return errorText only if it fails.

See the Error Codes Reference of this method for more details.

errorCodeOptionalString

return errorCode as -1 if method call fails

Error Codes Reference

Error Code

Error Text

Error Description

-1Invalid parameters

ClientId is invalid or register is not set

-1Malformed json

An internal error occurred when parsing the JSON object being prepared as a response (extremely unlikely).

Example

Example scenario

# luna-send -n 1 luna://com.webos.service.sleep/com/palm/power/suspendRequestRegister '{"clientId":"/var/run/ls2/T4fb64.4", "register":true}'

Response:
{
    "returnValue":true
}

shutdown/TESTresetShutdownState

ACG: sleep.management
  • Added: API level 24

Description

Called by test code to reset state machine to square 1.

Note: Used for developer testing purposes.

Parameters

None

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

true if success

Example

Example scenario

# luna-send -n 1 luna://com.webos.service.sleep/shutdown/TESTresetShutdownState '{}'

Response:

{
    "returnValue":true
}

shutdown/initiate

ACG: sleep.management
  • Added: API level 13

Description

Starts the shutdown process. It sends the shutdownApplications and shutdownServices signals to all the registered apps/services.

Returns "true" once the shutdown process is complete and the system decides that it can shutdown.

Note: This call does not do the actual shutdown; instead use the machineOff method. 

Parameters

None

Call Returns

Name

Required

Type

Description

successRequiredBoolean

Always returns true

Example

Example scenario

# luna-send -n 1 luna://com.webos.service.sleep/shutdown/initiate '{}'

Response:


  "success":true
}

shutdown/machineOff

ACG: sleep.management
  • Added: API level 13

Description

Shuts down the machine forcefully.

Parameters

Name

Required

Type

Description

reasonRequiredString

Reason for the shutdown.

Possible values are:

  • remoteKey: Power off using remote control.
  • offTimer: Power off using OFF timer.
  • localKey: Power off using using the devices hardware power on/off key.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation.

Possible values are:

  • true: Successful.
  • false: Not successful. Check the method's 'Error Codes' section for failure details (errorCode and/or errorText).

Error Codes Reference

Error Code

Error Text

Error Description

-1Invalid parameters

The reason parameter was not provided.

Example

Example scenario

# luna-send -n 1 luna://com.webos.service.sleep/shutdown/machineOff '{"reason":"remoteKey"}'

Response:


  "returnValue":true
}

shutdown/machineReboot

ACG: sleep.management
  • Added: API level 13

Description

Reboots the machine forcefully by calling "reboot".

Parameters

Name

Required

Type

Description

reasonRequiredString

The reason why caller wants to reboot the system.

Possible values are:

  • reset: Reboot after device was reset.
  • ota: Reboot after OTA update completion.
  • SwDownload: Reboot after software download.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation.

Possible values are:

  • true: Successful.
  • false: Not successful. Check the method's 'Error Codes' section for failure details (errorCode and/or errorText).

Error Codes Reference

Error Code

Error Text

Error Description

-1Invalid parameters

The reason parameter was not provided

Example

Example scenario

# luna-send -n 1 luna://com.webos.service.sleep/shutdown/machineReboot '{"reason":"reset"}'

Response:


  "returnValue":true
}

shutdown/shutdownApplicationsAck

ACG: sleep.management
  • Added: API level 13

Description

Sets the client's response as ACK for the "shutdownApplications" signal and trigger the dispatcher for the shutdown state machine, so that if the total client ACK count exceeds total number of clients, it can proceed to the next state.

Parameters

Name

Required

Type

Description

clientIdRequiredString

The unique token for this client which was generated in a previous shutdownApplicationsRegister call.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation.

Possible values are:

  • true: Successful.
  • false: Not successful. Check the method's 'Error Codes' section for failure details (errorCode and/or errorText).

Error Codes Reference

Error Code

Error Text

Error Description

-1Invalid parameters

The clientId parameter was not provided

-1Client not found

Client is not registered.

Example

Example scenario

# luna-send -n 1 luna://com.webos.service.sleep/shutdown/shutdownApplicationsAck '{"clientId":"/var/run/ls2/T4fb64.4"}'

Response:


  "returnValue":true
}

shutdown/shutdownApplicationsRegister

ACG: sleep.management
  • Added: API level 13

Description

Registers an application for the "shutdownApplications" signal. Returns the client ID of the client.

Parameters

Name

Required

Type

Description

clientNameRequiredString

A unique name which the caller decides for the application.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation.

Possible values are:

  • true: Successful.
  • false: Not successful. Check the method's 'Error Codes' section for failure details (errorCode and/or errorText).
clientIdRequiredString

This is a unique token generated for this client by this method, which should be used by the caller for acknowledging the shutdownApplications signal later.

Error Codes Reference

Error Code

Error Text

Error Description

-1Invalid parameters

The clientName parameter was not provided

Example

Example scenario

# luna-send -n 1 luna://com.webos.service.sleep/shutdown/shutdownApplicationsRegister '{"clientName":"facebook app"}'

Response:


  "returnValue":true,
  "clientId":"5zUn94NP.2"
}

shutdown/shutdownServicesAck

ACG: sleep.management
  • Added: API level 13

Description

Sets the client's response as ACK for the "shutdownServices" signal and trigger the dispatcher for the shutdown state machine, so that if the total client ACK count exceeds total number of clients, it can proceed to the next state.

Parameters

Name

Required

Type

Description

clientIdRequiredString

The unique token for this client which was generated in a previous shutdownServicesRegister call.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation.

Possible values are:

  • true: Successful.
  • false: Not successful. Check the method's 'Error Codes' section for failure details (errorCode and/or errorText).

Error Codes Reference

Error Code

Error Text

Error Description

-1Invalid parameters

The clientId parameter is not provided.

-1Client not found

Client is not registered.

Example

Example scenario

# luna-send -n 1 luna://com.webos.service.sleep/shutdown/shutdownServicesAck '{"clientId":"5zUn94NP.2"}'

Response:


  "returnValue":true
}

shutdown/shutdownServicesRegister

ACG: sleep.management
  • Added: API level 13

Description

Registers an application for the "shutdownApplications" signal. Returns the client ID of the client added.

Parameters

Name

Required

Type

Description

clientNameRequiredString

A unique name which the caller decides for the application

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation.

Possible values are:

  • true: Successful.
  • false: Not successful. Check the method's 'Error Codes' section for failure details (errorCode and/or errorText).
clientIdRequiredString

This is a unique token generated for this client by this method, which should be used by the caller for acknowledging the shutdownApplications signal later.

Error Codes Reference

Error Code

Error Text

Error Description

-1Invalid parameters

The clientName parameter is not provided.

Example

Example scenario

# luna-send -n 1 luna://com.webos.service.sleep/shutdown/shutdownServicesRegister '{"clientName":"facebook service"}'

Response:


  "returnValue":true,
  "clientId":"5zUn94NP.2"
}

time/alarmAdd

ACG: sleep.operation
  • Added: API level 24

Description

Set alarm to fire in a fixed time in the future.

Parameters

Name

Required

Type

Description

serviceNameOptionalStringName of the service for which the alarm is to be added
keyOptionalStringidentifier for the alarm
relative_timeRequiredString

amount of relative time after which the alarm should go off. time format is hh:mm:ss (hours:minutes:seconds)

subscribeOptionalBooleantrue if the results are to be subscribed

Call Returns

Name

Required

Type

Description

alarmIdOptionalNumber

alarmId if the alarm was successfully added

subscribedOptionalBoolean

subscribed parameter is received only if subscribe parameter is sent during alarmAdd request

true: if subscription is successful

false: is subscription failed

 

returnValueOptionalBoolean
  • If the method fails, returnValue will contain false
errorTextOptionalString

Error message on failure

Subscription Returns

Name

Required

Type

Description

alarmIdRequiredNumber

alarmId of the subscribed alarm

firedRequiredBoolean

true: if the alarm has fired

false: if the alarm has not fired

keyOptionalString

alarm identifier of the fired alarm

Error Codes Reference

Error Code

Error Text

Error Description

NoneInvalid format for alarm time

Payload format is incorrect

NoneUnknown error

Unknown error

-1Malformed json

Invalid json data

Example

Example scenario

1. luna-send -n 1 luna://com.webos.service.sleep/time/alarmAdd '{}'

Response:
{"returnValue":false,"errorText":"Invalid format for alarm time."}

2. luna-send -n 1 luna://com.webos.service.sleep/time/alarmAdd '{"serviceName":"/var/run/ls2/tmp", "key":"key1", "subscribe":false}'

Response:
{"returnValue":false,"errorText":"Invalid format for alarm time."}

3. luna-send -n 1 luna://com.webos.service.sleep/time/alarmAdd '{"serviceName":"/var/run/ls2/tmp", "key":"key1", "subscribe":true}'

Response:
{"returnValue":false,"errorText":"Invalid format for alarm time."}

4. luna-send -n 1 luna://com.webos.service.sleep/time/alarmAdd '{"relative_time":"0:0:2"}'

Response:
{"alarmId":0}

5. luna-send -n 1 luna://com.webos.service.sleep/time/alarmAdd '{"serviceName":"/var/run/ls2/tmp", "key":"key1", "relative_time":"0:0:5"}}'

Response:
{"alarmId":4}

6. luna-send -n 1 luna://com.webos.service.sleep/time/alarmAdd '{"serviceName":"/var/run/ls2/tmp", "key":"key1", "relative_time":"0:0:3", "subscribe":false}'

Response:
{"alarmId":5,"subscribed":false}

7. luna-send -n 1 luna://com.webos.service.sleep/time/alarmAdd '{"serviceName":"/var/run/ls2/tmp", "key":"key1", "relative_time":"0:0:3", "subscribe":true}'

Response:
{"alarmId":8,"subscribed":true}

8. luna-send -n 4 luna://com.webos.service.sleep/time/alarmAdd '{"serviceName":"/var/run/ls2/tmp", "key":"key2", "relative_time":"0:0:3", "subscribe":true}'

Response:
{"alarmId":10,"subscribed":true}

Subscription Return:
{"alarmId":10,"fired":true,"key":"key2"} // on fire

9. luna-send -n 3 luna://com.webos.service.sleep/time/alarmAdd '{"serviceName":"com.webos.service.sleep", "key":"calendarAlarm", "relative_time":"0:0:4", "subscribe":true}'

Response:
{"alarmId":12,"subscribed":true}

Subscription Return:
{"alarmId":12,"fired":true,"key":"calendarAlarm"} //if key exists on fire

10. luna-send -n 3 luna://com.webos.service.sleep/time/alarmAdd '{"serviceName":"com.webos.service.sleep", "relative_time":"0:0:4", "subscribe":true}'

Response:
{"alarmId":13,"subscribed":true}

Subscription Return:
{"alarmId":13,"fired":true} //without key on fire

time/alarmAddCalendar

ACG: sleep.operation
  • Added: API level 24

Description

Set a calendar event.

Parameters

Name

Required

Type

Description

serviceNameOptionalStringService name for which the alarm needs to be set
keyOptionalStringalarm identifier
dateRequiredString

date at which alarm should fire. format is mm-dd-yyyy

timeRequiredString

time at which alarm should fire. format is hh:mm:ss (0-23 hrs) (hh- hours, mm-minutes, ss-seconds)

subscribeOptionalBooleanto subscribe to the results of this call

Call Returns

Name

Required

Type

Description

alarmIdOptionalNumber

alarm Id of the added calendar alarm if alarmAddCalendar is successful

subscribedOptionalString

subscribed parameter is received only if subscribe parameter is sent during alarmAddCalendar request

true: if subscription is successful

false: is subscription failed

keyOptionalString

alarm identifier of the fired alarm if provided during the alarmAddCalendar request.

firedOptionalBoolean

true: if the alarm has fired

false: if the alarm has not fired

returnValueOptionalBoolean
  • If the method fails, returnValue will contain false
errorTextOptionalString

Error message on failure

Subscription Returns

Name

Required

Type

Description

alarmIdRequiredNumber

alarmId of the subscribed alarm

firedRequiredBoolean

true: if the alarm has fired

false: if the alarm has not fired

keyOptionalString

alarm identifier of the fired alarm

Error Codes Reference

Error Code

Error Text

Error Description

NoneInvalid format for alarm time.

Invalid format for alarm time.

NoneUnknown error

Unknown error

-1malformed json object

Invalid json object

Example

Example scenario

1. luna-send -n 2 luna://com.webos.service.sleep/time/alarmAddCalendar '{"date":"01-24-2020", "time":"10:01:03", "subscribe":}'

Response:
{"returnValue":false, "errorCode":-1,"errorText":"Malformed json."}

2. luna-send -n 1 luna://com.webos.service.sleep/time/alarmAddCalendar '{}'

Response:
{"returnValue":false,"errorText":"Invalid format for alarm time."}

3. luna-send -n 1 luna://com.webos.service.sleep/time/alarmAddCalendar '{"serviceName":"com.palm.X"}'

Response:
{"returnValue":false,"errorText":"Invalid format for alarm time."}

4. luna-send -n 1 luna://com.webos.service.sleep/time/alarmAddCalendar '{"key":"calendarAlarm"}'

Response:
{"returnValue":false,"errorText":"Invalid format for alarm time."}

5. luna-send -n 1 luna://com.webos.service.sleep/time/alarmAddCalendar '{"serviceName":"com.palm.X", "key":"calendarAlarm", "date":"23-01-2020", "subscribe":false}'

Response:
{"returnValue":false,"errorText":"Invalid format for alarm time."}

6. luna-send -n 1 luna://com.webos.service.sleep/time/alarmAddCalendar '{"serviceName":"com.palm.X", "key":"calendarAlarm", "time":"23:49:03", "subscribe":false}'

Response:
{"returnValue":false,"errorText":"Invalid format for alarm time."}

7. luna-send -n 1 luna://com.webos.service.sleep/time/alarmAddCalendar '{"date":"23-01-2020", "time":"49:03"}'

Response:
{"returnValue":false,"errorText":"Invalid format for alarm time."}

8. luna-send -n 1 luna://com.webos.service.sleep/time/alarmAddCalendar '{"date":"23-01-2020", "time":"23:52:03"}'

Response:
{"returnValue":false,"errorText":"Invalid format for alarm time."}

9. luna-send -n 1 luna://com.webos.service.sleep/time/alarmAddCalendar '{"date":"01-23-2020", "time":"23:52:03"}'

Response:
{"alarmId":14}

10. luna-send -n 2 luna://com.webos.service.sleep/time/alarmAddCalendar '{"date":"01-23-2020", "time":"23:56:03", "subscribe":true}' //already fired

Subscription Return:
{"alarmId":17,"fired":true}

Response:
{"alarmId":17,"subscribed":true}

11. luna-send -n 2 luna://com.webos.service.sleep/time/alarmAddCalendar '{"date":"01-24-2020", "time":"10:00:03", "subscribe":true}' //not yet fired

Response:
{"alarmId":22,"subscribed":true}

Subscription Return:
{"alarmId":22,"fired":true} //on fire

12. luna-send -n 2 luna://com.webos.service.sleep/time/alarmAddCalendar '{"date":"01-24-2020", "time":"10:01:03", "subscribe":false}' //no subscription

Response:
{"alarmId":23,"subscribed":false}

13. luna-send -n 2 luna://com.webos.service.sleep/time/alarmAddCalendar '{"date":"01-23-2020", "time":"23:56:03", "subscribe":false}'

Response:
{"alarmId":26,"subscribed":false}

time/alarmQuery

ACG: sleep.operation
  • Added: API level 24

Description

Query for set of alarms identified by 'serviceName' & 'key'.

Parameters

Name

Required

Type

Description

serviceNameRequiredStringservice name for which the alarm is being queried
keyRequiredStringidentifier for the alarm

Call Returns

Name

Required

Type

Description

returnValueOptionalBoolean
  • If the method fails, returnValue will contain false
alarmsOptionalObject array

An array of alarms identified by provided serviceName and key

errorTextOptionalString

Error message if call fails

Error Codes Reference

Error Code

Error Text

Error Description

-1malformed json object

Invalid json data

Example

Example scenario

1. luna-send -n 1 luna://com.webos.service.sleep/time/alarmQuery '{"serviceName":"com.palm.ser2", "key":"alarmCalendar2"}'

Response:
{"alarms": []}

2. luna-send -n 1 luna://com.webos.service.sleep/time/alarmQuery '{"serviceName":"com.palm.ser2", "key":"alarmCalendar"}'

Response:
{"alarms": []}

3. luna-send -n 1 luna://com.webos.service.sleep/time/alarmQuery '{"serviceName":"com.palm.ser2"}'

Response:
{"returnValue":false,"errorText":"alarmQuery parameters are missing."}

4. luna-send -n 1 luna://com.webos.service.sleep/time/alarmQuery '{"serviceName":"", "key":"alarmCalendar2"}'

Response:
{"alarms": []}

5. luna-send -n 1 luna://com.webos.service.sleep/time/alarmQuery '{"key":"alarmCalendar2"}'

Response:
{"returnValue":false,"errorText":"alarmQuery parameters are missing."}

time/alarmRemove

ACG: sleep.operation
Deprecated
  • Added: API level 29
  • Deprecated: API level 30

Description

Removes an alarm by id.

Parameters

Name

Required

Type

Description

alarmIdRequirednumberid of the alarm to be removed.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean
  • If the method succeeds, returnValue will contain true.
  • If the method fails, returnValue will contain false

Error Codes Reference

Error Code

Error Text

Error Description

-1Malformed json.

InValid json format provided.

Example

Example scenario

1. luna-send -n 1 luna://com.webos.service.sleep/time/alarmRemove '{"alarmId":10}'

Response:
{"returnValue":false}

2. luna-send -n 1 luna://com.webos.service.sleep/time/alarmRemove '{"alarmId":29}'


Response:
{"returnValue":true}

3. luna-send -n 1 luna://com.webos.service.sleep/time/alarmRemove '{"alarmId":""}'

Response:
{"returnValue":false}

4. luna-send -n 1 luna://com.webos.service.sleep/time/alarmRemove '{}'

Response:
{"returnValue":false}

5. luna-send -n 1 luna://com.webos.service.sleep/time/alarmRemove '{""}'

Response:
{"returnValue":false, "errorCode":-1,"errorText":"Malformed json."}

6. luna-send -n 1 luna://com.webos.service.sleep/time/alarmRemove '{''}'

Response:
{"returnValue":false}

7. luna-send -n 1 luna://com.webos.service.sleep/time/alarmRemove '{[]}'

Response:
{"returnValue":false, "errorCode":-1,"errorText":"Malformed json."}

8. luna-send -n 1 luna://com.webos.service.sleep/time/alarmRemove '{"key":"k1"}'

Response:
{"returnValue":false}

time/internalAlarmFired

ACG: sleep.operation
  • Added: API level 24

Description

Called when an RTC alarm is fired.

Parameters

None

Example

Example scenario

# luna-send -n 1 luna://com.webos.service.sleep/time/internalAlarmFired '{}'

timeout/clear

ACG: sleep.operation
  • Added: API level 13

Description

Handles a timeout/clear message and deletes a timeout by its key.

Parameters

Name

Required

Type

Description

keyRequiredString

Unique identifier for the alarm

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation. 

Possible values are:

  • true: Successful.
  • false: Not successful. Check the method's 'Error Codes' section for failure details (errorCode and/or errorText).
keyOptionalString

Unique identifier for the alarm

Error Codes Reference

Error Code

Error Text

Error Description

-1Malformed JSON object

Invalid JSON data

-1Invalid parameters

Invalid parameters data received

Example

Example scenario

# luna-send -n 1 luna://com.webos.service.sleep/timeout/clear '{"key":"com.webos.service.activitymanager.wakeup"}'

Response:

{
    "returnValue":true,
    "key":"com.webos.service.activitymanager.wakeup"
}

timeout/set

ACG: sleep.operation
  • Added: API level 13

Description

Handles a timeout/set message and adds a new power timeout. Relative timeouts can be set by passing the "in" parameter. Absolute timeouts can be set by passing the "at" parameter.

Parameters

Name

Required

Type

Description

keyRequiredString

Unique key to identify individual alarms

atRequiredString

Absolute time for the alarm to be set to. Either this or the "in" parameter must be passed.

inRequiredString

Relative time for the alarm to be set to. Either this or the "at" parameter must be passed.

uriRequiredString

URI to be passed to the alarm

paramsRequiredString

Parameters for the URI.

wakeupOptionalBoolean

If a wakeup alarm needs to be set.

activity_idOptionalString

Activity ID

activity_duration_msOptionalNumber

Duration in milliseconds to keep the device ON. Needs to be provided only if activity_id is provided.

keep_existingOptionalBoolean

Set to true to keep existing alarms with the same key

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation.

Possible values are:

  • true: Successful.
  • false: Not successful. Check the method's 'Error Codes' section for failure details (errorCode and/or errorText).
keyOptionalString

Unique key used to identify the alarm

kept_existingOptionalBoolean

If the existing alarms have been kept

Error Codes Reference

Error Code

Error Text

Error Description

NoneInvalid format for 'timeout/set'

Invalid format of parameters.

-1Malformed JSON object

Invalid JSON data

Example

Example scenario

# luna-send -n 1 luna://com.webos.service.sleep/timeout/set '{
      "at":"03/12/2014 06:26:46",
      "key":"com.webos.service.activitymanager.wakeup",
      "params":{},
      "uri":"luna://com.webos.service.activitymanager/callback/scheduledwakeup",
      "wakeup":true
}'

Response:

{
    "returnValue":true,
    "key":"com.webos.service.activitymanager.wakeup"
}

Signals/Events

shutdown/shutdownApplications

This is the signal sent out by the sleepd daemon to the applications when the shutdown process starts. The daemon expects to get a response from all the registered applications if they are ready for the system shutdown.

shutdown/shutdownServices

This is the signal sent out by the sleepd daemon to the services when the shutdown process starts. The daemon expects to get a response from all the registered services if they are ready for the system shutdown.

Contents