Package sl4a client management into a service. (#511)
This is the final straw to remove all the private service managing methods in `AndroidDevice`.
diff --git a/tools/sl4a_shell.py b/tools/sl4a_shell.py
index 1006ff8..b771417 100755
--- a/tools/sl4a_shell.py
+++ b/tools/sl4a_shell.py
@@ -13,7 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
"""Tool to interactively call sl4a methods.
SL4A (Scripting Layer for Android) is an RPC service exposing API calls on
@@ -38,29 +37,32 @@
import logging
from mobly.controllers.android_device_lib import jsonrpc_shell_base
+from mobly.controllers.android_device_lib.services import sl4a_service
class Sl4aShell(jsonrpc_shell_base.JsonRpcShellBase):
def _start_services(self, console_env):
"""Overrides superclass."""
- self._ad.load_sl4a()
- console_env['s'] = self._ad.sl4a
+ self._ad.services.register('sl4a', sl4a_service.Sl4aService)
+ console_env['s'] = self._ad.services.sl4a
console_env['sl4a'] = self._ad.sl4a
console_env['ed'] = self._ad.ed
def _get_banner(self, serial):
- lines = ['Connected to %s.' % serial,
- 'Call methods against:',
- ' ad (android_device.AndroidDevice)',
- ' sl4a or s (SL4A)',
- ' ed (EventDispatcher)']
+ lines = [
+ 'Connected to %s.' % serial, 'Call methods against:',
+ ' ad (android_device.AndroidDevice)', ' sl4a or s (SL4A)',
+ ' ed (EventDispatcher)'
+ ]
return '\n'.join(lines)
if __name__ == '__main__':
- parser = argparse.ArgumentParser(description='Interactive client for sl4a.')
+ parser = argparse.ArgumentParser(
+ description='Interactive client for sl4a.')
parser.add_argument(
- '-s', '--serial',
+ '-s',
+ '--serial',
help=
'Device serial to connect to (if more than one device is connected)')
args = parser.parse_args()