Skip to content

Commit

Permalink
Amazon Video Status Fix for Fire 4K (#162)
Browse files Browse the repository at this point in the history
* Fix Amazon Video State Fire 4K

* Fix Amazon Video State Fire 4K

* Fix test (?)

Co-authored-by: Jeff Irion <JeffLIrion@users.noreply.github.com>
  • Loading branch information
lolouk44 and JeffLIrion committed May 1, 2020
1 parent ea040c9 commit feec949
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions androidtv/firetv.py
Expand Up @@ -99,11 +99,12 @@ def update(self, get_running_apps=True):

# Amazon Video
elif current_app == constants.APP_AMAZON_VIDEO:
if wake_lock_size == 5:
if media_session_state == 2:
state = constants.STATE_PAUSED
elif media_session_state == 3:
state = constants.STATE_PLAYING
else:
# wake_lock_size == 2
state = constants.STATE_PAUSED
state = constants.STATE_STANDBY

# Firefox
elif current_app == constants.APP_FIREFOX:
Expand Down
9 changes: 6 additions & 3 deletions tests/test_firetv.py
Expand Up @@ -321,12 +321,15 @@ def test_state_detection(self):
(constants.STATE_STANDBY, "com.amazon.tv.launcher", ["com.amazon.tv.launcher"]))

# Amazon Video
self.assertUpdate([True, True, 5, constants.APP_AMAZON_VIDEO, 3, [constants.APP_AMAZON_VIDEO]],
self.assertUpdate([True, True, 1, constants.APP_AMAZON_VIDEO, 3, [constants.APP_AMAZON_VIDEO]],
(constants.STATE_PLAYING, constants.APP_AMAZON_VIDEO, [constants.APP_AMAZON_VIDEO]))

self.assertUpdate([True, True, 2, constants.APP_AMAZON_VIDEO, 3, [constants.APP_AMAZON_VIDEO]],
self.assertUpdate([True, True, 1, constants.APP_AMAZON_VIDEO, 2, [constants.APP_AMAZON_VIDEO]],
(constants.STATE_PAUSED, constants.APP_AMAZON_VIDEO, [constants.APP_AMAZON_VIDEO]))

self.assertUpdate([True, True, 1, constants.APP_AMAZON_VIDEO, 1, [constants.APP_AMAZON_VIDEO]],
(constants.STATE_STANDBY, constants.APP_AMAZON_VIDEO, [constants.APP_AMAZON_VIDEO]))

# Amazon Video with custom state detection rules
self.ftv._state_detection_rules = {constants.APP_AMAZON_VIDEO: ['media_session_state']}

Expand All @@ -341,7 +344,7 @@ def test_state_detection(self):

self.ftv._state_detection_rules = {constants.APP_AMAZON_VIDEO: [{'standby': {'media_session_state': 2}}]}
self.assertUpdate([True, True, 2, constants.APP_AMAZON_VIDEO, None, [constants.APP_AMAZON_VIDEO]],
(constants.STATE_PAUSED, constants.APP_AMAZON_VIDEO, [constants.APP_AMAZON_VIDEO]))
(constants.STATE_STANDBY, constants.APP_AMAZON_VIDEO, [constants.APP_AMAZON_VIDEO]))

# Firefox
self.assertUpdate([True, True, 3, constants.APP_FIREFOX, 3, [constants.APP_FIREFOX]],
Expand Down

0 comments on commit feec949

Please sign in to comment.