@aiot-toolkit/emulator 2.0.5-beta.2 → 2.0.5-beta.20
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/README.md +79 -46
- package/lib/emulatorutil/constants.js +11 -4
- package/lib/emulatorutil/running.js +1 -1
- package/lib/instance/common.d.ts +3 -1
- package/lib/instance/common.js +8 -7
- package/lib/instance/index.d.ts +2 -1
- package/lib/instance/index.js +3 -1
- package/lib/instance/minisound.d.ts +18 -0
- package/lib/instance/minisound.js +45 -0
- package/lib/instance/miwear.d.ts +1 -0
- package/lib/instance/miwear.js +16 -1
- package/lib/instance/miwear5.d.ts +3 -0
- package/lib/instance/miwear5.js +3 -0
- package/lib/shared/index.js +1 -1
- package/lib/static/proto/README.MD +2 -0
- package/lib/static/proto/emulator_controller.proto +1321 -0
- package/lib/static/proto/rtc_service.proto +117 -0
- package/lib/typing/Vvd.d.ts +2 -1
- package/lib/typing/Vvd.js +2 -1
- package/lib/vvd/grpc/grpcError.d.ts +1 -0
- package/lib/vvd/grpc/grpcError.js +10 -0
- package/lib/vvd/grpc/index.d.ts +27 -0
- package/lib/vvd/grpc/index.js +117 -0
- package/lib/vvd/grpc/types/GrpcClient.d.ts +4 -0
- package/lib/vvd/grpc/types/GrpcClient.js +5 -0
- package/lib/vvd/grpc/types/KeyEvent.d.ts +19 -0
- package/lib/vvd/grpc/types/KeyEvent.js +20 -0
- package/lib/vvd/grpc/types/MouseEvent.d.ts +30 -0
- package/lib/vvd/grpc/types/MouseEvent.js +5 -0
- package/lib/vvd/index.d.ts +2 -0
- package/lib/vvd/index.js +23 -12
- package/lib/vvd/logcat.js +3 -0
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -17,101 +17,134 @@ Vela 模拟器 SDK
|
|
|
17
17
|
## 安装
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
npm install @aiot/emulator
|
|
20
|
+
npm install @aiot-toolkit/emulator
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## 使用
|
|
24
24
|
|
|
25
|
-
###
|
|
25
|
+
### 初始化环境
|
|
26
26
|
|
|
27
27
|
```ts
|
|
28
28
|
import os from 'os'
|
|
29
29
|
import path from 'path'
|
|
30
|
-
import {
|
|
30
|
+
import { VvdManager } from '@aiot-toolkit/emulator'
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
const
|
|
32
|
+
async function main() {
|
|
33
|
+
const sdkHome = path.resolve(os.homedir(), '.export_dev')
|
|
34
|
+
const velaAvdCls = new VvdManager({ sdkHome })
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
avdArch: IAvdArchType.arm64,
|
|
40
|
-
avdHeight: '466',
|
|
41
|
-
avdWidth: '466',
|
|
42
|
-
imageType: VelaImageType.REL
|
|
36
|
+
const downloder = await velaAvdCls.downloadSDK({
|
|
37
|
+
force: true,
|
|
38
|
+
cliProgress: false,
|
|
39
|
+
parallelDownloads: 6
|
|
43
40
|
})
|
|
41
|
+
|
|
42
|
+
downloder.on('progress', (progress) => {
|
|
43
|
+
console.log(
|
|
44
|
+
`progress: ${progress.formattedSpeed} ${progress.formattedPercentage} ${progress.formatTotal} ${progress.formatTimeLeft}`
|
|
45
|
+
)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
await downloder.downlodPromise
|
|
49
|
+
|
|
50
|
+
console.log('download success')
|
|
44
51
|
}
|
|
52
|
+
|
|
53
|
+
main()
|
|
45
54
|
```
|
|
46
55
|
|
|
47
|
-
###
|
|
56
|
+
### 创建 VVD
|
|
48
57
|
|
|
49
58
|
```ts
|
|
50
59
|
import os from 'os'
|
|
51
60
|
import path from 'path'
|
|
52
|
-
import { IAvdArchType,
|
|
61
|
+
import { IAvdArchType, VvdManager, VelaImageType, getDefaultImage } from '@aiot-toolkit/emulator'
|
|
53
62
|
|
|
54
|
-
const
|
|
55
|
-
|
|
63
|
+
const velaAvdCls = new VvdManager({
|
|
64
|
+
sdkHome: path.resolve(os.homedir(), '.export_dev')
|
|
65
|
+
})
|
|
56
66
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
/** 创建一个 466 × 466 带 miwear 的模拟器 */
|
|
68
|
+
export async function createVVd() {
|
|
69
|
+
const defaultImage = getDefaultImage()
|
|
70
|
+
velaAvdCls.createVvd({
|
|
71
|
+
name: avdName,
|
|
72
|
+
imageType: defaultImage,
|
|
73
|
+
arch: IVvdArchType.arm,
|
|
74
|
+
imageDir: path.dirname(velaAvdCls.getLocalSystemPath(defaultImage)),
|
|
75
|
+
width: '466',
|
|
76
|
+
height: '466'
|
|
60
77
|
})
|
|
61
78
|
}
|
|
62
79
|
```
|
|
63
80
|
|
|
64
|
-
###
|
|
81
|
+
### 启动 VVD
|
|
65
82
|
|
|
66
83
|
```ts
|
|
67
84
|
import os from 'os'
|
|
68
85
|
import path from 'path'
|
|
69
|
-
import {
|
|
86
|
+
import { IAvdArchType, VvdManager, VelaImageType } from '@aiot-toolkit/emulator'
|
|
70
87
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
88
|
+
const velaAvdCls = new VvdManager({
|
|
89
|
+
sdkHome: path.resolve(os.homedir(), '.export_dev')
|
|
90
|
+
})
|
|
74
91
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
92
|
+
export async function startVvd(vvdName: string) {
|
|
93
|
+
/**
|
|
94
|
+
* coldBoot:boolean 是否冷启动
|
|
95
|
+
* emulatorInstance: EmulatorInstance 模拟器实例, 可以通过它与模拟器进行命令交互
|
|
96
|
+
* getAgent: () => Promise<GrpcEmulator> 获取模拟器的Agent,可以通过它与模拟器进行屏幕交互
|
|
97
|
+
*/
|
|
98
|
+
const { coldBoot, emulatorInstance, getAgent } = await velaAvdCls.startVvd({
|
|
99
|
+
vvdName
|
|
79
100
|
})
|
|
80
101
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
102
|
+
// 启动应用
|
|
103
|
+
emulatorInstance.startApp('com.xiaomi.mipicks')
|
|
104
|
+
|
|
105
|
+
const velaAgent = await getAgent()
|
|
106
|
+
// 获取模拟器截图
|
|
107
|
+
const imgBuffer = await velaAgent.getScreenshot()
|
|
108
|
+
// 点击模拟器指定位置,
|
|
109
|
+
await velaAgent.sendMouse({
|
|
110
|
+
x: 100,
|
|
111
|
+
y: 100,
|
|
112
|
+
// 按下
|
|
113
|
+
buttons: 1
|
|
114
|
+
})
|
|
115
|
+
await velaAgent.sendMouse({
|
|
116
|
+
x: 100,
|
|
117
|
+
y: 100,
|
|
118
|
+
// 松开
|
|
119
|
+
buttons: 0
|
|
85
120
|
})
|
|
86
|
-
|
|
87
|
-
await downloder.downlodPromise
|
|
88
|
-
|
|
89
|
-
console.log('download success')
|
|
90
121
|
}
|
|
91
|
-
|
|
92
|
-
main()
|
|
93
122
|
```
|
|
94
123
|
|
|
95
124
|
### 完整示例
|
|
96
125
|
|
|
97
126
|
```ts
|
|
98
127
|
// 安装 npm install @aiot/emulator
|
|
99
|
-
import
|
|
128
|
+
import os from 'os'
|
|
129
|
+
import path from 'path'
|
|
130
|
+
import { IAvdArchType, VvdManager, VelaImageType } from '@aiot-toolkit/emulator'
|
|
100
131
|
|
|
101
|
-
const velaAvdCls = new
|
|
132
|
+
const velaAvdCls = new VvdManager({
|
|
133
|
+
sdkHome: path.resolve(os.homedir(), '.export_dev')
|
|
134
|
+
})
|
|
102
135
|
|
|
103
136
|
/** 创建一个 466 × 466 带 miwear 的模拟器 */
|
|
104
137
|
velaAvdCls.createVvd({
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
138
|
+
name: 'O62',
|
|
139
|
+
arch: IAvdArchType.arm64,
|
|
140
|
+
height: '466',
|
|
141
|
+
width: '466',
|
|
109
142
|
imageType: VelaImageType.REL
|
|
110
143
|
})
|
|
111
144
|
|
|
112
145
|
/** 启动名为 'O62' 的模拟器 */
|
|
113
146
|
velaAvdCls.startVvd({
|
|
114
|
-
|
|
147
|
+
vvdName: 'O62'
|
|
115
148
|
})
|
|
116
149
|
|
|
117
150
|
export async function startVvd(vvdName: string) {}
|
|
@@ -33,7 +33,7 @@ var _shared = require("../shared");
|
|
|
33
33
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
34
34
|
const defaultSDKHome = exports.defaultSDKHome = _path.default.resolve(_os.default.homedir(), _Vvd.VELAHOME.SDK);
|
|
35
35
|
const defaultVvdHome = exports.defaultVvdHome = _path.default.resolve(_os.default.homedir(), _Vvd.VELAHOME.VVD);
|
|
36
|
-
const defaultImageHome = exports.defaultImageHome = _path.default.resolve(defaultSDKHome, 'system-images
|
|
36
|
+
const defaultImageHome = exports.defaultImageHome = _path.default.resolve(defaultSDKHome, 'system-images', (0, _shared.getDefaultImage)());
|
|
37
37
|
const defaultEmulatorHome = exports.defaultEmulatorHome = _path.default.resolve(defaultSDKHome, 'emulator');
|
|
38
38
|
const defaultSkinHome = exports.defaultSkinHome = _path.default.resolve(defaultSDKHome, 'skins');
|
|
39
39
|
const defaultQuickappHome = exports.defaultQuickappHome = _path.default.resolve(defaultSDKHome, 'qa');
|
|
@@ -57,21 +57,21 @@ const VelaImageVersionList = exports.VelaImageVersionList = [{
|
|
|
57
57
|
label: 'vela-miwear-watch-5.0',
|
|
58
58
|
description: '适用于手表/手环的,带表盘的 vela 5.0 镜像,不可自定义模拟器尺寸',
|
|
59
59
|
value: _Vvd.VelaImageType.VELA_MIWEAR_WATCH_5,
|
|
60
|
-
time: '
|
|
60
|
+
time: '20250612',
|
|
61
61
|
hide: false,
|
|
62
62
|
icon: ''
|
|
63
63
|
}, {
|
|
64
64
|
label: 'vela-watch-5.0',
|
|
65
65
|
description: '适用于手表/手环的,不带表盘的 vela 5.0 镜像,可自定义模拟器尺寸',
|
|
66
66
|
value: _Vvd.VelaImageType.VELA_WATCH_5,
|
|
67
|
-
time: '
|
|
67
|
+
time: '20250612',
|
|
68
68
|
hide: false,
|
|
69
69
|
icon: ''
|
|
70
70
|
}, {
|
|
71
71
|
label: 'vela-miwear-watch-4.0',
|
|
72
72
|
description: '原 vela-release-4.0 版本,适用于手表/手环的,带表盘的 vela 4.0 镜像,不可自定义模拟器尺寸',
|
|
73
73
|
value: _Vvd.VelaImageType.REL,
|
|
74
|
-
time: '
|
|
74
|
+
time: '20250526',
|
|
75
75
|
hide: false,
|
|
76
76
|
icon: ''
|
|
77
77
|
}, {
|
|
@@ -81,6 +81,13 @@ const VelaImageVersionList = exports.VelaImageVersionList = [{
|
|
|
81
81
|
time: '20250225',
|
|
82
82
|
hide: false,
|
|
83
83
|
icon: ''
|
|
84
|
+
}, {
|
|
85
|
+
label: 'vela-miwear-minisound-5.0',
|
|
86
|
+
description: '适用于音响的 vela-miwear 5.0 镜像,不可自定义模拟器尺寸',
|
|
87
|
+
value: _Vvd.VelaImageType.VELA_MIWEAR_MINISOUND_5,
|
|
88
|
+
time: '20250318',
|
|
89
|
+
hide: true,
|
|
90
|
+
icon: ''
|
|
84
91
|
}];
|
|
85
92
|
const EmulatorEnvVersion = exports.EmulatorEnvVersion = {
|
|
86
93
|
name: '模拟器资源版本管理',
|
|
@@ -72,8 +72,8 @@ function resolvePath(filePath) {
|
|
|
72
72
|
return _path.default.resolve(filePath);
|
|
73
73
|
}
|
|
74
74
|
function getRunningAvdConfigFiles() {
|
|
75
|
-
const dir = getEmulatorDefaultConfigDir();
|
|
76
75
|
try {
|
|
76
|
+
const dir = getEmulatorDefaultConfigDir();
|
|
77
77
|
const files = _fs.default.readdirSync(dir);
|
|
78
78
|
return files.filter(t => fileNamePattern.test(t)).map(t => _path.default.join(dir, t));
|
|
79
79
|
} catch (error) {
|
package/lib/instance/common.d.ts
CHANGED
|
@@ -7,9 +7,11 @@ declare abstract class CommonEmulatorInstance {
|
|
|
7
7
|
appDir: string;
|
|
8
8
|
static emulatorStartedFlag: RegExp;
|
|
9
9
|
static appInstalledFlag: RegExp;
|
|
10
|
+
static appInstallFailedFlag: RegExp;
|
|
10
11
|
static appUninstalledFlag: RegExp;
|
|
11
12
|
static appStartedFlag: RegExp;
|
|
12
13
|
static isAppInstalled(log: string): boolean;
|
|
14
|
+
static isAppInstallFailed(log: string): boolean;
|
|
13
15
|
static isAppUninstalled(log: string, packageName: string): boolean;
|
|
14
16
|
static isEmulatorStarted(log: string): boolean;
|
|
15
17
|
sn: string;
|
|
@@ -33,7 +35,7 @@ declare abstract class CommonEmulatorInstance {
|
|
|
33
35
|
abstract closeApp(appName: string): Promise<void>;
|
|
34
36
|
/** 启动应用,留给子类实现 */
|
|
35
37
|
abstract startApp(packageName: string, debug: boolean): Promise<void>;
|
|
36
|
-
/**
|
|
38
|
+
/** 推送指定文件,返回推送结果 */
|
|
37
39
|
push(sourcePath: string, targetPath: string): Promise<string>;
|
|
38
40
|
unzip(zipPath: string, targetPath: string): Promise<void>;
|
|
39
41
|
/** 推送指定 rpk */
|
package/lib/instance/common.js
CHANGED
|
@@ -16,13 +16,17 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
16
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
17
|
class CommonEmulatorInstance {
|
|
18
18
|
appDir = '/data/quickapp/app';
|
|
19
|
-
static emulatorStartedFlag = /quickapp_rpk_installer_init|rpk installer init done|booting completed/;
|
|
19
|
+
static emulatorStartedFlag = /quickapp_rpk_installer_init|rpk installer init done|booting completed|Boot completed/;
|
|
20
20
|
static appInstalledFlag = /InstallState_Finished|install finished/;
|
|
21
|
+
static appInstallFailedFlag = /uv_mq_read_cb: install prepare failed/;
|
|
21
22
|
static appUninstalledFlag = /uninstalled app/;
|
|
22
23
|
static appStartedFlag = /Start App loop/;
|
|
23
24
|
static isAppInstalled(log) {
|
|
24
25
|
return this.appInstalledFlag.test(log);
|
|
25
26
|
}
|
|
27
|
+
static isAppInstallFailed(log) {
|
|
28
|
+
return this.appInstallFailedFlag.test(log);
|
|
29
|
+
}
|
|
26
30
|
static isAppUninstalled(log, packageName) {
|
|
27
31
|
return new RegExp(this.appUninstalledFlag + ':\\s+' + packageName).test(log);
|
|
28
32
|
}
|
|
@@ -76,14 +80,14 @@ class CommonEmulatorInstance {
|
|
|
76
80
|
|
|
77
81
|
/** 启动应用,留给子类实现 */
|
|
78
82
|
|
|
79
|
-
/**
|
|
83
|
+
/** 推送指定文件,返回推送结果 */
|
|
80
84
|
async push(sourcePath, targetPath) {
|
|
81
85
|
// 1. adb push应用的rpk
|
|
82
86
|
const pushCmd = `adb -s ${this.sn} push "${sourcePath}" ${targetPath}`;
|
|
83
87
|
this.logger(`Excuting: ${pushCmd}`);
|
|
84
88
|
const res = await adbMiwt.execAdbCmdAsync(pushCmd);
|
|
85
89
|
this.logger(`Push result: ${res}`);
|
|
86
|
-
return
|
|
90
|
+
return res;
|
|
87
91
|
}
|
|
88
92
|
async unzip(zipPath, targetPath) {
|
|
89
93
|
const unzipCmd = `adb -s ${this.sn} shell unzip -o ${zipPath} -d ${targetPath}`;
|
|
@@ -96,10 +100,7 @@ class CommonEmulatorInstance {
|
|
|
96
100
|
async pushRpk(rpkPath, appPackageName) {
|
|
97
101
|
// 1. adb push应用的rpk
|
|
98
102
|
const targetPath = `${this.appDir}/${appPackageName}.rpk`;
|
|
99
|
-
|
|
100
|
-
this.logger(`Excuting: ${pushCmd}`);
|
|
101
|
-
const res = await adbMiwt.execAdbCmdAsync(pushCmd);
|
|
102
|
-
this.logger(`Push ${this.vvdName} rpk result: ${res}`);
|
|
103
|
+
await this.push(rpkPath, targetPath);
|
|
103
104
|
return targetPath;
|
|
104
105
|
}
|
|
105
106
|
|
package/lib/instance/index.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ import { VelaImageType } from '../typing/Vvd';
|
|
|
6
6
|
import { IEmulatorInstanceParams } from '../typing/Instance';
|
|
7
7
|
import { Vela5Instance } from './vela5';
|
|
8
8
|
import { VelaMiwear5 } from './miwear5';
|
|
9
|
-
|
|
9
|
+
import { MiniSound5 } from './minisound';
|
|
10
|
+
declare function getInstanceClass(imageType: VelaImageType): typeof GoldfishInstance | typeof MiwearInstance | typeof PreInstance | typeof Vela5Instance | typeof VelaMiwear5 | typeof MiniSound5;
|
|
10
11
|
/**
|
|
11
12
|
* 根据镜像决定使用哪个instance
|
|
12
13
|
* Vela正式版(4.0) -> MiwearInstance
|
package/lib/instance/index.js
CHANGED
|
@@ -42,6 +42,7 @@ var _pre = _interopRequireDefault(require("./pre"));
|
|
|
42
42
|
var _Vvd = require("../typing/Vvd");
|
|
43
43
|
var _vela = require("./vela5");
|
|
44
44
|
var _miwear2 = require("./miwear5");
|
|
45
|
+
var _minisound = require("./minisound");
|
|
45
46
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
46
47
|
function getInstanceClass(imageType) {
|
|
47
48
|
const map = {
|
|
@@ -49,7 +50,8 @@ function getInstanceClass(imageType) {
|
|
|
49
50
|
[_Vvd.VelaImageType.REL]: _miwear.default,
|
|
50
51
|
[_Vvd.VelaImageType.DEV]: _dev.default,
|
|
51
52
|
[_Vvd.VelaImageType.VELA_WATCH_5]: _vela.Vela5Instance,
|
|
52
|
-
[_Vvd.VelaImageType.VELA_MIWEAR_WATCH_5]: _miwear2.VelaMiwear5
|
|
53
|
+
[_Vvd.VelaImageType.VELA_MIWEAR_WATCH_5]: _miwear2.VelaMiwear5,
|
|
54
|
+
[_Vvd.VelaImageType.VELA_MIWEAR_MINISOUND_5]: _minisound.MiniSound5
|
|
53
55
|
};
|
|
54
56
|
return map[imageType] || _dev.default;
|
|
55
57
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { VelaImageType } from '../typing/Vvd';
|
|
2
|
+
import { VelaMiwear5 } from './miwear5';
|
|
3
|
+
export declare class MiniSound5 extends VelaMiwear5 {
|
|
4
|
+
imageType: VelaImageType;
|
|
5
|
+
appDir: string;
|
|
6
|
+
static emulatorStartedFlag: RegExp;
|
|
7
|
+
static appStartedFlag: RegExp;
|
|
8
|
+
/**
|
|
9
|
+
* 使用 pm 安装快应用
|
|
10
|
+
* @param targeRpk 快应用的rpk文件路径
|
|
11
|
+
*/
|
|
12
|
+
install(targeRpk: string): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* 使用 pm 卸载快应用
|
|
15
|
+
* @param packageName 快应用的包名
|
|
16
|
+
*/
|
|
17
|
+
uninstall(packageName: string): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MiniSound5 = void 0;
|
|
7
|
+
var _adb = require("@miwt/adb");
|
|
8
|
+
var _Vvd = require("../typing/Vvd");
|
|
9
|
+
var _miwear = require("./miwear5");
|
|
10
|
+
class MiniSound5 extends _miwear.VelaMiwear5 {
|
|
11
|
+
imageType = (() => _Vvd.VelaImageType.VELA_MIWEAR_MINISOUND_5)();
|
|
12
|
+
appDir = '/data/app';
|
|
13
|
+
static emulatorStartedFlag = /\[launchQuickApp.*\] Start main loop/;
|
|
14
|
+
static appStartedFlag = /Start main loop/;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 使用 pm 安装快应用
|
|
18
|
+
* @param targeRpk 快应用的rpk文件路径
|
|
19
|
+
*/
|
|
20
|
+
install(targeRpk) {
|
|
21
|
+
const installCmd = `adb -s ${this.sn} shell pm install ${targeRpk}`;
|
|
22
|
+
this.logger(`Excuting: ${installCmd}`);
|
|
23
|
+
const res = (0, _adb.execAdbCmdSync)(installCmd);
|
|
24
|
+
this.logger(`Install Res: ${res}`);
|
|
25
|
+
if (res.includes('(success 0)')) {
|
|
26
|
+
return Promise.resolve();
|
|
27
|
+
} else {
|
|
28
|
+
return Promise.reject(res);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 使用 pm 卸载快应用
|
|
34
|
+
* @param packageName 快应用的包名
|
|
35
|
+
*/
|
|
36
|
+
uninstall(packageName) {
|
|
37
|
+
const res = (0, _adb.execAdbCmdSync)(`adb -s ${this.sn} shell pm uninstall ${packageName}`);
|
|
38
|
+
if (res.includes('(success 0)')) {
|
|
39
|
+
return Promise.resolve();
|
|
40
|
+
} else {
|
|
41
|
+
return Promise.reject(res);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.MiniSound5 = MiniSound5;
|
package/lib/instance/miwear.d.ts
CHANGED
package/lib/instance/miwear.js
CHANGED
|
@@ -17,6 +17,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
17
17
|
* 针对 Vela正式版(4.0)的镜像
|
|
18
18
|
*/
|
|
19
19
|
class MiwearInstance extends _common.default {
|
|
20
|
+
static emulatorStartedFlag = /quickapp_rpk_installer_init|rpk installer init done/;
|
|
20
21
|
static appInstalledFlag = /InstallState_Finished|install finished/;
|
|
21
22
|
imageType = (() => _Vvd.VelaImageType.REL)();
|
|
22
23
|
appDir = '/data/quickapp/app';
|
|
@@ -26,14 +27,23 @@ class MiwearInstance extends _common.default {
|
|
|
26
27
|
* @param targeRpk 快应用的rpk文件路径
|
|
27
28
|
*/
|
|
28
29
|
async install(targeRpk) {
|
|
29
|
-
|
|
30
|
+
const installCmd = `adb -s ${this.sn} shell pm install ${targeRpk}`;
|
|
31
|
+
this.logger(`Excuting: ${installCmd}`);
|
|
32
|
+
adbMiwt.execAdbCmd(installCmd);
|
|
30
33
|
return new Promise((resolve, reject) => {
|
|
31
34
|
const func = msg => {
|
|
32
35
|
if (MiwearInstance.isAppInstalled(msg)) {
|
|
33
36
|
clearTimeout(timer);
|
|
34
37
|
this.logger(`Install to ${this.vvdName} ${targeRpk} successfully`);
|
|
38
|
+
this.stdoutReadline.off('line', func);
|
|
35
39
|
resolve();
|
|
36
40
|
}
|
|
41
|
+
if (MiwearInstance.isAppInstallFailed(msg)) {
|
|
42
|
+
clearTimeout(timer);
|
|
43
|
+
this.stdoutReadline.off('line', func);
|
|
44
|
+
this.logger(`Failed Install to ${this.vvdName} ${targeRpk}`);
|
|
45
|
+
reject(msg);
|
|
46
|
+
}
|
|
37
47
|
};
|
|
38
48
|
let timer = setTimeout(() => {
|
|
39
49
|
this.stdoutReadline.off('line', func);
|
|
@@ -41,6 +51,11 @@ class MiwearInstance extends _common.default {
|
|
|
41
51
|
reject('Install timeout');
|
|
42
52
|
}, 2 * 60 * 1000);
|
|
43
53
|
this.stdoutReadline.on('line', func);
|
|
54
|
+
this.stdoutReadline.on('close', () => {
|
|
55
|
+
this.stdoutReadline.removeAllListeners();
|
|
56
|
+
clearTimeout(timer);
|
|
57
|
+
reject('Device poweroff');
|
|
58
|
+
});
|
|
44
59
|
});
|
|
45
60
|
}
|
|
46
61
|
|
package/lib/instance/miwear5.js
CHANGED
|
@@ -4,9 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.VelaMiwear5 = void 0;
|
|
7
|
+
var _Vvd = require("../typing/Vvd");
|
|
7
8
|
var _miwear = _interopRequireDefault(require("./miwear"));
|
|
8
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
10
|
class VelaMiwear5 extends _miwear.default {
|
|
11
|
+
imageType = (() => _Vvd.VelaImageType.VELA_MIWEAR_WATCH_5)();
|
|
10
12
|
appDir = '/data/app';
|
|
13
|
+
static emulatorStartedFlag = /\[App Active Flag/;
|
|
11
14
|
}
|
|
12
15
|
exports.VelaMiwear5 = VelaMiwear5;
|
package/lib/shared/index.js
CHANGED
|
@@ -16,7 +16,7 @@ function isVelaImageType(value) {
|
|
|
16
16
|
return Object.values(_Vvd.VelaImageType).includes(value);
|
|
17
17
|
}
|
|
18
18
|
function isMiwearImageType(val) {
|
|
19
|
-
return [_Vvd.VelaImageType.REL, _Vvd.VelaImageType.VELA_MIWEAR_WATCH_5].includes(val);
|
|
19
|
+
return [_Vvd.VelaImageType.REL, _Vvd.VelaImageType.VELA_MIWEAR_WATCH_5, _Vvd.VelaImageType.VELA_MIWEAR_MINISOUND_5].includes(val);
|
|
20
20
|
}
|
|
21
21
|
function getDefaultImage() {
|
|
22
22
|
return _Vvd.VelaImageType.VELA_MIWEAR_WATCH_5;
|