Repository navigation
Expand file tree
/
Copy pathdevice.json
More file actions
686 lines (686 loc) · 22.8 KB
/
Copy pathdevice.json
File metadata and controls
686 lines (686 loc) · 22.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
{
"source": "..\\api\\device.md",
"modules": [
{
"textRaw": "Device",
"name": "device",
"stability": 2,
"stabilityText": "Stable",
"desc": "<p>device模块提供了与设备有关的信息与操作,例如获取设备宽高,内存使用率,IMEI,调整设备亮度、音量等。</p>\n<p>此模块的部分函数,例如调整音量,需要"修改系统设置"的权限。如果没有该权限,会抛出<code>SecurityException</code>并跳转到权限设置界面。</p>\n",
"properties": [
{
"textRaw": "`width` {number} ",
"type": "number",
"name": "width",
"desc": "<p>设备屏幕分辨率宽度。例如1080。</p>\n"
},
{
"textRaw": "`height` {number} ",
"type": "number",
"name": "height",
"desc": "<p>设备屏幕分辨率高度。例如1920。</p>\n"
},
{
"textRaw": "`buildId` {string} ",
"type": "string",
"name": "buildId",
"desc": "<p>Either a changelist number, or a label like "M4-rc20".</p>\n<p>修订版本号,或者诸如"M4-rc20"的标识。</p>\n"
},
{
"textRaw": "`broad` {string} ",
"type": "string",
"name": "broad",
"desc": "<p>The name of the underlying board, like "goldfish".</p>\n<p>设备的主板(?)型号。</p>\n"
},
{
"textRaw": "`brand` {string} ",
"type": "string",
"name": "brand",
"desc": "<p>The consumer-visible brand with which the product/hardware will be associated, if any.</p>\n<p>与产品或硬件相关的厂商品牌,如"Xiaomi", "Huawei"等。</p>\n"
},
{
"textRaw": "`device` {string} ",
"type": "string",
"name": "device",
"desc": "<p>The name of the industrial design.</p>\n<p>设备在工业设计中的名称。</p>\n"
},
{
"textRaw": "`model` {string} ",
"type": "string",
"name": "model",
"desc": "<p>The end-user-visible name for the end product.</p>\n<p>设备型号。</p>\n"
},
{
"textRaw": "`product` {string} ",
"type": "string",
"name": "product",
"desc": "<p>The name of the overall product.</p>\n<p>整个产品的名称。</p>\n"
},
{
"textRaw": "`bootloader` {string} ",
"type": "string",
"name": "bootloader",
"desc": "<p>The system bootloader version number.</p>\n<p>设备Bootloader的版本。</p>\n"
},
{
"textRaw": "`hardware` {string} ",
"type": "string",
"name": "hardware",
"desc": "<p>The name of the hardware (from the kernel command line or /proc).</p>\n<p>设备的硬件名称(来自内核命令行或者/proc)。</p>\n"
},
{
"textRaw": "`fingerprint` {string} ",
"type": "string",
"name": "fingerprint",
"desc": "<p>A string that uniquely identifies this build. Do not attempt to parse this value.</p>\n<p>构建(build)的唯一标识码。</p>\n"
},
{
"textRaw": "`serial` {string} ",
"type": "string",
"name": "serial",
"desc": "<p>A hardware serial number, if available. Alphanumeric only, case-insensitive.</p>\n<p>硬件序列号。</p>\n"
},
{
"textRaw": "`sdkInt` {number} ",
"type": "number",
"name": "sdkInt",
"desc": "<p>The user-visible SDK version of the framework; its possible values are defined in Build.VERSION_CODES.</p>\n<p>安卓系统API版本。例如安卓4.4的sdkInt为19。</p>\n"
},
{
"textRaw": "`incremental` {string} ",
"type": "string",
"name": "incremental",
"desc": "<p>The internal value used by the underlying source control to represent this build. E.g., a perforce changelist number or a git hash.</p>\n"
},
{
"textRaw": "`release` {string} ",
"type": "string",
"name": "release",
"desc": "<p>The user-visible version string. E.g., "1.0" or "3.4b5".</p>\n<p>Android系统版本号。例如"5.0", "7.1.1"。</p>\n"
},
{
"textRaw": "`baseOS` {string} ",
"type": "string",
"name": "baseOS",
"desc": "<p>The base OS build the product is based on.</p>\n"
},
{
"textRaw": "`securityPatch` {string} ",
"type": "string",
"name": "securityPatch",
"desc": "<p>The user-visible security patch level.</p>\n<p>安全补丁程序级别。</p>\n"
},
{
"textRaw": "`codename` {string} ",
"type": "string",
"name": "codename",
"desc": "<p>The current development codename, or the string "REL" if this is a release build.</p>\n<p>开发代号,例如发行版是"REL"。</p>\n"
}
],
"methods": [
{
"textRaw": "device.getIMEI()",
"type": "method",
"name": "getIMEI",
"signatures": [
{
"params": [
{
"textRaw": "{string} ",
"type": "string"
}
]
},
{
"params": []
}
],
"desc": "<p>返回设备的IMEI.</p>\n"
},
{
"textRaw": "device.getAndroidId()",
"type": "method",
"name": "getAndroidId",
"signatures": [
{
"params": [
{
"textRaw": "{string} ",
"type": "string"
}
]
},
{
"params": []
}
],
"desc": "<p>返回设备的Android ID。</p>\n<p>Android ID为一个用16进制字符串表示的64位整数,在设备第一次使用时随机生成,之后不会更改,除非恢复出厂设置。</p>\n"
},
{
"textRaw": "device.getMacAddress()",
"type": "method",
"name": "getMacAddress",
"signatures": [
{
"params": [
{
"textRaw": "{string} ",
"type": "string"
}
]
},
{
"params": []
}
],
"desc": "<p>返回设备的Mac地址。该函数需要在有WLAN连接的情况下才能获取,否则会返回null。</p>\n<p><strong>可能的后续修改</strong>:未来可能增加有root权限的情况下通过root权限获取,从而在没有WLAN连接的情况下也能返回正确的Mac地址,因此请勿使用此函数判断WLAN连接。</p>\n"
},
{
"textRaw": "device.getBrightness()",
"type": "method",
"name": "getBrightness",
"signatures": [
{
"params": [
{
"textRaw": "{number} ",
"type": "number"
}
]
},
{
"params": []
}
],
"desc": "<p>返回当前的(手动)亮度。范围为0~255。</p>\n"
},
{
"textRaw": "device.getBrightnessMode()",
"type": "method",
"name": "getBrightnessMode",
"signatures": [
{
"params": [
{
"textRaw": "{number} ",
"type": "number"
}
]
},
{
"params": []
}
],
"desc": "<p>返回当前亮度模式,0为手动亮度,1为自动亮度。</p>\n"
},
{
"textRaw": "device.setBrightness(b)",
"type": "method",
"name": "setBrightness",
"signatures": [
{
"params": [
{
"textRaw": "`b` {number} 亮度,范围0~255 ",
"name": "b",
"type": "number",
"desc": "亮度,范围0~255"
}
]
},
{
"params": [
{
"name": "b"
}
]
}
],
"desc": "<p>设置当前手动亮度。如果当前是自动亮度模式,该函数不会影响屏幕的亮度。</p>\n<p>此函数需要"修改系统设置"的权限。如果没有该权限,会抛出SecurityException并跳转到权限设置界面。</p>\n"
},
{
"textRaw": "device.setBrightnessMode(mode)",
"type": "method",
"name": "setBrightnessMode",
"signatures": [
{
"params": [
{
"textRaw": "`mode` {number} 亮度模式,0为手动亮度,1为自动亮度 ",
"name": "mode",
"type": "number",
"desc": "亮度模式,0为手动亮度,1为自动亮度"
}
]
},
{
"params": [
{
"name": "mode"
}
]
}
],
"desc": "<p>设置当前亮度模式。</p>\n<p>此函数需要"修改系统设置"的权限。如果没有该权限,会抛出SecurityException并跳转到权限设置界面。</p>\n"
},
{
"textRaw": "device.getMusicVolume()",
"type": "method",
"name": "getMusicVolume",
"signatures": [
{
"params": [
{
"textRaw": "{number} 整数值 ",
"type": "number",
"desc": "整数值"
}
]
},
{
"params": []
}
],
"desc": "<p>返回当前媒体音量。</p>\n"
},
{
"textRaw": "device.getNotificationVolume()",
"type": "method",
"name": "getNotificationVolume",
"signatures": [
{
"params": [
{
"textRaw": "{number} 整数值 ",
"type": "number",
"desc": "整数值"
}
]
},
{
"params": []
}
],
"desc": "<p>返回当前通知音量。</p>\n"
},
{
"textRaw": "device.getAlarmVolume()",
"type": "method",
"name": "getAlarmVolume",
"signatures": [
{
"params": [
{
"textRaw": "{number} 整数值 ",
"type": "number",
"desc": "整数值"
}
]
},
{
"params": []
}
],
"desc": "<p>返回当前闹钟音量。</p>\n"
},
{
"textRaw": "device.getMusicMaxVolume()",
"type": "method",
"name": "getMusicMaxVolume",
"signatures": [
{
"params": [
{
"textRaw": "{number} 整数值 ",
"type": "number",
"desc": "整数值"
}
]
},
{
"params": []
}
],
"desc": "<p>返回媒体音量的最大值。</p>\n"
},
{
"textRaw": "device.getNotificationMaxVolume()",
"type": "method",
"name": "getNotificationMaxVolume",
"signatures": [
{
"params": [
{
"textRaw": "{number} 整数值 ",
"type": "number",
"desc": "整数值"
}
]
},
{
"params": []
}
],
"desc": "<p>返回通知音量的最大值。</p>\n"
},
{
"textRaw": "device.getAlarmMaxVolume()",
"type": "method",
"name": "getAlarmMaxVolume",
"signatures": [
{
"params": [
{
"textRaw": "{number} 整数值 ",
"type": "number",
"desc": "整数值"
}
]
},
{
"params": []
}
],
"desc": "<p>返回闹钟音量的最大值。</p>\n"
},
{
"textRaw": "device.setMusicVolume(volume)",
"type": "method",
"name": "setMusicVolume",
"signatures": [
{
"params": [
{
"textRaw": "`volume` {number} 音量 ",
"name": "volume",
"type": "number",
"desc": "音量"
}
]
},
{
"params": [
{
"name": "volume"
}
]
}
],
"desc": "<p>设置当前媒体音量。</p>\n<p>此函数需要"修改系统设置"的权限。如果没有该权限,会抛出SecurityException并跳转到权限设置界面。</p>\n"
},
{
"textRaw": "device.setNotificationVolume(volume)",
"type": "method",
"name": "setNotificationVolume",
"signatures": [
{
"params": [
{
"textRaw": "`volume` {number} 音量 ",
"name": "volume",
"type": "number",
"desc": "音量"
}
]
},
{
"params": [
{
"name": "volume"
}
]
}
],
"desc": "<p>设置当前通知音量。</p>\n<p>此函数需要"修改系统设置"的权限。如果没有该权限,会抛出SecurityException并跳转到权限设置界面。</p>\n"
},
{
"textRaw": "device.setAlarmVolume(volume)",
"type": "method",
"name": "setAlarmVolume",
"signatures": [
{
"params": [
{
"textRaw": "`volume` {number} 音量 ",
"name": "volume",
"type": "number",
"desc": "音量"
}
]
},
{
"params": [
{
"name": "volume"
}
]
}
],
"desc": "<p>设置当前闹钟音量。</p>\n<p>此函数需要"修改系统设置"的权限。如果没有该权限,会抛出SecurityException并跳转到权限设置界面。</p>\n"
},
{
"textRaw": "device.getBattery()",
"type": "method",
"name": "getBattery",
"signatures": [
{
"params": [
{
"textRaw": "{number} 0.0~100.0的浮点数 ",
"type": "number",
"desc": "0.0~100.0的浮点数"
}
]
},
{
"params": []
}
],
"desc": "<p>返回当前电量百分比。</p>\n"
},
{
"textRaw": "device.isCharging()",
"type": "method",
"name": "isCharging",
"signatures": [
{
"params": [
{
"textRaw": "{boolean} ",
"type": "boolean"
}
]
},
{
"params": []
}
],
"desc": "<p>返回设备是否正在充电。</p>\n"
},
{
"textRaw": "device.getTotalMem()",
"type": "method",
"name": "getTotalMem",
"signatures": [
{
"params": [
{
"textRaw": "{number} ",
"type": "number"
}
]
},
{
"params": []
}
],
"desc": "<p>返回设备内存总量,单位字节(B)。1MB = 1024 * 1024B。</p>\n"
},
{
"textRaw": "device.getAvailMem()",
"type": "method",
"name": "getAvailMem",
"signatures": [
{
"params": [
{
"textRaw": "{number} ",
"type": "number"
}
]
},
{
"params": []
}
],
"desc": "<p>返回设备当前可用的内存,单位字节(B)。</p>\n"
},
{
"textRaw": "device.isScreenOn()",
"type": "method",
"name": "isScreenOn",
"signatures": [
{
"params": [
{
"textRaw": "返回 {boolean} ",
"name": "返回",
"type": "boolean"
}
]
},
{
"params": []
}
],
"desc": "<p>返回设备屏幕是否是亮着的。如果屏幕亮着,返回<code>true</code>; 否则返回<code>false</code>。</p>\n<p>需要注意的是,类似于vivo xplay系列的息屏时钟不属于"屏幕亮着"的情况,虽然屏幕确实亮着但只能显示时钟而且不可交互,此时<code>isScreenOn()</code>也会返回<code>false</code>。</p>\n"
},
{
"textRaw": "device.wakeUp()",
"type": "method",
"name": "wakeUp",
"desc": "<p>唤醒设备。包括唤醒设备CPU、屏幕等。可以用来点亮屏幕。</p>\n",
"signatures": [
{
"params": []
}
]
},
{
"textRaw": "device.wakeUpIfNeeded()",
"type": "method",
"name": "wakeUpIfNeeded",
"desc": "<p>如果屏幕没有点亮,则唤醒设备。</p>\n",
"signatures": [
{
"params": []
}
]
},
{
"textRaw": "device.keepScreenOn([timeout])",
"type": "method",
"name": "keepScreenOn",
"signatures": [
{
"params": [
{
"textRaw": "`timeout` {number} 屏幕保持常亮的时间, 单位毫秒。如果不加此参数,则一直保持屏幕常亮。 ",
"name": "timeout",
"type": "number",
"desc": "屏幕保持常亮的时间, 单位毫秒。如果不加此参数,则一直保持屏幕常亮。",
"optional": true
}
]
},
{
"params": [
{
"name": "timeout",
"optional": true
}
]
}
],
"desc": "<p>保持屏幕常亮。</p>\n<p>此函数无法阻止用户使用锁屏键等正常关闭屏幕,只能使得设备在无人操作的情况下保持屏幕常亮;同时,如果此函数调用时屏幕没有点亮,则会唤醒屏幕。</p>\n<p>在某些设备上,如果不加参数timeout,只能在Auto.js的界面保持屏幕常亮,在其他界面会自动失效,这是因为设备的省电策略造成的。因此,建议使用比较长的时长来代替"一直保持屏幕常亮"的功能,例如<code>device.keepScreenOn(3600 * 1000)</code>。</p>\n<p>可以使用<code>device.cancelKeepingAwake()</code>来取消屏幕常亮。</p>\n<pre><code>//一直保持屏幕常亮\ndevice.keepScreenOn()\n</code></pre>"
},
{
"textRaw": "device.keepScreenDim([timeout])",
"type": "method",
"name": "keepScreenDim",
"signatures": [
{
"params": [
{
"textRaw": "`timeout` {number} 屏幕保持常亮的时间, 单位毫秒。如果不加此参数,则一直保持屏幕常亮。 ",
"name": "timeout",
"type": "number",
"desc": "屏幕保持常亮的时间, 单位毫秒。如果不加此参数,则一直保持屏幕常亮。",
"optional": true
}
]
},
{
"params": [
{
"name": "timeout",
"optional": true
}
]
}
],
"desc": "<p>保持屏幕常亮,但允许屏幕变暗来节省电量。此函数可以用于定时脚本唤醒屏幕操作,不需要用户观看屏幕,可以让屏幕变暗来节省电量。</p>\n<p>此函数无法阻止用户使用锁屏键等正常关闭屏幕,只能使得设备在无人操作的情况下保持屏幕常亮;同时,如果此函数调用时屏幕没有点亮,则会唤醒屏幕。</p>\n<p>可以使用<code>device.cancelKeepingAwake()</code>来取消屏幕常亮。</p>\n"
},
{
"textRaw": "device.cancelKeepingAwake()",
"type": "method",
"name": "cancelKeepingAwake",
"desc": "<p>取消设备保持唤醒状态。用于取消<code>device.keepScreenOn()</code>, <code>device.keepScreenDim()</code>等函数设置的屏幕常亮。</p>\n",
"signatures": [
{
"params": []
}
]
},
{
"textRaw": "device.vibrate(millis)",
"type": "method",
"name": "vibrate",
"signatures": [
{
"params": [
{
"textRaw": "`millis` {number} 震动时间,单位毫秒 ",
"name": "millis",
"type": "number",
"desc": "震动时间,单位毫秒"
}
]
},
{
"params": [
{
"name": "millis"
}
]
}
],
"desc": "<p>使设备震动一段时间。</p>\n<pre><code>//震动两秒\ndevice.vibrate(2000);\n</code></pre>"
},
{
"textRaw": "device.cancelVibration()",
"type": "method",
"name": "cancelVibration",
"desc": "<p>如果设备处于震动状态,则取消震动。</p>\n",
"signatures": [
{
"params": []
}
]
}
],
"type": "module",
"displayName": "Device"
}
]
}