2017-09-01 12:43:10 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# pylint: disable=C0111,C0326
|
|
|
|
|
2017-10-15 00:51:38 +01:00
|
|
|
import enum
|
2017-09-23 21:17:57 +01:00
|
|
|
import platform
|
2017-09-01 12:43:10 +01:00
|
|
|
import requests
|
2018-02-03 00:36:08 +00:00
|
|
|
from . import credentials
|
|
|
|
from . import devlist
|
|
|
|
from . import dumpmgr
|
|
|
|
from . import servervote
|
|
|
|
from . import tclcheck
|
|
|
|
from . import tclrequest
|
|
|
|
from . import tclchecksum
|
|
|
|
from . import tclencheader
|
|
|
|
from . import xmltools
|
2017-09-23 21:17:57 +01:00
|
|
|
|
|
|
|
def make_escapes_work():
|
|
|
|
system = platform.system()
|
|
|
|
if system == "Windows":
|
|
|
|
try:
|
|
|
|
import colorama
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
colorama.init()
|
|
|
|
|
|
|
|
|
2017-10-15 00:51:38 +01:00
|
|
|
def default_enum(enumname, vardict):
|
|
|
|
return enum.IntEnum(enumname, vardict, module=__name__, qualname="tcllib.FotaCheck.{}".format(enumname))
|
|
|
|
|
2018-02-03 00:36:08 +00:00
|
|
|
class FotaCheck(
|
|
|
|
tclcheck.TclCheck,
|
|
|
|
tclrequest.TclRequest,
|
|
|
|
tclchecksum.TclChecksum,
|
|
|
|
tclencheader.TclEncHeader,
|
|
|
|
servervote.ServerVote,
|
|
|
|
credentials.Credentials,
|
|
|
|
devlist.DevList,
|
|
|
|
dumpmgr.DumpMgr,
|
|
|
|
xmltools.XmlTools
|
|
|
|
):
|
2017-09-01 20:53:21 +01:00
|
|
|
VDKEY = b"eJwdjwEOwDAIAr8kKFr//7HhmqXp8AIIDrYAgg8byiUXrwRJRXja+d6iNxu0AhUooDCN9rd6rDLxmGIakUVWo3IGCTRWqCAt6X4jGEIUAxgN0eYWnp+LkpHQAg/PsO90ELsy0Npm/n2HbtPndFgGEV31R9OmT4O4nrddjc3Qt6nWscx7e+WRHq5UnOudtjw5skuV09pFhvmqnOEIs4ljPeel1wfLYUF4\n"
|
2017-10-15 00:51:38 +01:00
|
|
|
CKTP = default_enum("CKTP", ["AUTO", "MANUAL"])
|
|
|
|
MODE = default_enum("MODE", {"OTA": 2, "FULL": 4})
|
|
|
|
RTD = default_enum("RTD", ["UNROOTED", "ROOTED"])
|
|
|
|
CHNL = default_enum("CHNL", ["3G", "WIFI"])
|
|
|
|
CLTP = default_enum("CLTP", {"MOBILE": 10, "DESKTOP": 2010})
|
2017-10-30 22:17:45 +00:00
|
|
|
CKOT = default_enum("CKOT", ["ALL", "AOTA_ONLY", "FOTA_ONLY"])
|
2017-09-01 12:43:10 +01:00
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.serid = "543212345000000"
|
|
|
|
self.curef = "PRD-63117-011"
|
|
|
|
self.fv = "AAM481"
|
|
|
|
self.osvs = "7.1.1"
|
2017-10-15 00:51:38 +01:00
|
|
|
self.mode = self.MODE.FULL
|
2017-09-01 12:43:10 +01:00
|
|
|
self.ftype = "Firmware"
|
2017-10-15 00:51:38 +01:00
|
|
|
self.cltp = self.CLTP.MOBILE
|
|
|
|
self.cktp = self.CKTP.MANUAL
|
2017-10-30 22:17:45 +00:00
|
|
|
self.ckot = self.CKOT.ALL
|
2017-10-15 00:51:38 +01:00
|
|
|
self.rtd = self.RTD.UNROOTED
|
|
|
|
self.chnl = self.CHNL.WIFI
|
2017-10-05 22:51:07 +01:00
|
|
|
self.g2master = None
|
|
|
|
self.master_servers = [
|
|
|
|
"g2master-us-east.tclclouds.com",
|
|
|
|
"g2master-us-west.tclclouds.com",
|
|
|
|
"g2master-eu-west.tclclouds.com",
|
|
|
|
"g2master-ap-south.tclclouds.com",
|
|
|
|
"g2master-ap-north.tclclouds.com",
|
|
|
|
"g2master-sa-east.tclclouds.com",
|
|
|
|
]
|
2017-10-06 00:19:56 +01:00
|
|
|
self.master_servers_weights = [3] * len(self.master_servers)
|
2017-10-06 00:37:10 +01:00
|
|
|
self.check_time_sum = 3
|
|
|
|
self.check_time_count = 1
|
2018-01-17 23:47:27 +00:00
|
|
|
self.last_dump_filename = None
|
2017-09-01 16:58:00 +01:00
|
|
|
self.reset_session()
|
|
|
|
|
|
|
|
def reset_session(self):
|
2017-09-01 12:43:10 +01:00
|
|
|
self.g2master = self.get_master_server()
|
2017-09-01 16:58:00 +01:00
|
|
|
self.sess = requests.Session()
|
2017-10-15 00:51:38 +01:00
|
|
|
if self.mode == self.MODE.FULL:
|
2017-09-01 16:58:00 +01:00
|
|
|
self.sess.headers.update({"User-Agent": "com.tcl.fota/5.1.0.2.0029.0, Android"})
|
|
|
|
else:
|
|
|
|
self.sess.headers.update({"User-Agent": "tcl"})
|
|
|
|
return self.sess
|