am 509868b1: Merge "NetworkSettings: Cannot dismiss progress dialog sometimes."

# By Bin Li
# Via Bin Li (1) and Gerrit Code Review (1)
* commit '509868b1644c98adc0ae630a26d32d039e588765':
  NetworkSettings: Cannot dismiss progress dialog sometimes.
diff --git a/src/com/android/phone/NetworkSetting.java b/src/com/android/phone/NetworkSetting.java
index ed606c4..5917795 100644
--- a/src/com/android/phone/NetworkSetting.java
+++ b/src/com/android/phone/NetworkSetting.java
@@ -106,8 +106,15 @@
                 case EVENT_AUTO_SELECT_DONE:
                     if (DBG) log("hideProgressPanel");
 
-                    if (mIsForeground) {
+                    // Always try to dismiss the dialog because activity may
+                    // be moved to background after dialog is shown.
+                    try {
                         dismissDialog(DIALOG_NETWORK_AUTO_SELECT);
+                    } catch (IllegalArgumentException e) {
+                        // "auto select" is always trigged in foreground, so "auto select" dialog
+                        //  should be shown when "auto select" is trigged. Should NOT get
+                        // this exception, and Log it.
+                        Log.w(LOG_TAG, "[NetworksList] Fail to dismiss auto select dialog", e);
                     }
                     getPreferenceScreen().setEnabled(true);
 
@@ -387,8 +394,16 @@
         // update the state of the preferences.
         if (DBG) log("hideProgressPanel");
 
-        if (mIsForeground) {
+
+        // Always try to dismiss the dialog because activity may
+        // be moved to background after dialog is shown.
+        try {
             dismissDialog(DIALOG_NETWORK_LIST_LOAD);
+        } catch (IllegalArgumentException e) {
+            // It's not a error in following scenario, we just ignore it.
+            // "Load list" dialog will not show, if NetworkQueryService is
+            // connected after this activity is moved to background.
+            if (DBG) log("Fail to dismiss network load list dialog");
         }
 
         getPreferenceScreen().setEnabled(true);