Adapt scan settings based on client state.

If BLE scanning client goes into non-foreground state then force
SCAN_MODE_LOW_POWER scan settings for this client. Restore the original
scan settings if the scanning client comes back to foreground.

Update scanning interval/window numbers for more power savings.

Test: Ran following tests manually:
1: Foreground to background transition (and vice-vera) of an
   application doing filtered scans.
2: Foreground to background transition (and vice-vera) of an
   application doing unfiltered scans.
3: Screen on-off (and vice-versa) while an application is doing
   filtered scans.
4: Screen on-off (and vice-versa) while an application is doing
   unfiltered scans.
5. Repeated above tests for all modes: Opportunistic, low power,
   balanced and low latency.
6. Measured power improvements for updated scanning interval/window
   numbers.

BUG: 38198694
BUG: 62491228
Change-Id: Id80fcdcae6021667232339dc1f637f3903b2fc05
3 files changed