1*9c5db199SXin Li# Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 2*9c5db199SXin Li# Use of this source code is governed by a BSD-style license that can be 3*9c5db199SXin Li# found in the LICENSE file. 4*9c5db199SXin Li 5*9c5db199SXin Liimport dbus 6*9c5db199SXin Liimport dbus.service 7*9c5db199SXin Li 8*9c5db199SXin Lifrom autotest_lib.client.cros.cellular import mm1_constants 9*9c5db199SXin Lifrom autotest_lib.client.cros.cellular.pseudomodem import dbus_std_ifaces 10*9c5db199SXin Lifrom autotest_lib.client.cros.cellular.pseudomodem import pm_constants 11*9c5db199SXin Lifrom autotest_lib.client.cros.cellular.pseudomodem import utils 12*9c5db199SXin Li 13*9c5db199SXin Liclass Testing(dbus_std_ifaces.DBusProperties): 14*9c5db199SXin Li """ 15*9c5db199SXin Li The testing object allows the pseudomodem to be configured on the fly 16*9c5db199SXin Li over D-Bus. It exposes a basic set of commands that can be used to 17*9c5db199SXin Li simulate network events (such as SMS) or various other modem configurations 18*9c5db199SXin Li that are needed for testing/debugging. 19*9c5db199SXin Li 20*9c5db199SXin Li """ 21*9c5db199SXin Li 22*9c5db199SXin Li def __init__(self, modem, bus): 23*9c5db199SXin Li self._modem = modem 24*9c5db199SXin Li dbus_std_ifaces.DBusProperties.__init__(self, 25*9c5db199SXin Li pm_constants.TESTING_PATH, 26*9c5db199SXin Li bus) 27*9c5db199SXin Li 28*9c5db199SXin Li 29*9c5db199SXin Li @utils.log_dbus_method() 30*9c5db199SXin Li @dbus.service.method(pm_constants.I_TESTING, out_signature='b') 31*9c5db199SXin Li def IsAlive(self): 32*9c5db199SXin Li """ 33*9c5db199SXin Li A heartbeat method. 34*9c5db199SXin Li 35*9c5db199SXin Li This method can be called by clients to check that pseudomodem is alive. 36*9c5db199SXin Li 37*9c5db199SXin Li @returns: True, always. 38*9c5db199SXin Li 39*9c5db199SXin Li """ 40*9c5db199SXin Li return True 41*9c5db199SXin Li 42*9c5db199SXin Li 43*9c5db199SXin Li def _InitializeProperties(self): 44*9c5db199SXin Li return { pm_constants.I_TESTING: { 'Modem': self._modem.path } } 45*9c5db199SXin Li 46*9c5db199SXin Li 47*9c5db199SXin Li @utils.log_dbus_method() 48*9c5db199SXin Li @dbus.service.method(pm_constants.I_TESTING, in_signature='ss') 49*9c5db199SXin Li def ReceiveSms(self, sender, text): 50*9c5db199SXin Li """ 51*9c5db199SXin Li Simulates a fake SMS. 52*9c5db199SXin Li 53*9c5db199SXin Li @param sender: String containing the phone number of the sender. 54*9c5db199SXin Li @param text: String containing the SMS message contents. 55*9c5db199SXin Li 56*9c5db199SXin Li """ 57*9c5db199SXin Li self._modem.sms_handler.receive_sms(text, sender) 58*9c5db199SXin Li 59*9c5db199SXin Li 60*9c5db199SXin Li @utils.log_dbus_method() 61*9c5db199SXin Li @dbus.service.method(pm_constants.I_TESTING, in_signature='a(ubay)') 62*9c5db199SXin Li def UpdatePco(self, pco_value): 63*9c5db199SXin Li """ 64*9c5db199SXin Li Sets the Pco to the specified value. If the Modem.Modem3gpp 65*9c5db199SXin Li properties are currently not exposed (e.g. due to a locked or absent 66*9c5db199SXin Li SIM), this method will do nothing. 67*9c5db199SXin Li 68*9c5db199SXin Li @param pco_value: The PCO list. 69*9c5db199SXin Li 70*9c5db199SXin Li """ 71*9c5db199SXin Li if mm1_constants.I_MODEM_3GPP in self._modem.properties: 72*9c5db199SXin Li self._modem.AssignPco(pco_value) 73*9c5db199SXin Li 74*9c5db199SXin Li @utils.log_dbus_method() 75*9c5db199SXin Li @dbus.service.method(pm_constants.I_TESTING, in_signature='u') 76*9c5db199SXin Li def SetSubscriptionState(self, 77*9c5db199SXin Li registered_subscription_state): 78*9c5db199SXin Li """ 79*9c5db199SXin Li Sets the Pco to something denoting the requested subscription state. 80*9c5db199SXin Li If the Modem.Modem3gpp properties are currently not exposed (e.g. due 81*9c5db199SXin Li to a locked or absent SIM), this method will do nothing. 82*9c5db199SXin Li 83*9c5db199SXin Li @param registered_subscription_state: This value is returned as the 84*9c5db199SXin Li subscription state when the modem is registered on the network. 85*9c5db199SXin Li See mm1_constants.MM_MODEM_3GPP_SUBSCRIPTION_STATE_*. 86*9c5db199SXin Li 87*9c5db199SXin Li """ 88*9c5db199SXin Li if mm1_constants.I_MODEM_3GPP in self._modem.properties: 89*9c5db199SXin Li self._modem.AssignSubscriptionState(registered_subscription_state) 90