Merge "Fix SETUP_DATA_CALL handling."

This commit is contained in:
Wink Saville
2011-02-04 15:04:38 -08:00
committed by Android (Google) Code Review
2 changed files with 37 additions and 27 deletions

View File

@@ -401,22 +401,26 @@ public abstract class DataConnection extends HierarchicalStateMachine {
try {
cid = response.cid;
linkProperties.setInterfaceName(response.ifname);
for (String addr : response.addresses) {
LinkAddress la;
if (!InetAddress.isNumeric(addr)) {
EventLogTags.writeBadIpAddress(addr);
throw new UnknownHostException("Non-numeric ip addr=" + addr);
if (response.addresses != null && response.addresses.length > 0) {
for (String addr : response.addresses) {
LinkAddress la;
if (!InetAddress.isNumeric(addr)) {
EventLogTags.writeBadIpAddress(addr);
throw new UnknownHostException("Non-numeric ip addr=" + addr);
}
InetAddress ia = InetAddress.getByName(addr);
if (ia instanceof Inet4Address) {
la = new LinkAddress(ia, 32);
} else {
la = new LinkAddress(ia, 128);
}
linkProperties.addLinkAddress(la);
}
InetAddress ia = InetAddress.getByName(addr);
if (ia instanceof Inet4Address) {
la = new LinkAddress(ia, 32);
} else {
la = new LinkAddress(ia, 128);
}
linkProperties.addLinkAddress(la);
} else {
EventLogTags.writeBadIpAddress("no address for ifname=" + response.ifname);
throw new UnknownHostException("no address for ifname=" + response.ifname);
}
if (response.dnses.length != 0) {
if (response.dnses != null && response.dnses.length > 0) {
for (String addr : response.dnses) {
if (!InetAddress.isNumeric(addr)) {
EventLogTags.writePdpBadDnsAddress("dns=" + addr);

View File

@@ -44,6 +44,7 @@ import android.telephony.NeighboringCellInfo;
import android.telephony.PhoneNumberUtils;
import android.telephony.SmsManager;
import android.telephony.SmsMessage;
import android.text.TextUtils;
import android.util.Config;
import android.util.Log;
@@ -2945,7 +2946,7 @@ public final class RIL extends BaseCommands implements CommandsInterface {
dataCall.type = p.readString();
p.readString(); // Ignore apn
String addresses = p.readString();
if (addresses != null) {
if (TextUtils.isEmpty(addresses)) {
dataCall.addresses = addresses.split(" ");
}
} else {
@@ -2954,12 +2955,15 @@ public final class RIL extends BaseCommands implements CommandsInterface {
dataCall.active = p.readInt();
dataCall.type = p.readString();
dataCall.ifname = p.readString();
if (TextUtils.isEmpty(dataCall.ifname)) {
throw new RuntimeException("getDataCallState, no ifname");
}
String addresses = p.readString();
if (addresses != null) {
if (!TextUtils.isEmpty(addresses)) {
dataCall.addresses = addresses.split(" ");
}
String dnses = p.readString();
if (addresses != null) {
if (!TextUtils.isEmpty(dnses)) {
dataCall.dnses = dnses.split(" ");
}
}
@@ -2991,23 +2995,25 @@ public final class RIL extends BaseCommands implements CommandsInterface {
DataCallState dataCall;
if (ver < 5) {
if (num != 3) {
throw new RuntimeException(
"RIL_REQUEST_SETUP_DATA_CALL response expecting 3 strings got " + num);
}
dataCall = new DataCallState();
dataCall.version = ver;
dataCall.cid = Integer.parseInt(p.readString());
dataCall.ifname = p.readString();
if (dataCall.ifname == null) {
if (TextUtils.isEmpty(dataCall.ifname)) {
throw new RuntimeException(
"RIL_REQUEST_SETUP_DATA_CALL response ifname");
"RIL_REQUEST_SETUP_DATA_CALL response, no ifname");
}
String addresses = p.readString();
if (addresses == null) {
throw new RuntimeException(
"RIL_REQUEST_SETUP_DATA_CALL response no addresses");
if (!TextUtils.isEmpty(addresses)) {
dataCall.addresses = addresses.split(" ");
}
if (num >= 4) {
String dnses = p.readString();
Log.d(LOG_TAG, "responseSetupDataCall got dnses=" + dnses);
if (!TextUtils.isEmpty(dnses)) {
dataCall.dnses = dnses.split(" ");
}
}
dataCall.addresses = addresses.split(" ");
} else {
if (num != 1) {
throw new RuntimeException(