Device

interface Device : Variable

设备信息与操作接口。

提供对安卓设备硬件信息、系统状态、存储空间、网络状态的只读访问, 震动控制等交互功能。

注意:部分方法在 Android 高版本(如 Android 10+)上可能受系统隐私策略限制, 无法获取真实数据(如 Serial, MacAddress),文档中已对相应方法做出说明。

Author

M8Test

Since

1.0.0

Functions

Link copied to clipboard
abstract fun getAndroidId(): String

获取 Android ID。

Link copied to clipboard
abstract fun getAvailableRam(): Long

获取设备当前可用内存 (RAM)。 包含系统视为可回收的缓存内存。

Link copied to clipboard
abstract fun getAvailableStorage(): Long

获取内部存储 (ROM) 的当前剩余可用空间。

Link copied to clipboard
abstract fun getBatteryLevel(): Int

获取当前电池电量百分比。

Link copied to clipboard
abstract fun getBootloader(): String

获取系统 Bootloader 版本号。 对应 android.os.Build.BOOTLOADER

Link copied to clipboard
abstract fun getBrand(): String

获取设备品牌。 对应系统属性 android.os.Build.BRAND

Link copied to clipboard
abstract fun getCpuAbi(): String

获取 CPU 主指令集架构 (ABI)。 优先返回 Build.SUPPORTED_ABIS 的第一个元素,即设备最优选的架构。

Link copied to clipboard
abstract fun getFingerprint(): String

获取系统构建指纹 (Fingerprint)。 对应 android.os.Build.FINGERPRINT。 这是一个唯一标识当前系统构建版本的字符串,包含品牌、型号、版本等信息。

Link copied to clipboard
abstract fun getGlobalName(): String

获取作为全局变量时的名称.

Link copied to clipboard
abstract fun getIpAddress(): String

获取设备当前的 IP 地址 (IPv4)。 会遍历所有网络接口,跳过回环地址 (127.0.0.1),返回第一个有效的 IPv4 地址。 适用于 Wi-Fi 和移动数据网络。

Link copied to clipboard
abstract fun getLanguage(): String

获取设备当前的语言环境标签。

Link copied to clipboard
abstract fun getMacAddress(): String

获取 Wi-Fi 接口的 MAC 地址。

Link copied to clipboard
abstract fun getManufacturer(): String

获取设备制造商。 对应系统属性 android.os.Build.MANUFACTURER

Link copied to clipboard
abstract fun getModel(): String

获取设备型号。 对应系统属性 android.os.Build.MODEL

Link copied to clipboard
abstract fun getProduct(): String

获取设备产品名称。 对应系统属性 android.os.Build.PRODUCT

Link copied to clipboard
abstract fun getPublicType(): Type

获取 Variable 注入到脚本时需要显示的类型.

Link copied to clipboard
abstract fun getRelease(): String

获取安卓系统版本名称。 对应 android.os.Build.VERSION.RELEASE

Link copied to clipboard
abstract fun getScreenDensity(): Float

获取屏幕逻辑密度 (Logical Density)。 这是屏幕密度与基准密度 (160 dpi) 的比例因子。

Link copied to clipboard
abstract fun getScreenDensityDpi(): Int

获取屏幕每英寸点数 (DPI - Dots Per Inch)。

Link copied to clipboard
abstract fun getScreenHeight(): Int

获取屏幕高度的绝对像素值。

Link copied to clipboard
abstract fun getScreenWidth(): Int

获取屏幕宽度的绝对像素值。

Link copied to clipboard
abstract fun getSdkInt(): Int

获取安卓系统 SDK 版本号。 对应 android.os.Build.VERSION.SDK_INT

Link copied to clipboard
abstract fun getSerial(): String

获取设备硬件序列号 (Serial Number)。

Link copied to clipboard
abstract fun getTotalRam(): Long

获取设备物理总内存 (RAM)。

Link copied to clipboard
abstract fun getTotalStorage(): Long

获取内部存储 (ROM) 的总空间。 通常指数据分区 (/data) 的大小。

Link copied to clipboard
abstract fun isCharging(): Boolean

判断设备当前是否正在充电。 包括 USB 充电、AC 充电或无线充电。

Link copied to clipboard
abstract fun isPrefixRequired(): Boolean

是否需要添加前缀, 每种编程语言添加的前缀不一样, 前缀可以通过 Language.getVariablePrefix 获取.

Link copied to clipboard
abstract fun isSuffixRequired(): Boolean

是否需要添加后缀, 每种编程语言添加的后缀不一样, 后缀可以通过 Language.getVariableSuffix 获取.

Link copied to clipboard
abstract fun vibrate(milliseconds: Long)

控制设备震动。