Permalink
Browse files

Handle newer libhtc_ril.so releases

Querying available networks returns five strings per network instead of
four which breaks that functionality in RILJ. This fix most likely
appiles to every library since Hero.

Disabled per default, define BOARD_USE_NEW_LIBRIL_HTC if you are
building with libhtc_ril.so libraries version 2 and above.

Change-Id: I910d0e34c95b2b46c1d66adf0ca9f116dbf39c04
  • Loading branch information...
aleho committed Nov 22, 2010
1 parent 76e1a7b commit bf591d8700b903ce5fb9de54523ca6f193479fa8
Showing with 34 additions and 3 deletions.
  1. +3 −0 libril/Android.mk
  2. +30 −2 libril/ril.cpp
  3. +1 −1 libril/ril_commands.h
View
@@ -14,6 +14,9 @@ LOCAL_SHARED_LIBRARIES := \
libhardware_legacy
LOCAL_CFLAGS :=
+ifdef BOARD_USE_NEW_LIBRIL_HTC
+ LOCAL_CFLAGS += -DNEW_LIBRIL_HTC
+endif
LOCAL_MODULE:= libril
View
@@ -209,6 +209,8 @@ static void dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI);
static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI);
static int responseInts(Parcel &p, void *response, size_t responselen);
static int responseStrings(Parcel &p, void *response, size_t responselen);
+static int responseStringsNetworks(Parcel &p, void *response, size_t responselen);
+static int responseStrings(Parcel &p, void *response, size_t responselen, bool network_search);
static int responseString(Parcel &p, void *response, size_t responselen);
static int responseVoid(Parcel &p, void *response, size_t responselen);
static int responseCallList(Parcel &p, void *response, size_t responselen);
@@ -1284,8 +1286,16 @@ responseInts(Parcel &p, void *response, size_t responselen) {
return 0;
}
-/** response is a char **, pointing to an array of char *'s */
static int responseStrings(Parcel &p, void *response, size_t responselen) {
+ return responseStrings(p, response, responselen, false);
+}
+
+static int responseStringsNetworks(Parcel &p, void *response, size_t responselen) {
+ return responseStrings(p, response, responselen, true);
+}
+
+/** response is a char **, pointing to an array of char *'s */
+static int responseStrings(Parcel &p, void *response, size_t responselen, bool network_search) {
int numStrings;
if (response == NULL && responselen != 0) {
@@ -1304,11 +1314,29 @@ static int responseStrings(Parcel &p, void *response, size_t responselen) {
char **p_cur = (char **) response;
numStrings = responselen / sizeof(char *);
+#ifdef NEW_LIBRIL_HTC
+ if (network_search == true) {
+ // we only want four entries for each network
+ p.writeInt32 (numStrings - (numStrings / 5));
+ } else {
+ p.writeInt32 (numStrings);
+ }
+ int sCount = 0;
+#else
p.writeInt32 (numStrings);
+#endif
/* each string*/
startResponse;
for (int i = 0 ; i < numStrings ; i++) {
+#ifdef NEW_LIBRIL_HTC
+ sCount++;
+ // ignore the fifth string that is returned by newer HTC libhtc_ril.so.
+ if (network_search == true && sCount % 5 == 0) {
+ sCount = 0;
+ continue;
+ }
+#endif
appendPrintBuf("%s%s,", printBuf, (char*)p_cur[i]);
writeStringToParcel (p, p_cur[i]);
}
@@ -2239,7 +2267,7 @@ static void listenCallback (int fd, short flags, void *param) {
LOGE("Error on accept() errno:%d", errno);
/* start listening for new connections again */
rilEventAddWakeup(&s_listen_event);
- return;
+ return;
}
/* check the credential of the other side and only accept socket from
View
@@ -62,7 +62,7 @@
{RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE, dispatchVoid, responseInts},
{RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, dispatchVoid, responseVoid},
{RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL, dispatchString, responseVoid},
- {RIL_REQUEST_QUERY_AVAILABLE_NETWORKS , dispatchVoid, responseStrings},
+ {RIL_REQUEST_QUERY_AVAILABLE_NETWORKS , dispatchVoid, responseStringsNetworks},
{RIL_REQUEST_DTMF_START, dispatchString, responseVoid},
{RIL_REQUEST_DTMF_STOP, dispatchVoid, responseVoid},
{RIL_REQUEST_BASEBAND_VERSION, dispatchVoid, responseString},

0 comments on commit bf591d8

Please sign in to comment.