[feature][T8TSK-135] RIL3.0 soceket broadcast optimistion 4
Change-Id: Ia50de7c8bb4eebf52b139b92e21e9c8cef18ebe3
diff --git a/framework/lynq-ril-service/src/ril.cpp b/framework/lynq-ril-service/src/ril.cpp
index 960389b..a7105b6 100755
--- a/framework/lynq-ril-service/src/ril.cpp
+++ b/framework/lynq-ril-service/src/ril.cpp
@@ -91,6 +91,10 @@
#include "lynq_fota.h"
/*lt add end*/
/*Warren add for t800 RIL service 2021_12_10 end*/
+#ifdef LED_SUPPORT
+#include "led.h"
+#endif
+#include "lynq_shm.h"
#define LOG_TAG "DEMO_RIL"
#define WAIT_TIME_FOR_SIM_SWITCH 30
@@ -171,6 +175,11 @@
//int LYNQ_RIL_respSocket(Parcel &p,RIL_Token t);
//int LYNQ_RIL_urcBroadcast(Parcel &p);
+/*hq add for urc broadcast opti 2023/01/06 */
+#define SHM_BUFFER_INDEX_OFFSET 1
+#define SHM_BUFFER_SIZE_OFFSET 16
+#define urc_broadcase_shm_size_limit 20
+
int lynq_urc_socket_fd = 0;
struct sockaddr_in urc_broadcast_addr;
/*Warren add for t800 RIL service 2021_12_10 end*/
@@ -4779,7 +4788,7 @@
break;
}
/*Warren add for t800 ril service 2021/12/16 start*/
- ret = LYNQ_RIL_urcBroadcast(p);
+ ret = LYNQ_RIL_urcBroadcast(p,unsolResponse);
/*Warren add for t800 ril service 2021/12/16 end*/
#if 0
if (ret != 0 && unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
@@ -5256,6 +5265,7 @@
case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED";
case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED";
case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED";
+ case RIL_UNSOL_RESPONSE_PS_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED";
case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS";
case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT";
case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM";
@@ -5573,7 +5583,7 @@
if(utils::is_suppport_dsss()) {
int id = Phone_utils::get_enable_sim_for_dsss();
init(id);
- }
+ }
}
@@ -6112,17 +6122,57 @@
return 0;
}
-int LYNQ_RIL_urcBroadcast(Parcel &p)
+bool is_need_use_shm(int dataSize, int urc_id)
+{
+ switch(urc_id)
+ {
+ /*network*/
+ case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED:
+ case RIL_UNSOL_RESPONSE_PS_NETWORK_STATE_CHANGED:
+ case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED:
+ case RIL_UNSOL_SIGNAL_STRENGTH:
+
+ /*call*/
+ case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED:
+ case RIL_UNSOL_CALL_RING:
+ case RIL_UNSOL_RINGBACK_TONE:
+ case RIL_UNSOL_CALL_INFO_INDICATION:
+#ifdef ECALL_SUPPORT
+ case RIL_UNSOL_ECALL_INDICATIONS://9502
+#endif
+ break;
+ default:
+ return false;
+ }
+ if(dataSize>urc_broadcase_shm_size_limit && dataSize <= get_max_shem_buffer_size())
+ {
+ return true;
+ }
+ return false;
+}
+
+int LYNQ_RIL_urcBroadcast(Parcel &p, int urc_id)
{
RLOGD("LYNQ_RIL_urcBroadcast send start");
- int ret =0;
- bool sendResult =false;
- ssize_t sent = 0;
- uint8_t dataLength[4];
- int verify = 0x55aa;
- p.setDataPosition(0);
+ int ret =0;
+ ssize_t sent = 0;
+ p.setDataPosition(0);
int dataSize = p.dataSize();
const uint8_t* data = p.data();
+ RLOGD("LYNQ_RIL_urcBroadcast urc_id is %d, dataSize=%d, msg is %s", urc_id, dataSize, requestToString(urc_id));
+ if(is_need_use_shm(dataSize,urc_id))
+ {
+ int index,level;
+ if(get_cur_shem_buffer_index(dataSize,&level,&index))
+ {
+ char* p_shm_buffer=get_shem_buffer(level,index);
+ memcpy(p_shm_buffer,data,dataSize);
+ uint32_t* pFirstInt = (uint32_t*) const_cast<uint8_t*> (data);
+ *pFirstInt=*pFirstInt+((index+1)<<SHM_BUFFER_INDEX_OFFSET)+((dataSize)<<SHM_BUFFER_SIZE_OFFSET);
+ dataSize=sizeof(int32_t)*2;
+ RLOGD("LYNQ_RIL_urcBroadcast use share mem level is %d, index is %d",level,index);
+ }
+ }
sent = sendto(lynq_urc_socket_fd, data, dataSize, 0, (struct sockaddr *)&urc_broadcast_addr, sizeof(urc_broadcast_addr));
if( sent < 0 )
{
@@ -6130,6 +6180,7 @@
sent,lynq_urc_socket_fd, dataSize);
return -1;
}
+
return 0;
}
/*Warren add for t800 RIL Service 2021/12/10 end*/