views:

296

answers:

1

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.

+1  A: 

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.

Richard