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
This commit is contained in:
Harry Youd
2017-02-22 14:05:30 +00:00
parent 3ecb352c17
commit 63aaa30ba1

View File

@@ -73,6 +73,9 @@ public class SetupWizardUtils {
private static final String TAG = SetupWizardUtils.class.getSimpleName(); 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(){} private SetupWizardUtils(){}
public static SharedPreferences getPrefs(Context context) { public static SharedPreferences getPrefs(Context context) {
@@ -166,15 +169,14 @@ public class SetupWizardUtils {
} }
public static boolean hasGMS(Context context) { public static boolean hasGMS(Context context) {
if (PackageManagerUtils if (PackageManagerUtils.isAppInstalled(context, GMS_PACKAGE) &&
.isAppInstalled(context, "com.google.android.gms")) { PackageManagerUtils.isAppInstalled(context, GMS_SUW_PACKAGE)) {
PackageManager packageManager = context.getPackageManager(); PackageManager packageManager = context.getPackageManager();
if (LOGV) { if (LOGV) {
Log.v(TAG, "com.google.android.setupwizard state =" + packageManager Log.v(TAG, GMS_SUW_PACKAGE + " state = " +
.getApplicationEnabledSetting("com.google.android.setupwizard")); packageManager.getApplicationEnabledSetting(GMS_SUW_PACKAGE));
} }
return packageManager return packageManager.getApplicationEnabledSetting(GMS_SUW_PACKAGE) !=
.getApplicationEnabledSetting("com.google.android.setupwizard") !=
COMPONENT_ENABLED_STATE_DISABLED; COMPONENT_ENABLED_STATE_DISABLED;
} }
return false; return false;