• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2#
3#   Copyright 2020 - The Android Open Source Project
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of the License at
8#
9#       http://www.apache.org/licenses/LICENSE-2.0
10#
11#   Unless required by applicable law or agreed to in writing, software
12#   distributed under the License is distributed on an "AS IS" BASIS,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16
17from acts.controllers.fuchsia_lib.base_lib import BaseLib
18
19COMMAND_RESTART_SESSION = 'basemgr_facade.RestartSession'
20COMMAND_START_BASEMGR = 'basemgr_facade.StartBasemgr'
21COMMAND_KILL_BASEMGR = 'basemgr_facade.KillBasemgr'
22
23
24class FuchsiaBasemgrLib(BaseLib):
25    def __init__(self, addr, tc, client_id):
26        self.address = addr
27        self.test_counter = tc
28        self.client_id = client_id
29
30    def restartSession(self):
31        """Restarts an ongoing basemgr session
32
33        Returns:
34            Dictionary:
35                error: None, unless an error occurs
36                result: 'Success', 'NoSessionToRestart', or None if error
37        """
38        test_cmd = COMMAND_RESTART_SESSION
39        test_id = self.build_id(self.test_counter)
40        self.test_counter += 1
41
42        return self.send_command(test_id, test_cmd, {})
43
44    def startBasemgr(self):
45        """Starts basemgr service
46
47        Returns:
48            Dictionary:
49                error: None, unless an error occurs
50                result: 'Success' or None if error
51        """
52        test_cmd = COMMAND_START_BASEMGR
53        test_id = self.build_id(self.test_counter)
54        self.test_counter += 1
55
56        return self.send_command(test_id, test_cmd, {})
57
58    def killBasemgr(self):
59        """Kill basemgr service, if one is running
60
61        Returns:
62            Dictionary:
63                error: None, unless an error occurs
64                result: 'Success', 'NoBasemgrToKill', or None if error
65        """
66        test_cmd = COMMAND_KILL_BASEMGR
67        test_id = self.build_id(self.test_counter)
68        self.test_counter += 1
69
70        return self.send_command(test_id, test_cmd, {})
71