Merge "[Bugfix][T106BUG-628] fix rtc idx error"
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 a50e87e..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"
+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 4f0fcc7..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
@@ -27,7 +27,8 @@
 

 #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"

@@ -42,6 +43,8 @@
 #define BOOTABLE   "45227"

 #define UNBOOTABLE "47806"

 

+#define FOTA_WAKELOCK_NAME "FOTA_WAKELOCK"

+

 

 #define    LYNQ_UPGRADE_STATUS_VERIFING            (0)

 #define    LYNQ_UPGRADE_STATUS_VERIFY_SUCCESS      (1)

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

 int upgrade_size = 0;

 

+

 typedef struct

 {

     int system;

@@ -137,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)

@@ -182,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)

@@ -206,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)

         {

@@ -223,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)

         {

@@ -443,17 +475,33 @@
 int lynq_fota_nrestart(void)

 {

     int ret = 0;

+    int tmp = 0;

+    int lock_fd = 0;

+    lock_fd = qser_wakelock_create(FOTA_WAKELOCK_NAME, strlen(FOTA_WAKELOCK_NAME));

+    if(lock_fd < 0)

+    {

+        LYERRLOG("Create fota wakelock failed %d",lock_fd);

+    }

+

+    qser_wakelock_lock(lock_fd);

     ret = rock_update_main(0);

     if(ret != 0)

     {

-         LYINFLOG("Upgrade failed !!!!");

-         return -1;

+        LYINFLOG("Upgrade failed !!!!");

     }

     else

     {

         LYINFLOG("upgrade success!!!");

     }

-    return 0;

+

+    qser_wakelock_unlock(lock_fd);

+    tmp = qser_wakelock_destroy(lock_fd);

+    if(tmp < 0)

+    {

+        LYERRLOG("Destroy fota wakelock failed");

+    }

+    

+    return ret;

 }

 

 /*****************************************

@@ -474,13 +522,30 @@
     }

     

     int ret = 0;

+    int lock_fd = 0;

+    int tmp = 0;

+    lock_fd = qser_wakelock_create(FOTA_WAKELOCK_NAME, strlen(FOTA_WAKELOCK_NAME));

+    if(lock_fd < 0)

+    {

+        LYERRLOG("Create fota wakelock failed %d",lock_fd);

+    }

+

+    qser_wakelock_lock(lock_fd);

+

     ret = rock_update_main(1);

     LYINFLOG("rock_update_main ret = %d\n", ret);

     if(ret != 0)

     {

         LYINFLOG("fota update fail!\n");

     }

-    return 0;

+

+    qser_wakelock_unlock(lock_fd);

+    tmp = qser_wakelock_destroy(lock_fd);

+    if(tmp < 0)

+    {

+        LYERRLOG("Destroy fota wakelock failed");

+    }

+    return ret;

 

 }

 

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/makefile b/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/makefile
index 632441c..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 := \

@@ -40,7 +41,8 @@
     -lnvram \

     -lflags \

     -lzxiclzma \

-

+    -llynq-qser-autosuspend \

+    -ldebug_info \

 

 SOURCES = $(wildcard *.cpp)

 

diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/power_4line/hal_xp2xp.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/power_4line/hal_xp2xp.c
index c0b745f..08f1dee 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/power_4line/hal_xp2xp.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/power_4line/hal_xp2xp.c
@@ -359,7 +359,7 @@
 			}

 			

 		}

-        msleep(40);

+        msleep(1000);

         wakeup_irq_occurs = 1;

         wake_up_interruptible(&wakeup_dtr_wqhead);

 		enable_irq(xp2xp_dev->eint_irq);