2017-09-21 09:19:48 +00:00
|
|
|
from . import googleplay_pb2
|
2017-09-15 20:11:44 +00:00
|
|
|
import time
|
2017-09-16 17:12:06 +00:00
|
|
|
import os
|
2017-10-04 11:42:52 +00:00
|
|
|
import sys
|
|
|
|
|
|
|
|
VERSION = sys.version_info[0]
|
|
|
|
if VERSION == 2:
|
|
|
|
import ConfigParser
|
|
|
|
else:
|
|
|
|
import configparser
|
2017-09-15 20:11:44 +00:00
|
|
|
|
2017-08-27 15:32:05 +00:00
|
|
|
|
2017-10-12 17:46:20 +00:00
|
|
|
DFE_TARGETS = "CAEScFfqlIEG6gUYogFWrAISK1WDAg+hAZoCDgIU1gYEOIACFkLMAeQBnASLATlASUuyAyqCAjY5igOMBQzfA/IClwFbApUC4ANbtgKVAS7OAX8YswHFBhgDwAOPAmGEBt4OfKkB5weSB5AFASkiN68akgMaxAMSAQEBA9kBO7UBFE1KVwIDBGs3go6BBgEBAgMECQgJAQIEAQMEAQMBBQEBBAUEFQYCBgUEAwMBDwIBAgOrARwBEwMEAg0mrwESfTEcAQEKG4EBMxghChMBDwYGASI3hAEODEwXCVh/EREZA4sBYwEdFAgIIwkQcGQRDzQ2fTC2AjfVAQIBAYoBGRg2FhYFBwEqNzACJShzFFblAo0CFxpFNBzaAd0DHjIRI4sBJZcBPdwBCQGhAUd2A7kBLBVPngEECHl0UEUMtQETigHMAgUFCc0BBUUlTywdHDgBiAJ+vgKhAU0uAcYCAWQ/5ALUAw1UwQHUBpIBCdQDhgL4AY4CBQICjARbGFBGWzA1CAEMOQH+BRAOCAZywAIDyQZ2MgM3BxsoAgUEBwcHFia3AgcGTBwHBYwBAlcBggFxSGgIrAEEBw4QEqUCASsWadsHCgUCBQMD7QICA3tXCUw7ugJZAwGyAUwpIwM5AwkDBQMJA5sBCw8BNxBVVBwVKhebARkBAwsQEAgEAhESAgQJEBCZATMdzgEBBwG8AQQYKSMUkAEDAwY/CTs4/wEaAUt1AwEDAQUBAgIEAwYEDx1dB2wGeBFgTQ"
|
2017-10-10 16:35:40 +00:00
|
|
|
LANG = "en_US"
|
2017-10-12 17:46:20 +00:00
|
|
|
TIMEZONE = 'America/New_York'
|
2017-10-10 16:35:40 +00:00
|
|
|
GOOGLE_PUBKEY = "AAAAgMom/1a/v0lblO2Ubrt60J2gcuXSljGFQXgcyZWveWLEwo6prwgi3iJIZdodyhKZQrNWp5nKJ3srRXcUW+F1BD3baEVGcmEgqaLZUNBjm057pKRI16kB0YppeGx5qIQ5QjKzsR8ETQbKLNWgRY0QRNVz34kMJR3P/LgHax/6rmf5AAAAAwEAAQ=="
|
2017-08-27 15:32:05 +00:00
|
|
|
|
2017-09-18 14:06:57 +00:00
|
|
|
# parse phone config from the file 'device.properties'.
|
|
|
|
# if you want to add another phone, just create another section in
|
|
|
|
# the file. Some configurations for common phones can be found here:
|
|
|
|
# https://github.com/yeriomin/play-store-api/tree/master/src/main/resources
|
2017-10-04 11:42:52 +00:00
|
|
|
if VERSION == 2:
|
|
|
|
config = ConfigParser.ConfigParser()
|
|
|
|
else:
|
|
|
|
config = configparser.ConfigParser()
|
|
|
|
|
2017-10-10 16:35:40 +00:00
|
|
|
filepath = os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
|
|
|
'device.properties')
|
2017-09-16 17:12:06 +00:00
|
|
|
config.read(filepath)
|
|
|
|
device = {}
|
2017-10-12 17:46:20 +00:00
|
|
|
# initialize device, because we need to setup UserAgent
|
|
|
|
# before the end of login method. If the login defines a different
|
|
|
|
# device, it won't cause conflicts
|
|
|
|
for (key, value) in config.items('angler'):
|
|
|
|
device[key] = value
|
2017-10-09 19:34:40 +00:00
|
|
|
|
2017-10-10 16:35:40 +00:00
|
|
|
|
2017-10-09 19:34:40 +00:00
|
|
|
def getDevicesCodenames():
|
2017-10-10 17:18:20 +00:00
|
|
|
"""Returns a list containing devices codenames"""
|
2017-10-09 19:34:40 +00:00
|
|
|
return config.sections()
|
2017-09-15 20:11:44 +00:00
|
|
|
|
2017-10-10 16:35:40 +00:00
|
|
|
|
2017-10-10 17:18:20 +00:00
|
|
|
def getDevicesReadableNames():
|
2017-10-10 17:23:58 +00:00
|
|
|
"""Returns codename and readable name for each device"""
|
2017-10-10 17:18:20 +00:00
|
|
|
sections = getDevicesCodenames()
|
|
|
|
output = []
|
|
|
|
for s in sections:
|
|
|
|
output.append({'codename': s,
|
|
|
|
'readableName': config[s]['userreadablename']})
|
|
|
|
return output
|
|
|
|
|
|
|
|
|
2017-10-12 17:46:20 +00:00
|
|
|
def getUserAgent():
|
|
|
|
return "Android-Finsky/7.1.15 (" \
|
|
|
|
"api=3" \
|
|
|
|
",versionCode={versionCode}" \
|
|
|
|
",sdk={sdk}" \
|
|
|
|
",device={device}" \
|
|
|
|
",hardware={hardware}" \
|
|
|
|
",product={product}".format(versionCode=device['vending.version'],
|
|
|
|
sdk=device['build.version.sdk_int'],
|
|
|
|
device=device['build.device'],
|
|
|
|
hardware=device['build.hardware'],
|
|
|
|
product=device['build.product'])
|
|
|
|
|
|
|
|
|
2017-09-16 17:12:06 +00:00
|
|
|
def getDeviceConfig():
|
2017-09-18 14:06:57 +00:00
|
|
|
libList = device['sharedlibraries'].split(",")
|
|
|
|
featureList = device['features'].split(",")
|
|
|
|
localeList = device['locales'].split(",")
|
|
|
|
glList = device['gl.extensions'].split(",")
|
|
|
|
platforms = device['platforms'].split(",")
|
|
|
|
|
2017-10-12 17:46:20 +00:00
|
|
|
hasFiveWayNavigation = (device['hasfivewaynavigation'] == 'true')
|
|
|
|
hasHardKeyboard = (device['hashardkeyboard'] == 'true')
|
2017-09-16 17:12:06 +00:00
|
|
|
deviceConfig = googleplay_pb2.DeviceConfigurationProto()
|
|
|
|
deviceConfig.touchScreen = int(device['touchscreen'])
|
|
|
|
deviceConfig.keyboard = int(device['keyboard'])
|
|
|
|
deviceConfig.navigation = int(device['navigation'])
|
|
|
|
deviceConfig.screenLayout = int(device['screenlayout'])
|
2017-10-12 17:46:20 +00:00
|
|
|
deviceConfig.hasHardKeyboard = hasHardKeyboard
|
|
|
|
deviceConfig.hasFiveWayNavigation = hasFiveWayNavigation
|
2017-09-16 17:12:06 +00:00
|
|
|
deviceConfig.screenDensity = int(device['screen.density'])
|
|
|
|
deviceConfig.screenWidth = int(device['screen.width'])
|
|
|
|
deviceConfig.screenHeight = int(device['screen.height'])
|
|
|
|
deviceConfig.glEsVersion = int(device['gl.version'])
|
|
|
|
for x in platforms:
|
|
|
|
deviceConfig.nativePlatform.append(x)
|
|
|
|
for x in libList:
|
|
|
|
deviceConfig.systemSharedLibrary.append(x)
|
|
|
|
for x in featureList:
|
|
|
|
deviceConfig.systemAvailableFeature.append(x)
|
|
|
|
for x in localeList:
|
|
|
|
deviceConfig.systemSupportedLocale.append(x)
|
|
|
|
for x in glList:
|
|
|
|
deviceConfig.glExtension.append(x)
|
|
|
|
return deviceConfig
|
2017-09-15 20:11:44 +00:00
|
|
|
|
2017-10-10 16:35:40 +00:00
|
|
|
|
2017-09-16 17:12:06 +00:00
|
|
|
def getAndroidBuild():
|
|
|
|
androidBuild = googleplay_pb2.AndroidBuildProto()
|
|
|
|
androidBuild.id = device['build.fingerprint']
|
|
|
|
androidBuild.product = device['build.hardware']
|
|
|
|
androidBuild.carrier = device['build.brand']
|
|
|
|
androidBuild.radio = device['build.radio']
|
|
|
|
androidBuild.bootloader = device['build.bootloader']
|
|
|
|
androidBuild.device = device['build.device']
|
|
|
|
androidBuild.sdkVersion = int(device['build.version.sdk_int'])
|
|
|
|
androidBuild.model = device['build.model']
|
|
|
|
androidBuild.manufacturer = device['build.manufacturer']
|
|
|
|
androidBuild.buildProduct = device['build.product']
|
|
|
|
androidBuild.client = device['client']
|
|
|
|
androidBuild.otaInstalled = False
|
|
|
|
androidBuild.timestamp = int(time.time())
|
|
|
|
androidBuild.googleServices = int(device['gsf.version'])
|
|
|
|
return androidBuild
|
2017-09-15 20:11:44 +00:00
|
|
|
|
2017-10-10 16:35:40 +00:00
|
|
|
|
2017-09-16 17:12:06 +00:00
|
|
|
def getAndroidCheckin():
|
|
|
|
androidCheckin = googleplay_pb2.AndroidCheckinProto()
|
|
|
|
androidCheckin.build.CopyFrom(getAndroidBuild())
|
|
|
|
androidCheckin.lastCheckinMsec = 0
|
|
|
|
androidCheckin.cellOperator = device['celloperator']
|
|
|
|
androidCheckin.simOperator = device['simoperator']
|
|
|
|
androidCheckin.roaming = device['roaming']
|
|
|
|
androidCheckin.userNumber = 0
|
|
|
|
return androidCheckin
|
2017-09-15 20:11:44 +00:00
|
|
|
|
2017-10-10 16:35:40 +00:00
|
|
|
|
2017-10-09 19:34:40 +00:00
|
|
|
def getAndroidCheckinRequest(device_codename):
|
|
|
|
for (key, value) in config.items(device_codename):
|
|
|
|
device[key] = value
|
2017-09-16 17:12:06 +00:00
|
|
|
request = googleplay_pb2.AndroidCheckinRequest()
|
|
|
|
request.id = 0
|
|
|
|
request.checkin.CopyFrom(getAndroidCheckin())
|
2017-10-12 17:46:20 +00:00
|
|
|
request.locale = LANG
|
|
|
|
request.timeZone = TIMEZONE
|
2017-09-16 17:12:06 +00:00
|
|
|
request.version = 3
|
|
|
|
request.deviceConfiguration.CopyFrom(getDeviceConfig())
|
|
|
|
request.fragment = 0
|
|
|
|
return request
|