Squashed 'LYNQ_PUBLIC/' changes from f6dab8fc7..b3e00b1a6

b3e00b1a6 [Bugfix][API-1545][AUTOSUSPEND] sync system time to rtc once when systemtime is after rtc

git-subtree-dir: LYNQ_PUBLIC
git-subtree-split: b3e00b1a6700a23fd79042e76ffd75f0b879cd92
Change-Id: I9c18f9a3c3ea02842fe24633905ff34a328a6e84
diff --git a/IC_meta/mtk/2735/suspend-service/files/autosuspend_wakeup_count.c b/IC_meta/mtk/2735/suspend-service/files/autosuspend_wakeup_count.c
index 9720e5d..76c9a86 100755
--- a/IC_meta/mtk/2735/suspend-service/files/autosuspend_wakeup_count.c
+++ b/IC_meta/mtk/2735/suspend-service/files/autosuspend_wakeup_count.c
@@ -75,6 +75,7 @@
 
 static long start_time;  // 出错点:time_info_t 结构体两个成员都是long,因此这两个变量必须是long型,不能定义成int
 static long end_time; 
+static int systemtime_sync_flag = 0;
 
 
 # define TEMP_FAILURE_RETRY(expression) \
@@ -253,6 +254,16 @@
         return -1;
     }
 
+    if (systemtime_sync_flag == 0)
+    {
+        ALOGI("suspend_ctrl need sync time to rtc\n");
+        if (system("timedatectl status | grep -E \"Universal time|RTC time\" | awk -F\": \" '{print \"date -d \\\"\"$2\"\\\" +%s\"}' | sh | tr '\n' ' ' | awk '{print \"[ \"$1\" -gt \"$2 \" ] && hwclock -w\"}' | sh") == 0)
+        {
+            ALOGI("suspend_ctrl sync time to rtc success\n");
+            systemtime_sync_flag = 1;
+        }
+    }
+
     system("echo \"autosuspend:Sys seek\" >/dev/console");
 
     RLOGD("suspend_ctrl: start write reg_netsys\n");