blob: ada8acf5e4416632204ab2e22ac1d4d823e0875b [file] [log] [blame]
# Copyright 2015 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import logging
import logging.handlers
import common
from autotest_lib.client.cros import constants
from autotest_lib.client.cros import dark_resume_listener
from autotest_lib.client.cros import xmlrpc_server
from autotest_lib.client.cros.power import sys_power
from autotest_lib.client.cros.power import power_utils
class DarkResumeXmlRpcDelegate(xmlrpc_server.XmlRpcDelegate):
"""Exposes methods called remotely during dark resume autotests.
All instance methods of this object without a preceding '_' are exposed via
an XMLRPC server. This is not a stateless handler object, which means that
if you store state inside the delegate, that state will remain around for
future calls.
def __init__(self):
super(DarkResumeXmlRpcDelegate, self).__init__()
self._listener = dark_resume_listener.DarkResumeListener()
def suspend_bg_for_dark_resume(self, suspend_for_secs):
Suspends the system for dark resume.
@param suspend_for_secs : If not 0, sets a rtc alarm to
wake the system after|suspend_for_secs| secs.
if suspend_for_secs == 0 :
def set_stop_resuspend(self, stop_resuspend):
Stops resuspend on seeing a dark resume.
@param stop_resuspend: Stops resuspend of the device on seeing a
a dark resume if |stop_resuspend| is true.
def get_dark_resume_count(self):
"""Gets the number of dark resumes that have occurred since
this listener was created."""
return self._listener.count
def has_lid(self):
Checks whether the DUT has lid.
@return: Returns True if the device has a lid, False otherwise.
return power_utils.has_lid()
if __name__ == '__main__':
handler = logging.handlers.SysLogHandler(address = '/dev/log')
formatter = logging.Formatter(
'dark_resume_xmlrpc_server: [%(levelname)s] %(message)s')
logging.debug('dark_resume_xmlrpc_server main...')
server = xmlrpc_server.XmlRpcServer(
'localhost', constants.DARK_RESUME_XMLRPC_SERVER_PORT)