1. wifi
2. MDS
3. WAP2
4. BIS-B
5. directTCP
6. WAP
HttpConnection hconn = hconn = (HttpConnection) Connector.open(url + connectionstring);
1. MDS (mobile data service): if no connection string is given, this is a default connection.
A. coverage check: CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_MDS)
B. connection string: “;deviceside = false”
2. BIS (blackberry internet services): if your application is approved from the blackberry, your application will connect to server regardless of internet configuration of device.
A. Coverage check: CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_DIRECT)
B. Connection string: “;deviceside = true”
3. Direct TCP: This method depends on carrier and supports limited roaming.
A. Coverage check: CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_DIRECT)
B. Connection string: “deviceside = true;apn=; tunnelauthusername=; tunnelauthpassword=”
4. WAP 2: It will connect through wap gateway and connection string provided by service book’s connectionUID.
A. A.Coverage check: CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_DIRECT)
B. connection string: ;deviceside=true” + “;ConnectionUID=” +wapRecord.getUid()
5. WAP 1.0:
A. Coverage check: CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_DIRECT)
B. connection String: “;deviceside = true;WapGatewayIP=
6. WiFi:
A. CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_DIRECT, RadioInfo.WAF_WLAN, false)
B. Connection string: “;interface = wifi”
7. Magic word(“;ConnectionType=mds-public”): This word is not documented anywhere in blackberry docs but it works for approx 90% of devices.
A. Coverage check: CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_DIRECT)
B. Connection string: “;deviceside=false”+mdspubRecord.getUid()+ “;ConnectionType=mds-public”
/**
* Determines what connection type to use and returns the necessary string to use it.
* @return A string with the connection info
*/
private static String getConnectionString()
{
// This code is based on the connection code developed by Mike Nelson of AccelGolf.
// http://blog.accelgolf.com/2009/05/22/blackberry-cross-carrier-and-cross-network-http-connection
String connectionString = null;
// Simulator behavior is controlled by the USE_MDS_IN_SIMULATOR variable.
if(DeviceInfo.isSimulator())
{
if(UploaderThread.USE_MDS_IN_SIMULATOR)
{
logMessage("Device is a simulator and USE_MDS_IN_SIMULATOR is true");
connectionString = ";deviceside=false";
}
else
{
logMessage("Device is a simulator and USE_MDS_IN_SIMULATOR is false");
connectionString = ";deviceside=true";
}
}
// Wifi is the preferred transmission method
else if(WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED)
{
logMessage("Device is connected via Wifi.");
connectionString = ";interface=wifi";
}
// Is the carrier network the only way to connect?
else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT)
{
logMessage("Carrier coverage.");
String carrierUid = getCarrierBIBSUid();
if(carrierUid == null)
{
// Has carrier coverage, but not BIBS. So use the carrier's TCP network
logMessage("No Uid");
connectionString = ";deviceside=true";
}
else
{
// otherwise, use the Uid to construct a valid carrier BIBS request
logMessage("uid is: " + carrierUid);
connectionString = ";deviceside=false;connectionUID="+carrierUid + ";ConnectionType=mds-public";
}
}
// Check for an MDS connection instead (BlackBerry Enterprise Server)
else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS)
{
logMessage("MDS coverage found");
connectionString = ";deviceside=false";
}
// If there is no connection available abort to avoid bugging the user unnecssarily.
else if(CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE)
{
logMessage("There is no available connection.");
}
// In theory, all bases are covered so this shouldn't be reachable.
else
{
logMessage("no other options found, assuming device.");
connectionString = ";deviceside=true";
}
return connectionString;
}
/**
* Looks through the phone's service book for a carrier provided BIBS network
* @return The uid used to connect to that network.
*/
private static String getCarrierBIBSUid()
{
ServiceRecord[] records = ServiceBook.getSB().getRecords();
int currentRecord;
for(currentRecord = 0; currentRecord < records.length; currentRecord++) { if(records[currentRecord].getCid().toLowerCase().equals("ippp")) { if(records[currentRecord].getName().toLowerCase().indexOf("bibs") >= 0)
{
return records[currentRecord].getUid();
}
}
}
return null;
}
No comments:
Post a Comment