diff options
Diffstat (limited to 'mobly/controllers/android_device_lib/sl4a_client.py')
-rw-r--r-- | mobly/controllers/android_device_lib/sl4a_client.py | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/mobly/controllers/android_device_lib/sl4a_client.py b/mobly/controllers/android_device_lib/sl4a_client.py index 725a61c..ac59f5b 100644 --- a/mobly/controllers/android_device_lib/sl4a_client.py +++ b/mobly/controllers/android_device_lib/sl4a_client.py @@ -24,7 +24,8 @@ _DEVICE_SIDE_PORT = 8080 _LAUNCH_CMD = ( 'am start -a com.googlecode.android_scripting.action.LAUNCH_SERVER ' '--ei com.googlecode.android_scripting.extra.USE_SERVICE_PORT %s ' - 'com.googlecode.android_scripting/.activity.ScriptingLayerServiceLauncher') + 'com.googlecode.android_scripting/.activity.ScriptingLayerServiceLauncher' +) # Maximum time to wait for the app to start on the device (10 minutes). # TODO: This timeout is set high in order to allow for retries in # start_app_and_connect. Decrease it when the call to connect() has the option @@ -59,7 +60,8 @@ class Sl4aClient(jsonrpc_client_base.JsonRpcClientBase): out = self._adb.shell('pm list package') if not utils.grep('com.googlecode.android_scripting', out): raise jsonrpc_client_base.AppStartError( - self._ad, '%s is not installed on %s' % (_APP_NAME, self._adb.serial)) + self._ad, '%s is not installed on %s' % (_APP_NAME, self._adb.serial) + ) self.disable_hidden_api_blacklist() # sl4a has problems connecting after disconnection, so kill the apk and @@ -108,8 +110,9 @@ class Sl4aClient(jsonrpc_client_base.JsonRpcClientBase): try: self.closeSl4aSession() except Exception: - self.log.exception('Failed to gracefully shut down %s.', - self.app_name) + self.log.exception( + 'Failed to gracefully shut down %s.', self.app_name + ) # Close the socket connection. self.disconnect() @@ -141,23 +144,25 @@ class Sl4aClient(jsonrpc_client_base.JsonRpcClientBase): started = True break except Exception: - self.log.debug('%s is not yet running, retrying', - self.app_name, - exc_info=True) + self.log.debug( + '%s is not yet running, retrying', self.app_name, exc_info=True + ) time.sleep(1) if not started: raise jsonrpc_client_base.AppRestoreConnectionError( - self._ad, '%s failed to connect for %s at host port %s, ' - 'device port %s' % - (self.app_name, self._adb.serial, self.host_port, self.device_port)) + self._ad, + '%s failed to connect for %s at host port %s, device port %s' + % (self.app_name, self._adb.serial, self.host_port, self.device_port), + ) def _start_event_client(self): # Start an EventDispatcher for the current sl4a session event_client = Sl4aClient(self._ad) event_client.host_port = self.host_port event_client.device_port = self.device_port - event_client.connect(uid=self.uid, - cmd=jsonrpc_client_base.JsonRpcCommand.CONTINUE) + event_client.connect( + uid=self.uid, cmd=jsonrpc_client_base.JsonRpcCommand.CONTINUE + ) ed = event_dispatcher.EventDispatcher(event_client) ed.start() return ed |