Add mbtk dump and
Change-Id: I510bbfa20d954d4212cbb7710337de029cfc95e1
diff --git a/mbtk/mbtk_rild/src/main.c b/mbtk/mbtk_rild/src/main.c
index 8741e8d..4faeced 100755
--- a/mbtk/mbtk_rild/src/main.c
+++ b/mbtk/mbtk_rild/src/main.c
@@ -37,6 +37,9 @@
#define BUFFER_SIZE 2048
#define UEVENT_USIM_DEV "/devices/virtual/usim_event/usim0"
#define MBTK_BOOT_SERVER_READY "/etc/init.d/mbtk_boot_server_ready"
+#define MBTK_BOOT_NET_READY "/etc/init.d/mbtk_boot_net_ready"
+#define MBTK_RILD_PID_FILE "/var/run/mbtk_rild.pid"
+#define MBTK_RILD_TEMP_FILE "/tmp/mbtk_rild.count"
struct cooling_device
{
@@ -51,6 +54,7 @@
extern mbtK_cell_pack_info_t cell_info;
extern info_cgact_wait_t cgact_wait;
extern bool at_process;
+static bool is_first_boot = FALSE;
void setRadioPower(int isOn);
int urc_msg_distribute(bool async_process, info_urc_msg_id_enum msg, void *data, int data_len);
@@ -144,6 +148,22 @@
}
}
+static void mbtk_net_ready()
+{
+ // /etc/init.d/mbtk_boot_net_ready
+ if(is_first_boot) {
+ if(access(MBTK_BOOT_NET_READY , X_OK) == 0) {
+ LOGD("Exec : %s", MBTK_BOOT_NET_READY);
+ system(MBTK_BOOT_NET_READY);
+ } else {
+ LOGE("%s can not exec.", MBTK_BOOT_NET_READY);
+ }
+ is_first_boot = FALSE; // Only one time.
+ } else {
+ LOGD("No exec : %s", MBTK_BOOT_NET_READY);
+ }
+}
+
bool sms_cmt = false;
mbtk_sim_card_info sim_info_reg={0};
static void onUnsolicited(const char *s, const char *sms_pdu)
@@ -423,6 +443,8 @@
if(data[0] == 1)
{
mbtk_net_led_set(MBTK_NET_LED_NET_CONNECT);
+
+ mbtk_net_ready();
}
else
{
@@ -630,7 +652,7 @@
{
net_info.sim_state = MBTK_SIM_ABSENT;
}
-
+
sim_info_reg.sim = -1;
if(strStartsWith(s, "*SIMDETEC:1,NOS"))
sim_info_reg.sim = 0;
@@ -1831,13 +1853,18 @@
#endif
}
-static void mbtk_server_ready()
+static void mbtk_ril_ready()
{
// /etc/init.d/mbtk_boot_server_ready
- if(access(MBTK_BOOT_SERVER_READY , X_OK) == 0) {
- system(MBTK_BOOT_SERVER_READY);
+ if(is_first_boot) {
+ if(access(MBTK_BOOT_SERVER_READY , X_OK) == 0) {
+ LOGD("Exec : %s", MBTK_BOOT_SERVER_READY);
+ system(MBTK_BOOT_SERVER_READY);
+ } else {
+ LOGE("%s can not exec.", MBTK_BOOT_SERVER_READY);
+ }
} else {
- LOGE("%s can not exec.", MBTK_BOOT_SERVER_READY);
+ LOGD("No exec : %s", MBTK_BOOT_SERVER_READY);
}
}
@@ -1845,8 +1872,49 @@
int main(int argc, char *argv[])
{
mbtk_log_init("radio", "MBTK_RIL");
+
+#ifdef MBTK_DUMP_SUPPORT
+ mbtk_debug_open(NULL, TRUE);
+#endif
+
+// Using Killall,the file lock may be not release.
+#if 0
+ if(app_already_running(MBTK_RILD_PID_FILE)) {
+ LOGW("daemon already running.");
+ exit(1);
+ }
+#endif
+
LOGI("mbtk_ril start.");
+ int fd = open(MBTK_RILD_TEMP_FILE, O_CREAT | O_RDWR, 0644);
+ if(fd > 0) {
+ char buff[10] = {0};
+ int count = 0;
+ if(read(fd, buff, sizeof(buff)) > 0) {
+ count = atoi(buff);
+ } else {
+ count = 0;
+ }
+
+ if(count <= 0) {
+ is_first_boot = TRUE;
+ count = 0;
+ } else {
+ is_first_boot = FALSE;
+ }
+
+ count++;
+ memset(buff, 0, sizeof(buff));
+ snprintf(buff, sizeof(buff), "%d", count);
+ write(fd, buff, strlen(buff));
+ close(fd);
+ } else {
+ is_first_boot = FALSE;
+ LOGE("Open %s fail:%d", MBTK_RILD_TEMP_FILE, errno);
+ LOGW("Will not exec %s and %s.", MBTK_BOOT_SERVER_READY, MBTK_BOOT_NET_READY);
+ }
+
if(InProduction_Mode()) {
LOGI("Is Production Mode, will exit...");
exit(0);
@@ -1889,10 +1957,10 @@
LOGE("mbtk_info_server_start() fail.");
return -1;
}
-
+
#ifdef MBTK_PROJECT_T108
mbtk_led_init();
-#endif
+#endif
#if 0
if(uevent_main())
@@ -1912,7 +1980,7 @@
fota_result_check();
- mbtk_server_ready();
+ mbtk_ril_ready();
server_ready_set();//Set the server readiness state
while(1)