I get the connection parameters for my HTTP call using the code that follows below.
It works on my test phones and emulators. However for some people (possibly just 9700 users, but I can’t guarantee it) it causes "Failed to transmit" errors even when they have an otherwise working 3G/wifi connection.
What am I doing wrong?
private String getConnectionParameters()
{
String strCP = null;
int coverageStatus = CoverageInfo.getCoverageStatus();
if((coverageStatus & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT)
{
// Carrier coverage
String carrierUid = getCarrierBIBSUid();
if(carrierUid == null)
{
String wap2 = getWAP2ServiceRecord();
if (wap2 != null)
{
// Try using WAP2
strCP = ";deviceside=false;connectionUID="+wap2;
}
else
{
// Has carrier coverage, but not BIBS or WAP2. So use the carrier's TCP network
strCP = ";deviceside=true";
}
}
else
{
// otherwise, use the Uid to construct a valid carrier BIBS request
strCP = ";deviceside=false;connectionUID="+carrierUid + ";ConnectionType=mds-public";
}
}
else if((coverageStatus & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS)
{
// MDS coverage found
strCP = ";deviceside=false";
}
else if((WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) && RadioInfo.areWAFsSupported(RadioInfo.WAF_WLAN))
{
// Device is connected via Wifi
strCP = ";interface=wifi";
}
else if(coverageStatus == CoverageInfo.COVERAGE_NONE)
{
// There is no available connection
strCP = "";
}
else
{
// no other options found, assuming device
strCP = ";deviceside=true";
}
return strCP;
}
private String getCarrierBIBSUid()
{
ServiceRecord[] records = ServiceBook.getSB().getRecords();
for(int i = 0; i < records.length; i++)
{
if(records[i].getCid().toLowerCase().equals("ippp"))
{
if(records[i].getName().toLowerCase().indexOf("bibs") >= 0)
{
return records[i].getUid();
}
}
}
return null;
}
private String getWAP2ServiceRecord()
{
ServiceBook sb = ServiceBook.getSB();
ServiceRecord[] records = sb.getRecords();
for (int i = 0; i < records.length; i++)
{
String cid = records[i].getCid().toLowerCase();
String uid = records[i].getUid().toLowerCase();
if ((cid.indexOf("wptcp") != -1) && (uid.indexOf("wifi") == -1) && (uid.indexOf("mms") == -1))
{
return records[i].getUid();
}
}
return null;
}
I had the same issue with my connection class before I found the Versatile Monkey connection code
My problem was with BIS connections, you need to loop and try each connection. Not sure if it’s a carrier thing, or a CDMA vs GSM thing.