Blackberry - 这是检测有效连接类型的有保证的方法吗?

发布于 2024-08-14 01:24:44 字数 2409 浏览 11 评论 0原文

我创建了以下两种方法来可靠地构建连接以进行数据连接。到目前为止,我在与用户测试这种方法时还没有遇到任何问题。

我很想获得一些关于这种方法的社区反馈,并让我知道 buildConnectionString() 中是否出现任何问题。请参阅下面的代码:

private static String buildConnectionString()
{

    //The Device is a simultaor --> TCP
    if (DeviceInfo.isSimulator())
        return ";deviceside=true;ConnectionTimeout=20000";

    String st = "";

    //A carrier is providing us with the data service
    if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_CARRIER) == CoverageInfo.COVERAGE_CARRIER)
    {

        // blackberry internet service
        ServiceRecord rec = getBIBSRecord();//Apply for BIS access to get info about BIS recordset
        if (rec != null)//couldn't find the right record
            st = "[THIS CONNECTION STRING IS REMOVED, PLEASE APPLY FOR BIS ACCESS TO GET THIS STRING]";
        else if(GetWap2().length() > 0)
            st = GetWap2();
        else
            st = ";deviceside=true";// let the phone try to do the work

    }
    else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS)
        st = ";deviceside=false";// use the clients blackberry enterprise server
    else
        st = ";deviceside=true";// let the phone do the work if it can

    return st + ";ConnectionTimeout=45000";
}

public static String GetWap2() {
    String wap2Postfix = null;
    final ServiceBook sb = ServiceBook.getSB();
    final ServiceRecord[] records = sb.findRecordsByCid("WPTCP");

    for (int i = 0; i < records.length; i++) {
        // Search through all service records to find the valid non Wi-Fi
        // WAP 2.0 Gateway Service Record.
        if (records[i].isValid() && !records[i].isDisabled()
                && records[i].getUid() != null
                && records[i].getUid().length() != 0
                && records[i].getUid().toLowerCase().indexOf("wifi") == -1
                && records[i].getUid().toLowerCase().indexOf("mms") == -1) {
            wap2Postfix = ";ConnectionUID=" + records[i].getUid();
            break;
        }//endif
    }//end for
    return wap2Postfix;
}// end wap postfix

可能需要考虑的问题:

  • 如果存在 BIS 字符串(找到记录集),它是否始终有效(除了被公司网络阻止之外)?
  • 如果存在 WAP2 字符串(找到记录集),它是否始终有效(除了被公司网络阻止之外)?
  • 我应该首先检查 MDS 支持而不是运营商支持吗?
  • 除了运营商阻止连接的极端情况外,上述方法是否有效?

让我知道吧!

I've created following two methods for reliably building a connection for making a data connection. So far I haven't had any issues testing this approach with users.

I'd love to get some community feedback about this approach and letting me know if anything seems in buildConnectionString(). Please see code below:

private static String buildConnectionString()
{

    //The Device is a simultaor --> TCP
    if (DeviceInfo.isSimulator())
        return ";deviceside=true;ConnectionTimeout=20000";

    String st = "";

    //A carrier is providing us with the data service
    if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_CARRIER) == CoverageInfo.COVERAGE_CARRIER)
    {

        // blackberry internet service
        ServiceRecord rec = getBIBSRecord();//Apply for BIS access to get info about BIS recordset
        if (rec != null)//couldn't find the right record
            st = "[THIS CONNECTION STRING IS REMOVED, PLEASE APPLY FOR BIS ACCESS TO GET THIS STRING]";
        else if(GetWap2().length() > 0)
            st = GetWap2();
        else
            st = ";deviceside=true";// let the phone try to do the work

    }
    else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS)
        st = ";deviceside=false";// use the clients blackberry enterprise server
    else
        st = ";deviceside=true";// let the phone do the work if it can

    return st + ";ConnectionTimeout=45000";
}

public static String GetWap2() {
    String wap2Postfix = null;
    final ServiceBook sb = ServiceBook.getSB();
    final ServiceRecord[] records = sb.findRecordsByCid("WPTCP");

    for (int i = 0; i < records.length; i++) {
        // Search through all service records to find the valid non Wi-Fi
        // WAP 2.0 Gateway Service Record.
        if (records[i].isValid() && !records[i].isDisabled()
                && records[i].getUid() != null
                && records[i].getUid().length() != 0
                && records[i].getUid().toLowerCase().indexOf("wifi") == -1
                && records[i].getUid().toLowerCase().indexOf("mms") == -1) {
            wap2Postfix = ";ConnectionUID=" + records[i].getUid();
            break;
        }//endif
    }//end for
    return wap2Postfix;
}// end wap postfix

Possible questions to consider:

  • If a BIS string exists (recordset found), will it always work (aside from being blocked by a corporate network)?
  • If a WAP2 string exists (recordset found), will it always work (aside from being blocked by a corporate network)?
  • Should I check for MDS support first as opposed to carrier support?
  • Beyond extreme cases where carriers block a connection, will the above approach work?

Let me me know!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文