1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
|
3
|
|
|
"""Pseudo-devices for desktop/mobile requests""" |
4
|
|
|
|
5
|
|
|
class Device(): |
|
|
|
|
6
|
|
|
CLTP_STATES = { |
7
|
|
|
"MOBILE": 10, # only show actual newer versions or HTTP 206 |
8
|
|
|
"DESKTOP": 2010, # always show latest version for FULL updates |
9
|
|
|
} |
10
|
|
|
MODE_STATES = {"OTA": 2, "FULL": 4} |
11
|
|
|
CHNL_STATES = {"3G": 1, "WIFI": 2} |
12
|
|
|
CKTP_STATES = {"AUTO": 1, "MANUAL": 2} |
13
|
|
|
CKOT_STATES = {"ALL": 1, "AOTA_ONLY": 2, "FOTA_ONLY": 3} |
14
|
|
|
|
15
|
|
|
def __init__(self, curef, fwver): |
16
|
|
|
self.curef = curef |
17
|
|
|
self.imei = "" |
18
|
|
|
self.osver = "7.1.1" |
19
|
|
|
self.fwver = fwver |
20
|
|
|
self.rtd = 0 |
21
|
|
|
self.cltp = self.CLTP_STATES["DESKTOP"] |
22
|
|
|
self.mode = self.MODE_STATES["FULL"] |
23
|
|
|
self.type = "Firmware" |
24
|
|
|
self.chnl = self.CHNL_STATES["WIFI"] |
25
|
|
|
self.cktp = self.CKTP_STATES["MANUAL"] |
26
|
|
|
self.ckot = self.CKOT_STATES["ALL"] |
27
|
|
|
self.ua = "tcl" |
28
|
|
|
|
29
|
|
|
def is_rooted(self): |
|
|
|
|
30
|
|
|
return (self.rtd == 1) |
|
|
|
|
31
|
|
|
|
32
|
|
|
def set_rooted(self, new_state: bool): |
|
|
|
|
33
|
|
|
if new_state: |
34
|
|
|
self.rtd = 1 |
35
|
|
|
else: |
36
|
|
|
self.rtd = 0 |
37
|
|
|
|
38
|
|
|
def set_cltp(self, new_cltp: str): |
|
|
|
|
39
|
|
|
# (Numerical CLTPs can be set by direct assigns.) |
40
|
|
|
# Throws exception when invalid cltp given: |
41
|
|
|
self.cltp = self.CLTP_STATES[new_cltp] |
42
|
|
|
|
43
|
|
|
def set_mode(self, new_mode: str): |
|
|
|
|
44
|
|
|
# (Numerical MODEs can be set by direct assigns.) |
45
|
|
|
# Throws exception when invalid mode given: |
46
|
|
|
self.mode = self.MODE_STATES[new_mode] |
47
|
|
|
|
48
|
|
|
def set_chnl(self, new_chnl: str): |
|
|
|
|
49
|
|
|
# (Numerical CHNLs can be set by direct assigns.) |
50
|
|
|
# Throws exception when invalid mode given: |
51
|
|
|
self.chnl = self.CHNL_STATES[new_chnl] |
52
|
|
|
|
53
|
|
|
def set_ckot(self, new_ckot: str): |
|
|
|
|
54
|
|
|
# (Numerical CKOTs can be set by direct assigns.) |
55
|
|
|
# Throws exception when invalid mode given: |
56
|
|
|
self.ckot = self.CKOT_STATES[new_ckot] |
57
|
|
|
|
58
|
|
|
class MobileDevice(Device): |
|
|
|
|
59
|
|
|
def __init__(self, curef="PRD-63117-011", fwver="AAO472"): |
60
|
|
|
super().__init__(curef, fwver) |
61
|
|
|
self.imei = "3531510" |
62
|
|
|
self.set_cltp("MOBILE") |
63
|
|
|
self.set_mode("OTA") |
64
|
|
|
self.ua = "com.tcl.fota/5.1.0.2.0029.0, Android" |
65
|
|
|
|
66
|
|
|
class DesktopDevice(Device): |
|
|
|
|
67
|
|
|
def __init__(self, curef="PRD-63117-011", fwver="AAA000"): |
68
|
|
|
super().__init__(curef, fwver) |
69
|
|
|
self.imei = "543212345000000" |
70
|
|
|
self.set_cltp("DESKTOP") |
71
|
|
|
self.set_mode("FULL") |
72
|
|
|
|
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.