[Feature][T108][task-view-1632]add gnss_check-mbtk_source
Only Configure:No
Affected branch:mbtk_source_ds
Affected module:sdk_ready
Is it affected on: only ASR
Self-test: Yes
Doc Update:No
Change-Id: Ie214a88b9ee43345f2732f4def2ed2379067591b
diff --git a/mbtk/mbtk_sdk_ready/src/main.c b/mbtk/mbtk_sdk_ready/src/main.c
index 999bd42..49be048 100755
--- a/mbtk/mbtk_sdk_ready/src/main.c
+++ b/mbtk/mbtk_sdk_ready/src/main.c
@@ -9,6 +9,8 @@
//#include <signal.h>
#include <cutils/properties.h>
#include <stdint.h>
+#include <string.h>
+#include <time.h>
#include "mbtk_log.h"
#include "mbtk_info_api.h"
@@ -210,13 +212,43 @@
return NULL;
}
-static void* check_gnss()
-{
- LOGE("[SDK_READY] check_gnss entry.");
- //update_gnss_value();
- while(1)
+static int is_process_running(const char *process_name)
+{
+ char command[128];
+ FILE *fp;
+ int found = 0;
+
+ snprintf(command, sizeof(command), "ps | grep -v grep | grep '%s'", process_name);
+ fp = popen(command, "r");
+ if (!fp)
{
- sleep(UINT32_MAX);
+ LOGE("[GNSS_CHECK] popen failed for command: %s", command);
+ return 0;
+ }
+
+ char line[256];
+ if (fgets(line, sizeof(line), fp))
+ {
+ found = 1;
+ }
+ pclose(fp);
+ return found;
+}
+
+static void* check_gnss(void *arg)
+{
+ UNUSED(arg);
+ const char *gnss_process_name = "mbtk_gnssd";
+ int current_status;
+ while (1)
+ {
+ current_status = is_process_running(gnss_process_name);
+ if (current_status == 0)
+ {
+ LOGI("[GNSS_CHECK] GNSS process stopped, setting status to 1");
+ update_gnss_value();
+ }
+ sleep(30);
}
return NULL;
}