assistsx-js 0.0.2028 → 0.0.2030
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AssistsX.d.ts +8 -1
- package/dist/AssistsX.js +13 -1
- package/dist/AssistsXAsync.d.ts +9 -1
- package/dist/AssistsXAsync.js +15 -1
- package/dist/CallMethod.d.ts +1 -0
- package/dist/CallMethod.js +1 -0
- package/dist/DeviceInfo.d.ts +69 -0
- package/dist/DeviceInfo.js +50 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
- package/src/AssistsX.ts +15 -2
- package/src/AssistsXAsync.ts +20 -2
- package/src/CallMethod.ts +1 -0
- package/src/DeviceInfo.ts +144 -0
- package/src/index.ts +1 -0
package/dist/AssistsX.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { CallResponse } from "./CallResponse";
|
|
|
7
7
|
import { Bounds } from "./Bounds";
|
|
8
8
|
import { AccessibilityEventFilter } from "AccessibilityEventFilter";
|
|
9
9
|
import { AppInfo } from "./AppInfo";
|
|
10
|
+
import { DeviceInfo } from "./DeviceInfo";
|
|
10
11
|
/**
|
|
11
12
|
* 无障碍事件数据结构
|
|
12
13
|
*/
|
|
@@ -126,6 +127,12 @@ export declare class AssistsX {
|
|
|
126
127
|
* @returns 剪贴板最新文本
|
|
127
128
|
*/
|
|
128
129
|
static getClipboardLatestText(): any;
|
|
130
|
+
/**
|
|
131
|
+
* 在浏览器中打开URL
|
|
132
|
+
* @param url 要打开的URL
|
|
133
|
+
* @returns 是否成功打开
|
|
134
|
+
*/
|
|
135
|
+
static openUrlInBrowser(url: string): boolean;
|
|
129
136
|
static isAppInstalled(packageName: string): boolean;
|
|
130
137
|
/**
|
|
131
138
|
* 对指定节点进行截图
|
|
@@ -404,7 +411,7 @@ export declare class AssistsX {
|
|
|
404
411
|
static getUniqueDeviceId(): any;
|
|
405
412
|
static getAndroidID(): any;
|
|
406
413
|
static getMacAddress(timeout?: number): Promise<any>;
|
|
407
|
-
static getDeviceInfo(timeout?: number): Promise<
|
|
414
|
+
static getDeviceInfo(timeout?: number): Promise<DeviceInfo>;
|
|
408
415
|
static getNetworkType(timeout?: number): Promise<any>;
|
|
409
416
|
static setAccessibilityEventFilters(value: AccessibilityEventFilter[]): Promise<any>;
|
|
410
417
|
static addAccessibilityEventFilter(value: AccessibilityEventFilter): Promise<any>;
|
package/dist/AssistsX.js
CHANGED
|
@@ -8,6 +8,7 @@ import { CallResponse } from "./CallResponse";
|
|
|
8
8
|
import { Bounds } from "./Bounds";
|
|
9
9
|
import { decodeBase64UTF8, generateUUID } from "./Utils";
|
|
10
10
|
import { AppInfo } from "./AppInfo";
|
|
11
|
+
import { DeviceInfo } from "./DeviceInfo";
|
|
11
12
|
// 回调函数存储对象
|
|
12
13
|
export const callbacks = new Map();
|
|
13
14
|
// 无障碍事件监听器存储
|
|
@@ -168,6 +169,17 @@ export class AssistsX {
|
|
|
168
169
|
const response = this.call(CallMethod.getClipboardLatestText);
|
|
169
170
|
return response.getDataOrDefault({});
|
|
170
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* 在浏览器中打开URL
|
|
174
|
+
* @param url 要打开的URL
|
|
175
|
+
* @returns 是否成功打开
|
|
176
|
+
*/
|
|
177
|
+
static openUrlInBrowser(url) {
|
|
178
|
+
const response = this.call(CallMethod.openUrlInBrowser, {
|
|
179
|
+
args: { url },
|
|
180
|
+
});
|
|
181
|
+
return response.getDataOrDefault(false);
|
|
182
|
+
}
|
|
171
183
|
static isAppInstalled(packageName) {
|
|
172
184
|
const response = this.call(CallMethod.isAppInstalled, {
|
|
173
185
|
args: { packageName },
|
|
@@ -602,7 +614,7 @@ export class AssistsX {
|
|
|
602
614
|
const response = await this.asyncCall(CallMethod.getDeviceInfo, {
|
|
603
615
|
timeout,
|
|
604
616
|
});
|
|
605
|
-
return response.getDataOrDefault({});
|
|
617
|
+
return DeviceInfo.fromJSON(response.getDataOrDefault({}));
|
|
606
618
|
}
|
|
607
619
|
static async getNetworkType(timeout) {
|
|
608
620
|
const response = await this.asyncCall(CallMethod.getNetworkType, {
|
package/dist/AssistsXAsync.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { Node } from "./Node";
|
|
6
6
|
import { Bounds } from "./Bounds";
|
|
7
7
|
import { AppInfo } from "./AppInfo";
|
|
8
|
+
import { DeviceInfo } from "./DeviceInfo";
|
|
8
9
|
import { WebFloatingWindowOptions } from "./AssistsX";
|
|
9
10
|
export declare class AssistsXAsync {
|
|
10
11
|
/**
|
|
@@ -359,7 +360,7 @@ export declare class AssistsXAsync {
|
|
|
359
360
|
static getUniqueDeviceId(timeout?: number): Promise<any>;
|
|
360
361
|
static getAndroidID(timeout?: number): Promise<any>;
|
|
361
362
|
static getMacAddress(timeout?: number): Promise<any>;
|
|
362
|
-
static getDeviceInfo(timeout?: number): Promise<
|
|
363
|
+
static getDeviceInfo(timeout?: number): Promise<DeviceInfo>;
|
|
363
364
|
/**
|
|
364
365
|
* 获取屏幕尺寸
|
|
365
366
|
* @param timeout 超时时间(秒),默认30秒
|
|
@@ -372,4 +373,11 @@ export declare class AssistsXAsync {
|
|
|
372
373
|
* @returns 应用窗口尺寸对象
|
|
373
374
|
*/
|
|
374
375
|
static getAppScreenSize(timeout?: number): Promise<any>;
|
|
376
|
+
/**
|
|
377
|
+
* 在浏览器中打开URL
|
|
378
|
+
* @param url 要打开的URL
|
|
379
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
380
|
+
* @returns 是否成功打开
|
|
381
|
+
*/
|
|
382
|
+
static openUrlInBrowser(url: string, timeout?: number): Promise<boolean>;
|
|
375
383
|
}
|
package/dist/AssistsXAsync.js
CHANGED
|
@@ -8,6 +8,7 @@ import { CallResponse } from "./CallResponse";
|
|
|
8
8
|
import { Bounds } from "./Bounds";
|
|
9
9
|
import { generateUUID } from "./Utils";
|
|
10
10
|
import { AppInfo } from "./AppInfo";
|
|
11
|
+
import { DeviceInfo } from "./DeviceInfo";
|
|
11
12
|
import { callbacks, } from "./AssistsX";
|
|
12
13
|
export class AssistsXAsync {
|
|
13
14
|
/**
|
|
@@ -600,7 +601,7 @@ export class AssistsXAsync {
|
|
|
600
601
|
const response = await this.asyncCall(CallMethod.getDeviceInfo, {
|
|
601
602
|
timeout,
|
|
602
603
|
});
|
|
603
|
-
return response.getDataOrDefault({});
|
|
604
|
+
return DeviceInfo.fromJSON(response.getDataOrDefault({}));
|
|
604
605
|
}
|
|
605
606
|
/**
|
|
606
607
|
* 获取屏幕尺寸
|
|
@@ -624,4 +625,17 @@ export class AssistsXAsync {
|
|
|
624
625
|
});
|
|
625
626
|
return response.getDataOrDefault("{}");
|
|
626
627
|
}
|
|
628
|
+
/**
|
|
629
|
+
* 在浏览器中打开URL
|
|
630
|
+
* @param url 要打开的URL
|
|
631
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
632
|
+
* @returns 是否成功打开
|
|
633
|
+
*/
|
|
634
|
+
static async openUrlInBrowser(url, timeout) {
|
|
635
|
+
const response = await this.asyncCall(CallMethod.openUrlInBrowser, {
|
|
636
|
+
args: { url },
|
|
637
|
+
timeout,
|
|
638
|
+
});
|
|
639
|
+
return response.getDataOrDefault(false);
|
|
640
|
+
}
|
|
627
641
|
}
|
package/dist/CallMethod.d.ts
CHANGED
|
@@ -49,5 +49,6 @@ export declare const CallMethod: {
|
|
|
49
49
|
readonly getNetworkType: "getNetworkType";
|
|
50
50
|
readonly isAppInstalled: "isAppInstalled";
|
|
51
51
|
readonly getClipboardLatestText: "getClipboardLatestText";
|
|
52
|
+
readonly openUrlInBrowser: "openUrlInBrowser";
|
|
52
53
|
};
|
|
53
54
|
export type CallMethodType = (typeof CallMethod)[keyof typeof CallMethod];
|
package/dist/CallMethod.js
CHANGED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 设备信息实体类
|
|
3
|
+
*/
|
|
4
|
+
export declare class DeviceInfo {
|
|
5
|
+
/**
|
|
6
|
+
* 设备唯一标识
|
|
7
|
+
*/
|
|
8
|
+
uniqueDeviceId: string;
|
|
9
|
+
/**
|
|
10
|
+
* Android ID
|
|
11
|
+
*/
|
|
12
|
+
androidID: string;
|
|
13
|
+
/**
|
|
14
|
+
* MAC地址
|
|
15
|
+
*/
|
|
16
|
+
macAddress: string;
|
|
17
|
+
/**
|
|
18
|
+
* 是否已Root
|
|
19
|
+
*/
|
|
20
|
+
isDeviceRooted: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* 制造商
|
|
23
|
+
*/
|
|
24
|
+
manufacturer: string;
|
|
25
|
+
/**
|
|
26
|
+
* 设备型号
|
|
27
|
+
*/
|
|
28
|
+
model: string;
|
|
29
|
+
/**
|
|
30
|
+
* SDK版本号
|
|
31
|
+
*/
|
|
32
|
+
sdkVersionCode: number;
|
|
33
|
+
/**
|
|
34
|
+
* SDK版本名称
|
|
35
|
+
*/
|
|
36
|
+
sdkVersionName: string;
|
|
37
|
+
/**
|
|
38
|
+
* ABI列表
|
|
39
|
+
*/
|
|
40
|
+
abiList: string[];
|
|
41
|
+
/**
|
|
42
|
+
* 是否启用ADB调试
|
|
43
|
+
*/
|
|
44
|
+
isAdbEnabled: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* 是否启用开发者选项
|
|
47
|
+
*/
|
|
48
|
+
isDevelopmentSettingsEnabled: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* 是否为模拟器
|
|
51
|
+
*/
|
|
52
|
+
isEmulator: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* 是否为平板
|
|
55
|
+
*/
|
|
56
|
+
isTablet: boolean;
|
|
57
|
+
constructor(uniqueDeviceId?: string, androidID?: string, macAddress?: string, isDeviceRooted?: boolean, manufacturer?: string, model?: string, sdkVersionCode?: number, sdkVersionName?: string, abiList?: string[], isAdbEnabled?: boolean, isDevelopmentSettingsEnabled?: boolean, isEmulator?: boolean, isTablet?: boolean);
|
|
58
|
+
/**
|
|
59
|
+
* 从JSON对象创建DeviceInfo实例
|
|
60
|
+
* @param data JSON对象
|
|
61
|
+
* @returns DeviceInfo实例
|
|
62
|
+
*/
|
|
63
|
+
static fromJSON(data: any): DeviceInfo;
|
|
64
|
+
/**
|
|
65
|
+
* 转换为JSON对象
|
|
66
|
+
* @returns JSON对象
|
|
67
|
+
*/
|
|
68
|
+
toJSON(): any;
|
|
69
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 设备信息实体类
|
|
3
|
+
*/
|
|
4
|
+
export class DeviceInfo {
|
|
5
|
+
constructor(uniqueDeviceId = "", androidID = "", macAddress = "", isDeviceRooted = false, manufacturer = "", model = "", sdkVersionCode = 0, sdkVersionName = "", abiList = [], isAdbEnabled = false, isDevelopmentSettingsEnabled = false, isEmulator = false, isTablet = false) {
|
|
6
|
+
this.uniqueDeviceId = uniqueDeviceId;
|
|
7
|
+
this.androidID = androidID;
|
|
8
|
+
this.macAddress = macAddress;
|
|
9
|
+
this.isDeviceRooted = isDeviceRooted;
|
|
10
|
+
this.manufacturer = manufacturer;
|
|
11
|
+
this.model = model;
|
|
12
|
+
this.sdkVersionCode = sdkVersionCode;
|
|
13
|
+
this.sdkVersionName = sdkVersionName;
|
|
14
|
+
this.abiList = abiList;
|
|
15
|
+
this.isAdbEnabled = isAdbEnabled;
|
|
16
|
+
this.isDevelopmentSettingsEnabled = isDevelopmentSettingsEnabled;
|
|
17
|
+
this.isEmulator = isEmulator;
|
|
18
|
+
this.isTablet = isTablet;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 从JSON对象创建DeviceInfo实例
|
|
22
|
+
* @param data JSON对象
|
|
23
|
+
* @returns DeviceInfo实例
|
|
24
|
+
*/
|
|
25
|
+
static fromJSON(data) {
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
27
|
+
return new DeviceInfo((_a = data.uniqueDeviceId) !== null && _a !== void 0 ? _a : "", (_b = data.androidID) !== null && _b !== void 0 ? _b : "", (_c = data.macAddress) !== null && _c !== void 0 ? _c : "", (_d = data.isDeviceRooted) !== null && _d !== void 0 ? _d : false, (_e = data.manufacturer) !== null && _e !== void 0 ? _e : "", (_f = data.model) !== null && _f !== void 0 ? _f : "", (_g = data.sdkVersionCode) !== null && _g !== void 0 ? _g : 0, (_h = data.sdkVersionName) !== null && _h !== void 0 ? _h : "", (_j = data.abiList) !== null && _j !== void 0 ? _j : [], (_k = data.isAdbEnabled) !== null && _k !== void 0 ? _k : false, (_l = data.isDevelopmentSettingsEnabled) !== null && _l !== void 0 ? _l : false, (_m = data.isEmulator) !== null && _m !== void 0 ? _m : false, (_o = data.isTablet) !== null && _o !== void 0 ? _o : false);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 转换为JSON对象
|
|
31
|
+
* @returns JSON对象
|
|
32
|
+
*/
|
|
33
|
+
toJSON() {
|
|
34
|
+
return {
|
|
35
|
+
uniqueDeviceId: this.uniqueDeviceId,
|
|
36
|
+
androidID: this.androidID,
|
|
37
|
+
macAddress: this.macAddress,
|
|
38
|
+
isDeviceRooted: this.isDeviceRooted,
|
|
39
|
+
manufacturer: this.manufacturer,
|
|
40
|
+
model: this.model,
|
|
41
|
+
sdkVersionCode: this.sdkVersionCode,
|
|
42
|
+
sdkVersionName: this.sdkVersionName,
|
|
43
|
+
abiList: this.abiList,
|
|
44
|
+
isAdbEnabled: this.isAdbEnabled,
|
|
45
|
+
isDevelopmentSettingsEnabled: this.isDevelopmentSettingsEnabled,
|
|
46
|
+
isEmulator: this.isEmulator,
|
|
47
|
+
isTablet: this.isTablet,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
package/src/AssistsX.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { Bounds } from "./Bounds";
|
|
|
9
9
|
import { decodeBase64UTF8, generateUUID } from "./Utils";
|
|
10
10
|
import { AccessibilityEventFilter } from "AccessibilityEventFilter";
|
|
11
11
|
import { AppInfo } from "./AppInfo";
|
|
12
|
+
import { DeviceInfo } from "./DeviceInfo";
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* 无障碍事件数据结构
|
|
@@ -265,6 +266,18 @@ export class AssistsX {
|
|
|
265
266
|
return response.getDataOrDefault({});
|
|
266
267
|
}
|
|
267
268
|
|
|
269
|
+
/**
|
|
270
|
+
* 在浏览器中打开URL
|
|
271
|
+
* @param url 要打开的URL
|
|
272
|
+
* @returns 是否成功打开
|
|
273
|
+
*/
|
|
274
|
+
public static openUrlInBrowser(url: string): boolean {
|
|
275
|
+
const response = this.call(CallMethod.openUrlInBrowser, {
|
|
276
|
+
args: { url },
|
|
277
|
+
});
|
|
278
|
+
return response.getDataOrDefault(false);
|
|
279
|
+
}
|
|
280
|
+
|
|
268
281
|
public static isAppInstalled(packageName: string): boolean {
|
|
269
282
|
const response = this.call(CallMethod.isAppInstalled, {
|
|
270
283
|
args: { packageName },
|
|
@@ -872,11 +885,11 @@ export class AssistsX {
|
|
|
872
885
|
});
|
|
873
886
|
return response.getDataOrDefault({});
|
|
874
887
|
}
|
|
875
|
-
public static async getDeviceInfo(timeout?: number): Promise<
|
|
888
|
+
public static async getDeviceInfo(timeout?: number): Promise<DeviceInfo> {
|
|
876
889
|
const response = await this.asyncCall(CallMethod.getDeviceInfo, {
|
|
877
890
|
timeout,
|
|
878
891
|
});
|
|
879
|
-
return response.getDataOrDefault({});
|
|
892
|
+
return DeviceInfo.fromJSON(response.getDataOrDefault({}));
|
|
880
893
|
}
|
|
881
894
|
public static async getNetworkType(timeout?: number): Promise<any> {
|
|
882
895
|
const response = await this.asyncCall(CallMethod.getNetworkType, {
|
package/src/AssistsXAsync.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { CallResponse } from "./CallResponse";
|
|
|
8
8
|
import { Bounds } from "./Bounds";
|
|
9
9
|
import { generateUUID } from "./Utils";
|
|
10
10
|
import { AppInfo } from "./AppInfo";
|
|
11
|
+
import { DeviceInfo } from "./DeviceInfo";
|
|
11
12
|
import {
|
|
12
13
|
AssistsX,
|
|
13
14
|
callbacks,
|
|
@@ -867,11 +868,11 @@ export class AssistsXAsync {
|
|
|
867
868
|
});
|
|
868
869
|
return response.getDataOrDefault({});
|
|
869
870
|
}
|
|
870
|
-
public static async getDeviceInfo(timeout?: number): Promise<
|
|
871
|
+
public static async getDeviceInfo(timeout?: number): Promise<DeviceInfo> {
|
|
871
872
|
const response = await this.asyncCall(CallMethod.getDeviceInfo, {
|
|
872
873
|
timeout,
|
|
873
874
|
});
|
|
874
|
-
return response.getDataOrDefault({});
|
|
875
|
+
return DeviceInfo.fromJSON(response.getDataOrDefault({}));
|
|
875
876
|
}
|
|
876
877
|
|
|
877
878
|
/**
|
|
@@ -898,6 +899,23 @@ export class AssistsXAsync {
|
|
|
898
899
|
return response.getDataOrDefault("{}");
|
|
899
900
|
}
|
|
900
901
|
|
|
902
|
+
/**
|
|
903
|
+
* 在浏览器中打开URL
|
|
904
|
+
* @param url 要打开的URL
|
|
905
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
906
|
+
* @returns 是否成功打开
|
|
907
|
+
*/
|
|
908
|
+
public static async openUrlInBrowser(
|
|
909
|
+
url: string,
|
|
910
|
+
timeout?: number
|
|
911
|
+
): Promise<boolean> {
|
|
912
|
+
const response = await this.asyncCall(CallMethod.openUrlInBrowser, {
|
|
913
|
+
args: { url },
|
|
914
|
+
timeout,
|
|
915
|
+
});
|
|
916
|
+
return response.getDataOrDefault(false);
|
|
917
|
+
}
|
|
918
|
+
|
|
901
919
|
/**
|
|
902
920
|
* 发送HTTP请求
|
|
903
921
|
* @param options 请求选项
|
package/src/CallMethod.ts
CHANGED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 设备信息实体类
|
|
3
|
+
*/
|
|
4
|
+
export class DeviceInfo {
|
|
5
|
+
/**
|
|
6
|
+
* 设备唯一标识
|
|
7
|
+
*/
|
|
8
|
+
uniqueDeviceId: string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Android ID
|
|
12
|
+
*/
|
|
13
|
+
androidID: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* MAC地址
|
|
17
|
+
*/
|
|
18
|
+
macAddress: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 是否已Root
|
|
22
|
+
*/
|
|
23
|
+
isDeviceRooted: boolean;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 制造商
|
|
27
|
+
*/
|
|
28
|
+
manufacturer: string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 设备型号
|
|
32
|
+
*/
|
|
33
|
+
model: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* SDK版本号
|
|
37
|
+
*/
|
|
38
|
+
sdkVersionCode: number;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* SDK版本名称
|
|
42
|
+
*/
|
|
43
|
+
sdkVersionName: string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* ABI列表
|
|
47
|
+
*/
|
|
48
|
+
abiList: string[];
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 是否启用ADB调试
|
|
52
|
+
*/
|
|
53
|
+
isAdbEnabled: boolean;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 是否启用开发者选项
|
|
57
|
+
*/
|
|
58
|
+
isDevelopmentSettingsEnabled: boolean;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 是否为模拟器
|
|
62
|
+
*/
|
|
63
|
+
isEmulator: boolean;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 是否为平板
|
|
67
|
+
*/
|
|
68
|
+
isTablet: boolean;
|
|
69
|
+
|
|
70
|
+
constructor(
|
|
71
|
+
uniqueDeviceId: string = "",
|
|
72
|
+
androidID: string = "",
|
|
73
|
+
macAddress: string = "",
|
|
74
|
+
isDeviceRooted: boolean = false,
|
|
75
|
+
manufacturer: string = "",
|
|
76
|
+
model: string = "",
|
|
77
|
+
sdkVersionCode: number = 0,
|
|
78
|
+
sdkVersionName: string = "",
|
|
79
|
+
abiList: string[] = [],
|
|
80
|
+
isAdbEnabled: boolean = false,
|
|
81
|
+
isDevelopmentSettingsEnabled: boolean = false,
|
|
82
|
+
isEmulator: boolean = false,
|
|
83
|
+
isTablet: boolean = false
|
|
84
|
+
) {
|
|
85
|
+
this.uniqueDeviceId = uniqueDeviceId;
|
|
86
|
+
this.androidID = androidID;
|
|
87
|
+
this.macAddress = macAddress;
|
|
88
|
+
this.isDeviceRooted = isDeviceRooted;
|
|
89
|
+
this.manufacturer = manufacturer;
|
|
90
|
+
this.model = model;
|
|
91
|
+
this.sdkVersionCode = sdkVersionCode;
|
|
92
|
+
this.sdkVersionName = sdkVersionName;
|
|
93
|
+
this.abiList = abiList;
|
|
94
|
+
this.isAdbEnabled = isAdbEnabled;
|
|
95
|
+
this.isDevelopmentSettingsEnabled = isDevelopmentSettingsEnabled;
|
|
96
|
+
this.isEmulator = isEmulator;
|
|
97
|
+
this.isTablet = isTablet;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 从JSON对象创建DeviceInfo实例
|
|
102
|
+
* @param data JSON对象
|
|
103
|
+
* @returns DeviceInfo实例
|
|
104
|
+
*/
|
|
105
|
+
static fromJSON(data: any): DeviceInfo {
|
|
106
|
+
return new DeviceInfo(
|
|
107
|
+
data.uniqueDeviceId ?? "",
|
|
108
|
+
data.androidID ?? "",
|
|
109
|
+
data.macAddress ?? "",
|
|
110
|
+
data.isDeviceRooted ?? false,
|
|
111
|
+
data.manufacturer ?? "",
|
|
112
|
+
data.model ?? "",
|
|
113
|
+
data.sdkVersionCode ?? 0,
|
|
114
|
+
data.sdkVersionName ?? "",
|
|
115
|
+
data.abiList ?? [],
|
|
116
|
+
data.isAdbEnabled ?? false,
|
|
117
|
+
data.isDevelopmentSettingsEnabled ?? false,
|
|
118
|
+
data.isEmulator ?? false,
|
|
119
|
+
data.isTablet ?? false
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* 转换为JSON对象
|
|
125
|
+
* @returns JSON对象
|
|
126
|
+
*/
|
|
127
|
+
toJSON(): any {
|
|
128
|
+
return {
|
|
129
|
+
uniqueDeviceId: this.uniqueDeviceId,
|
|
130
|
+
androidID: this.androidID,
|
|
131
|
+
macAddress: this.macAddress,
|
|
132
|
+
isDeviceRooted: this.isDeviceRooted,
|
|
133
|
+
manufacturer: this.manufacturer,
|
|
134
|
+
model: this.model,
|
|
135
|
+
sdkVersionCode: this.sdkVersionCode,
|
|
136
|
+
sdkVersionName: this.sdkVersionName,
|
|
137
|
+
abiList: this.abiList,
|
|
138
|
+
isAdbEnabled: this.isAdbEnabled,
|
|
139
|
+
isDevelopmentSettingsEnabled: this.isDevelopmentSettingsEnabled,
|
|
140
|
+
isEmulator: this.isEmulator,
|
|
141
|
+
isTablet: this.isTablet,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
package/src/index.ts
CHANGED