From 9bdede058f3ea58d22bc37578c8c27f46a694e05 Mon Sep 17 00:00:00 2001 From: fenglu Date: Tue, 14 Apr 2015 14:53:55 -0700 Subject: [PATCH] Link Capacity Estimation - RIL support Change-Id: I9c4d4901d823d719be2b8bdec64f08eda342de53 --- ril/libril/ril.cpp | 55 +++++++++++++++++++++++++++++++++ ril/libril/ril_commands.h | 3 ++ ril/libril/ril_unsol_commands.h | 1 + 3 files changed, 59 insertions(+) diff --git a/ril/libril/ril.cpp b/ril/libril/ril.cpp index ec50701..9f30999 100644 --- a/ril/libril/ril.cpp +++ b/ril/libril/ril.cpp @@ -300,6 +300,8 @@ static int responseHardwareConfig(Parcel &p, void *response, size_t responselen) static int responseDcRtInfo(Parcel &p, void *response, size_t responselen); static int responseRadioCapability(Parcel &p, void *response, size_t responselen); static int responseSSData(Parcel &p, void *response, size_t responselen); +static int responseLceStatus(Parcel &p, void *response, size_t responselen); +static int responseLceData(Parcel &p, void *response, size_t responselen); static int decodeVoiceRadioTechnology (RIL_RadioState radioState); static int decodeCdmaSubscriptionSource (RIL_RadioState radioState); @@ -3740,6 +3742,59 @@ static int responseDcRtInfo(Parcel &p, void *response, size_t responselen) return 0; } +static int responseLceStatus(Parcel &p, void *response, size_t responselen) { + if (response == NULL || responselen != sizeof(RIL_LceStatusInfo)) { + if (response == NULL) { + RLOGE("invalid response: NULL"); + } + else { + RLOGE("responseLceStatus: invalid response length %d expecting len: d%", + sizeof(RIL_LceStatusInfo), responselen); + } + return RIL_ERRNO_INVALID_RESPONSE; + } + + RIL_LceStatusInfo *p_cur = (RIL_LceStatusInfo *)response; + p.write((void *)p_cur, 1); // p_cur->lce_status takes one byte. + p.writeInt32(p_cur->actual_interval_ms); + + startResponse; + appendPrintBuf("LCE Status: %d, actual_interval_ms: %d", + p_cur->lce_status, p_cur->actual_interval_ms); + closeResponse; + + return 0; +} + +static int responseLceData(Parcel &p, void *response, size_t responselen) { + if (response == NULL || responselen != sizeof(RIL_LceDataInfo)) { + if (response == NULL) { + RLOGE("invalid response: NULL"); + } + else { + RLOGE("responseLceData: invalid response length %d expecting len: d%", + sizeof(RIL_LceDataInfo), responselen); + } + return RIL_ERRNO_INVALID_RESPONSE; + } + + RIL_LceDataInfo *p_cur = (RIL_LceDataInfo *)response; + p.writeInt32(p_cur->last_hop_capacity_kbps); + + /* p_cur->confidence_level and p_cur->lce_suspended take 1 byte each.*/ + p.write((void *)&(p_cur->confidence_level), 1); + p.write((void *)&(p_cur->lce_suspended), 1); + + startResponse; + appendPrintBuf("LCE info received: capacity %d confidence level %d + and suspended %d", + p_cur->last_hop_capacity_kbps, p_cur->confidence_level, + p_cur->lce_suspended); + closeResponse; + + return 0; +} + /** * A write on the wakeup fd is done just to pop us out of select() * We empty the buffer here and then ril_event will reset the timers on the diff --git a/ril/libril/ril_commands.h b/ril/libril/ril_commands.h index a4f8447..16a7dcd 100644 --- a/ril/libril/ril_commands.h +++ b/ril/libril/ril_commands.h @@ -146,3 +146,6 @@ {RIL_REQUEST_SHUTDOWN, dispatchVoid, responseVoid}, {RIL_REQUEST_GET_RADIO_CAPABILITY, dispatchVoid, responseRadioCapability}, {RIL_REQUEST_SET_RADIO_CAPABILITY, dispatchRadioCapability, responseRadioCapability}, + {RIL_REQUEST_START_LCE, dispatchInts, responseLceStatus}, + {RIL_REQUEST_STOP_LCE, dispatchVoid, responseLceStatus}, + {RIL_REQUEST_PULL_LCEDATA, dispatchVoid, responseLceData}, diff --git a/ril/libril/ril_unsol_commands.h b/ril/libril/ril_unsol_commands.h index 6ea7157..eb9e12d 100644 --- a/ril/libril/ril_unsol_commands.h +++ b/ril/libril/ril_unsol_commands.h @@ -59,3 +59,4 @@ {RIL_UNSOL_RADIO_CAPABILITY, responseRadioCapability, WAKE_PARTIAL}, {RIL_UNSOL_ON_SS, responseSSData, WAKE_PARTIAL}, {RIL_UNSOL_STK_CC_ALPHA_NOTIFY, responseString, WAKE_PARTIAL}, + {RIL_UNSOL_LCEDATA_RECV, responseLceData, WAKE_PARTIAL}, -- 2.20.1