Skip to content

Scan occassionally returns no results until restarted #130

Description

@albertmoravec

I am currently trying to implement low-power background scanning using hardware batching, but on my device I sometimes get 0 ScanResults back after starting particular scan. Restarting the scan with identical settings fixes the issue and I get results normally.

Here's how I configure and start the scan:

val scanSettings = ScanSettings.Builder()
  .setUseHardwareFilteringIfSupported(true)
  .setUseHardwareBatchingIfSupported(true)
  .setScanMode(ScanSettings.SCAN_MODE_BALANCED)
  .setReportDelay(10 * 1000)
  .build()

val macFilter = ScanFilter.Builder()
  .setManufacturerData(
    0xFFFF,
    ubyteArrayOf(49u, 53u, 57u, 54u).toByteArray(),
    ubyteArrayOf(0xFFu, 0xFFu, 0xFFu, 0xFFu).toByteArray()
  )
  .build()

scanner.startScan(mutableListOf(macFilter), scanSettings, callback)

I am also able to reproduce the issue without using any scan filter, so it is not an issue in filter configuration. The issue is present with both SCAN_MODE_BALANCED and SCAN_MODE_LOW_POWER (seems to be an issue even with SCAN_MODE_LOW_LATENCY, but I wasn't able to reproduce it at least twice).

Full example can be seen here.

Device used:
Model: Xiaomi Mi 9T Pro
Android: 11

I personally think this issue is going to be hardware-related, but I'm looking for any possible clues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions