Device info setup moved inside __init__

Since most of the device data is used only for the checkin procedure,
which is run only after the first login with email and passwd, it
is useless to have functions in GooglePlayAPI to modify them at runtime.

Now if the user wants to specify custom data, this data should be
provided as arguments to the constructor.
This commit is contained in:
Domenico Iezzi 2017-11-10 22:25:33 +01:00
parent e6c69a5552
commit 6a9f29c6ce
No known key found for this signature in database
GPG Key ID: 7AC94D5DDA2FB7EE

View File

@ -45,11 +45,21 @@ class GooglePlayAPI(object):
CHECKINURL = BASE + "checkin" CHECKINURL = BASE + "checkin"
AUTHURL = BASE + "auth" AUTHURL = BASE + "auth"
def __init__(self, debug=False, device_codename='bacon'): def __init__(self, debug=False, device_codename='bacon',
locale=None, timezone=None,
sim_operator=None, cell_operator=None):
self.authSubToken = None self.authSubToken = None
self.gsfId = None self.gsfId = None
self.debug = debug self.debug = debug
self.deviceBuilder = config.DeviceBuilder(device_codename) self.deviceBuilder = config.DeviceBuilder(device_codename)
if locale is not None:
self.deviceBuilder.locale = locale
if timezone is not None:
self.deviceBuilder.timezone = timezone
if sim_operator is not None:
self.deviceBuilder.device['simoperator'] = sim_operator
if cell_operator is not None:
self.deviceBuilder.device['celloperator'] = cell_operator
# save last response text for error logging # save last response text for error logging
self.lastResponseText = None self.lastResponseText = None
@ -609,23 +619,6 @@ class GooglePlayAPI(object):
return self.delivery(packageName, versionCode, offerType, dlToken, return self.delivery(packageName, versionCode, offerType, dlToken,
progress_bar=progress_bar, expansion_files=expansion_files) progress_bar=progress_bar, expansion_files=expansion_files)
def changeDevice(self, device_codename):
self.deviceBuilder = config.DeviceBuilder(device_codename)
# Helpers
def getLocale(self):
return self.deviceBuilder.locale
def setLocale(self, locale):
self.deviceBuilder.locale = locale
def getTimeZone(self):
return self.deviceBuilder.timezone
def setTimeZone(self, timezone):
self.deviceBuilder.timezone = timezone
@staticmethod @staticmethod
def getDevicesCodenames(): def getDevicesCodenames():
return config.getDevicesCodenames() return config.getDevicesCodenames()