4

According to the documentation of Android Beacon Library,

Fast background detections on Android 5.0+

On Android 5.0, new scanning APIs allow for more efficient background scanning that saves provide similar power savings to the technique described above, but with much faster beacon detection times. Instead of it taking up to five minutes to detect a beacon (with the defaults described above), it detections of new beacons generally take place within a few seconds.

But looking at Android's official documentation, the major new thing that I can find is this BlueToothLeScanner which is introduced in API 21.
This documentation of this new class does not mention anything about using less energy.

Assuming Android Beacon Library is also using these frameworks, why will it save more energy?
i.e. Does the handling of this library have any difference from calling startScan() in my own app, without using this library?

Community
  • 1
  • 1
Sira Lam
  • 5,179
  • 3
  • 34
  • 68

2 Answers2

1

Android 5 introduced new scanning APIs supporting scan filters, which look for a byte pattern in a BLE advertisement packet. These filters are designed for Bluetooth chips that implement these filters in hardware. This means the Bluetooth chips will offload all of the processing until there is a match, and only then send the packet to the operating system. This is much more efficient from a battery perspective. My own tests on a Nexus 5 when scan filters were introduced showed that filters used <10% the battery of an unfiltered scan. Newer generation chips on newer phones have gotten even more efficient.

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • I didn't expect that was a hardware filter. Many thanks! – Sira Lam Mar 05 '18 at 06:05
  • So, in fact that means it is the same as calling `startScan()` without using the library, and still have the same battery preserving efffect? – Sira Lam Mar 05 '18 at 06:06
  • Yes, the library doesn't use any undocumented APIs,so you can do the same things directly. The advantage of the library is that it saves you development time by doing all these things for you. – davidgyoung Mar 05 '18 at 12:56
1

In the API prior to Lollipop, there was no scan window / interval setting. The parameters used were hardcoded to 5000/5000 which means the radio is on all the time listening for incoming advertisements.

With the new API you can set the scan window / interval to "balanced" which will use the parameters 500/5000 or similar. That requires 10% energy compared to when the radio is active 100%!

The new API also have methods so that packet filtering can be done in the Bluetooth chip rather than the main CPU. This could reduce the power a bit but I think this will only be significant in noisy areas (many advertisers).

Emil
  • 16,784
  • 2
  • 41
  • 52