Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffLIrion committed Jun 21, 2020
1 parent 0816b1d commit c1ee536
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions androidtv/basetv/basetv_sync.py
Expand Up @@ -84,7 +84,7 @@ def __init__(self, host, port=5555, adbkey='', adb_server_ip='', adb_server_port
def adb_shell(self, cmd):
"""Send an ADB command.
This calls :py:meth:`androidtv.adb_manager.ADBPythonSync.shell` or :py:meth:`androidtv.adb_manager.ADBServerSync.shell`,
This calls :py:meth:`androidtv.adb_manager.adb_manager_sync.ADBPythonSync.shell` or :py:meth:`androidtv.adb_manager.adb_manager_sync.ADBServerSync.shell`,
depending on whether the Python ADB implementation or an ADB server is used for communicating with the device.
Parameters
Expand All @@ -103,7 +103,7 @@ def adb_shell(self, cmd):
def adb_pull(self, local_path, device_path):
"""Pull a file from the device.
This calls :py:meth:`androidtv.adb_manager.ADBPythonSync.pull` or :py:meth:`androidtv.adb_manager.ADBServerSync.pull`,
This calls :py:meth:`androidtv.adb_manager.adb_manager_sync.ADBPythonSync.pull` or :py:meth:`androidtv.adb_manager.adb_manager_sync.ADBServerSync.pull`,
depending on whether the Python ADB implementation or an ADB server is used for communicating with the device.
Parameters
Expand All @@ -119,7 +119,7 @@ def adb_pull(self, local_path, device_path):
def adb_push(self, local_path, device_path):
"""Push a file to the device.
This calls :py:meth:`androidtv.adb_manager.ADBPythonSync.push` or :py:meth:`androidtv.adb_manager.ADBServerSync.push`,
This calls :py:meth:`androidtv.adb_manager.adb_manager_sync.ADBPythonSync.push` or :py:meth:`androidtv.adb_manager.adb_manager_sync.ADBServerSync.push`,
depending on whether the Python ADB implementation or an ADB server is used for communicating with the device.
Parameters
Expand All @@ -135,7 +135,7 @@ def adb_push(self, local_path, device_path):
def adb_screencap(self):
"""Take a screencap.
This calls :py:meth:`androidtv.adb_manager.ADBPythonSync.screencap` or :py:meth:`androidtv.adb_manager.ADBServerSync.screencap`,
This calls :py:meth:`androidtv.adb_manager.adb_manager_sync.ADBPythonSync.screencap` or :py:meth:`androidtv.adb_manager.adb_manager_sync.ADBServerSync.screencap`,
depending on whether the Python ADB implementation or an ADB server is used for communicating with the device.
Returns
Expand Down Expand Up @@ -169,8 +169,8 @@ def adb_connect(self, always_log_errors=True, auth_timeout_s=constants.DEFAULT_A
def adb_close(self):
"""Close the ADB connection.
This only works for the Python ADB implementation (see :meth:`androidtv.adb_manager.ADBPythonSync.close`).
For the ADB server approach, this doesn't do anything (see :meth:`androidtv.adb_manager.ADBServerSync.close`).
This only works for the Python ADB implementation (see :meth:`androidtv.adb_manager.adb_manager_sync.ADBPythonSync.close`).
For the ADB server approach, this doesn't do anything (see :meth:`androidtv.adb_manager.adb_manager_sync.ADBServerSync.close`).
"""
self._adb.close()
Expand Down Expand Up @@ -205,62 +205,74 @@ def get_device_properties(self):
# ======================================================================= #
def audio_output_device(self):
"""Get the current audio playback device.
Returns
-------
str, None
The current audio playback device, or ``None`` if it could not be determined
"""
stream_music = self._get_stream_music()

return self._audio_output_device(stream_music)

def audio_state(self):
"""Check if audio is playing, paused, or idle.
Returns
-------
str, None
The audio state, as determined from the ADB shell command :py:const:`androidtv.constants.CMD_AUDIO_STATE`, or ``None`` if it could not be determined
"""
audio_state_response = self._adb.shell(constants.CMD_AUDIO_STATE)
return self._audio_state(audio_state_response)

def awake(self):
"""Check if the device is awake (screensaver is not running).
Returns
-------
bool
Whether or not the device is awake (screensaver is not running)
"""
return self._adb.shell(constants.CMD_AWAKE + constants.CMD_SUCCESS1_FAILURE0) == '1'

def current_app(self):
"""Return the current app.
Returns
-------
str, None
The ID of the current app, or ``None`` if it could not be determined
"""
current_app_response = self._adb.shell(constants.CMD_CURRENT_APP)

return self._current_app(current_app_response)

def is_volume_muted(self):
"""Whether or not the volume is muted.
Returns
-------
bool, None
Whether or not the volume is muted, or ``None`` if it could not be determined
"""
stream_music = self._get_stream_music()

return self._is_volume_muted(stream_music)

def media_session_state(self):
"""Get the state from the output of ``dumpsys media_session``.
Returns
-------
int, None
The state from the output of the ADB shell command ``dumpsys media_session``, or ``None`` if it could not be determined
"""
media_session_state_response = self._adb.shell(constants.CMD_MEDIA_SESSION_STATE_FULL)

Expand All @@ -270,19 +282,23 @@ def media_session_state(self):

def screen_on(self):
"""Check if the screen is on.
Returns
-------
bool
Whether or not the device is on
"""
return self._adb.shell(constants.CMD_SCREEN_ON + constants.CMD_SUCCESS1_FAILURE0) == '1'

def volume(self):
"""Get the absolute volume level.
Returns
-------
int, None
The absolute volume level, or ``None`` if it could not be determined
"""
stream_music = self._get_stream_music()
audio_output_device = self._audio_output_device(stream_music)
Expand All @@ -291,21 +307,25 @@ def volume(self):

def volume_level(self):
"""Get the relative volume level.
Returns
-------
float, None
The volume level (between 0 and 1), or ``None`` if it could not be determined
"""
volume = self.volume()

return self._volume_level(volume)

def wake_lock_size(self):
"""Get the size of the current wake lock.
Returns
-------
int, None
The size of the current wake lock, or ``None`` if it could not be determined
"""
wake_lock_size_response = self._adb.shell(constants.CMD_WAKE_LOCK_SIZE)

Expand Down

0 comments on commit c1ee536

Please sign in to comment.