diff options
author | Christopher N. Hesse <raymanfx@gmail.com> | 2017-02-11 18:59:31 +0100 |
---|---|---|
committer | Christopher N. Hesse <raymanfx@gmail.com> | 2017-02-12 12:12:17 +0000 |
commit | caece2d972717c9dbf3afe6833e323fe76e1ad4a (patch) | |
tree | 4d28746c359bca983967a6ce98b60e012872d134 | |
parent | 7c367c0adfc38927061afc99ab19df94404b483d (diff) | |
download | android_hardware_samsung-caece2d972717c9dbf3afe6833e323fe76e1ad4a.tar.gz android_hardware_samsung-caece2d972717c9dbf3afe6833e323fe76e1ad4a.tar.bz2 android_hardware_samsung-caece2d972717c9dbf3afe6833e323fe76e1ad4a.zip |
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
-rwxr-xr-x | ril/libril/ril.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/ril/libril/ril.cpp b/ril/libril/ril.cpp index a2d1e4e..c449026 100755 --- a/ril/libril/ril.cpp +++ b/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); + + /* + * 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; + } + } RLOGD("SAMSUNG: unsolResponse=%d, unsolResponseIndex=%d", unsolResponse, unsolResponseIndex); } - pRI_elements = pRI == s_unsolResponses - ? (int32_t)NUM_ELEMS(s_unsolResponses) : (int32_t)NUM_ELEMS(s_unsolResponses_v); - 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) { |