[Bugfix][T108][bug-view-2354]Fix device band changed

            Only Configure: No
            Affected branch: mbtk_source_ds
            Affected module: system
            Is it affected on IC: only ASR
            Self-test: yes
            Doc Update: no

Change-Id: I5cb00c61411dbde81461b1606a31ab2aa45377a2
diff --git a/mbtk/mbtk_rild_v2/src/main.c b/mbtk/mbtk_rild_v2/src/main.c
index 180e932..1c55e2c 100755
--- a/mbtk/mbtk_rild_v2/src/main.c
+++ b/mbtk/mbtk_rild_v2/src/main.c
@@ -2917,6 +2917,32 @@
     return NULL;
 }

 

+static int check_device_info(void)
+{
+    mbtk_device_info_basic_t info_basic;
+    memset(&info_basic,0,sizeof(mbtk_device_info_basic_t));
+    int result = mbtk_dev_info_read(MBTK_DEVICE_INFO_ITEM_BASIC, &info_basic, sizeof(mbtk_device_info_basic_t));
+    if(result != 0)
+    {
+        LOGE("mbtk_dev_info_read(BASIC) fail. reset \n");
+	return -1;
+    }
+    return 0;
+}
+
+static int config_file_exists(void)
+{
+    ATResponse *response = NULL;
+
+    int err = at_send_command(portType_2_portId(MBTK_SIM_1, ATPORTTYPE_0), "AT*MRD_CDF=Q,TTPCom_NRAM2_CUSTOMIZATION_DATA.gki", &response);
+    if(err < 0 || response->success == 0)
+    {
+        LOGD("config_file gki check fail \n");
+        return 0;
+    }
+    return -1;
+}
+
 static void band_support_init()

 {

     mbtk_device_info_modem_t info_modem;

@@ -3049,7 +3075,7 @@
 
 OK
 */
-/*
+
 static void* band_config_thread()
 {
     band_info.band_set_success = FALSE;

@@ -3083,7 +3109,7 @@
     LOGD("Set Band thread exit.");
     return NULL;
 }
-*/
+
 

 

 int ril_server_start()

@@ -3096,10 +3122,15 @@
 
     //check cfun and sim card status
     ril_at_ready_process();
-

+
+    // check device info
+    int check_res = check_device_info();
+
+    // check gki config 
+    int file_res = config_file_exists();
+
     // Init support band.

     band_support_init();

-
     //any AT instruction that is not sent through pack_process_thread needs to precede the thread
     //thread create
     if(ril_info.sock_listen_fd > 0)

@@ -3201,8 +3232,8 @@
     char buff[10];
     memset(buff, 0, 10);
     property_get("persist.mbtk.band_config", buff, "");
-    /*
-    if(strlen(buff) == 0) {
+    
+    if(strlen(buff) == 0 && check_res == 0 && file_res == 0) {
         pthread_t band_pid;
         if(pthread_create(&band_pid, &thread_attr, band_config_thread, NULL))
         {
@@ -3211,8 +3242,6 @@
     }
 
     pthread_attr_destroy(&thread_attr);

-    */
-

     if(asr_auto_data_call_enable()) {

         ril_cid_start = MBTK_RIL_CID_2;

 

diff --git a/mbtk/mbtk_utils/device_info.c b/mbtk/mbtk_utils/device_info.c
index 63efced..cf335d7 100755
--- a/mbtk/mbtk_utils/device_info.c
+++ b/mbtk/mbtk_utils/device_info.c
@@ -11,7 +11,7 @@
 /*
 * Exec shell command.
 */
-/*
+
 static bool shell_cmd_exec(const char *cmd, char *buf, int buf_size){
     FILE *fcmd;
     bool result = FALSE;
@@ -45,7 +45,7 @@
     return result;
 }
 
-*/
+
 static char* band_2_str(mbtk_modem_band_area_enum band_area)
 {
     switch(band_area)
@@ -163,7 +163,7 @@
 static int band_set_by_at(mbtk_device_info_modem_t *band)
 {
     char cmd[100] = {0};
-//    char rsp[100] = {0};
+    char rsp[100] = {0};
 
     // Only support 4G/5G
     if(band->modem.v2.net_support & MBTK_NET_SUPPORT_5G) {
@@ -186,7 +186,7 @@
             sprintf(cmd, "serial_atcmd AT*BAND=%d,%d,%d,%d,%d", band->modem.v2.net_pref, band->modem.v2.band_gsm, band->modem.v2.band_wcdma, band->modem.v2.band_tdlte, band->modem.v2.band_fddlte);
         }
     }
-/*
+
     if(shell_cmd_exec(cmd, rsp, sizeof(rsp))) {
         if(strstr(rsp, "\r\nOK\r\n")) {
             return 0;
@@ -196,8 +196,6 @@
     } else {
         return -1;
     }
-    */
-    return 0;
 }
 
 /*
@@ -268,6 +266,7 @@
         */
         printf("Version:%d\n", info_basic.version);
         if(info_basic.version == DEV_INFO_VERSION_V1) {
+            printf("Dev_info.version:%d\n", info_basic.version);
             printf("Project:%s\n", info_basic.basic.v1.project);
             printf("Custom_Model:%s\n", info_basic.basic.v1.project_cust);
             printf("Revision_Out:%s\n", info_basic.basic.v1.revision_out);
@@ -276,6 +275,8 @@
             printf("AB System:%s\n", info_basic.basic.v1.ab_support ? "Yes" : "No");
             printf("Reboot flag:%d\n", info_basic.basic.v1.reboot_flag);
         } else {
+	
+            printf("Dev_info.version:%d\n", info_basic.version);
             printf("Project:%s\n", info_basic.basic.v2.project);
             printf("Custom_Model:%s\n", info_basic.basic.v2.project_cust);
             printf("Revision_Out:%s\n", info_basic.basic.v2.revision_out);