Add ability to fake devices

Signed-off-by: Matlink <matlink@matlink.fr>
This commit is contained in:
Matlink 2017-10-09 21:34:40 +02:00
parent 1cdb35128b
commit 1b47fdbe19
3 changed files with 1351 additions and 7 deletions

View File

@ -27,8 +27,9 @@ else:
filepath = os.path.join( os.path.dirname( os.path.realpath(__file__) ), 'device.properties') filepath = os.path.join( os.path.dirname( os.path.realpath(__file__) ), 'device.properties')
config.read(filepath) config.read(filepath)
device = {} device = {}
for (key, value) in config.items('angler'):
device[key] = value def getDevicesCodenames():
return config.sections()
def getDeviceConfig(): def getDeviceConfig():
libList = device['sharedlibraries'].split(",") libList = device['sharedlibraries'].split(",")
@ -88,7 +89,9 @@ def getAndroidCheckin():
androidCheckin.userNumber = 0 androidCheckin.userNumber = 0
return androidCheckin return androidCheckin
def getAndroidCheckinRequest(): def getAndroidCheckinRequest(device_codename):
for (key, value) in config.items(device_codename):
device[key] = value
request = googleplay_pb2.AndroidCheckinRequest() request = googleplay_pb2.AndroidCheckinRequest()
request.id = 0 request.id = 0
request.checkin.CopyFrom(getAndroidCheckin()) request.checkin.CopyFrom(getAndroidCheckin())

File diff suppressed because it is too large Load Diff

View File

@ -104,11 +104,11 @@ class GooglePlayAPI(object):
headers["Authorization"] = "GoogleLogin auth=%s" % self.authSubToken headers["Authorization"] = "GoogleLogin auth=%s" % self.authSubToken
return headers return headers
def checkin(self, email, ac2dmToken): def checkin(self, email, ac2dmToken, device_codename):
headers = self.getDefaultHeaders() headers = self.getDefaultHeaders()
headers["Content-Type"] = "application/x-protobuffer" headers["Content-Type"] = "application/x-protobuffer"
request = config.getAndroidCheckinRequest() request = config.getAndroidCheckinRequest(device_codename)
stringRequest = request.SerializeToString() stringRequest = request.SerializeToString()
res = requests.post(self.CHECKINURL, data=stringRequest, res = requests.post(self.CHECKINURL, data=stringRequest,
@ -149,7 +149,7 @@ class GooglePlayAPI(object):
response = googleplay_pb2.ResponseWrapper.FromString(res.content) response = googleplay_pb2.ResponseWrapper.FromString(res.content)
def login(self, email=None, password=None, gsfId=None, authSubToken=None): def login(self, email=None, password=None, gsfId=None, authSubToken=None, device_codename='angler'):
"""Login to your Google Account. """Login to your Google Account.
For first time login you should provide: For first time login you should provide:
* email * email
@ -192,7 +192,7 @@ class GooglePlayAPI(object):
else: else:
raise LoginError("Auth token not found.") raise LoginError("Auth token not found.")
self.gsfId = self.checkin(email, ac2dmToken) self.gsfId = self.checkin(email, ac2dmToken, device_codename)
if self.debug: if self.debug:
print("Google Services Framework Id: %s" % "{0:x}".format(self.gsfId)) print("Google Services Framework Id: %s" % "{0:x}".format(self.gsfId))
self.getAuthSubToken(email, encryptedPass) self.getAuthSubToken(email, encryptedPass)
@ -494,3 +494,6 @@ class GooglePlayAPI(object):
return self.delivery(packageName, versionCode, return self.delivery(packageName, versionCode,
offerType, dlToken, progress_bar=progress_bar) offerType, dlToken, progress_bar=progress_bar)
@staticmethod
def getDevicesCodenames():
return config.getDevicesCodenames()