From e72beaa265757823f13b1b31d4c88b42186f4b1c Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 23 Jan 2014 07:47:32 -0800 Subject: [PATCH] add and use isGooglePlayApp() --- .../org/eehouse/android/xw4/UpdateCheckReceiver.java | 8 ++++---- .../XWords4/src/org/eehouse/android/xw4/Utils.java | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/UpdateCheckReceiver.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/UpdateCheckReceiver.java index 599475788..63f0b4a37 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/UpdateCheckReceiver.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/UpdateCheckReceiver.java @@ -108,12 +108,12 @@ public class UpdateCheckReceiver extends BroadcastReceiver { JSONObject params = new JSONObject(); PackageManager pm = context.getPackageManager(); String packageName = context.getPackageName(); - String installer = pm.getInstallerPackageName( packageName ); - if ( "com.google.android.feedback".equals( installer ) - || "com.android.vending".equals( installer ) ) { - // Do nothing; it's a Market app + if ( Utils.isGooglePlayApp( context ) ) { + // Do nothing } else { + String installer = pm.getInstallerPackageName( packageName ); + try { int versionCode = pm.getPackageInfo( packageName, 0 ).versionCode; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java index b29a7707c..e40ae41ba 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java @@ -464,6 +464,16 @@ public class Utils { return result; } + public static boolean isGooglePlayApp( Context context ) + { + PackageManager pm = context.getPackageManager(); + String packageName = context.getPackageName(); + String installer = pm.getInstallerPackageName( packageName ); + boolean result = "com.google.android.feedback".equals( installer ) + || "com.android.vending".equals( installer ); + return result; + } + private static void setFirstBootStatics( Context context ) { int thisVersion = getAppVersion( context );