diff --git a/android_tv_rc/__pycache__/adb_client.cpython-311.pyc b/android_tv_rc/__pycache__/adb_client.cpython-311.pyc index 2979f5c..adc0ed5 100644 Binary files a/android_tv_rc/__pycache__/adb_client.cpython-311.pyc and b/android_tv_rc/__pycache__/adb_client.cpython-311.pyc differ diff --git a/android_tv_rc/__pycache__/android_tv_controller.cpython-311.pyc b/android_tv_rc/__pycache__/android_tv_controller.cpython-311.pyc index c48ecaa..03d9172 100644 Binary files a/android_tv_rc/__pycache__/android_tv_controller.cpython-311.pyc and b/android_tv_rc/__pycache__/android_tv_controller.cpython-311.pyc differ diff --git a/docs/android_tv_rc/adb_client.html b/docs/android_tv_rc/adb_client.html index 1e32054..590035a 100644 --- a/docs/android_tv_rc/adb_client.html +++ b/docs/android_tv_rc/adb_client.html @@ -52,6 +52,14 @@
AndroidTVController.android_tv_rc.adb_clientModule AndroidTVController.android_tv_rc.adb_clientModule AndroidTVController.android_tv_rc.adb_client
@@ -821,6 +833,13 @@ Classes
2-Make sure your computer running the python library and the android device is on the same network.
3-Enable the USB/Wireless/ADB debugging feature on your android TV device depending on your version & get your TV IP address.
you can follow this link https://www.makeuseof.com/how-to-use-adb-on-android-tv/
+Some important resources:
+https://developer.android.com/tools/adb
+https://developer.android.com/studio/command-line/adb
+https://technastic.com/set-up-adb-over-wifi-android/
+https://technastic.com/adb-shell-commands-list/
+https://technastic.com/adb-commands-list-adb-cheat-sheet/
+https://www.makeuseof.com/how-to-use-adb-on-android-tv/
Args
verbose
: bool
@@ -853,6 +872,14 @@ Args
3-Enable the USB/Wireless/ADB debugging feature on your android TV device depending on your version & get your TV IP address.
you can follow this link `https://www.makeuseof.com/how-to-use-adb-on-android-tv/`
+ Some important resources:
+ https://developer.android.com/tools/adb
+ https://developer.android.com/studio/command-line/adb
+ https://technastic.com/set-up-adb-over-wifi-android/
+ https://technastic.com/adb-shell-commands-list/
+ https://technastic.com/adb-commands-list-adb-cheat-sheet/
+ https://www.makeuseof.com/how-to-use-adb-on-android-tv/
+
Args:
verbose (bool): The `verbose` parameter is a boolean flag that determines whether or not to
enable verbose logging. If set to `True`, it will display additional information during the
@@ -1581,6 +1608,8 @@ Args
keycode (KeyCode): the keycode to send, table of key codes: https://www.temblast.com/ref/akeyscode.htm
long_press (bool): specify if simulate a long press for the key or not. Defaults to False.
"""
+ if self.__selected_device is None:
+ return
command = f'input keyevent {keycode.name}'
if long_press:
command += ' --longpress'
@@ -1596,6 +1625,8 @@ Args
text (str): the text string to send.
encode_spaces (bool): specify if spaces should be replaced by `%s` or not. Defaults to True.
"""
+ if self.__selected_device is None:
+ return
processed_text = text.replace(' ', '%s') if encode_spaces else text
self.execute_shell_command(f'input text {processed_text}')
@@ -2430,6 +2461,8 @@ Args
keycode (KeyCode): the keycode to send, table of key codes: https://www.temblast.com/ref/akeyscode.htm
long_press (bool): specify if simulate a long press for the key or not. Defaults to False.
"""
+ if self.__selected_device is None:
+ return
command = f'input keyevent {keycode.name}'
if long_press:
command += ' --longpress'
@@ -2460,6 +2493,8 @@ Args
text (str): the text string to send.
encode_spaces (bool): specify if spaces should be replaced by `%s` or not. Defaults to True.
"""
+ if self.__selected_device is None:
+ return
processed_text = text.replace(' ', '%s') if encode_spaces else text
self.execute_shell_command(f'input text {processed_text}')
diff --git a/docs/android_tv_rc/android_tv_controller.html b/docs/android_tv_rc/android_tv_controller.html
index 7b16bd2..fac026a 100644
--- a/docs/android_tv_rc/android_tv_controller.html
+++ b/docs/android_tv_rc/android_tv_controller.html
@@ -51,10 +51,26 @@ Module AndroidTVController.android_tv_rc.android_tv_cont
Defaults to False.
"""
self.__adb_client = ADBClient(verbose, show_command)
- self.__adb_client.connect(ip)
+ self.__ip = ip
+ def connect(self) -> bool:
+ """
+ Start connection to TV IP.
+ """
+ return self.__adb_client.connect(self.__ip)
+
+
+
+ def is_connected(self) -> bool:
+ """
+ Check if connection is successfully established.
+ """
+ return self.__adb_client.is_connected(self.__ip)
+
+
+
def get_adb_client(self):
"""
Return the adb session client.
@@ -213,7 +229,7 @@ Module AndroidTVController.android_tv_rc.android_tv_cont
- def open_app(self, package: str, activity: str):
+ def open_app(self, app: AndroidTVApps):
"""
The function starts app with the specified package and activity.
@@ -223,50 +239,41 @@ Module AndroidTVController.android_tv_rc.android_tv_cont
and try to interpret the output dump to extract the main launcher activity.
Args:
- package (str): The package parameter is a string that represents the package name of the
- Android application you want to start. This is typically the unique identifier for the app and
- is specified in the AndroidManifest.xml file of the app.
- activity (str): The "activity" parameter refers to the specific activity or screen within the
- Android app that you want to start. An activity represents a single screen with a user
- interface, and it is the basic building block of an Android app. Each activity has a unique name
- that is specified in the AndroidManifest.xml file
+ app (AndroidTVApps): The app name in form of package/activity.
"""
+ package, activity = app.value.split('/')
self.__adb_client.start_app(package, activity)
def open_youtube(self):
"""Opens Youtube TV application"""
- app = AndroidTVApps.YOUTUBE.value.split('/')
- self.open_app(app[0], app[1])
+ self.open_app(AndroidTVApps.YOUTUBE)
def open_netflix(self):
"""Opens Netflix application"""
- app = AndroidTVApps.NETFLIX.value.split('/')
- self.open_app(app[0], app[1])
+ self.open_app(AndroidTVApps.NETFLIX)
+
def open_amazon_prime(self):
"""Opens Amazon Prime Video application"""
- app = AndroidTVApps.AMAZON_PRIME.value.split('/')
- self.open_app(app[0], app[1])
+ self.open_app(AndroidTVApps.AMAZON_PRIME)
def open_watch_it(self):
"""Opens Watch IT application"""
- app = AndroidTVApps.WATCH_IT.value.split('/')
- self.open_app(app[0], app[1])
+ self.open_app(AndroidTVApps.WATCH_IT)
def open_shahid(self):
"""Opens Shahid application"""
- app = AndroidTVApps.SHAHID.value.split('/')
- self.open_app(app[0], app[1])
+ self.open_app(AndroidTVApps.SHAHID)
@@ -323,10 +330,26 @@ Args
Defaults to False.
"""
self.__adb_client = ADBClient(verbose, show_command)
- self.__adb_client.connect(ip)
+ self.__ip = ip
+ def connect(self) -> bool:
+ """
+ Start connection to TV IP.
+ """
+ return self.__adb_client.connect(self.__ip)
+
+
+
+ def is_connected(self) -> bool:
+ """
+ Check if connection is successfully established.
+ """
+ return self.__adb_client.is_connected(self.__ip)
+
+
+
def get_adb_client(self):
"""
Return the adb session client.
@@ -485,7 +508,7 @@ Args
- def open_app(self, package: str, activity: str):
+ def open_app(self, app: AndroidTVApps):
"""
The function starts app with the specified package and activity.
@@ -495,53 +518,60 @@ Args
and try to interpret the output dump to extract the main launcher activity.
Args:
- package (str): The package parameter is a string that represents the package name of the
- Android application you want to start. This is typically the unique identifier for the app and
- is specified in the AndroidManifest.xml file of the app.
- activity (str): The "activity" parameter refers to the specific activity or screen within the
- Android app that you want to start. An activity represents a single screen with a user
- interface, and it is the basic building block of an Android app. Each activity has a unique name
- that is specified in the AndroidManifest.xml file
+ app (AndroidTVApps): The app name in form of package/activity.
"""
+ package, activity = app.value.split('/')
self.__adb_client.start_app(package, activity)
def open_youtube(self):
"""Opens Youtube TV application"""
- app = AndroidTVApps.YOUTUBE.value.split('/')
- self.open_app(app[0], app[1])
+ self.open_app(AndroidTVApps.YOUTUBE)
def open_netflix(self):
"""Opens Netflix application"""
- app = AndroidTVApps.NETFLIX.value.split('/')
- self.open_app(app[0], app[1])
+ self.open_app(AndroidTVApps.NETFLIX)
+
def open_amazon_prime(self):
"""Opens Amazon Prime Video application"""
- app = AndroidTVApps.AMAZON_PRIME.value.split('/')
- self.open_app(app[0], app[1])
+ self.open_app(AndroidTVApps.AMAZON_PRIME)
def open_watch_it(self):
"""Opens Watch IT application"""
- app = AndroidTVApps.WATCH_IT.value.split('/')
- self.open_app(app[0], app[1])
+ self.open_app(AndroidTVApps.WATCH_IT)
def open_shahid(self):
"""Opens Shahid application"""
- app = AndroidTVApps.SHAHID.value.split('/')
- self.open_app(app[0], app[1])
+ self.open_app(AndroidTVApps.SHAHID)
+def connect(self) ‑> bool
+
Start connection to TV IP.
def connect(self) -> bool:
+ """
+ Start connection to TV IP.
+ """
+ return self.__adb_client.connect(self.__ip)
+
def get_adb_client(self)
+def is_connected(self) ‑> bool
+
Check if connection is successfully established.
def is_connected(self) -> bool:
+ """
+ Check if connection is successfully established.
+ """
+ return self.__adb_client.is_connected(self.__ip)
+
def open_amazon_prime(self)
def open_amazon_prime(self):
"""Opens Amazon Prime Video application"""
- app = AndroidTVApps.AMAZON_PRIME.value.split('/')
- self.open_app(app[0], app[1])
+ self.open_app(AndroidTVApps.AMAZON_PRIME)
-def open_app(self, package: str, activity: str)
+def open_app(self, app: AndroidTVApps)
The function starts app with the specified package and activity.
@@ -584,21 +629,14 @@package
: str
activity
: str
app
: AndroidTVApps
def open_app(self, package: str, activity: str):
+def open_app(self, app: AndroidTVApps):
"""
The function starts app with the specified package and activity.
@@ -608,14 +646,9 @@ Args
and try to interpret the output dump to extract the main launcher activity.
Args:
- package (str): The package parameter is a string that represents the package name of the
- Android application you want to start. This is typically the unique identifier for the app and
- is specified in the AndroidManifest.xml file of the app.
- activity (str): The "activity" parameter refers to the specific activity or screen within the
- Android app that you want to start. An activity represents a single screen with a user
- interface, and it is the basic building block of an Android app. Each activity has a unique name
- that is specified in the AndroidManifest.xml file
+ app (AndroidTVApps): The app name in form of package/activity.
"""
+ package, activity = app.value.split('/')
self.__adb_client.start_app(package, activity)
def open_netflix(self):
"""Opens Netflix application"""
- app = AndroidTVApps.NETFLIX.value.split('/')
- self.open_app(app[0], app[1])
+ self.open_app(AndroidTVApps.NETFLIX)
@@ -645,8 +677,7 @@ Args
def open_shahid(self):
"""Opens Shahid application"""
- app = AndroidTVApps.SHAHID.value.split('/')
- self.open_app(app[0], app[1])
+ self.open_app(AndroidTVApps.SHAHID)
@@ -660,8 +691,7 @@ Args
def open_watch_it(self):
"""Opens Watch IT application"""
- app = AndroidTVApps.WATCH_IT.value.split('/')
- self.open_app(app[0], app[1])
+ self.open_app(AndroidTVApps.WATCH_IT)
@@ -675,8 +705,7 @@ Args
def open_youtube(self):
"""Opens Youtube TV application"""
- app = AndroidTVApps.YOUTUBE.value.split('/')
- self.open_app(app[0], app[1])
+ self.open_app(AndroidTVApps.YOUTUBE)
@@ -970,7 +999,9 @@ Index
-
AndroidTVController