summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Hillenbrand <codeworkx@cyanogenmod.org>2013-04-19 14:40:17 +0200
committerDaniel Hillenbrand <codeworkx@cyanogenmod.org>2013-04-19 14:40:17 +0200
commitdc1dbaa7233f4bcd822ca00ed867c2348de01e75 (patch)
tree5eec712c19de009670dc754ed03713f61c3f2b57
parentcc2ea7f7c576b61a559d914be91693454f7166a6 (diff)
downloaddevice_samsung_i9300-dc1dbaa7233f4bcd822ca00ed867c2348de01e75.zip
device_samsung_i9300-dc1dbaa7233f4bcd822ca00ed867c2348de01e75.tar.gz
device_samsung_i9300-dc1dbaa7233f4bcd822ca00ed867c2348de01e75.tar.bz2
i9300: fix 2g/3g toggle
If we're trying to set network mode 0, modem always responds with network mode 7 which causes the upper layer to set network mode 0 again. This results in a never ending loop of setting 0 and getting 7. If we're getting mode 7 we'll rewrite it to mode 0 and everyone is happy. Change-Id: Ibff9e9162589135350dd2c4b3fb392ef64d95e4a
-rw-r--r--libril/ril.cpp36
-rw-r--r--libril/ril_commands.h2
2 files changed, 37 insertions, 1 deletions
diff --git a/libril/ril.cpp b/libril/ril.cpp
index 199d9ed..351e646 100644
--- a/libril/ril.cpp
+++ b/libril/ril.cpp
@@ -211,6 +211,7 @@ static void dispatchGsmBrSmsCnf(Parcel &p, RequestInfo *pRI);
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 responseIntsGetPreferredNetworkType(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);
@@ -1410,6 +1411,41 @@ responseInts(Parcel &p, void *response, size_t responselen) {
return 0;
}
+static int
+responseIntsGetPreferredNetworkType(Parcel &p, void *response, size_t responselen) {
+ int numInts;
+
+ if (response == NULL && responselen != 0) {
+ ALOGE("invalid response: NULL");
+ return RIL_ERRNO_INVALID_RESPONSE;
+ }
+ if (responselen % sizeof(int) != 0) {
+ ALOGE("invalid response length %d expected multiple of %d\n",
+ (int)responselen, (int)sizeof(int));
+ return RIL_ERRNO_INVALID_RESPONSE;
+ }
+
+ int *p_int = (int *) response;
+
+ numInts = responselen / sizeof(int *);
+ p.writeInt32 (numInts);
+
+ /* each int*/
+ startResponse;
+ for (int i = 0 ; i < numInts ; i++) {
+ if (i == 0 && p_int[0] == 7) {
+ ALOGE("REQUEST_GET_PREFERRED_NETWORK_TYPE: NETWORK_MODE_GLOBAL => NETWORK_MODE_WCDMA_PREF");
+ p_int[0] = 0;
+ }
+ appendPrintBuf("%s%d,", printBuf, p_int[i]);
+ p.writeInt32(p_int[i]);
+ }
+ removeLastChar;
+ closeResponse;
+
+ return 0;
+}
+
/** response is a char **, pointing to an array of char *'s
The parcel will begin with the version */
static int responseStringsWithVersion(int version, Parcel &p, void *response, size_t responselen) {
diff --git a/libril/ril_commands.h b/libril/ril_commands.h
index 96f06ba..e7ed278 100644
--- a/libril/ril_commands.h
+++ b/libril/ril_commands.h
@@ -88,7 +88,7 @@
{RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM, dispatchInts, responseVoid},
{RIL_REQUEST_EXPLICIT_CALL_TRANSFER, dispatchVoid, responseVoid},
{RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, dispatchInts, responseVoid},
- {RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE, dispatchVoid, responseInts},
+ {RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE, dispatchVoid, responseIntsGetPreferredNetworkType},
{RIL_REQUEST_GET_NEIGHBORING_CELL_IDS, dispatchVoid, responseCellList},
{RIL_REQUEST_SET_LOCATION_UPDATES, dispatchInts, responseVoid},
{RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, dispatchInts, responseVoid},