Loading src/java/com/android/internal/telephony/RIL.java +77 −5 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import android.hardware.radio.V1_0.SimApdu; import android.hardware.radio.V1_0.SmsWriteArgs; import android.hardware.radio.V1_0.UusInfo; import android.net.ConnectivityManager; import android.net.NetworkUtils; import android.os.AsyncResult; import android.os.Build; import android.os.Handler; Loading Loading @@ -81,7 +82,9 @@ import android.telephony.SignalStrength; import android.telephony.SmsManager; import android.telephony.TelephonyHistogram; import android.telephony.TelephonyManager; import android.telephony.data.DataCallResponse; import android.telephony.data.DataProfile; import android.telephony.data.InterfaceAddress; import android.text.TextUtils; import android.util.Log; import android.util.SparseArray; Loading @@ -91,7 +94,6 @@ import com.android.internal.telephony.cat.ComprehensionTlv; import com.android.internal.telephony.cat.ComprehensionTlvTag; import com.android.internal.telephony.cdma.CdmaInformationRecords; import com.android.internal.telephony.cdma.CdmaSmsBroadcastConfigInfo; import com.android.internal.telephony.dataconnection.DataCallResponse; import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo; import com.android.internal.telephony.metrics.TelephonyMetrics; import com.android.internal.telephony.nano.TelephonyProto.SmsSession; Loading @@ -102,6 +104,8 @@ import java.io.DataInputStream; import java.io.FileDescriptor; import java.io.IOException; import java.io.PrintWriter; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; Loading Loading @@ -1114,16 +1118,84 @@ public class RIL extends BaseCommands implements CommandsInterface { * @return converted DataCallResponse object */ static DataCallResponse convertDataCallResult(SetupDataCallResult dcResult) { // Process address String[] addresses = null; if (!TextUtils.isEmpty(dcResult.addresses)) { addresses = dcResult.addresses.split(" "); } List<InterfaceAddress> iaList = new ArrayList<>(); if (addresses != null) { for (String address : addresses) { address = address.trim(); if (address.isEmpty()) continue; String[] ap = address.split("/"); int addrPrefixLen = 0; if (ap.length == 2) { addrPrefixLen = Integer.parseInt(ap[1]); } try { InterfaceAddress ia = new InterfaceAddress(ap[0], addrPrefixLen); iaList.add(ia); } catch (UnknownHostException e) { Rlog.e(RILJ_LOG_TAG, "Unknown host exception: " + e); } } } // Process dns String[] dnses = null; if (!TextUtils.isEmpty(dcResult.dnses)) { dnses = dcResult.dnses.split(" "); } List<InetAddress> dnsList = new ArrayList<>(); if (dnses != null) { for (String dns : dnses) { dns = dns.trim(); InetAddress ia; try { ia = NetworkUtils.numericToInetAddress(dns); dnsList.add(ia); } catch (IllegalArgumentException e) { Rlog.e(RILJ_LOG_TAG, "Unknown dns: " + dns + ", exception = " + e); } } } // Process gateway String[] gateways = null; if (!TextUtils.isEmpty(dcResult.gateways)) { gateways = dcResult.gateways.split(" "); } List<InetAddress> gatewayList = new ArrayList<>(); if (gateways != null) { for (String gateway : gateways) { gateway = gateway.trim(); InetAddress ia; try { ia = NetworkUtils.numericToInetAddress(gateway); gatewayList.add(ia); } catch (IllegalArgumentException e) { Rlog.e(RILJ_LOG_TAG, "Unknown gateway: " + gateway + ", exception = " + e); } } } return new DataCallResponse(dcResult.status, dcResult.suggestedRetryTime, dcResult.cid, dcResult.active, dcResult.type, dcResult.ifname, dcResult.addresses, dcResult.dnses, dcResult.gateways, dcResult.pcscf, iaList, dnsList, gatewayList, new ArrayList<>(Arrays.asList(dcResult.pcscf.trim().split("\\s*,\\s*"))), dcResult.mtu ); } Loading src/java/com/android/internal/telephony/RadioIndication.java +1 −1 Original line number Diff line number Diff line Loading @@ -88,11 +88,11 @@ import android.telephony.CellInfo; import android.telephony.PcoData; import android.telephony.SignalStrength; import android.telephony.SmsMessage; import android.telephony.data.DataCallResponse; import com.android.internal.telephony.cdma.CdmaCallWaitingNotification; import com.android.internal.telephony.cdma.CdmaInformationRecords; import com.android.internal.telephony.cdma.SmsMessageConverter; import com.android.internal.telephony.dataconnection.DataCallResponse; import com.android.internal.telephony.gsm.SsData; import com.android.internal.telephony.gsm.SuppServiceNotification; import com.android.internal.telephony.nano.TelephonyProto.SmsSession; Loading src/java/com/android/internal/telephony/RadioResponse.java +1 −1 Original line number Diff line number Diff line Loading @@ -46,9 +46,9 @@ import android.telephony.PhoneNumberUtils; import android.telephony.SignalStrength; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.data.DataCallResponse; import android.text.TextUtils; import com.android.internal.telephony.dataconnection.DataCallResponse; import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo; import com.android.internal.telephony.uicc.IccCardApplicationStatus; import com.android.internal.telephony.uicc.IccCardStatus; Loading src/java/com/android/internal/telephony/dataconnection/DataCallResponse.javadeleted 100644 → 0 +0 −114 Original line number Diff line number Diff line /* * Copyright (C) 2009 Qualcomm Innovation Center, Inc. All Rights Reserved. * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.telephony.dataconnection; import android.os.SystemProperties; import android.text.TextUtils; /** * This is RIL_Data_Call_Response_v5 from ril.h */ public class DataCallResponse { private final boolean DBG = true; private final String LOG_TAG = "DataCallResponse"; public final int status; public final int suggestedRetryTime; public final int cid; public final int active; public final String type; public final String ifname; public final String [] addresses; public final String [] dnses; public final String[] gateways; public final String [] pcscf; public final int mtu; public DataCallResponse(int status, int suggestedRetryTime, int cid, int active, String type, String ifname, String addresses, String dnses, String gateways, String pcscf, int mtu) { this.status = status; this.suggestedRetryTime = suggestedRetryTime; this.cid = cid; this.active = active; this.type = (type == null) ? "" : type; this.ifname = (ifname == null) ? "" : ifname; if ((status == DcFailCause.NONE.getErrorCode()) && TextUtils.isEmpty(ifname)) { throw new RuntimeException("DataCallResponse, no ifname"); } this.addresses = TextUtils.isEmpty(addresses) ? new String[0] : addresses.split(" "); this.dnses = TextUtils.isEmpty(dnses) ? new String[0] : dnses.split(" "); String[] myGateways = TextUtils.isEmpty(gateways) ? new String[0] : gateways.split(" "); // set gateways if (myGateways.length == 0) { String propertyPrefix = "net." + this.ifname + "."; String sysGateways = SystemProperties.get(propertyPrefix + "gw"); if (sysGateways != null) { myGateways = sysGateways.split(" "); } else { myGateways = new String[0]; } } this.gateways = myGateways; this.pcscf = TextUtils.isEmpty(pcscf) ? new String[0] : pcscf.split(" "); this.mtu = mtu; } @Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append("DataCallResponse: {") .append(" status=").append(status) .append(" retry=").append(suggestedRetryTime) .append(" cid=").append(cid) .append(" active=").append(active) .append(" type=").append(type) .append(" ifname=").append(ifname) .append(" mtu=").append(mtu) .append(" addresses=["); for (String addr : addresses) { sb.append(addr); sb.append(","); } if (addresses.length > 0) sb.deleteCharAt(sb.length()-1); sb.append("] dnses=["); for (String addr : dnses) { sb.append(addr); sb.append(","); } if (dnses.length > 0) sb.deleteCharAt(sb.length()-1); sb.append("] gateways=["); for (String addr : gateways) { sb.append(addr); sb.append(","); } if (gateways.length > 0) sb.deleteCharAt(sb.length()-1); sb.append("] pcscf=["); for (String addr : pcscf) { sb.append(addr); sb.append(","); } if (pcscf.length > 0) sb.deleteCharAt(sb.length()-1); sb.append("]}"); return sb.toString(); } } src/java/com/android/internal/telephony/dataconnection/DataConnection.java +38 −83 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import android.net.NetworkAgent; import android.net.NetworkCapabilities; import android.net.NetworkInfo; import android.net.NetworkMisc; import android.net.NetworkUtils; import android.net.ProxyInfo; import android.net.RouteInfo; import android.net.StringNetworkSpecifier; Loading @@ -37,7 +36,9 @@ import android.os.SystemProperties; import android.telephony.Rlog; import android.telephony.ServiceState; import android.telephony.TelephonyManager; import android.telephony.data.DataCallResponse; import android.telephony.data.DataProfile; import android.telephony.data.InterfaceAddress; import android.text.TextUtils; import android.util.LocalLog; import android.util.Pair; Loading Loading @@ -452,13 +453,13 @@ public class DataConnection extends StateMachine { addState(mDisconnectingErrorCreatingConnection, mDefaultState); setInitialState(mInactiveState); mApnContexts = new HashMap<ApnContext, ConnectionParams>(); mApnContexts = new HashMap<>(); } /** * Begin setting up a data connection, calls setupDataCall * and the ConnectionParams will be returned with the * EVENT_SETUP_DATA_CONNECTION_DONE AsyncResul.userObj. * EVENT_SETUP_DATA_CONNECTION_DONE AsyncResult.userObj. * * @param cp is the connection parameters */ Loading @@ -473,7 +474,7 @@ public class DataConnection extends StateMachine { DataCallResponse response = new DataCallResponse( mDcTesterFailBringUpAll.getDcFailBringUp().mFailCause.getErrorCode(), mDcTesterFailBringUpAll.getDcFailBringUp().mSuggestedRetryTime, 0, 0, "", "", "", "", "", "", PhoneConstants.UNSET_MTU); null, null, null, null, PhoneConstants.UNSET_MTU); Message msg = obtainMessage(EVENT_SETUP_DATA_CONNECTION_DONE, cp); AsyncResult.forMessage(msg, response, null); Loading Loading @@ -717,16 +718,16 @@ public class DataConnection extends StateMachine { result.mFailCause = DcFailCause.RADIO_NOT_AVAILABLE; } else { result = SetupResult.ERR_RilError; result.mFailCause = DcFailCause.fromInt(response.status); result.mFailCause = DcFailCause.fromInt(response.getStatus()); } } else if (response.status != 0) { } else if (response.getStatus() != 0) { result = SetupResult.ERR_RilError; result.mFailCause = DcFailCause.fromInt(response.status); result.mFailCause = DcFailCause.fromInt(response.getStatus()); } else { if (DBG) log("onSetupConnectionCompleted received successful DataCallResponse"); mCid = response.cid; mCid = response.getCallId(); mPcscfAddr = response.pcscf; mPcscfAddr = response.getPcscfs().toArray(new String[response.getPcscfs().size()]); result = updateLinkProperty(response).setupResult; } Loading Loading @@ -1027,7 +1028,7 @@ public class DataConnection extends StateMachine { private SetupResult setLinkProperties(DataCallResponse response, LinkProperties linkProperties) { // Check if system property dns usable String propertyPrefix = "net." + response.ifname + "."; String propertyPrefix = "net." + response.getIfname() + "."; String dnsServers[] = new String[2]; dnsServers[0] = SystemProperties.get(propertyPrefix + "dns1"); dnsServers[1] = SystemProperties.get(propertyPrefix + "dns2"); Loading @@ -1039,103 +1040,57 @@ public class DataConnection extends StateMachine { // a failure we'll clear again at the bottom of this code. linkProperties.clear(); if (response.status == DcFailCause.NONE.getErrorCode()) { if (response.getStatus() == DcFailCause.NONE.getErrorCode()) { try { // set interface name linkProperties.setInterfaceName(response.ifname); linkProperties.setInterfaceName(response.getIfname()); // set link addresses if (response.addresses != null && response.addresses.length > 0) { for (String addr : response.addresses) { addr = addr.trim(); if (addr.isEmpty()) continue; LinkAddress la; int addrPrefixLen; String [] ap = addr.split("/"); if (ap.length == 2) { addr = ap[0]; addrPrefixLen = Integer.parseInt(ap[1]); } else { addrPrefixLen = 0; } InetAddress ia; try { ia = NetworkUtils.numericToInetAddress(addr); } catch (IllegalArgumentException e) { throw new UnknownHostException("Non-numeric ip addr=" + addr); } if (!ia.isAnyLocalAddress()) { if (response.getAddresses().size() > 0) { for (InterfaceAddress ia : response.getAddresses()) { if (!ia.getAddress().isAnyLocalAddress()) { int addrPrefixLen = ia.getNetworkPrefixLength(); if (addrPrefixLen == 0) { // Assume point to point addrPrefixLen = (ia instanceof Inet4Address) ? 32 : 128; addrPrefixLen = (ia.getAddress() instanceof Inet4Address) ? 32 : 128; } if (DBG) log("addr/pl=" + addr + "/" + addrPrefixLen); if (DBG) log("addr/pl=" + ia.getAddress() + "/" + addrPrefixLen); LinkAddress la; try { la = new LinkAddress(ia, addrPrefixLen); la = new LinkAddress(ia.getAddress(), addrPrefixLen); } catch (IllegalArgumentException e) { throw new UnknownHostException("Bad parameter for LinkAddress, ia=" + ia.getHostAddress() + "/" + addrPrefixLen); + ia.getAddress().getHostAddress() + "/" + addrPrefixLen); } linkProperties.addLinkAddress(la); } } } else { throw new UnknownHostException("no address for ifname=" + response.ifname); throw new UnknownHostException("no address for ifname=" + response.getIfname()); } // set dns servers if (response.dnses != null && response.dnses.length > 0) { for (String addr : response.dnses) { addr = addr.trim(); if (addr.isEmpty()) continue; InetAddress ia; try { ia = NetworkUtils.numericToInetAddress(addr); } catch (IllegalArgumentException e) { throw new UnknownHostException("Non-numeric dns addr=" + addr); } if (!ia.isAnyLocalAddress()) { linkProperties.addDnsServer(ia); } } } else if (okToUseSystemPropertyDns) { dnsServers[0] = SystemProperties.get(propertyPrefix + "dns1"); dnsServers[1] = SystemProperties.get(propertyPrefix + "dns2"); for (String dnsAddr : dnsServers) { dnsAddr = dnsAddr.trim(); if (dnsAddr.isEmpty()) continue; InetAddress ia; try { ia = NetworkUtils.numericToInetAddress(dnsAddr); } catch (IllegalArgumentException e) { throw new UnknownHostException("Non-numeric dns addr=" + dnsAddr); } if (!ia.isAnyLocalAddress()) { linkProperties.addDnsServer(ia); if (response.getDnses().size() > 0) { for (InetAddress dns : response.getDnses()) { if (!dns.isAnyLocalAddress()) { linkProperties.addDnsServer(dns); } } } else { throw new UnknownHostException("Empty dns response and no system default dns"); } for (String addr : response.gateways) { addr = addr.trim(); if (addr.isEmpty()) continue; InetAddress ia; try { ia = NetworkUtils.numericToInetAddress(addr); } catch (IllegalArgumentException e) { throw new UnknownHostException("Non-numeric gateway addr=" + addr); } // Allow 0.0.0.0 or :: as a gateway; this indicates a point-to-point interface. linkProperties.addRoute(new RouteInfo(ia)); for (InetAddress gateway : response.getGateways()) { // Allow 0.0.0.0 or :: as a gateway; // this indicates a point-to-point interface. linkProperties.addRoute(new RouteInfo(gateway)); } // set interface MTU // this may clobber the setting read from the APN db, but that's ok linkProperties.setMtu(response.mtu); linkProperties.setMtu(response.getMtu()); result = SetupResult.SUCCESS; } catch (UnknownHostException e) { Loading @@ -1150,8 +1105,8 @@ public class DataConnection extends StateMachine { // An error occurred so clear properties if (result != SetupResult.SUCCESS) { if (DBG) { log("setLinkProperties: error clearing LinkProperties status=" + response.status + " result=" + result); log("setLinkProperties: error clearing LinkProperties status=" + response.getStatus() + " result=" + result); } linkProperties.clear(); } Loading Loading @@ -2070,19 +2025,19 @@ public class DataConnection extends StateMachine { */ // The value < 0 means no value is suggested if (response.suggestedRetryTime < 0) { if (response.getSuggestedRetryTime() < 0) { if (DBG) log("No suggested retry delay."); return RetryManager.NO_SUGGESTED_RETRY_DELAY; } // The value of Integer.MAX_VALUE(0x7fffffff) means no retry. else if (response.suggestedRetryTime == Integer.MAX_VALUE) { else if (response.getSuggestedRetryTime() == Integer.MAX_VALUE) { if (DBG) log("Modem suggested not retrying."); return RetryManager.NO_RETRY; } // We need to cast it to long because the value returned from RIL is a 32-bit integer, // but the time values used in AlarmManager are all 64-bit long. return (long) response.suggestedRetryTime; return (long) response.getSuggestedRetryTime(); } /** Loading Loading
src/java/com/android/internal/telephony/RIL.java +77 −5 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import android.hardware.radio.V1_0.SimApdu; import android.hardware.radio.V1_0.SmsWriteArgs; import android.hardware.radio.V1_0.UusInfo; import android.net.ConnectivityManager; import android.net.NetworkUtils; import android.os.AsyncResult; import android.os.Build; import android.os.Handler; Loading Loading @@ -81,7 +82,9 @@ import android.telephony.SignalStrength; import android.telephony.SmsManager; import android.telephony.TelephonyHistogram; import android.telephony.TelephonyManager; import android.telephony.data.DataCallResponse; import android.telephony.data.DataProfile; import android.telephony.data.InterfaceAddress; import android.text.TextUtils; import android.util.Log; import android.util.SparseArray; Loading @@ -91,7 +94,6 @@ import com.android.internal.telephony.cat.ComprehensionTlv; import com.android.internal.telephony.cat.ComprehensionTlvTag; import com.android.internal.telephony.cdma.CdmaInformationRecords; import com.android.internal.telephony.cdma.CdmaSmsBroadcastConfigInfo; import com.android.internal.telephony.dataconnection.DataCallResponse; import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo; import com.android.internal.telephony.metrics.TelephonyMetrics; import com.android.internal.telephony.nano.TelephonyProto.SmsSession; Loading @@ -102,6 +104,8 @@ import java.io.DataInputStream; import java.io.FileDescriptor; import java.io.IOException; import java.io.PrintWriter; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; Loading Loading @@ -1114,16 +1118,84 @@ public class RIL extends BaseCommands implements CommandsInterface { * @return converted DataCallResponse object */ static DataCallResponse convertDataCallResult(SetupDataCallResult dcResult) { // Process address String[] addresses = null; if (!TextUtils.isEmpty(dcResult.addresses)) { addresses = dcResult.addresses.split(" "); } List<InterfaceAddress> iaList = new ArrayList<>(); if (addresses != null) { for (String address : addresses) { address = address.trim(); if (address.isEmpty()) continue; String[] ap = address.split("/"); int addrPrefixLen = 0; if (ap.length == 2) { addrPrefixLen = Integer.parseInt(ap[1]); } try { InterfaceAddress ia = new InterfaceAddress(ap[0], addrPrefixLen); iaList.add(ia); } catch (UnknownHostException e) { Rlog.e(RILJ_LOG_TAG, "Unknown host exception: " + e); } } } // Process dns String[] dnses = null; if (!TextUtils.isEmpty(dcResult.dnses)) { dnses = dcResult.dnses.split(" "); } List<InetAddress> dnsList = new ArrayList<>(); if (dnses != null) { for (String dns : dnses) { dns = dns.trim(); InetAddress ia; try { ia = NetworkUtils.numericToInetAddress(dns); dnsList.add(ia); } catch (IllegalArgumentException e) { Rlog.e(RILJ_LOG_TAG, "Unknown dns: " + dns + ", exception = " + e); } } } // Process gateway String[] gateways = null; if (!TextUtils.isEmpty(dcResult.gateways)) { gateways = dcResult.gateways.split(" "); } List<InetAddress> gatewayList = new ArrayList<>(); if (gateways != null) { for (String gateway : gateways) { gateway = gateway.trim(); InetAddress ia; try { ia = NetworkUtils.numericToInetAddress(gateway); gatewayList.add(ia); } catch (IllegalArgumentException e) { Rlog.e(RILJ_LOG_TAG, "Unknown gateway: " + gateway + ", exception = " + e); } } } return new DataCallResponse(dcResult.status, dcResult.suggestedRetryTime, dcResult.cid, dcResult.active, dcResult.type, dcResult.ifname, dcResult.addresses, dcResult.dnses, dcResult.gateways, dcResult.pcscf, iaList, dnsList, gatewayList, new ArrayList<>(Arrays.asList(dcResult.pcscf.trim().split("\\s*,\\s*"))), dcResult.mtu ); } Loading
src/java/com/android/internal/telephony/RadioIndication.java +1 −1 Original line number Diff line number Diff line Loading @@ -88,11 +88,11 @@ import android.telephony.CellInfo; import android.telephony.PcoData; import android.telephony.SignalStrength; import android.telephony.SmsMessage; import android.telephony.data.DataCallResponse; import com.android.internal.telephony.cdma.CdmaCallWaitingNotification; import com.android.internal.telephony.cdma.CdmaInformationRecords; import com.android.internal.telephony.cdma.SmsMessageConverter; import com.android.internal.telephony.dataconnection.DataCallResponse; import com.android.internal.telephony.gsm.SsData; import com.android.internal.telephony.gsm.SuppServiceNotification; import com.android.internal.telephony.nano.TelephonyProto.SmsSession; Loading
src/java/com/android/internal/telephony/RadioResponse.java +1 −1 Original line number Diff line number Diff line Loading @@ -46,9 +46,9 @@ import android.telephony.PhoneNumberUtils; import android.telephony.SignalStrength; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.data.DataCallResponse; import android.text.TextUtils; import com.android.internal.telephony.dataconnection.DataCallResponse; import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo; import com.android.internal.telephony.uicc.IccCardApplicationStatus; import com.android.internal.telephony.uicc.IccCardStatus; Loading
src/java/com/android/internal/telephony/dataconnection/DataCallResponse.javadeleted 100644 → 0 +0 −114 Original line number Diff line number Diff line /* * Copyright (C) 2009 Qualcomm Innovation Center, Inc. All Rights Reserved. * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.telephony.dataconnection; import android.os.SystemProperties; import android.text.TextUtils; /** * This is RIL_Data_Call_Response_v5 from ril.h */ public class DataCallResponse { private final boolean DBG = true; private final String LOG_TAG = "DataCallResponse"; public final int status; public final int suggestedRetryTime; public final int cid; public final int active; public final String type; public final String ifname; public final String [] addresses; public final String [] dnses; public final String[] gateways; public final String [] pcscf; public final int mtu; public DataCallResponse(int status, int suggestedRetryTime, int cid, int active, String type, String ifname, String addresses, String dnses, String gateways, String pcscf, int mtu) { this.status = status; this.suggestedRetryTime = suggestedRetryTime; this.cid = cid; this.active = active; this.type = (type == null) ? "" : type; this.ifname = (ifname == null) ? "" : ifname; if ((status == DcFailCause.NONE.getErrorCode()) && TextUtils.isEmpty(ifname)) { throw new RuntimeException("DataCallResponse, no ifname"); } this.addresses = TextUtils.isEmpty(addresses) ? new String[0] : addresses.split(" "); this.dnses = TextUtils.isEmpty(dnses) ? new String[0] : dnses.split(" "); String[] myGateways = TextUtils.isEmpty(gateways) ? new String[0] : gateways.split(" "); // set gateways if (myGateways.length == 0) { String propertyPrefix = "net." + this.ifname + "."; String sysGateways = SystemProperties.get(propertyPrefix + "gw"); if (sysGateways != null) { myGateways = sysGateways.split(" "); } else { myGateways = new String[0]; } } this.gateways = myGateways; this.pcscf = TextUtils.isEmpty(pcscf) ? new String[0] : pcscf.split(" "); this.mtu = mtu; } @Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append("DataCallResponse: {") .append(" status=").append(status) .append(" retry=").append(suggestedRetryTime) .append(" cid=").append(cid) .append(" active=").append(active) .append(" type=").append(type) .append(" ifname=").append(ifname) .append(" mtu=").append(mtu) .append(" addresses=["); for (String addr : addresses) { sb.append(addr); sb.append(","); } if (addresses.length > 0) sb.deleteCharAt(sb.length()-1); sb.append("] dnses=["); for (String addr : dnses) { sb.append(addr); sb.append(","); } if (dnses.length > 0) sb.deleteCharAt(sb.length()-1); sb.append("] gateways=["); for (String addr : gateways) { sb.append(addr); sb.append(","); } if (gateways.length > 0) sb.deleteCharAt(sb.length()-1); sb.append("] pcscf=["); for (String addr : pcscf) { sb.append(addr); sb.append(","); } if (pcscf.length > 0) sb.deleteCharAt(sb.length()-1); sb.append("]}"); return sb.toString(); } }
src/java/com/android/internal/telephony/dataconnection/DataConnection.java +38 −83 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import android.net.NetworkAgent; import android.net.NetworkCapabilities; import android.net.NetworkInfo; import android.net.NetworkMisc; import android.net.NetworkUtils; import android.net.ProxyInfo; import android.net.RouteInfo; import android.net.StringNetworkSpecifier; Loading @@ -37,7 +36,9 @@ import android.os.SystemProperties; import android.telephony.Rlog; import android.telephony.ServiceState; import android.telephony.TelephonyManager; import android.telephony.data.DataCallResponse; import android.telephony.data.DataProfile; import android.telephony.data.InterfaceAddress; import android.text.TextUtils; import android.util.LocalLog; import android.util.Pair; Loading Loading @@ -452,13 +453,13 @@ public class DataConnection extends StateMachine { addState(mDisconnectingErrorCreatingConnection, mDefaultState); setInitialState(mInactiveState); mApnContexts = new HashMap<ApnContext, ConnectionParams>(); mApnContexts = new HashMap<>(); } /** * Begin setting up a data connection, calls setupDataCall * and the ConnectionParams will be returned with the * EVENT_SETUP_DATA_CONNECTION_DONE AsyncResul.userObj. * EVENT_SETUP_DATA_CONNECTION_DONE AsyncResult.userObj. * * @param cp is the connection parameters */ Loading @@ -473,7 +474,7 @@ public class DataConnection extends StateMachine { DataCallResponse response = new DataCallResponse( mDcTesterFailBringUpAll.getDcFailBringUp().mFailCause.getErrorCode(), mDcTesterFailBringUpAll.getDcFailBringUp().mSuggestedRetryTime, 0, 0, "", "", "", "", "", "", PhoneConstants.UNSET_MTU); null, null, null, null, PhoneConstants.UNSET_MTU); Message msg = obtainMessage(EVENT_SETUP_DATA_CONNECTION_DONE, cp); AsyncResult.forMessage(msg, response, null); Loading Loading @@ -717,16 +718,16 @@ public class DataConnection extends StateMachine { result.mFailCause = DcFailCause.RADIO_NOT_AVAILABLE; } else { result = SetupResult.ERR_RilError; result.mFailCause = DcFailCause.fromInt(response.status); result.mFailCause = DcFailCause.fromInt(response.getStatus()); } } else if (response.status != 0) { } else if (response.getStatus() != 0) { result = SetupResult.ERR_RilError; result.mFailCause = DcFailCause.fromInt(response.status); result.mFailCause = DcFailCause.fromInt(response.getStatus()); } else { if (DBG) log("onSetupConnectionCompleted received successful DataCallResponse"); mCid = response.cid; mCid = response.getCallId(); mPcscfAddr = response.pcscf; mPcscfAddr = response.getPcscfs().toArray(new String[response.getPcscfs().size()]); result = updateLinkProperty(response).setupResult; } Loading Loading @@ -1027,7 +1028,7 @@ public class DataConnection extends StateMachine { private SetupResult setLinkProperties(DataCallResponse response, LinkProperties linkProperties) { // Check if system property dns usable String propertyPrefix = "net." + response.ifname + "."; String propertyPrefix = "net." + response.getIfname() + "."; String dnsServers[] = new String[2]; dnsServers[0] = SystemProperties.get(propertyPrefix + "dns1"); dnsServers[1] = SystemProperties.get(propertyPrefix + "dns2"); Loading @@ -1039,103 +1040,57 @@ public class DataConnection extends StateMachine { // a failure we'll clear again at the bottom of this code. linkProperties.clear(); if (response.status == DcFailCause.NONE.getErrorCode()) { if (response.getStatus() == DcFailCause.NONE.getErrorCode()) { try { // set interface name linkProperties.setInterfaceName(response.ifname); linkProperties.setInterfaceName(response.getIfname()); // set link addresses if (response.addresses != null && response.addresses.length > 0) { for (String addr : response.addresses) { addr = addr.trim(); if (addr.isEmpty()) continue; LinkAddress la; int addrPrefixLen; String [] ap = addr.split("/"); if (ap.length == 2) { addr = ap[0]; addrPrefixLen = Integer.parseInt(ap[1]); } else { addrPrefixLen = 0; } InetAddress ia; try { ia = NetworkUtils.numericToInetAddress(addr); } catch (IllegalArgumentException e) { throw new UnknownHostException("Non-numeric ip addr=" + addr); } if (!ia.isAnyLocalAddress()) { if (response.getAddresses().size() > 0) { for (InterfaceAddress ia : response.getAddresses()) { if (!ia.getAddress().isAnyLocalAddress()) { int addrPrefixLen = ia.getNetworkPrefixLength(); if (addrPrefixLen == 0) { // Assume point to point addrPrefixLen = (ia instanceof Inet4Address) ? 32 : 128; addrPrefixLen = (ia.getAddress() instanceof Inet4Address) ? 32 : 128; } if (DBG) log("addr/pl=" + addr + "/" + addrPrefixLen); if (DBG) log("addr/pl=" + ia.getAddress() + "/" + addrPrefixLen); LinkAddress la; try { la = new LinkAddress(ia, addrPrefixLen); la = new LinkAddress(ia.getAddress(), addrPrefixLen); } catch (IllegalArgumentException e) { throw new UnknownHostException("Bad parameter for LinkAddress, ia=" + ia.getHostAddress() + "/" + addrPrefixLen); + ia.getAddress().getHostAddress() + "/" + addrPrefixLen); } linkProperties.addLinkAddress(la); } } } else { throw new UnknownHostException("no address for ifname=" + response.ifname); throw new UnknownHostException("no address for ifname=" + response.getIfname()); } // set dns servers if (response.dnses != null && response.dnses.length > 0) { for (String addr : response.dnses) { addr = addr.trim(); if (addr.isEmpty()) continue; InetAddress ia; try { ia = NetworkUtils.numericToInetAddress(addr); } catch (IllegalArgumentException e) { throw new UnknownHostException("Non-numeric dns addr=" + addr); } if (!ia.isAnyLocalAddress()) { linkProperties.addDnsServer(ia); } } } else if (okToUseSystemPropertyDns) { dnsServers[0] = SystemProperties.get(propertyPrefix + "dns1"); dnsServers[1] = SystemProperties.get(propertyPrefix + "dns2"); for (String dnsAddr : dnsServers) { dnsAddr = dnsAddr.trim(); if (dnsAddr.isEmpty()) continue; InetAddress ia; try { ia = NetworkUtils.numericToInetAddress(dnsAddr); } catch (IllegalArgumentException e) { throw new UnknownHostException("Non-numeric dns addr=" + dnsAddr); } if (!ia.isAnyLocalAddress()) { linkProperties.addDnsServer(ia); if (response.getDnses().size() > 0) { for (InetAddress dns : response.getDnses()) { if (!dns.isAnyLocalAddress()) { linkProperties.addDnsServer(dns); } } } else { throw new UnknownHostException("Empty dns response and no system default dns"); } for (String addr : response.gateways) { addr = addr.trim(); if (addr.isEmpty()) continue; InetAddress ia; try { ia = NetworkUtils.numericToInetAddress(addr); } catch (IllegalArgumentException e) { throw new UnknownHostException("Non-numeric gateway addr=" + addr); } // Allow 0.0.0.0 or :: as a gateway; this indicates a point-to-point interface. linkProperties.addRoute(new RouteInfo(ia)); for (InetAddress gateway : response.getGateways()) { // Allow 0.0.0.0 or :: as a gateway; // this indicates a point-to-point interface. linkProperties.addRoute(new RouteInfo(gateway)); } // set interface MTU // this may clobber the setting read from the APN db, but that's ok linkProperties.setMtu(response.mtu); linkProperties.setMtu(response.getMtu()); result = SetupResult.SUCCESS; } catch (UnknownHostException e) { Loading @@ -1150,8 +1105,8 @@ public class DataConnection extends StateMachine { // An error occurred so clear properties if (result != SetupResult.SUCCESS) { if (DBG) { log("setLinkProperties: error clearing LinkProperties status=" + response.status + " result=" + result); log("setLinkProperties: error clearing LinkProperties status=" + response.getStatus() + " result=" + result); } linkProperties.clear(); } Loading Loading @@ -2070,19 +2025,19 @@ public class DataConnection extends StateMachine { */ // The value < 0 means no value is suggested if (response.suggestedRetryTime < 0) { if (response.getSuggestedRetryTime() < 0) { if (DBG) log("No suggested retry delay."); return RetryManager.NO_SUGGESTED_RETRY_DELAY; } // The value of Integer.MAX_VALUE(0x7fffffff) means no retry. else if (response.suggestedRetryTime == Integer.MAX_VALUE) { else if (response.getSuggestedRetryTime() == Integer.MAX_VALUE) { if (DBG) log("Modem suggested not retrying."); return RetryManager.NO_RETRY; } // We need to cast it to long because the value returned from RIL is a 32-bit integer, // but the time values used in AlarmManager are all 64-bit long. return (long) response.suggestedRetryTime; return (long) response.getSuggestedRetryTime(); } /** Loading