support reinjecting supl url for sim hot swap

modem might reset during sim hot swap, in which case
the prior supl url shall be remembered so that can be
reinjected. This change enables it.

Bug: 17288144

Change-Id: I86ec898a54bc8706720c29a1ea67ce27153ee981
diff --git a/loc_api/libloc_api_50001/loc_eng.cpp b/loc_api/libloc_api_50001/loc_eng.cpp
index d6e64df..8bbf8be 100644
--- a/loc_api/libloc_api_50001/loc_eng.cpp
+++ b/loc_api/libloc_api_50001/loc_eng.cpp
@@ -2443,29 +2443,29 @@
     ENTRY_LOG_CALLFLOW();
     int ret_val = 0;
 
+    LOC_LOGV("save the address, type: %d, hostname: %s, port: %d",
+             (int) type, hostname, port);
+    switch (type)
+    {
+    case LOC_AGPS_SUPL_SERVER:
+        strlcpy(loc_eng_data.supl_host_buf, hostname,
+                sizeof(loc_eng_data.supl_host_buf));
+        loc_eng_data.supl_port_buf = port;
+        loc_eng_data.supl_host_set = 1;
+        break;
+    case LOC_AGPS_CDMA_PDE_SERVER:
+        strlcpy(loc_eng_data.c2k_host_buf, hostname,
+                sizeof(loc_eng_data.c2k_host_buf));
+        loc_eng_data.c2k_port_buf = port;
+        loc_eng_data.c2k_host_set = 1;
+        break;
+    default:
+        LOC_LOGE("loc_eng_set_server_proxy, unknown server type = %d", (int) type);
+    }
+
     if (NULL != loc_eng_data.adapter)
     {
         ret_val = loc_eng_set_server(loc_eng_data, type, hostname, port);
-    } else {
-        LOC_LOGW("set_server called before init. save the address, type: %d, hostname: %s, port: %d",
-                 (int) type, hostname, port);
-        switch (type)
-        {
-        case LOC_AGPS_SUPL_SERVER:
-            strlcpy(loc_eng_data.supl_host_buf, hostname,
-                    sizeof(loc_eng_data.supl_host_buf));
-            loc_eng_data.supl_port_buf = port;
-            loc_eng_data.supl_host_set = 1;
-            break;
-        case LOC_AGPS_CDMA_PDE_SERVER:
-            strlcpy(loc_eng_data.c2k_host_buf, hostname,
-                    sizeof(loc_eng_data.c2k_host_buf));
-            loc_eng_data.c2k_port_buf = port;
-            loc_eng_data.c2k_host_set = 1;
-            break;
-        default:
-            LOC_LOGE("loc_eng_set_server_proxy, unknown server type = %d", (int) type);
-        }
     }
 
     EXIT_LOG(%d, ret_val);