From c56c8c99e9e078dccf43c2251c3a94cf477f2812 Mon Sep 17 00:00:00 2001 From: Russell Brenner Date: Wed, 4 Jun 2014 14:31:42 -0700 Subject: [PATCH] Don't advance when recreating from bundle The fragment is recreated from a bundle when returning from finished activities, like the OTA and walled garden checks. Telling WizardManager to advance to the next screen causes a duplicate activity because WizardManager has already responded to the other finished activity. Bug: 15393012 Change-Id: I9817e106a0b243b3943bff6edafc228e9e002232 --- .../settings/wifi/WifiSettingsForSetupWizard.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/wifi/WifiSettingsForSetupWizard.java b/src/com/android/settings/wifi/WifiSettingsForSetupWizard.java index 25b12b94954..17fca9f84e8 100644 --- a/src/com/android/settings/wifi/WifiSettingsForSetupWizard.java +++ b/src/com/android/settings/wifi/WifiSettingsForSetupWizard.java @@ -104,6 +104,7 @@ public class WifiSettingsForSetupWizard extends WifiSettings { WifiManager.EXTRA_NETWORK_INFO); changeNextButtonState(info.isConnected()); if (mAutoFinishOnConnection && info.isConnected()) { + Log.d(TAG, "mReceiver.onReceive context=" + context + " intent=" + intent); finishOrNext(Activity.RESULT_OK); } } @@ -202,7 +203,12 @@ public class WifiSettingsForSetupWizard extends WifiSettings { // first if we're supposed to finish once we have a connection mAutoFinishOnConnection = intent.getBooleanExtra(EXTRA_AUTO_FINISH_ON_CONNECT, false); - if (mAutoFinishOnConnection) { + /* + * When entering with a savedInstanceState, we may be returning from a later activity in the + * setup flow. It's not clear yet if there are other possible circumstances. It's not + * appropriate to refire our activity results, so we skip that here. + */ + if (mAutoFinishOnConnection && null == savedInstanceState) { // Hide the next button if (hasNextButton()) { getNextButton().setVisibility(View.GONE); @@ -212,6 +218,7 @@ public class WifiSettingsForSetupWizard extends WifiSettings { activity.getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity != null && connectivity.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected()) { + Log.d(TAG, "onActivityCreated Auto-finishing"); finishOrNext(Activity.RESULT_OK); return; }