Merge "[Bugfix][T106BUG-654][MONITOR]Unable to trigger callback when SDK and ping exceptions occur"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-fota/liblynq-qser-fota.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-fota/liblynq-qser-fota.bb
index d401000..34b067d 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-fota/liblynq-qser-fota.bb
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-fota/liblynq-qser-fota.bb
@@ -5,10 +5,11 @@
 #LICENSE = "Mobiletek""
 LICENSE = "CLOSED"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
-DEPENDS += "bootchart  liblynq-log libupi-ab openssl libflags liblynq-qser-autosuspend"
+DEPENDS += "bootchart  liblynq-log libupi-ab openssl libflags liblynq-qser-autosuspend libdebug-info"
 
 #inherit workonsrc
 WORKONSRC = "${TOPDIR}/../src/lynq/lib/liblynq-qser-fota/"
+ZXIC_INC = "${TOPDIR}/../zxic_code/pub/include/infra/"
 
 FILESEXTRAPATHS_prepend :="${TOPDIR}/../src/lynq/lib/:"
 SRC_URI = " \
@@ -41,7 +42,7 @@
 
 #INHIBIT_PACKAGE_STRIP = "1"
 do_compile () {
-		oe_runmake all -C ${SRC-DIR} ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -Wl,--hash-style=gnu -DTELEPHONYWARE"
+		oe_runmake all -C ${SRC-DIR} ROOT=${STAGING_DIR_HOST} ZXIC_INCLUDE=${ZXIC_INC} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -Wl,--hash-style=gnu -DTELEPHONYWARE"
 }
 
 do_install () {
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/lynq-qser-fota.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/lynq-qser-fota.cpp
index 1c0ae3a..10f967a 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/lynq-qser-fota.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/lynq-qser-fota.cpp
@@ -28,7 +28,7 @@
 #include "include/lynq-qser-fota.h"

 #include "liblog/lynq_deflog.h"

 #include "include/lynq-qser-autosuspend.h"

-

+#include "pub_debug_info.h"

 

 #define FOTA_REBOOT_FLAG "/mnt/userdata/.fota_reboot_flag"

 #define FOTA_FLAG_FILE "/mnt/userdata/.back_up_flag"

@@ -67,6 +67,7 @@
 int total_size = 0;

 int upgrade_size = 0;

 

+

 typedef struct

 {

     int system;

@@ -140,6 +141,11 @@
     int current_slot = 0;

     int fota_sync_flag = 0;

     int reboot_flg = NO_REBOOT;

+    time_t startTime;

+    time_t endTime;

+    struct tm *localTime;

+    double elapsed = 0;

+

     FILE *fp = NULL;

     fp = fopen(FOTA_FLAG_FILE,"w+");

     if(fp == NULL)

@@ -185,15 +191,43 @@
         LYINFLOG("Verify package failed exit upgrade");

         return -1;

     }

-    

+

+    startTime = time(NULL);

+    if(startTime == (time_t)-1) 

+    {

+        LYERRLOG("Failed to get the current time.\n");

+    }

     

     LYINFLOG("-----Begin to upgrade ----");

     ret = lynq_fota_upgrade();

+    

+    endTime = time(NULL);

+    if(endTime == (time_t)-1) 

+    {

+        LYERRLOG("Failed to get the current time.\n");

+    }

+    elapsed = difftime(endTime, startTime);

+    localTime = localtime(&endTime);

     if(ret != 0)

     {

-        LYINFLOG("Fota upgrade failed!!!");

+        LYERRLOG("Upgrade failed");

+        ret =  sc_debug_info_record(MODULE_ID_CAP_FOTA,"failed,spendtime: %.2lf seconds,package size:%d,finished time %s", elapsed,total_size,asctime(localTime));

+        if(ret <= 0)

+        {

+            LYERRLOG("lynq_record_debug_info failed");

+        }

         return -1;

     }

+    else

+    {

+        LYINFLOG("Upgrade success");

+        ret =  sc_debug_info_record(MODULE_ID_CAP_FOTA,"success,spendtime: %.2lf seconds,package size:%d,finished time %s", elapsed,total_size,asctime(localTime));

+        if(ret <= 0)

+        {

+            LYERRLOG("lynq_record_debug_info failed");

+        }

+    }

+

 

     ret = lynq_get_upgrade_status();

     if(ret != LYNQ_UPGRADE_STATUS_UPDATE_SUCCESS)

@@ -209,12 +243,9 @@
         return -1;

     }

 

-    

     if(current_slot == atoi(SYSTEM_A))

     {

         LYINFLOG("current system is system a");

-

-        

         ret = lynq_set_boot_to_system((char *)SYSTEM_B);

         if(ret != 0)

         {

@@ -226,8 +257,6 @@
     else if( current_slot == atoi(SYSTEM_B))

     {

         LYINFLOG("current system is system a");

-

-        

         ret = lynq_set_boot_to_system((char *)SYSTEM_A);

         if(ret != 0)

         {

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/makefile b/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/makefile
index 8f823e9..e211f81 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/makefile
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/makefile
@@ -14,6 +14,7 @@
 LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1 -DHAVE_ENDIAN_H -DHAVE_PTHREADS -DHAVE_SYS_UIO_H -DHAVE_POSIX_FILEMAP -DHAVE_STRLCPY -DHAVE_PRCTL -DHAVE_MEMSET16 -DHAVE_MEMSET32 -DANDROID_SMP=0

 endif

 

+LOCAL_CFLAGS += -D_USE_ZXIC_DEBUG_INFO

 

 $(warning ################# rock ROOT: $(ROOT),includedir:$(includedir),)

 

@@ -27,7 +28,7 @@
   -I$(ROOT)$(includedir)/glib-2.0 \

   -I$(ROOT)$(libdir)/glib-2.0/include \

   -I$(ROOT)$(includedir)  \

-

+  -I$(ZXIC_INCLUDE) \

 

 

 LOCAL_LIBS := \

@@ -41,6 +42,7 @@
     -lflags \

     -lzxiclzma \

     -llynq-qser-autosuspend \

+    -ldebug_info \

 

 SOURCES = $(wildcard *.cpp)

 

diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libscrtc/sc_rtc_timer.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libscrtc/sc_rtc_timer.c
index 7130fa1..5e44885 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libscrtc/sc_rtc_timer.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libscrtc/sc_rtc_timer.c
@@ -508,6 +508,8 @@
 {

     int ret = -1;

 

+    sc_rtc_user_cb_t *rtc_cb_exist = NULL;

+

 	if (client_id <= 0)

 	{

 		SCLOGD("client_id is invalid.\n");

@@ -515,24 +517,36 @@
 	}

 

     ret = rtc_timer_del(rtc_id, client_id);

+    /* Started by AICoder, pid:j189fw1aabbb7d914c690841c092ac245366c5bb */

+    if(sc_rtc_cb.client_id == client_id)

+    {  

+       pthread_mutex_lock(&g_rtc_timer_mutex);

+       rtc_cb_exist = sc_rtc_timer_find_by_id(rtc_id);

+       if(!rtc_cb_exist)

+        {

+            SCLOGD("rtc timer with id:%d does not exist!\n",rtc_id);

+            pthread_mutex_unlock(&g_rtc_timer_mutex);

+            return -1;

+        }

+        sc_rtc_timer_free_by_id(rtc_id);

+        pthread_mutex_unlock(&g_rtc_timer_mutex);

+    }

+    else if(sc_rtc_cb.alarm_modid == client_id)

+    {  

+        pthread_mutex_lock(&g_rtc_poweroff_alarm_mutex);

+        rtc_cb_exist = sc_rtc_poweroff_alarm_find_by_id(rtc_id);

+        if(!rtc_cb_exist)

+        {

+            SCLOGD("rtc poweroff alarm with id:%d does not exist!\n",rtc_id);

+            pthread_mutex_unlock(&g_rtc_poweroff_alarm_mutex);

+            return -1;

+        }

+        sc_rtc_poweroff_alarm_free_by_id(rtc_id);

+        pthread_mutex_unlock(&g_rtc_poweroff_alarm_mutex);

+    }

+    /* Ended by AICoder, pid:j189fw1aabbb7d914c690841c092ac245366c5bb */

 

-	if(sc_rtc_cb.client_id == client_id)

-	{	

-	    pthread_mutex_lock(&g_rtc_timer_mutex);

 

-	    sc_rtc_timer_free_by_id(rtc_id);

-

-	    pthread_mutex_unlock(&g_rtc_timer_mutex);

-	}

-

-	if(sc_rtc_cb.alarm_modid == client_id)

-	{	

-	    pthread_mutex_lock(&g_rtc_poweroff_alarm_mutex);

-

-	    sc_rtc_poweroff_alarm_free_by_id(rtc_id);

-

-	    pthread_mutex_unlock(&g_rtc_poweroff_alarm_mutex);

-	}

     return ret;

 }