From 6a9f29c6ceb2565abcd500487c205775a9336eda Mon Sep 17 00:00:00 2001 From: Domenico Iezzi Date: Fri, 10 Nov 2017 22:25:33 +0100 Subject: [PATCH] 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. --- gpapi/googleplay.py | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/gpapi/googleplay.py b/gpapi/googleplay.py index 11ce1bf..b595d3f 100644 --- a/gpapi/googleplay.py +++ b/gpapi/googleplay.py @@ -45,11 +45,21 @@ class GooglePlayAPI(object): CHECKINURL = BASE + "checkin" 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.gsfId = None self.debug = debug 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 self.lastResponseText = None @@ -609,23 +619,6 @@ class GooglePlayAPI(object): return self.delivery(packageName, versionCode, offerType, dlToken, 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 def getDevicesCodenames(): return config.getDevicesCodenames()