Api37
A mock environment for Android 17 (Cinnamon Bun).
Android 17 added new connectGatt API with an option to automatically request high MTU, and opportunistic connections. Bonding is no longer possible, unless the app has BLUETOOTH_PRIVILEDED permission, which is not available for 3-rd party apps. The app needs to be signed with the same certificate as the device.
In scanning, a new scan type allows for passive scan.
See (Behavior Changes Android 17).
Parameters
The device name, by default set to "Mock".
Whether Bluetooth is supported on the device.
Whether Bluetooth is enabled on the device.
Whether the Bluetooth privileged permission is granted. This permission can only be granted in own AOSP builds, not for 3rd party apps.
Whether multi advertisement is supported by the chipset.
Whether LE Extended Advertising feature is supported.
Whether LE Periodic Advertising feature is supported.
The maximum LE advertising data length in bytes, if LE Extended Advertising feature is supported.
The maximum Link Layer MTU size in range 27 - 251.
Whether LE 2M PHY is supported on the device.
Whether LE Coded PHY is supported on the device.
Whether the device can scan for Bluetooth LE devices advertising on LE Coded PHY as Primary PHY.
Whether the BLUETOOTH_SCAN permission is initially granted.
Whether the BLUETOOTH_CONNECT permission is initially granted.
Whether the BLUETOOTH_ADVERTISE permission is initially granted.
Whether the app is not using results of Bluetooth LE scanning to estimate device location. By default, neverForLocation flag is assumed.
Whether the fine location permission is initially granted.
Whether location service is enabled on the device.
A callback that will be called when the app requests to advertise. The callback should return TX power level used for mock advertising.
A callback that will be called when the mock central manager requests to scan for devices. It returns whether the scan was successful, secretly failed, or returned an error.
Some early Android devices were sending only one Scan Request message for a single device per scan. Non-connectable devices were reported continuously, but connectable devices were reported only once. The client had to stop and start scanning again to receive further advertisements. This flag simulates this issue. It was encountered e.g. on Nexus 4.
Some Android devices claim they can only transmit 27-byte long PDUs on Link Layer in the LLCP Data Length Update procedure, while later trying to send 251 bytes. This causes the peripheral to terminate the connection. This flag simulates this issue. It was encountered e.g. on Samsung A8 and Samsung A8 Tab.
Constructors
Properties
A callback that will be called when the app requests to advertise. The callback should return the TX power level used for mock advertising.
Whether the BLUETOOTH_ADVERTISE permission is granted. The permission can be set to true to emulate it being granted in runtime.
Whether the BLUETOOTH_CONNECT permission is granted. The permission can be set to true to emulate it being granted in runtime.
Whether the BLUETOOTH_SCAN permission is granted. The permission can be set to true to emulate it being granted in runtime.
Whether the fine location permission is granted. The permission can be set to true to emulate it being granted in runtime.
Some Android devices claim they can only transmit 27-byte long PDUs on Link Layer in the LLCP Data Length Update procedure, while later trying to send 251 bytes. This causes the peripheral to terminate the connection. This flag simulates this issue. It was encountered e.g. on Samsung A8 and Samsung A8 Tab.
Some early Android devices were sending only one Scan Request message for a single device per scan. Non-connectable devices were reported continuously, but connectable devices were reported only once. The client had to stop and start scanning again to receive further advertisements. This flag simulates this issue. It was encountered e.g. on Nexus 4.
A callback that will be called when the mock central manager requests to scan for devices. It returns whether the scan was successful, secretly failed, or returned an error.