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

Commit 63a54165 authored by Adnan Begovic's avatar Adnan Begovic
Browse files

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
(cherry picked from commit fe7ac152)
parent 4ef90086
Loading
Loading
Loading
Loading
+29 −1
Original line number Original line Diff line number Diff line
@@ -100,12 +100,34 @@ public class GmsAccountPage extends SetupPage {
            getCallbacks().onPreviousPage();
            getCallbacks().onPreviousPage();
        } else {
        } else {
            super.doLoadAction(fragmentManager, action);
            super.doLoadAction(fragmentManager, action);
            if (!SetupWizardUtils.accountExists(mContext, SetupWizardApp.ACCOUNT_TYPE_GMS)) {
                launchGmsAccountSetup();
                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
    @Override
    public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
    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 (requestCode == SetupWizardApp.REQUEST_CODE_SETUP_GMS && data != null) {
            if (SetupWizardUtils.isOwner() && resultCode == Activity.RESULT_OK) {
            if (SetupWizardUtils.isOwner() && resultCode == Activity.RESULT_OK) {


@@ -170,6 +192,9 @@ public class GmsAccountPage extends SetupPage {
    }
    }


    private void launchGmsRestorePage(boolean restorePicker) {
    private void launchGmsRestorePage(boolean restorePicker) {
        if (SetupWizardApp.DEBUG) {
            Log.d(TAG, "Launching gms restore page with restorePicker " + restorePicker);
        }
        try {
        try {
            // GMS can disable this after logging in sometimes
            // GMS can disable this after logging in sometimes
            if (SetupWizardUtils.enableGMSSetupWizard(mContext)) {
            if (SetupWizardUtils.enableGMSSetupWizard(mContext)) {
@@ -219,6 +244,9 @@ public class GmsAccountPage extends SetupPage {
    }
    }


    private void launchGmsAccountSetup() {
    private void launchGmsAccountSetup() {
        if (SetupWizardApp.DEBUG) {
            Log.d(TAG, "Launching gms account page");
        }
        Bundle bundle = new Bundle();
        Bundle bundle = new Bundle();
        bundle.putBoolean(SetupWizardApp.EXTRA_FIRST_RUN, true);
        bundle.putBoolean(SetupWizardApp.EXTRA_FIRST_RUN, true);
        bundle.putBoolean(SetupWizardApp.EXTRA_ALLOW_SKIP, true);
        bundle.putBoolean(SetupWizardApp.EXTRA_ALLOW_SKIP, true);