1
|
|
|
#!/usr/bin/env python3 |
2
|
|
|
# -*- coding: utf-8 -*- |
3
|
|
|
|
4
|
|
|
"""Pseudo-devices for desktop/mobile requests""" |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
class Device(): |
|
|
|
|
8
|
|
|
"""Generic pseudo-device class.""" |
9
|
|
|
CLTP_STATES = { |
10
|
|
|
"MOBILE": 10, # only show actual newer versions or HTTP 206 |
11
|
|
|
"DESKTOP": 2010, # always show latest version for FULL updates |
12
|
|
|
} |
13
|
|
|
MODE_STATES = {"OTA": 2, "FULL": 4} |
14
|
|
|
CHNL_STATES = {"3G": 1, "WIFI": 2} |
15
|
|
|
CKTP_STATES = {"AUTO": 1, "MANUAL": 2} |
16
|
|
|
CKOT_STATES = {"ALL": 1, "AOTA_ONLY": 2, "FOTA_ONLY": 3} |
17
|
|
|
|
18
|
|
|
def __init__(self, curef, fwver): |
19
|
|
|
"""Populate variables.""" |
20
|
|
|
self.curef = curef |
21
|
|
|
self.imei = "" |
22
|
|
|
self.osver = "7.1.1" |
23
|
|
|
self.fwver = fwver |
24
|
|
|
self.rtd = 0 |
25
|
|
|
self.cltp = self.CLTP_STATES["DESKTOP"] |
26
|
|
|
self.mode = self.MODE_STATES["FULL"] |
27
|
|
|
self.type = "Firmware" |
28
|
|
|
self.chnl = self.CHNL_STATES["WIFI"] |
29
|
|
|
self.cktp = self.CKTP_STATES["MANUAL"] |
30
|
|
|
self.ckot = self.CKOT_STATES["ALL"] |
31
|
|
|
self.uagent = "tcl" |
32
|
|
|
|
33
|
|
|
def is_rooted(self): |
34
|
|
|
"""Get RTD as boolean.""" |
35
|
|
|
return self.rtd == 1 |
36
|
|
|
|
37
|
|
|
def set_rooted(self, new_state: bool): |
38
|
|
|
"""Set RTD as integer.""" |
39
|
|
|
self.rtd = int(new_state) |
40
|
|
|
|
41
|
|
|
def set_cltp(self, new_cltp: str): |
42
|
|
|
"""Set CLTP while handling non-numeric input.""" |
43
|
|
|
# (Numerical CLTPs can be set by direct assigns.) |
44
|
|
|
# Throws exception when invalid cltp given: |
45
|
|
|
self.cltp = self.CLTP_STATES[new_cltp] |
46
|
|
|
|
47
|
|
|
def set_mode(self, new_mode: str): |
48
|
|
|
"""Set MODE while handling non-numeric input.""" |
49
|
|
|
# (Numerical MODEs can be set by direct assigns.) |
50
|
|
|
# Throws exception when invalid mode given: |
51
|
|
|
self.mode = self.MODE_STATES[new_mode] |
52
|
|
|
|
53
|
|
|
def set_chnl(self, new_chnl: str): |
54
|
|
|
"""Set CHNL while handling non-numeric input.""" |
55
|
|
|
# (Numerical CHNLs can be set by direct assigns.) |
56
|
|
|
# Throws exception when invalid mode given: |
57
|
|
|
self.chnl = self.CHNL_STATES[new_chnl] |
58
|
|
|
|
59
|
|
|
def set_ckot(self, new_ckot: str): |
60
|
|
|
"""Set CKOT while handling non-numeric input.""" |
61
|
|
|
# (Numerical CKOTs can be set by direct assigns.) |
62
|
|
|
# Throws exception when invalid mode given: |
63
|
|
|
self.ckot = self.CKOT_STATES[new_ckot] |
64
|
|
|
|
65
|
|
|
|
66
|
|
|
class MobileDevice(Device): |
|
|
|
|
67
|
|
|
"""Generic mobile (i.e. OTA) device.""" |
68
|
|
|
|
69
|
|
|
def __init__(self, curef="PRD-63117-011", fwver="AAO472"): |
70
|
|
|
"""Populate variables.""" |
71
|
|
|
super().__init__(curef, fwver) |
72
|
|
|
self.imei = "3531510" |
73
|
|
|
self.set_cltp("MOBILE") |
74
|
|
|
self.set_mode("OTA") |
75
|
|
|
self.uagent = "com.tcl.fota/5.1.0.2.0029.0, Android" |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
class DesktopDevice(Device): |
|
|
|
|
79
|
|
|
"""Generic desktop (i.e. full) device.""" |
80
|
|
|
|
81
|
|
|
def __init__(self, curef="PRD-63117-011", fwver="AAA000"): |
82
|
|
|
"""Populate variables.""" |
83
|
|
|
super().__init__(curef, fwver) |
84
|
|
|
self.imei = "543212345000000" |
85
|
|
|
self.set_cltp("DESKTOP") |
86
|
|
|
self.set_mode("FULL") |
87
|
|
|
|