2018-02-05 23:22:24 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""Pseudo-devices for desktop/mobile requests"""
|
|
|
|
|
2018-02-06 18:27:36 +00:00
|
|
|
|
2018-02-05 23:22:24 +00:00
|
|
|
class Device():
|
2018-02-06 00:03:25 +00:00
|
|
|
"""Generic pseudo-device class."""
|
2018-02-05 23:22:24 +00:00
|
|
|
CLTP_STATES = {
|
|
|
|
"MOBILE": 10, # only show actual newer versions or HTTP 206
|
|
|
|
"DESKTOP": 2010, # always show latest version for FULL updates
|
|
|
|
}
|
|
|
|
MODE_STATES = {"OTA": 2, "FULL": 4}
|
|
|
|
CHNL_STATES = {"3G": 1, "WIFI": 2}
|
|
|
|
CKTP_STATES = {"AUTO": 1, "MANUAL": 2}
|
|
|
|
CKOT_STATES = {"ALL": 1, "AOTA_ONLY": 2, "FOTA_ONLY": 3}
|
|
|
|
|
|
|
|
def __init__(self, curef, fwver):
|
2018-02-06 00:03:25 +00:00
|
|
|
"""Populate variables."""
|
2018-02-05 23:22:24 +00:00
|
|
|
self.curef = curef
|
|
|
|
self.imei = ""
|
|
|
|
self.osver = "7.1.1"
|
|
|
|
self.fwver = fwver
|
|
|
|
self.rtd = 0
|
|
|
|
self.cltp = self.CLTP_STATES["DESKTOP"]
|
|
|
|
self.mode = self.MODE_STATES["FULL"]
|
|
|
|
self.type = "Firmware"
|
|
|
|
self.chnl = self.CHNL_STATES["WIFI"]
|
|
|
|
self.cktp = self.CKTP_STATES["MANUAL"]
|
|
|
|
self.ckot = self.CKOT_STATES["ALL"]
|
|
|
|
self.ua = "tcl"
|
|
|
|
|
|
|
|
def is_rooted(self):
|
2018-02-06 00:03:25 +00:00
|
|
|
"""Get RTD as boolean."""
|
|
|
|
return self.rtd == 1
|
2018-02-05 23:22:24 +00:00
|
|
|
|
|
|
|
def set_rooted(self, new_state: bool):
|
2018-02-06 00:03:25 +00:00
|
|
|
"""Set RTD as integer."""
|
|
|
|
self.rtd = int(new_state)
|
2018-02-05 23:22:24 +00:00
|
|
|
|
|
|
|
def set_cltp(self, new_cltp: str):
|
2018-02-06 00:03:25 +00:00
|
|
|
"""Set CLTP while handling non-numeric input."""
|
2018-02-05 23:22:24 +00:00
|
|
|
# (Numerical CLTPs can be set by direct assigns.)
|
|
|
|
# Throws exception when invalid cltp given:
|
|
|
|
self.cltp = self.CLTP_STATES[new_cltp]
|
|
|
|
|
|
|
|
def set_mode(self, new_mode: str):
|
2018-02-06 00:03:25 +00:00
|
|
|
"""Set MODE while handling non-numeric input."""
|
2018-02-05 23:22:24 +00:00
|
|
|
# (Numerical MODEs can be set by direct assigns.)
|
|
|
|
# Throws exception when invalid mode given:
|
|
|
|
self.mode = self.MODE_STATES[new_mode]
|
|
|
|
|
|
|
|
def set_chnl(self, new_chnl: str):
|
2018-02-06 00:03:25 +00:00
|
|
|
"""Set CHNL while handling non-numeric input."""
|
2018-02-05 23:22:24 +00:00
|
|
|
# (Numerical CHNLs can be set by direct assigns.)
|
|
|
|
# Throws exception when invalid mode given:
|
|
|
|
self.chnl = self.CHNL_STATES[new_chnl]
|
|
|
|
|
|
|
|
def set_ckot(self, new_ckot: str):
|
2018-02-06 00:03:25 +00:00
|
|
|
"""Set CKOT while handling non-numeric input."""
|
2018-02-05 23:22:24 +00:00
|
|
|
# (Numerical CKOTs can be set by direct assigns.)
|
|
|
|
# Throws exception when invalid mode given:
|
|
|
|
self.ckot = self.CKOT_STATES[new_ckot]
|
|
|
|
|
2018-02-06 18:27:36 +00:00
|
|
|
|
2018-02-05 23:22:24 +00:00
|
|
|
class MobileDevice(Device):
|
2018-02-06 00:03:25 +00:00
|
|
|
"""Generic mobile (i.e. OTA) device."""
|
2018-02-06 18:27:36 +00:00
|
|
|
|
2018-02-05 23:22:24 +00:00
|
|
|
def __init__(self, curef="PRD-63117-011", fwver="AAO472"):
|
2018-02-06 18:27:36 +00:00
|
|
|
"""Populate variables."""
|
2018-02-05 23:22:24 +00:00
|
|
|
super().__init__(curef, fwver)
|
|
|
|
self.imei = "3531510"
|
|
|
|
self.set_cltp("MOBILE")
|
|
|
|
self.set_mode("OTA")
|
|
|
|
self.ua = "com.tcl.fota/5.1.0.2.0029.0, Android"
|
|
|
|
|
2018-02-06 18:27:36 +00:00
|
|
|
|
2018-02-05 23:22:24 +00:00
|
|
|
class DesktopDevice(Device):
|
2018-02-06 00:03:25 +00:00
|
|
|
"""Generic desktop (i.e. full) device."""
|
2018-02-06 18:27:36 +00:00
|
|
|
|
2018-02-05 23:22:24 +00:00
|
|
|
def __init__(self, curef="PRD-63117-011", fwver="AAA000"):
|
2018-02-06 18:27:36 +00:00
|
|
|
"""Populate variables."""
|
2018-02-05 23:22:24 +00:00
|
|
|
super().__init__(curef, fwver)
|
|
|
|
self.imei = "543212345000000"
|
|
|
|
self.set_cltp("DESKTOP")
|
|
|
|
self.set_mode("FULL")
|