CoverageInfo.getCoverageStatus() 与 CoverageInfo.isCoverageSufficient(),它们相同吗?

发布于 2024-08-11 06:59:23 字数 705 浏览 9 评论 0原文

在尝试确定是否支持特定连接时,我对 CoverageInfo.getCoverageStatus() 和 CoverageInfo.isCoverageSufficient() 之间的差异感到困惑。例如:

// check mds with getCoverageStatus() and bitwise check
boolean hasMdsCoverage1 = (CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS;
// check mds with isCoverageSufficient()
boolean hasMdsCoverage2 = CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_MDS);

hasMdsCoverage1hasMdsCoverage2 似乎返回相同的结果,但为什么有两种不同的方法呢?是否存在返回不同结果的情况?

理想情况下,我想使用 CoverageInfo.isCoverageSufficent(),因为这在代码中看起来更干净,但在这样做之前,我想确保我没有错过任何 getCoverageStatus( ) 会提供。

注意:我用它来检查通过 BIS、MDS、WAP 和 WAP2 协议的有效连接。

In trying to determing a if a specific connection is supported, I'm cofused about the difference between CoverageInfo.getCoverageStatus() and CoverageInfo.isCoverageSufficient(). For example:

// check mds with getCoverageStatus() and bitwise check
boolean hasMdsCoverage1 = (CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS;
// check mds with isCoverageSufficient()
boolean hasMdsCoverage2 = CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_MDS);

Both hasMdsCoverage1 and hasMdsCoverage2 seem to return the same result, but why two different approaches? Is there ever a case where they'll return a different result?

Ideally I'd like to use CoverageInfo.isCoverageSufficent() since this looks cleaner in code, but before I do so I want to make sure I'm not missing out on anything that getCoverageStatus() would provide.

NOTE: I'm using this to check for valid connections via BIS, MDS, WAP and WAP2 protocols.

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

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

发布评论

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

评论(1

弄潮 2024-08-18 06:59:23

getCoverageStatus() 返回 COVERAGE_ 标志位掩码*,其中 isCoverageSufficient() 如果设备在某些可用路线上具有由coverageType 指定的覆盖类型,则返回布尔值 true;否则为假。当按照您的方式编码时,没有区别,但在 hasMdsCoverage1 中,您需要进行额外的处理,使它们等效。 isCoverageSufficient 在这种情况下可能更方便, getCoverageStatus 在其他情况下可能更方便。如果前者调用后者,我不会感到惊讶。许多不同的支持库中有许多这样的示例。

getCoverageStatus() returns A bitmask of COVERAGE_ flags*, where isCoverageSufficient() returns a boolean true if the device has the type of coverage specified by coverageType, over some available route; otherwise false. When coded the way you have there is no difference, but in hasMdsCoverage1 you have additional processing that makes them equivalent. isCoverageSufficient may be more convenient it this case, getCoverageStatus may be more convenient in others. I would not be surprised if the former calls the latter. There are many such examples in many different support libraries.

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