DeviceInfo

data class DeviceInfo(val apiLevel: Int, val manufacturer: String, val model: String, val product: String, val displayWidth: Int, val displayHeight: Int, val displayRotation: DisplayRotation, val currentPackage: String?, val screenOn: Boolean, val keyguardLocked: Boolean, val keyguardSecure: Boolean, val keyboardShown: Boolean, val autoRotate: Boolean, val animationsEnabled: Boolean, val darkMode: Boolean, val fontScale: Float, val densityDpi: Int, val airplaneMode: Boolean, val wifiEnabled: Boolean, val mobileDataEnabled: Boolean, val systemLocales: List<String> = emptyList(), val stayAwake: Boolean = false, val highContrastText: Boolean? = null, val colorInversion: Boolean? = null, val boldText: Boolean = false) : Artifact(source)

Facts about the device at the moment of Device.info: identity, display geometry and rotation, screen, keyguard and keyboard state, the package owning the focused window and the device conditions (Device.setAnimations and the rest). Serialized as JSON.

Constructors

Link copied to clipboard
constructor(apiLevel: Int, manufacturer: String, model: String, product: String, displayWidth: Int, displayHeight: Int, displayRotation: DisplayRotation, currentPackage: String?, screenOn: Boolean, keyguardLocked: Boolean, keyguardSecure: Boolean, keyboardShown: Boolean, autoRotate: Boolean, animationsEnabled: Boolean, darkMode: Boolean, fontScale: Float, densityDpi: Int, airplaneMode: Boolean, wifiEnabled: Boolean, mobileDataEnabled: Boolean, systemLocales: List<String> = emptyList(), stayAwake: Boolean = false, highContrastText: Boolean? = null, colorInversion: Boolean? = null, boldText: Boolean = false)

Properties

Link copied to clipboard

Airplane mode is on.

Link copied to clipboard

Window, transition or animator animations run (any of the three scales is not 0).

Link copied to clipboard
Link copied to clipboard

Auto-rotate is on: the sensor turns the display (off while a rotation is frozen).

Link copied to clipboard

The system font is bold (API 31+; always false below).

Link copied to clipboard
open override val bytes: ByteArray

The serialized form: PNG, UTF-8 XML, UTF-8 JSON or UTF-8 text.

Link copied to clipboard

Color inversion is on; null when Android does not let Tap read it.

Link copied to clipboard

The package owning the focused window, when there is one.

Link copied to clipboard

The UI is in night mode (dark theme).

Link copied to clipboard

The display density apps see, in dpi.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val extension: String

The usual file extension for bytes, without the dot, e.g. png.

Link copied to clipboard

The font scale apps see (1.0 = the default size).

Link copied to clipboard

High-contrast text is on; null when Android does not let Tap read it.

Link copied to clipboard

A soft keyboard (any input method's window) is on screen.

Link copied to clipboard

The keyguard (lock screen) is showing.

Link copied to clipboard

A PIN, pattern or password is set: Tap cannot dismiss this keyguard.

Link copied to clipboard
Link copied to clipboard
open override val mediaType: String

The IANA media type of bytes, e.g. image/png.

Link copied to clipboard

Mobile data is switched on; false on a device without telephony.

Link copied to clipboard
Link copied to clipboard

PORTRAIT when the display is at least as tall as it is wide.

Link copied to clipboard
Link copied to clipboard

The screen is on (interactive).

Link copied to clipboard

The screen stays on while plugged in (Device.setStayAwake).

Link copied to clipboard

The device's languages, BCP-47 tags in preference order (Device.setSystemLocales).

Link copied to clipboard

Wi-Fi is switched on (also while airplane mode is on); says nothing about a connection.

Functions

Link copied to clipboard
open fun save(path: Path): Path

Writes bytes to path (parent directories are created) and returns path.