EncryptionState

sealed class EncryptionState

The state of the encryption of the link with a peripheral.

Having the bond information (Peripheral.hasBondInformation) does not mean that the link is encrypted: the bond information is stored by this Android device, whether the peripheral is connected or not. A bonded peripheral should encrypt the link right after connecting, but it may fail to do so, for example when the peripheral lost the keys. Use this state to check that the connection is secure.

The state is reported from Android 16 (API 36). Earlier versions do not tell whether the link is encrypted, and the state is Unknown. Note, that old Android versions did not require encryption to be resumed when connecting to a bonded device, so a device could pretend to be another one, and use an unencrypted link.

See also

Inheritors

Types

Link copied to clipboard

The encryption algorithm.

Link copied to clipboard
data class Encrypted(val algorithm: EncryptionState.Algorithm, val keySize: Int? = null) : EncryptionState

The link is encrypted.

Link copied to clipboard
data class NotEncrypted(val reason: EncryptionState.Reason? = null) : EncryptionState

The link is not encrypted.

Link copied to clipboard
sealed class Reason

The reason why the link is not encrypted.

Link copied to clipboard
data object Unknown : EncryptionState

It is not known whether the link is encrypted.