ril: Fix unsol response array mapping

* Instead of messing around with indices, look up
   the requestNumber in the array.
 * This has a cost of O(N) instead of O(1) with the
   previous implementation, but we don't receive unsol
   response codes frequently enough to be worried about
   this.
 * This was needed because a few vendor reponses, aka
   RIL_UNSOL_SNDMGR_WB_AMR_REPORT at index 33 and
   RIL_UNSOL_SNDMGR_CLOCK_CTRL at index 34
   could not be addressed by their array indices anymore
   because we cannot calculate their index by the unsol
   response code we receive from the modem.

Change-Id: I27319e621c777fe19ae8908d7e0c4a46d6dd6d3b
tirimbino
Christopher N. Hesse 8 years ago
parent 7c367c0adf
commit caece2d972
  1. 25
      ril/libril/ril.cpp

@ -5656,23 +5656,36 @@ void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE;
pRI = s_unsolResponses;
pRI_elements = (int32_t)NUM_ELEMS(s_unsolResponses);
/* Hack to include Samsung responses */
if (unsolResponse > RIL_VENDOR_COMMANDS_OFFSET + RIL_UNSOL_RESPONSE_BASE) {
unsolResponseIndex -= RIL_VENDOR_COMMANDS_OFFSET;
pRI = s_unsolResponses_v;
pRI_elements = (int32_t)NUM_ELEMS(s_unsolResponses_v);
RLOGD("SAMSUNG: unsolResponse=%d, unsolResponseIndex=%d", unsolResponse, unsolResponseIndex);
/*
* Some of the vendor response codes cannot be found by calculating their index anymore,
* because they have an even higher offset and are not ordered in the array.
* Example: RIL_UNSOL_SNDMGR_WB_AMR_REPORT = 20017, but it's at index 33 in the vendor
* response array.
* Thus, look through all the vendor URIs (Unsol Response Info) and pick the correct index.
* This has a cost of O(N).
*/
int pRI_index;
for (pRI_index = 0; pRI_index < pRI_elements; pRI_index++) {
if (pRI[pRI_index].requestNumber == unsolResponse) {
unsolResponseIndex = pRI_index;
}
}
pRI_elements = pRI == s_unsolResponses
? (int32_t)NUM_ELEMS(s_unsolResponses) : (int32_t)NUM_ELEMS(s_unsolResponses_v);
RLOGD("SAMSUNG: unsolResponse=%d, unsolResponseIndex=%d", unsolResponse, unsolResponseIndex);
}
if (unsolResponseIndex >= 0 && unsolResponseIndex < pRI_elements) {
pRI = &pRI[unsolResponseIndex];
} else {
RLOGE("unsolResponseIndex out of bounds: %d, using %s response array", unsolResponseIndex,
pRI == s_unsolResponses ? "AOSP" : "Samsung");
RLOGE("could not map unsolResponse=%d to %s response array (index=%d)", unsolResponse,
pRI == s_unsolResponses ? "AOSP" : "Samsung", unsolResponseIndex);
}
if (pRI == NULL || pRI->responseFunction == NULL) {

Loading…
Cancel
Save