Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63aaa30b authored by Harry Youd's avatar Harry Youd
Browse files

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
parent 3ecb352c
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -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;