From 2d4e9865f940b3642a8e358abc2d37bcbdb65026 Mon Sep 17 00:00:00 2001 From: Sergey Eremin Date: Mon, 22 May 2017 17:16:38 +0300 Subject: [PATCH] Issue #168 GSF version code is saved properly into device.properties now. Fallback version updated --- .../CrashLetterDeviceInfoBuilder.java | 2 +- .../yalpstore/NativeDeviceInfoProvider.java | 27 +++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/github/yeriomin/yalpstore/CrashLetterDeviceInfoBuilder.java b/app/src/main/java/com/github/yeriomin/yalpstore/CrashLetterDeviceInfoBuilder.java index 953e5ff9c..67e4cbc80 100644 --- a/app/src/main/java/com/github/yeriomin/yalpstore/CrashLetterDeviceInfoBuilder.java +++ b/app/src/main/java/com/github/yeriomin/yalpstore/CrashLetterDeviceInfoBuilder.java @@ -22,7 +22,6 @@ public class CrashLetterDeviceInfoBuilder extends CrashLetterBuilder { static { staticProperties.put("Client", "android-google"); - staticProperties.put("GSF.version", "16"); staticProperties.put("Roaming", "mobile-notroaming"); staticProperties.put("TimeZone", TimeZone.getDefault().getID()); staticProperties.put("GL.Extensions", TextUtils.join(",", EglExtensionRetriever.getEglExtensions())); @@ -92,6 +91,7 @@ public class CrashLetterDeviceInfoBuilder extends CrashLetterBuilder { values.put("HasFiveWayNavigation", Boolean.toString(config.navigation == Configuration.NAVIGATIONHIDDEN_YES)); ConfigurationInfo configurationInfo = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getDeviceConfigurationInfo(); values.put("GL.Version", Integer.toString(configurationInfo.reqGlEsVersion)); + values.put("GSF.version", Integer.toString(NativeDeviceInfoProvider.getGsfVersionCode(context))); return values; } diff --git a/app/src/main/java/com/github/yeriomin/yalpstore/NativeDeviceInfoProvider.java b/app/src/main/java/com/github/yeriomin/yalpstore/NativeDeviceInfoProvider.java index 1df7a12dd..0a03fc0f6 100644 --- a/app/src/main/java/com/github/yeriomin/yalpstore/NativeDeviceInfoProvider.java +++ b/app/src/main/java/com/github/yeriomin/yalpstore/NativeDeviceInfoProvider.java @@ -25,8 +25,7 @@ import java.util.TimeZone; public class NativeDeviceInfoProvider implements DeviceInfoProvider { - // Getting this requires a permission and google services to be installed - static private final int GOOGLE_SERVICES_VERSION_CODE = 80711500; + static private final int GOOGLE_SERVICES_VERSION_CODE = 10548448; private Context context; private String localeString; @@ -46,12 +45,13 @@ public class NativeDeviceInfoProvider implements DeviceInfoProvider { public String getUserAgentString() { return "Android-Finsky/7.1.15 (" + "api=3" - + ",versionCode=" + GOOGLE_SERVICES_VERSION_CODE + + ",versionCode=" + getGsfVersionCode(context) + ",sdk=" + Build.VERSION.SDK_INT + ",device=" + Build.DEVICE + ",hardware=" + (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO ? Build.HARDWARE : Build.PRODUCT) + ",product=" + Build.PRODUCT - + ")"; + + ")" + ; } public AndroidCheckinRequest generateAndroidCheckinRequest() { @@ -64,7 +64,8 @@ public class NativeDeviceInfoProvider implements DeviceInfoProvider { .setVersion(3) .setDeviceConfiguration(getDeviceConfigurationProto()) .setFragment(0) - .build(); + .build() + ; } private AndroidCheckinProto getCheckinProto() { @@ -95,8 +96,9 @@ public class NativeDeviceInfoProvider implements DeviceInfoProvider { .setClient("android-google") .setOtaInstalled(false) .setTimestamp(System.currentTimeMillis() / 1000) - .setGoogleServices(GOOGLE_SERVICES_VERSION_CODE) - .build(); + .setGoogleServices(getGsfVersionCode(context)) + .build() + ; } public DeviceConfigurationProto getDeviceConfigurationProto() { @@ -111,7 +113,8 @@ public class NativeDeviceInfoProvider implements DeviceInfoProvider { .addAllSystemSupportedLocale(getLocales(context)) .setGlEsVersion(configurationInfo.reqGlEsVersion) .addAllGlExtension(EglExtensionRetriever.getEglExtensions()) - .build(); + .build() + ; } private DeviceConfigurationProto.Builder addDisplayMetrics(DeviceConfigurationProto.Builder builder) { @@ -176,4 +179,12 @@ public class NativeDeviceInfoProvider implements DeviceInfoProvider { static public List getSharedLibraries(Context context) { return Arrays.asList(context.getPackageManager().getSystemSharedLibraryNames()); } + + static public int getGsfVersionCode(Context context) { + try { + return context.getPackageManager().getPackageInfo("com.google.android.gms", 0).versionCode; + } catch (PackageManager.NameNotFoundException e) { + return GOOGLE_SERVICES_VERSION_CODE; + } + } }