- Overview - 综述
- Q&A - 常见问题
- App - 应用
- Console - 控制台
- CoordinatesBasedAutomation - 基于坐标的触摸模拟
- Device - 设备
- Dialogs - 对话框
- Engines - 脚本引擎
- Events - 事件与监听
- Floaty - 悬浮窗
- Files - 文件系统
- Globals - 一般全局函数
- Http - HTTP
- Images - 图片与图色处理
- Keys - 按键模拟
- Modules - 模块
- WidgetsBasedAutomation - 基于控件的触摸模拟
- Shell - Shell命令
- Storages - 本地存储
- Threads - 多线程
- Timers - 定时器
- UI - 用户界面
- Work with Java - 调用Java API
Auto.js 3.0.0 文档
目录
- Device
- device.width
- device.height
- device.buildId
- device.broad
- device.brand
- device.device
- deivce.model
- device.product
- device.bootloader
- device.hardware
- device.fingerprint
- device.serial
- device.sdkInt
- device.incremental
- device.release
- device.baseOS
- device.securityPatch
- device.codename
- device.getIMEI()
- device.getAndroidId()
- device.getMacAddress()
- device.getBrightness()
- device.getBrightnessMode()
- device.setBrightness(b)
- device.setBrightnessMode(mode)
- device.getMusicVolume()
- device.getNotificationVolume()
- device.getAlarmVolume()
- device.getMusicMaxVolume()
- device.getNotificationMaxVolume()
- device.getAlarmMaxVolume()
- device.setMusicVolume(volume)
- device.setNotificationVolume(volume)
- device.setAlarmVolume(volume)
- device.getBattery()
- device.isCharging()
- device.getTotalMem()
- device.getAvailMem()
Device#
device模块提供了与设备有关的信息与操作,例如获取设备宽高,内存使用率,IMEI,调整设备亮度、音量等。
此模块的部分函数,例如调整音量,需要"修改系统设置"的权限。如果没有该权限,会抛出SecurityException并跳转到权限设置界面。
device.width#
设备屏幕分辨率宽度。例如1080。
device.height#
设备屏幕分辨率高度。例如1920。
device.buildId#
Either a changelist number, or a label like "M4-rc20".
修订版本号,或者诸如"M4-rc20"的标识。
device.broad#
The name of the underlying board, like "goldfish".
设备的主板(?)型号。
device.brand#
The consumer-visible brand with which the product/hardware will be associated, if any.
与产品或硬件相关的厂商品牌,如"Xiaomi", "Huawei"等。
device.device#
The name of the industrial design.
设备在工业设计中的名称。
deivce.model#
The end-user-visible name for the end product.
设备型号。
device.product#
The name of the overall product.
整个产品的名称。
device.bootloader#
The system bootloader version number.
设备Bootloader的版本。
device.hardware#
The name of the hardware (from the kernel command line or /proc).
设备的硬件名称(来自内核命令行或者/proc)。
device.fingerprint#
A string that uniquely identifies this build. Do not attempt to parse this value.
构建(build)的唯一标识码。
device.serial#
A hardware serial number, if available. Alphanumeric only, case-insensitive.
硬件序列号。
device.sdkInt#
The user-visible SDK version of the framework; its possible values are defined in Build.VERSION_CODES.
安卓系统API版本。例如安卓4.4的sdkInt为19。
device.incremental#
The internal value used by the underlying source control to represent this build. E.g., a perforce changelist number or a git hash.
device.release#
The user-visible version string. E.g., "1.0" or "3.4b5".
Android系统版本号。例如"5.0", "7.1.1"。
device.baseOS#
The base OS build the product is based on.
device.securityPatch#
The user-visible security patch level.
安全补丁程序级别。
device.codename#
The current development codename, or the string "REL" if this is a release build.
开发代号,例如发行版是"REL"。
device.getIMEI()#
返回设备的IMEI.
device.getAndroidId()#
返回设备的Android ID。
Android ID为一个用16进制字符串表示的64位整数,在设备第一次使用时随机生成,之后不会更改,除非恢复出厂设置。
device.getMacAddress()#
返回设备的Mac地址。该函数需要在有WLAN连接的情况下才能获取,否则会返回null。
可能的后续修改:未来可能增加有root权限的情况下通过root权限获取,从而在没有WLAN连接的情况下也能返回正确的Mac地址,因此请勿使用此函数判断WLAN连接。
device.getBrightness()#
返回当前的(手动)亮度。范围为0~255。
device.getBrightnessMode()#
返回当前亮度模式,0为手动亮度,1为自动亮度。
device.setBrightness(b)#
b<number> 亮度,范围0~255
设置当前手动亮度。如果当前是自动亮度模式,该函数不会影响屏幕的亮度。
此函数需要"修改系统设置"的权限。如果没有该权限,会抛出SecurityException并跳转到权限设置界面。
device.setBrightnessMode(mode)#
mode<number> 亮度模式,0为手动亮度,1为自动亮度
设置当前亮度模式。
此函数需要"修改系统设置"的权限。如果没有该权限,会抛出SecurityException并跳转到权限设置界面。
device.getMusicVolume()#
- <number> 整数值
返回当前媒体音量。
device.getNotificationVolume()#
- <number> 整数值
返回当前通知音量。
device.getAlarmVolume()#
- <number> 整数值
返回当前闹钟音量。
device.getMusicMaxVolume()#
- <number> 整数值
返回媒体音量的最大值。
device.getNotificationMaxVolume()#
- <number> 整数值
返回通知音量的最大值。
device.getAlarmMaxVolume()#
- <number> 整数值
返回闹钟音量的最大值。
device.setMusicVolume(volume)#
volume<number> 音量
设置当前媒体音量。
此函数需要"修改系统设置"的权限。如果没有该权限,会抛出SecurityException并跳转到权限设置界面。
device.setNotificationVolume(volume)#
volume<number> 音量
设置当前通知音量。
此函数需要"修改系统设置"的权限。如果没有该权限,会抛出SecurityException并跳转到权限设置界面。
device.setAlarmVolume(volume)#
volume<number> 音量
设置当前闹钟音量。
此函数需要"修改系统设置"的权限。如果没有该权限,会抛出SecurityException并跳转到权限设置界面。
device.getBattery()#
- <number> 0.0~100.0的浮点数
返回当前电量百分比。
device.isCharging()#
返回设备是否正在充电。
device.getTotalMem()#
返回设备内存总量,单位字节(B)。1MB = 1024 * 1024B。
device.getAvailMem()#
返回设备当前可用的内存,单位字节(B)。