[Bugfix][T106BUG-647] Add a sleep lock during the fota process and unlock it after the upgrade is completed
Only Configure:No
Affected branch:master
Affected module:fota
Is it affected on both ZXIC and MTK: ZXIC
Self-test: Yes
Doc Update: No
Change-Id: I836f5d436abd1f4029e13b0793f0791635464a4d
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..d401000 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,7 +5,7 @@
#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"
#inherit workonsrc
WORKONSRC = "${TOPDIR}/../src/lynq/lib/liblynq-qser-fota/"
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..1c0ae3a 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,6 +27,7 @@
#include "include/lynq-qser-fota.h"
#include "liblog/lynq_deflog.h"
+#include "include/lynq-qser-autosuspend.h"
#define FOTA_REBOOT_FLAG "/mnt/userdata/.fota_reboot_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)
@@ -443,17 +446,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 +493,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..8f823e9 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/makefile
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/makefile
@@ -40,7 +40,7 @@
-lnvram \
-lflags \
-lzxiclzma \
-
+ -llynq-qser-autosuspend \
SOURCES = $(wildcard *.cpp)