Skip to content

Commit

Permalink
Also apply the ambilight mode correction to saphi
Browse files Browse the repository at this point in the history
  • Loading branch information
elupus committed Mar 2, 2021
1 parent 2115d3c commit e85393e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
44 changes: 37 additions & 7 deletions haphilipsjs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from urllib.parse import quote
from secrets import token_bytes, token_hex
from base64 import b64decode, b64encode
from packaging import version

from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives.padding import PKCS7
Expand Down Expand Up @@ -159,22 +160,51 @@ def quirk_playpause_spacebar(self):
else:
return False

@property
def os_type(self):
if self.system is None:
return None

# android system have in direclty in root
os_type = self.system.get("os_type")
if os_type:
return os_type

#saphi stores in in features
os_type = self.system.get("featuring", {}).get("systemfeatures", {}).get("os_type")
if os_type:
return os_type

return None

@property
def quirk_ambilight_mode_ignored(self):
"""Return if this tv need workaround for ambilight bugs.
Android XTV app have bugs with their mode management for ambilight. It will
XTV app have bugs with their mode management for ambilight. It will
forgot to actuate the command to set mode back to internal. But will actually
do that if you give it an invalid mode.
It will also not report a correct ambilight mode after being changed by call.
So we need to remember last set mode.
It will also not report a correct ambilight mode after being
changed by call. So we need to remember last set mode.
Versions known affected:
- Android - 9.0.0
- Saphi - 4.6.0.2
Version known good
- Legacy - QF1EU-0.150.102.0
"""

if self.system:
return self.system.get("os_type", "").startswith("MSAF_")
else:
return False
os_type = self.os_type
if os_type:
if os_type.startswith("MSAF_"):
return True

if os_type == "Linux":
return True

return False

@property
def pairing_type(self):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_v6.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,15 @@ async def test_basic_data(client_mock, param: Param):
== "org.droidtv.nettv.market.MarketMainActivity-org.droidtv.nettv.market"
)
assert client_mock.quirk_ambilight_mode_ignored == True
assert client_mock.os_type == "MSAF_2019_P"

elif param.type == "saphi":
assert client_mock.system == SYSTEM_SAPHI_DECRYPTED
assert client_mock.sources == MOCK_SAPHI_SOURCES
assert client_mock.applications == {}
assert client_mock.application_id == None
assert client_mock.quirk_ambilight_mode_ignored == False
assert client_mock.quirk_ambilight_mode_ignored == True
assert client_mock.os_type == "Linux"

assert client_mock.channels == {
"1648": {"ccid": 1648, "preset": "1", "name": "Irdeto scrambled"},
Expand Down

0 comments on commit e85393e

Please sign in to comment.