Skip to content

Commit

Permalink
Fix the 'launch_app' method for Google TV devices (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffLIrion committed Oct 21, 2020
1 parent ec1d08e commit ed48435
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion androidtv/basetv/basetv_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ async def launch_app(self, app):
The ID of the app that will be launched
"""
await self._adb.shell(constants.CMD_LAUNCH_APP.format(app))
await self._adb.shell(constants.CMD_LAUNCH_APP.format(app) if not self._is_google_tv else constants.CMD_LAUNCH_APP_GOOGLE_TV.format(app))

async def stop_app(self, app):
"""Stop an app.
Expand Down
2 changes: 1 addition & 1 deletion androidtv/basetv/basetv_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def launch_app(self, app):
The ID of the app that will be launched
"""
self._adb.shell(constants.CMD_LAUNCH_APP.format(app))
self._adb.shell(constants.CMD_LAUNCH_APP.format(app) if not self._is_google_tv else constants.CMD_LAUNCH_APP_GOOGLE_TV.format(app))

def stop_app(self, app):
"""Stop an app.
Expand Down
3 changes: 3 additions & 0 deletions androidtv/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
#: Launch an app if it is not already the current app
CMD_LAUNCH_APP = "CURRENT_APP=$(dumpsys window windows | grep mCurrentFocus) && CURRENT_APP=${{CURRENT_APP#*{{* * }} && CURRENT_APP=${{CURRENT_APP%%/*}} && if [ $CURRENT_APP != '{0}' ]; then monkey -p {0} -c " + INTENT_LAUNCH + " --pct-syskeys 0 1; fi"

#: Launch an app if it is not already the current app (for Google TV devices)
CMD_LAUNCH_APP_GOOGLE_TV = "CURRENT_APP=$(dumpsys window windows | grep 'Window #1') && CURRENT_APP=${{CURRENT_APP#*{{* * }} && CURRENT_APP=${{CURRENT_APP%%/*}} && if [ $CURRENT_APP != '{0}' ]; then monkey -p {0} -c " + INTENT_LAUNCH + " --pct-syskeys 0 1; fi"

#: Get the state from ``dumpsys media_session``; this assumes that the variable ``CURRENT_APP`` has been defined
CMD_MEDIA_SESSION_STATE = "dumpsys media_session | grep -A 100 'Sessions Stack' | grep -A 100 $CURRENT_APP | grep -m 1 'state=PlaybackState {'"

Expand Down

0 comments on commit ed48435

Please sign in to comment.