Merge "[feature][T8TSK][mdlog]change mdlog command in suspend service"
diff --git a/IC_meta/mtk/2735/lynq-sdk-ready/lynq-sdk-ready.bb b/IC_meta/mtk/2735/lynq-sdk-ready/lynq-sdk-ready.bb
index b6ebaf0..0d6b4c2 100755
--- a/IC_meta/mtk/2735/lynq-sdk-ready/lynq-sdk-ready.bb
+++ b/IC_meta/mtk/2735/lynq-sdk-ready/lynq-sdk-ready.bb
@@ -3,7 +3,7 @@
 DESCRIPTION = "lynq sdk ready"

 LICENSE = "CLOSED"

 LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"

-DEPENDS += "platform-libs liblynq-sim liblynq-uci"

+DEPENDS += "platform-libs liblynq-sim liblynq-uci liblynq-misc"

 inherit workonsrc

 WORKONSRC = "${TOPDIR}/../LYNQ_PUBLIC/common_src/framework/lynq-sdk-ready/src"

 

diff --git a/IC_src/mtk/lib/liblynq-misc/include/lynq_misc.h b/IC_src/mtk/lib/liblynq-misc/include/lynq_misc.h
index 4207191..3bf0202 100755
--- a/IC_src/mtk/lib/liblynq-misc/include/lynq_misc.h
+++ b/IC_src/mtk/lib/liblynq-misc/include/lynq_misc.h
@@ -21,7 +21,7 @@
  * @return 0 success, -1 some error occur

  */

 int lynq_get_security_boot_flag(int * enabled_flag);

-

+int lynq_get_reboot_reason(void);

 #ifdef __cplusplus

 }

 #endif 

diff --git a/IC_src/mtk/lib/liblynq-misc/lynq_misc.cpp b/IC_src/mtk/lib/liblynq-misc/lynq_misc.cpp
index 6e6fe8d..ee28293 100755
--- a/IC_src/mtk/lib/liblynq-misc/lynq_misc.cpp
+++ b/IC_src/mtk/lib/liblynq-misc/lynq_misc.cpp
@@ -1,4 +1,6 @@
 #include <stdio.h>

+#include <string.h>

+#include <stdlib.h>

 #include "lynq_misc.h"

 #include "log/log.h"

 

@@ -40,3 +42,62 @@
     *enabled_flag = (value & 0x8) == 0 ? 0 : 1;

     return 0;

 }

+

+

+

+int lynq_get_reboot_reason(void)

+{

+    FILE *fp;

+    int ret;

+    char buffer[8];

+    int flag[3];

+    char *token;

+    int i = 1;

+    fp = popen("cat /proc/aed/reboot-reason|sed -n '1p'|awk '{print $3, $6,$9}'","r");

+    fgets(buffer, sizeof(buffer), fp);

+    pclose(fp);

+    RLOGE("buffer is %s, size is %d\n", buffer, sizeof(buffer));

+    token = strtok(buffer, " ");

+    flag[0] = atoi(token);

+    while(i < 3)

+    {

+        token = strtok(NULL, " ");

+        flag[i] = atoi(token);

+        i++;

+    }

+    if(flag[0] == 0)

+    {

+        ret = system("cat /sys/fs/pstore/console-ramoops-0 > /dev/null");

+        if(ret == 0)

+        {

+            RLOGE("reboot reason is sysrst pin\n");

+            return 1;

+        }

+        else

+        {

+            RLOGE("reboot reason is power off\n");

+            return 0;

+        }

+    }

+    else if(flag[0] == 2)

+    {

+        if(flag[2] == 0)

+        {

+            RLOGE("reboot reason is soft nomal reboot\n");

+            return 2;

+        }

+        else

+        {

+            RLOGE("reboot reason is panic\n");

+            return 3;

+        }

+    }

+    else

+    {

+        RLOGE("reboot reason is other\n");

+        return 4;

+    }

+

+    return 0;

+

+}

diff --git a/common_src/framework/lynq-sdk-ready/src/makefile b/common_src/framework/lynq-sdk-ready/src/makefile
index 1030e02..8d433c8 100755
--- a/common_src/framework/lynq-sdk-ready/src/makefile
+++ b/common_src/framework/lynq-sdk-ready/src/makefile
@@ -36,6 +36,7 @@
     -lbinder \
     -lpthread \
     -llynq-uci \
+    -llynq-misc \
 
 LOCAL_SRC_FILES_CPP = $(wildcard *.cpp timer/*.cpp)
 LOCAL_SRC_FILES_C = $(wildcard *.c)
diff --git a/common_src/framework/lynq-sdk-ready/src/timer/lynq_timer.cpp b/common_src/framework/lynq-sdk-ready/src/timer/lynq_timer.cpp
index bd377f6..d58c3cf 100755
--- a/common_src/framework/lynq-sdk-ready/src/timer/lynq_timer.cpp
+++ b/common_src/framework/lynq-sdk-ready/src/timer/lynq_timer.cpp
@@ -14,7 +14,7 @@
 #include <errno.h>

 #include "lynq_timer.h"

 #include <include/lynq_uci.h>

-
+#include <lynq_misc/lynq_misc.h>
 #include <stdlib.h>
 #include <fcntl.h>
 #include <assert.h>
@@ -671,7 +671,9 @@
     int debug_mode;

     int ret;

     int ret3;
-    

+    
+    ret = lynq_get_reboot_reason();
+    RLOGD("lynq_get_reboot_reason ret =%d\n", ret);
     ret = pthread_create(&thid, &a, timer_request_imei, NULL);

     if(ret != 0){

         RLOGD("pthread_create error!!!");