From 63aaa30ba166f20de71153fc2f7467d0705f39a4 Mon Sep 17 00:00:00 2001 From: Harry Youd Date: Wed, 22 Feb 2017 14:05:30 +0000 Subject: [PATCH] SetupWizard: Don't crash when missing Google SUW If com.google.android.gms is installed when com.google.android.setupwizard is not, our setup wizard crashes. Fix this by checking Google's setupwizard exists, and if not, not attempting to launch it. Change-Id: I6120304dd13dddf07c2769245765a3e98dec51fc --- .../setupwizard/util/SetupWizardUtils.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java b/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java index 55716309..1037e2c2 100644 --- a/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java +++ b/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java @@ -73,6 +73,9 @@ public class SetupWizardUtils { private static final String TAG = SetupWizardUtils.class.getSimpleName(); + private static final String GMS_PACKAGE = "com.google.android.gms"; + private static final String GMS_SUW_PACKAGE = "com.google.android.setupwizard"; + private SetupWizardUtils(){} public static SharedPreferences getPrefs(Context context) { @@ -166,15 +169,14 @@ public class SetupWizardUtils { } public static boolean hasGMS(Context context) { - if (PackageManagerUtils - .isAppInstalled(context, "com.google.android.gms")) { + if (PackageManagerUtils.isAppInstalled(context, GMS_PACKAGE) && + PackageManagerUtils.isAppInstalled(context, GMS_SUW_PACKAGE)) { PackageManager packageManager = context.getPackageManager(); if (LOGV) { - Log.v(TAG, "com.google.android.setupwizard state =" + packageManager - .getApplicationEnabledSetting("com.google.android.setupwizard")); + Log.v(TAG, GMS_SUW_PACKAGE + " state = " + + packageManager.getApplicationEnabledSetting(GMS_SUW_PACKAGE)); } - return packageManager - .getApplicationEnabledSetting("com.google.android.setupwizard") != + return packageManager.getApplicationEnabledSetting(GMS_SUW_PACKAGE) != COMPONENT_ENABLED_STATE_DISABLED; } return false;