Nils Fürste | a8263f4 | 2020-11-23 14:45:15 +0100 | [diff] [blame] | 1 | # osmo_gsm_tester: Base class for AndroidUE modems |
| 2 | # |
| 3 | # Copyright (C) 2020 by Software Radio Systems Limited |
| 4 | # |
| 5 | # Author: Nils Fürste <nils.fuerste@softwareradiosystems.com> |
| 6 | # Author: Bedran Karakoc <bedran.karakoc@softwareradiosystems.com> |
| 7 | # |
| 8 | # This program is free software: you can redistribute it and/or modify |
| 9 | # it under the terms of the GNU General Public License as |
| 10 | # published by the Free Software Foundation, either version 3 of the |
| 11 | # License, or (at your option) any later version. |
| 12 | # |
| 13 | # This program is distributed in the hope that it will be useful, |
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | # GNU General Public License for more details. |
| 17 | # |
| 18 | # You should have received a copy of the GNU General Public License |
| 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | |
| 21 | from ..core import log, process |
| 22 | from abc import ABCMeta |
| 23 | |
| 24 | |
| 25 | class AndroidHost(log.Origin, metaclass=ABCMeta): |
| 26 | """Base for everything AndroidUE related.""" |
| 27 | |
| 28 | ############## |
| 29 | # PROTECTED |
| 30 | ############## |
| 31 | def __init__(self, name): |
| 32 | log.Origin.__init__(self, log.C_TST, name) |
| 33 | |
| 34 | ######################## |
| 35 | # PUBLIC - INTERNAL API |
| 36 | ######################## |
| 37 | def run_androidue_cmd(self, name, popen_args): |
| 38 | # This function executes the given command directly on the Android UE. Therefore, |
| 39 | # ADB is used to execute commands locally and ssh for remote execution. Make sure |
| 40 | # Android SDK Platform-Tools >= 23 is installed |
| 41 | if self._run_node.is_local(): |
| 42 | # use adb instead of ssh |
| 43 | run_dir = self.run_dir.new_dir(name) |
| 44 | proc = process.AdbProcess(name, run_dir, self._run_node.adb_serial_id(), popen_args, env={}) |
| 45 | else: |
| 46 | proc = self.rem_host.RemoteProcess(name, popen_args, remote_env={}) |
| 47 | return proc |