Squashed 'LYNQ_PUBLIC/' changes from 994e41a76..f3dd8cbdf

f3dd8cbdf [Feature][ZK-92] ftp gpslog to soc with syslog
8bb9992d3 [Feature][API-1508] in NMEA-statement for ZK ,transfer BD to GB
17579bbfa [BugFix][API-1564]fix File descriptor leakage
9c8bb35ff Merge "[Bugfix][API-1561][mtklog]  support mtk log slim fota upgrade"
926d2ad75 [Bugfix][API-1561][mtklog]  support mtk log slim fota upgrade
4bcc14334 Merge "[Bugfix][ZK-78][FOTA]get process and upgrade status error when start fota up status"
610236b60 [Bugfix][ZK-78][FOTA]get process and upgrade status error when start fota up status
f700d98cb Merge "[Bugfix][API-1473][mdlog] lynq_query_registration_state type Voice  lac cid error"
0c874421d [Feature][T8TSK-320]Print the reason for the PDN when disconnected by the modem into the syslog
dac13540e Merge "[Feature][API-1406][API-1113]Adjust SEND_SMS timeout"
31850f3e5 Merge "[Feature][API-1557] FIX libvendor-ril can`t connected RILD issue"
d3a8f5da1 [Feature][API-1557] FIX libvendor-ril can`t connected RILD issue
2f4c07922 Merge "[Feature][T8TSK-316][rtp] rtp confirm to the standard of Geely"
1ee60ec01 Merge "[Bugfix][API-1551[network]  lynq_set_vlan_info, vlan_info is "", ret 8004"
98beaeaf3 Merge "[Bugfix][API-1534]After turning on the USB port, delay for 3 seconds to make a  call"
786e97304 [Feature][T8TSK-289] missing wom when add telephonyware to LYNQ_PUBLIC repo 0
d25d37156 [Bugfix][API-1534]After turning on the USB port, delay for 3 seconds to make a  call
4157623f6 [Feature][T8TSK-316][rtp] rtp confirm to the standard of Geely
c66c73d5d [Bugfix][API-1551[network]  lynq_set_vlan_info, vlan_info is "", ret 8004
4bf2e2e0b [Feature][API-1406][API-1113]Adjust SEND_SMS timeout
4b1c33121 [Bugfix][API-1473][mdlog] lynq_query_registration_state type Voice  lac cid error

git-subtree-dir: LYNQ_PUBLIC
git-subtree-split: f3dd8cbdf17f75f5c9672368b59c1cd59194fce6

Change-Id: Ie206616813b8064220450958d9f91e5048c08ac2
diff --git a/IC_src/mtk/lib/liblynq-fota/rock_ua/rock_ua.c b/IC_src/mtk/lib/liblynq-fota/rock_ua/rock_ua.c
index d510633..8fae757 100755
--- a/IC_src/mtk/lib/liblynq-fota/rock_ua/rock_ua.c
+++ b/IC_src/mtk/lib/liblynq-fota/rock_ua/rock_ua.c
@@ -289,10 +289,9 @@
         RLOGD("+[UA]: save_fota_status: Error opening metadata file: %s\n",strerror(errno));
         return -err;
     }
-    
+
     write(fd_fota_status, &fota_status,sizeof(fota_status));
     sync();
-    
     close(fd_fota_status);
 }
 
@@ -876,6 +875,10 @@
     }
     close(fd);
 //xf.li@20230830 add for ab_recover end
+    memset(&fota_status,0,sizeof(fota_status));
+    fota_status.ota_run = 1;
+    save_fota_status();
+
     hw_module = &HAL_MODULE_INFO_SYM;
 
     if (!hw_module ||
@@ -907,7 +910,6 @@
     RLOGD("Booting slot = %d, : isSlotMarkedSuccessful= %d\n",current_slot,is_successful);
 
 
-
     memset(&ctx, 0, sizeof(ctx));
     ctx.rom_base = 0;
     ctx.ram_base =(unsigned char *)&ram_buffer[0];
@@ -927,8 +929,6 @@
         return E_ROCK_FOTA_ADDR;
     }
 
-
-    memset(&fota_status,0,sizeof(fota_status));
     RLOGD("+[UA]: up_info.ota_run = %d\n",up_info.ota_run);
 
 #if 0
@@ -937,7 +937,6 @@
         up_info.ota_run = 0;
     }    
 #endif 
-
     up_info.ota_run = 0;
     if(backup_mode == 1)
     {
@@ -1099,14 +1098,13 @@
                 fd_write = fd_partition_b;
             }
 
-            fota_status.ota_run = i;
+            fota_status.ota_run = i+1;
             fota_status.update_status[i].check_delta = WAIT;
             fota_status.update_status[i].check_rom = WAIT;
             fota_status.update_status[i].update_result= WAIT;
 
             save_fota_status();
-        
-        
+
             up_info.ota_run = i+1;
             save_fota_info();
 
@@ -1173,8 +1171,7 @@
 
         now_patch = 0;
         up_info.ota_run = 0;
-        
-        memset(&fota_status,0,sizeof(fota_status));
+
         fota_status.switch_slot = WAIT;
         save_fota_status();
         
diff --git a/IC_src/mtk/lib/liblynq-gnss/include/lynq_gnss.h b/IC_src/mtk/lib/liblynq-gnss/include/lynq_gnss.h
index fac71b0..ea02c2e 100755
--- a/IC_src/mtk/lib/liblynq-gnss/include/lynq_gnss.h
+++ b/IC_src/mtk/lib/liblynq-gnss/include/lynq_gnss.h
@@ -110,7 +110,9 @@
 int lynq_gnss_epo_switch(LYNQ_CONF_SWITCH switch_op);

 

 int lynq_gnss_output_frequency_set(int frequency);

-

+#ifdef GNSS_BD_TRANSFORM_GB

+int lynq_gnss_bd_transform_enable(int flag);

+#endif

 int lynq_agps_set_enabled(LYNQ_CONF_SWITCH agps_status);

 

 int lynq_agps_get_enabled_status(int *status);

diff --git a/IC_src/mtk/lib/liblynq-gnss/makefile b/IC_src/mtk/lib/liblynq-gnss/makefile
index 1d21aef..66084e0 100755
--- a/IC_src/mtk/lib/liblynq-gnss/makefile
+++ b/IC_src/mtk/lib/liblynq-gnss/makefile
@@ -50,6 +50,10 @@
     LOCAL_CFLAGS += -DGNSS_CN_OUTPUT_SYSLOG

 endif

 

+ifeq ($(strip $(MOBILETEK_GNSS_BD_TRANSFORM_GB)), yes)

+    LOCAL_CFLAGS += -DGNSS_BD_TRANSFORM_GB

+endif

+

 

 

 $(warning libs=$(LOCAL_LIBS))

diff --git a/IC_src/mtk/lib/liblynq-gnss/src/lynq_callback.c b/IC_src/mtk/lib/liblynq-gnss/src/lynq_callback.c
index 51dd989..e0102a3 100755
--- a/IC_src/mtk/lib/liblynq-gnss/src/lynq_callback.c
+++ b/IC_src/mtk/lib/liblynq-gnss/src/lynq_callback.c
@@ -25,7 +25,8 @@
 #define NMEA_GGA "GGA"

 #define NMEA_VTG "VTG"

 #define NMEA_GSV "GSV"

-

+#define NMEA_BD "BD"

+#define NMEA_GB "GB"

 time_t reopen_start;

 extern lynq_gnss_cb* lynq_callbacks;

 extern lynq_raw_gnss_cbs *lynq_meas_callbacks;

@@ -75,6 +76,9 @@
 int count = 0;

 int nmea_count = 0;

 #endif

+#ifdef GNSS_BD_TRANSFORM_GB

+extern int BD_transform_GB_flag;

+#endif

 

 static inline int update_systime_time(GpsUtcTime gpstime)

 {

@@ -135,6 +139,22 @@
     }

 }

 #endif

+#ifdef GNSS_BD_TRANSFORM_GB

+void BD_transform_GB(char *str)

+{

+    int i;

+    int result;

+

+    strncpy(str + 1, NMEA_GB,strlen(NMEA_GB));

+    result = str[1];

+    for(i = 2; str[i] != '*'; i++)

+    {

+        result ^= str[i];

+    }

+    sprintf(str+i+1,"%02X",result);

+    return;

+}

+#endif

 

 void lynq_gps_nmea_callback(GpsUtcTime timestamp, const char* nmea, int length)

 {

@@ -191,6 +211,15 @@
         }

     }

 #endif

+#ifdef GNSS_BD_TRANSFORM_GB

+    char str[128];

+    if(BD_transform_GB_flag == 1 && strncmp(nmea + 1, NMEA_BD,strlen(NMEA_BD)) == 0)

+    {

+        strncpy(str,nmea,strlen(nmea));

+        BD_transform_GB(str);

+        nmea = str;

+    }

+#endif

 #ifdef GNSS_ELT_OUTPUT_CFG

     if(Open_ELT)

     {

diff --git a/IC_src/mtk/lib/liblynq-gnss/src/lynq_gnss.c b/IC_src/mtk/lib/liblynq-gnss/src/lynq_gnss.c
index 053a2fd..c6ad803 100755
--- a/IC_src/mtk/lib/liblynq-gnss/src/lynq_gnss.c
+++ b/IC_src/mtk/lib/liblynq-gnss/src/lynq_gnss.c
@@ -398,6 +398,15 @@
     return 0;

 }

 

+#ifdef GNSS_BD_TRANSFORM_GB

+int BD_transform_GB_flag = 0;

+int lynq_gnss_bd_transform_enable(int flag)

+{

+    BD_transform_GB_flag = flag;

+    return 0;

+}

+#endif

+

 lynq_atsvc_outcb atsvc_gnss_outcb;

 void atsvc_incb_entity(const char *input,const int length);

 int lynq_at_cgps(int at_type,char *at_paramter);

diff --git a/IC_src/mtk/lib/liblynq-wifi6/libwifi6.c b/IC_src/mtk/lib/liblynq-wifi6/libwifi6.c
index 60c4224..dbc9ef1 100755
--- a/IC_src/mtk/lib/liblynq-wifi6/libwifi6.c
+++ b/IC_src/mtk/lib/liblynq-wifi6/libwifi6.c
@@ -214,7 +214,7 @@
 
 static void notify_service_invoke_fail(int error)
 {
-    struct local_wpa_ctrl *lynq_wpa_ctrl = NULL;
+    struct wpa_ctrl *lynq_wpa_ctrl = NULL;
     pthread_mutex_lock(&s_global_check_mutex);
     if (error == -2) //timeout
     {
@@ -232,15 +232,19 @@
         {
             s_service_invoke_timeout_cnt = FAKE_MAX_INT_VALUE;
             pthread_cond_signal(&s_global_check_cond);
-        }
-        wpa_ctrl_close(lynq_wpa_ctrl);
+        }else
+         {
+            wpa_ctrl_close(lynq_wpa_ctrl);
+         }
         lynq_wpa_ctrl = wpa_ctrl_open(CTRL_PATH[1]);
         if (lynq_wpa_ctrl == NULL)
         {
             s_service_invoke_timeout_cnt = FAKE_MAX_INT_VALUE;
             pthread_cond_signal(&s_global_check_cond);
+        }else
+        {
+            wpa_ctrl_close(lynq_wpa_ctrl);
         }
-        wpa_ctrl_close(lynq_wpa_ctrl);
     }
 
     pthread_mutex_unlock(&s_global_check_mutex);
@@ -1582,18 +1586,31 @@
         pthread_join(g_sta_watcher_pid, NULL);
     if (g_sta_auto_watcher_pid != 0)
         pthread_join(g_sta_auto_watcher_pid, NULL);
-    if (g_lynq_wpa_ctrl[0] != NULL)
-        wpa_ctrl_close(g_lynq_wpa_ctrl[0]);
-    if (g_lynq_wpa_ctrl[1] != NULL)
-        wpa_ctrl_close(g_lynq_wpa_ctrl[1]);
+    if ( g_lynq_wpa_ctrl[0] != NULL)
+    {
+        if(g_lynq_wpa_ctrl[0]->ctrl != NULL)
+        {
+             wpa_ctrl_close(g_lynq_wpa_ctrl[0]->ctrl);
+        }
+        free(g_lynq_wpa_ctrl[0]);
+        g_lynq_wpa_ctrl[0] = NULL;
+    }
+
+    if ( g_lynq_wpa_ctrl[1] != NULL )
+    {
+        if( g_lynq_wpa_ctrl[1]->ctrl != NULL )
+        {
+            wpa_ctrl_close(g_lynq_wpa_ctrl[1]->ctrl);
+        }
+        free(g_lynq_wpa_ctrl[1]);
+        g_lynq_wpa_ctrl[1] = NULL;
+    }
     if (g_ap_tmp_watcher_pid != 0)
         pthread_join(g_ap_tmp_watcher_pid, NULL);
     g_ap_watcher_pid = 0;
     g_sta_watcher_pid = 0;
     g_sta_auto_watcher_pid = 0;
 //    g_ap_tmp_watcher_pid = 0;
-    g_lynq_wpa_ctrl[0] = NULL;
-    g_lynq_wpa_ctrl[1] = NULL;
     g_history_disconnect_valid_num = 0;   //clean history_disconenct_list info
     system("systemctl stop wg870_drv_insmod.service");
     pthread_mutex_unlock(&s_check_wpa_ctrl_mutex);