Skip to content

Commit

Permalink
Device info setup moved inside __init__
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Domenico Iezzi committed Nov 10, 2017
1 parent e6c69a5 commit 6a9f29c
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions gpapi/googleplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -609,23 +619,6 @@ def download(self, packageName, versionCode=None, offerType=1,
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()
Expand Down

0 comments on commit 6a9f29c

Please sign in to comment.