Repository: JeffLIrion/python-androidtv (language: python)

Issue:
Fix typo
Hey, I only now am checking all your work, from the pipy package to your fixes in python-adb, this is an amazing piece of work, thank you so much you're awesome!


Discussion / hints:
Thanks!

You should check out the work done by @caffeinatedmike: https://github.com/caffeinatedMike/python-androidtv and https://github.com/caffeinatedMike/androidtv. I don't actually own an Android TV device, so my contribution was just based off the Fire TV component.

Fix patch:
diff --git a/androidtv/constants.py b/androidtv/constants.py
index 175e4d8..6afc131 100644
--- a/androidtv/constants.py
+++ b/androidtv/constants.py
@@ -96,7 +96,7 @@ class DeviceEnum(IntEnum):
 )
 #: Assign focused application identifier to ``CURRENT_APP`` variable for an Android 11 device
 CMD_DEFINE_CURRENT_APP_VARIABLE11 = (
-    "CURRENT_APP=$(dumpsys window windows | grep 'mInputMethodTarget') && " + CMD_PARSE_CURRENT_APP11
+    "CURRENT_APP=$(dumpsys window windows | grep -E -m 1 'mInputMethod(Input)?Target') && " + CMD_PARSE_CURRENT_APP11
 )
 
 


Test patch:
diff --git a/tests/test_constants.py b/tests/test_constants.py
index 5f3fb45..8093b01 100644
--- a/tests/test_constants.py
+++ b/tests/test_constants.py
@@ -86,7 +86,7 @@ def test_constants(self):
         # CMD_CURRENT_APP11
         self.assertCommand(
             constants.CMD_CURRENT_APP11,
-            r"CURRENT_APP=$(dumpsys window windows | grep 'mInputMethodTarget') && CURRENT_APP=${CURRENT_APP%%/*} && CURRENT_APP=${CURRENT_APP##* } && echo $CURRENT_APP",
+            r"CURRENT_APP=$(dumpsys window windows | grep -E -m 1 'mInputMethod(Input)?Target') && CURRENT_APP=${CURRENT_APP%%/*} && CURRENT_APP=${CURRENT_APP##* } && echo $CURRENT_APP",
         )
 
         # CMD_CURRENT_APP_GOOGLE_TV
@@ -104,7 +104,7 @@ def test_constants(self):
         # CMD_CURRENT_APP_MEDIA_SESSION_STATE11
         self.assertCommand(
             constants.CMD_CURRENT_APP_MEDIA_SESSION_STATE11,
-            r"CURRENT_APP=$(dumpsys window windows | grep 'mInputMethodTarget') && CURRENT_APP=${CURRENT_APP%%/*} && CURRENT_APP=${CURRENT_APP##* } && echo $CURRENT_APP && dumpsys media_session | grep -A 100 'Sessions Stack' | grep -A 100 $CURRENT_APP | grep -m 1 'state=PlaybackState {'",
+            r"CURRENT_APP=$(dumpsys window windows | grep -E -m 1 'mInputMethod(Input)?Target') && CURRENT_APP=${CURRENT_APP%%/*} && CURRENT_APP=${CURRENT_APP##* } && echo $CURRENT_APP && dumpsys media_session | grep -A 100 'Sessions Stack' | grep -A 100 $CURRENT_APP | grep -m 1 'state=PlaybackState {'",
         )
 
         # CMD_CURRENT_APP_MEDIA_SESSION_STATE_GOOGLE_TV
@@ -143,7 +143,7 @@ def test_constants(self):
         # CMD_LAUNCH_APP11
         self.assertCommand(
             constants.CMD_LAUNCH_APP11,
-            r"CURRENT_APP=$(dumpsys window windows | grep 'mInputMethodTarget') && CURRENT_APP=${{CURRENT_APP%%/*}} && CURRENT_APP=${{CURRENT_APP##* }} && if [ $CURRENT_APP != '{0}' ]; then monkey -p {0} -c android.intent.category.LEANBACK_LAUNCHER --pct-syskeys 0 1; fi",
+            r"CURRENT_APP=$(dumpsys window windows | grep -E -m 1 'mInputMethod(Input)?Target') && CURRENT_APP=${{CURRENT_APP%%/*}} && CURRENT_APP=${{CURRENT_APP##* }} && if [ $CURRENT_APP != '{0}' ]; then monkey -p {0} -c android.intent.category.LEANBACK_LAUNCHER --pct-syskeys 0 1; fi",
         )
 
         # CMD_LAUNCH_APP_FIRETV