From fe7ac15220a85795164ce846ecf4cb546ce38121 Mon Sep 17 00:00:00 2001 From: Adnan Begovic Date: Thu, 14 Apr 2016 12:53:15 -0700 Subject: [PATCH] SetupWizard: Don't reprompt setup if account already exists. If a user goes through the gms flow, logging in, disabling backup, getting kicked over to restore, and deciding to set the device up as new, the existing logic would reprompt since the flow causes the load action to happen again. Now check for account existance, and skip the setup if true. Change-Id: I3502294d54fcb4e202dca37ff7c6165da4401808 TICKET: CYNGNOS-2459 --- .../setupwizard/setup/GmsAccountPage.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java b/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java index 9bcce42..1be40da 100644 --- a/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java @@ -100,12 +100,34 @@ public class GmsAccountPage extends SetupPage { getCallbacks().onPreviousPage(); } else { super.doLoadAction(fragmentManager, action); - launchGmsAccountSetup(); + if (!SetupWizardUtils.accountExists(mContext, SetupWizardApp.ACCOUNT_TYPE_GMS)) { + launchGmsAccountSetup(); + } else { + // This can happen if the user goes from setup -> restore, but chooses to set + // their device up as "new". Thus we need to not re-prompt this entire flow, + // skip ahead. CYNGNOS-2459 + if (SetupWizardApp.DEBUG) { + Log.d(TAG, "Google account already setup, skip gms setup"); + } + setHidden(true); + getCallbacks().onNextPage(); + } } } @Override public boolean onActivityResult(int requestCode, int resultCode, Intent data) { + if (SetupWizardApp.DEBUG) { + Log.d(TAG, "Received activity result from requestCode " + requestCode + + " with a resultCode of " + resultCode); + if (data != null) { + Bundle extras = data.getExtras(); + Log.d(TAG, "Within the activity result there were extras:"); + for (String extra : extras.keySet()) { + Log.d(TAG, "The key " + extra + " has a value of " + extras.get(extra)); + } + } + } if (requestCode == SetupWizardApp.REQUEST_CODE_SETUP_GMS && data != null) { if (SetupWizardUtils.isOwner() && resultCode == Activity.RESULT_OK) { @@ -170,6 +192,9 @@ public class GmsAccountPage extends SetupPage { } private void launchGmsRestorePage(boolean restorePicker) { + if (SetupWizardApp.DEBUG) { + Log.d(TAG, "Launching gms restore page with restorePicker " + restorePicker); + } try { // GMS can disable this after logging in sometimes if (SetupWizardUtils.enableGMSSetupWizard(mContext)) { @@ -219,6 +244,9 @@ public class GmsAccountPage extends SetupPage { } private void launchGmsAccountSetup() { + if (SetupWizardApp.DEBUG) { + Log.d(TAG, "Launching gms account page"); + } Bundle bundle = new Bundle(); bundle.putBoolean(SetupWizardApp.EXTRA_FIRST_RUN, true); bundle.putBoolean(SetupWizardApp.EXTRA_ALLOW_SKIP, true);