Skip to content

Commit

Permalink
Add CMD_DEVICE_PROPERTIES constant
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffLIrion committed Feb 3, 2022
1 parent 7d496ce commit b41c655
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 26 deletions.
14 changes: 1 addition & 13 deletions androidtv/basetv/basetv_async.py
Expand Up @@ -200,19 +200,7 @@ async def get_device_properties(self):
A dictionary with keys ``'wifimac'``, ``'ethmac'``, ``'serialno'``, ``'manufacturer'``, ``'model'``, and ``'sw_version'``
"""
properties = await self._adb.shell(
constants.CMD_MANUFACTURER
+ " && "
+ constants.CMD_MODEL
+ " && "
+ constants.CMD_SERIALNO
+ " && "
+ constants.CMD_VERSION
+ " && "
+ constants.CMD_MAC_WLAN0
+ " && "
+ constants.CMD_MAC_ETH0
)
properties = await self._adb.shell(constants.CMD_DEVICE_PROPERTIES)

self._parse_device_properties(properties)
return self.device_properties
Expand Down
14 changes: 1 addition & 13 deletions androidtv/basetv/basetv_sync.py
Expand Up @@ -200,19 +200,7 @@ def get_device_properties(self):
A dictionary with keys ``'wifimac'``, ``'ethmac'``, ``'serialno'``, ``'manufacturer'``, ``'model'``, and ``'sw_version'``
"""
properties = self._adb.shell(
constants.CMD_MANUFACTURER
+ " && "
+ constants.CMD_MODEL
+ " && "
+ constants.CMD_SERIALNO
+ " && "
+ constants.CMD_VERSION
+ " && "
+ constants.CMD_MAC_WLAN0
+ " && "
+ constants.CMD_MAC_ETH0
)
properties = self._adb.shell(constants.CMD_DEVICE_PROPERTIES)

self._parse_device_properties(properties)
return self.device_properties
Expand Down
15 changes: 15 additions & 0 deletions androidtv/constants.py
Expand Up @@ -166,6 +166,21 @@ class DeviceEnum(IntEnum):
CMD_MAC_WLAN0 = "ip addr show wlan0 | grep -m 1 ether"
CMD_MAC_ETH0 = "ip addr show eth0 | grep -m 1 ether"

#: The command used for getting the device properties
CMD_DEVICE_PROPERTIES = (
CMD_MANUFACTURER
+ " && "
+ CMD_MODEL
+ " && "
+ CMD_SERIALNO
+ " && "
+ CMD_VERSION
+ " && "
+ CMD_MAC_WLAN0
+ " && "
+ CMD_MAC_ETH0
)


# ADB key event codes
# https://developer.android.com/reference/android/view/KeyEvent
Expand Down
6 changes: 6 additions & 0 deletions tests/test_constants.py
Expand Up @@ -95,6 +95,12 @@ def test_constants(self):
r"CURRENT_APP=$(dumpsys activity a . | grep mResumedActivity) && CURRENT_APP=${CURRENT_APP#*ActivityRecord{* * } && CURRENT_APP=${CURRENT_APP#*{* * } && 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_DEVICE_PROPERTIES
self.assertCommand(
constants.CMD_DEVICE_PROPERTIES,
r"getprop ro.product.manufacturer && getprop ro.product.model && getprop ro.serialno && getprop ro.build.version.release && ip addr show wlan0 | grep -m 1 ether && ip addr show eth0 | grep -m 1 ether",
)

# CMD_HDMI_INPUT
self.assertCommand(
constants.CMD_HDMI_INPUT,
Expand Down

0 comments on commit b41c655

Please sign in to comment.