Android-x86
Fork
Spenden

  • R/O
  • HTTP
  • SSH
  • HTTPS

hardware-ril: Commit

hardware/ril


Commit MetaInfo

Revision836e7e2e097c00852b7cdcfe2a2edd3bbcd2c2c5 (tree)
Zeit2016-05-05 18:46:53
AutorChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

fix 3G support for android-x86

Start pppd directly to setup data connection.

Ändern Zusammenfassung

Diff

--- a/reference-ril/reference-ril.c
+++ b/reference-ril/reference-ril.c
@@ -49,7 +49,7 @@ static void *noopRemoveWarning( void *a ) { return a; }
4949 #define MAX_AT_RESPONSE 0x1000
5050
5151 /* pathname returned from RIL_REQUEST_SETUP_DATA_CALL / RIL_REQUEST_SETUP_DEFAULT_PDP */
52-#define PPP_TTY_PATH "eth0"
52+#define PPP_TTY_PATH "/dev/ppp0"
5353
5454 // Default MTU value
5555 #define DEFAULT_MTU 1500
@@ -361,7 +361,8 @@ static void onSIMReady()
361361 * ds = 1 // Status reports routed to TE
362362 * bfr = 1 // flush buffer
363363 */
364- at_send_command("AT+CNMI=1,2,2,1,1", NULL);
364+ at_send_command("AT+CNMI=1,2,2,1,0", NULL);
365+ ALOGI ("######### SIM READY !!\n");
365366 }
366367
367368 static void requestRadioPower(void *data, size_t datalen, RIL_Token t)
@@ -593,8 +594,31 @@ static void requestOrSendDataCallList(RIL_Token *t)
593594 /* I don't know where we are, so use the public Google DNS
594595 * servers by default and no gateway.
595596 */
596- responses[i].dnses = "8.8.8.8 8.8.4.4";
597- responses[i].gateways = "";
597+ int c;
598+ char ppp_dnses[(PROP_VALUE_MAX * 2) + 3] = "";
599+ char ppp_local_ip[PROP_VALUE_MAX] = "";
600+ char ppp_dns1[PROP_VALUE_MAX] = "8.8.8.8";
601+ char ppp_dns2[PROP_VALUE_MAX] = "8.8.4.4";
602+ char ppp_gw[PROP_VALUE_MAX] = "";
603+ for (c = 0; c < 10; ++c) {
604+ if (__system_property_get("net.ppp0.local-ip", ppp_local_ip)) {
605+ ALOGI("Got net.ppp0.local-ip: %s\n", ppp_local_ip);
606+ break;
607+ }
608+ usleep(1000000);
609+ }
610+ if (c >= 10) {
611+ ALOGE("Timeout waiting net.ppp0.local-ip - giving up!\n");
612+ goto error;
613+ }
614+ __system_property_get("net.dns1", ppp_dns1);
615+ __system_property_get("net.dns2", ppp_dns2);
616+ __system_property_get("net.ppp0.gw", ppp_gw);
617+ sprintf(ppp_dnses, "%s %s", ppp_dns1, ppp_dns2);
618+
619+ responses[i].addresses = ppp_local_ip;
620+ responses[i].dnses = ppp_dnses;
621+ responses[i].gateways = ppp_gw;
598622 }
599623 }
600624 }
@@ -1665,6 +1689,7 @@ static void requestSetupDataCall(void *data, size_t datalen, RIL_Token t)
16651689 char status[32] = {0};
16661690 int retry = 10;
16671691 const char *pdp_type;
1692+ char pppdcmd[512] = "/system/bin/pppd ";
16681693
16691694 RLOGD("requesting data connection to APN '%s'", apn);
16701695
@@ -1743,14 +1768,20 @@ static void requestSetupDataCall(void *data, size_t datalen, RIL_Token t)
17431768 err = at_send_command("AT+CGEREP=1,0", NULL);
17441769
17451770 // Hangup anything that's happening there now
1746- err = at_send_command("AT+CGACT=1,0", NULL);
1771+ err = at_send_command("AT+CGACT=0,1", NULL);
17471772
17481773 // Start data on PDP context 1
17491774 err = at_send_command("ATD*99***1#", &p_response);
17501775
17511776 if (err < 0 || p_response->success == 0) {
1752- goto error;
1777+ ALOGE("start data failed: %d", err);
17531778 }
1779+
1780+ if (!__system_property_get("rild.ppp.tty", pppdcmd + strlen(pppdcmd))) {
1781+ strcat(pppdcmd, "/dev/ttyUSB0");
1782+ }
1783+ strcat(pppdcmd, " call gprs");
1784+ system(pppdcmd);
17541785 }
17551786
17561787 requestOrSendDataCallList(&t);
@@ -3024,9 +3055,6 @@ static void initializeCallback(void *param __unused)
30243055 /* Alternating voice/data off */
30253056 at_send_command("AT+CMOD=0", NULL);
30263057
3027- /* Not muted */
3028- at_send_command("AT+CMUT=0", NULL);
3029-
30303058 /* +CSSU unsolicited supp service notifications */
30313059 at_send_command("AT+CSSN=0,1", NULL);
30323060
@@ -3329,7 +3357,7 @@ mainLoop(void *param __unused)
33293357 SOCK_STREAM );
33303358 } else if (s_device_path != NULL) {
33313359 fd = open (s_device_path, O_RDWR);
3332- if ( fd >= 0 && !memcmp( s_device_path, "/dev/ttyS", 9 ) ) {
3360+ if (fd >= 0) {
33333361 /* disable echo on serial ports */
33343362 struct termios ios;
33353363 tcgetattr( fd, &ios );
Show on old repository browser