[bugfix][T108][bug-view-1120/1161] ota maybe block if repeat upgrade no reboot and get current system faild

Only Configure: No
Affected branch:LYNQ_SDK_ASR_T108_V05.04.01.00
Affected module: fota
Is it affected on IC: only ASR
Self-test: yes
Doc Update: no

Change-Id: I7e5de43bf03aec9188c1891e9482895de9765007
diff --git a/mbtk/libql_lib_v2_rilv2/ql_absys_api.c b/mbtk/libql_lib_v2_rilv2/ql_absys_api.c
index 5d0b253..6ef07d8 100755
--- a/mbtk/libql_lib_v2_rilv2/ql_absys_api.c
+++ b/mbtk/libql_lib_v2_rilv2/ql_absys_api.c
@@ -10,24 +10,32 @@
 
 int ql_absys_get_cur_active_part(absystem_t *cur_system)
 {
-    int active;
 
-    active = mbtk_fota_get_active_absys_type();
-    if (active == 0)
+    FILE *file = NULL;
+    char cmdline[1024] = {0}; 
+    
+    file = fopen("/proc/cmdline", "r");
+    if(file == NULL)
     {
-        *cur_system = SYSTEM_A;
-    }
-    else if (active == 1)
-    {
-        *cur_system = SYSTEM_B;
-    }
-    else
-    {
-        LOGE("ql_absys_get_cur_active_part fail");
-        return -1;
+        LOGE("Failed to open /proc/cmdline");
+        return -1; 
     }
 
+    if(fgets(cmdline, sizeof(cmdline), file) != NULL)
+    {
+        if(strstr(cmdline, "system=a") != NULL) 
+        {
+            *cur_system = SYSTEM_A;
+        }
+        else
+        {
+            *cur_system = SYSTEM_B;
+        }
+    }
+
+    fclose(file); 
     return 0;
+
 }
 
 int ql_absys_switch(void)
diff --git a/mbtk/libql_lib_v2_rilv2/ql_fota_api.c b/mbtk/libql_lib_v2_rilv2/ql_fota_api.c
index 9b833da..3dac4c9 100755
--- a/mbtk/libql_lib_v2_rilv2/ql_fota_api.c
+++ b/mbtk/libql_lib_v2_rilv2/ql_fota_api.c
@@ -16,6 +16,7 @@
 
 #define StatFunc(x,y) stat(x,y)
 
+static int s_ota_flag = -1;
 int funstat(  char *filename)
 {
     int ret = 0;
@@ -52,11 +53,18 @@
     int ret = 0;
     int len = 0;
 
-    ret = mbtk_fota_init(ql_fota_cb);
-    if (ret)
+    if(s_ota_flag == -1)
     {
-        LOGE("ql_abfota_start_update init fail");
-        return -1;
+        ret = mbtk_fota_init(ql_fota_cb);
+        if (ret)
+        {
+            LOGE("ql_abfota_start_update init fail");
+            return -1;
+        }
+        else
+        {
+            s_ota_flag = 0;
+        }
     }
 
     memset(addr_buf, 0, sizeof(addr_buf));