SamsungA8

class SamsungA8(deviceName: String = "Samsung A8", isBluetoothEnabled: Boolean = true, isBluetoothScanPermissionGranted: Boolean = true, isBluetoothConnectPermissionGranted: Boolean = true, isBluetoothAdvertisePermissionGranted: Boolean = true, isNeverForLocationFlagSet: Boolean = true, isLocationPermissionGranted: Boolean = true, isLocationEnabled: Boolean = true, advertiser: MockAdvertiser = DEFAULT_MOCK_ADVERTISER, scanner: MockScanner = DEFAULT_MOCK_SCANNER) : MockAndroidEnvironment

A mock environment for the Samsung A8 with Android 14.

That device fails to properly negotiate the Maximum Transfer Usage (MTU) and Data Length Extension (DLE). It incorrectly claims, that can only transfer 27 bytes in a single LL packet, while later trying to send 251 bytes.

This causes the peer device to terminate the connection. A workaround for that is not requesting MTU higher than 23 (maximum value length equal to 20 bytes).

Parameters

deviceName

The device name, by default set to "Samsung A8".

isBluetoothEnabled

Whether Bluetooth is enabled on the device.

isBluetoothScanPermissionGranted

Whether the BLUETOOTH_SCAN permission is granted.

isBluetoothConnectPermissionGranted

Whether the BLUETOOTH_CONNECT permission is granted.

isBluetoothAdvertisePermissionGranted

Whether the BLUETOOTH_ADVERTISE permission is granted.

isNeverForLocationFlagSet

Whether the app is not using results of Bluetooth LE scanning to estimate device location. By default, neverForLocation flag is assumed.

isLocationPermissionGranted

Whether the fine location permission is initially granted.

isLocationEnabled

Whether location service is enabled on the device.

advertiser

A callback that will be called when the app requests to advertise. The callback should return TX power level used for mock advertising.

scanner

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.

Constructors

Link copied to clipboard
constructor(deviceName: String = "Samsung A8", isBluetoothEnabled: Boolean = true, isBluetoothScanPermissionGranted: Boolean = true, isBluetoothConnectPermissionGranted: Boolean = true, isBluetoothAdvertisePermissionGranted: Boolean = true, isNeverForLocationFlagSet: Boolean = true, isLocationPermissionGranted: Boolean = true, isLocationEnabled: Boolean = true, advertiser: MockAdvertiser = DEFAULT_MOCK_ADVERTISER, scanner: MockScanner = DEFAULT_MOCK_SCANNER)

Properties

Link copied to clipboard

A callback that will be called when the app requests to advertise. The callback should return the TX power level used for mock advertising.

Link copied to clipboard
open override val androidSdkVersion: Int
Link copied to clipboard
open override val bluetoothState: StateFlow<Manager.State>
Link copied to clipboard
open override var deviceName: String
Link copied to clipboard
Link copied to clipboard

Whether the BLUETOOTH_ADVERTISE permission is granted. The permission can be set to true to emulate it being granted in runtime.

Link copied to clipboard

Whether the BLUETOOTH_CONNECT permission is granted. The permission can be set to true to emulate it being granted in runtime.

Link copied to clipboard
open override val isBluetoothEnabled: Boolean
Link copied to clipboard

Whether the BLUETOOTH_SCAN permission is granted. The permission can be set to true to emulate it being granted in runtime.

Link copied to clipboard
open override val isBluetoothSupported: Boolean
Link copied to clipboard
open override val isLe2MPhySupported: Boolean
Link copied to clipboard
open override val isLeCodedPhySupported: Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Whether the fine location permission is granted. The permission can be set to true to emulate it being granted in runtime.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Whether the device can scan for Bluetooth LE devices advertising on LE Coded PHY as Primary PHY.

Link copied to clipboard

Some Android devices claim they can only transmit 27-byte long packets on L2CAP 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.

Link copied to clipboard

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.

Link copied to clipboard
open override val leMaximumAdvertisingDataLength: @Range(from = 31, to = 1650) Int
Link copied to clipboard
open override val locationState: StateFlow<Boolean>
Link copied to clipboard
Link copied to clipboard

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.

Functions

Link copied to clipboard
open override fun close()
Link copied to clipboard
open override fun enableBluetooth()
Link copied to clipboard

Simulates turning on/off location service on the mock device.

Link copied to clipboard

Simulates turning off Bluetooth adapter on the mock device.

Link copied to clipboard

Simulates turning on Bluetooth adapter on the mock device.