@aiot-toolkit/emulator 2.0.2-beta.1 → 2.0.2-beta.10

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 CHANGED
@@ -1,2 +1,15 @@
1
+ ## emulator
1
2
 
2
- emulator tool
3
+ QEMU模拟器
4
+
5
+ 模拟器的介绍可参考[开发帮助文档](https://xiaomi.f.mioffice.cn/docx/doxk4Rk6x67GanHlzQ8bEOrxtEe)里的「模拟器」章节
6
+
7
+ ## 目录结构
8
+
9
+ | 目录 | 描述 |
10
+ | -------- | ------------------------------------------------------------------------------- |
11
+ | avd | 模拟器的AVD,配置统一放置$HOME/.android/avd目录下 |
12
+ | instance | 模拟器实例,不同的Vela镜像版本会使用不同的instance,通过findInstance确定 |
13
+ | static | 创建AVD时需要用到的静态资源,常量配置文件 |
14
+ | typing | 接口定义 |
15
+ | utils | 工具函数 |
@@ -3,10 +3,22 @@ declare class VelaAvdCls {
3
3
  private avdHome;
4
4
  private sdkHome;
5
5
  constructor(avdResourcePaths: IAvdResourcePaths);
6
+ /**
7
+ * 创建Vela端的AVD,统一保存在.android目录下
8
+ * 1. 创建.android/advancedFeatures.ini文件
9
+ * 2. 创建.android/${avdName}.ini文件
10
+ * 3. 创建.android/${avdName}.avd/config.ini文件
11
+ * @param avdParams AVD参数,宽高、绑定的镜像路径等
12
+ * @returns
13
+ */
6
14
  createVelaAvd(avdParams: IAvdParams): boolean;
15
+ /** 根据AVD名字获取模拟器的详细信息 */
7
16
  getVelaAvdInfo(avdName: string): IAvdParams;
17
+ /** 根据名字删除AVD */
8
18
  deleteVelaAvd(avdName: string): boolean;
19
+ /** 获取已经创建的模拟器列表 */
9
20
  getVelaAvdList(): IAvdParams[];
21
+ /** 获取模拟器皮肤列表 */
10
22
  getVelaSkinList(): string[];
11
23
  }
12
24
  export default VelaAvdCls;
package/lib/avd/index.js CHANGED
@@ -8,6 +8,7 @@ const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const constants_1 = require("../static/constants");
10
10
  const Avd_1 = require("../typing/Avd");
11
+ const os_1 = __importDefault(require("os"));
11
12
  const EAvdParamsToIni = {
12
13
  'arm': {
13
14
  abiType: 'armeabi-v7a',
@@ -25,7 +26,21 @@ class VelaAvdCls {
25
26
  fs_1.default.mkdirSync(this.avdHome, { recursive: true });
26
27
  }
27
28
  }
29
+ /**
30
+ * 创建Vela端的AVD,统一保存在.android目录下
31
+ * 1. 创建.android/advancedFeatures.ini文件
32
+ * 2. 创建.android/${avdName}.ini文件
33
+ * 3. 创建.android/${avdName}.avd/config.ini文件
34
+ * @param avdParams AVD参数,宽高、绑定的镜像路径等
35
+ * @returns
36
+ */
28
37
  createVelaAvd(avdParams) {
38
+ // 在.android下创建advancedFeatures.ini文件
39
+ const advancedFeaturesIni = path_1.default.resolve(os_1.default.homedir(), '.android/advancedFeatures.ini');
40
+ if (!fs_1.default.existsSync(advancedFeaturesIni)) {
41
+ const iniSourcePath = path_1.default.join(__dirname, '../static/advancedFeatures.ini');
42
+ fs_1.default.copyFileSync(iniSourcePath, advancedFeaturesIni);
43
+ }
29
44
  const { avdName, avdArch, avdWidth, avdHeight, avdSkin, avdImagePath = constants_1.defaultImageHome } = avdParams;
30
45
  const avdDir = path_1.default.resolve(this.avdHome, `${avdName}.avd`);
31
46
  const avdIni = path_1.default.resolve(this.avdHome, `${avdName}.ini`);
@@ -69,6 +84,7 @@ class VelaAvdCls {
69
84
  throw (`createVelaAvd: ${e.message}`);
70
85
  }
71
86
  }
87
+ /** 根据AVD名字获取模拟器的详细信息 */
72
88
  getVelaAvdInfo(avdName) {
73
89
  const avdInfo = {
74
90
  avdName,
@@ -105,6 +121,7 @@ class VelaAvdCls {
105
121
  return avdInfo;
106
122
  }
107
123
  }
124
+ /** 根据名字删除AVD */
108
125
  deleteVelaAvd(avdName) {
109
126
  const avdDir = path_1.default.resolve(this.avdHome, `${avdName}.avd`);
110
127
  const avdIni = path_1.default.resolve(this.avdHome, `${avdName}.ini`);
@@ -117,6 +134,7 @@ class VelaAvdCls {
117
134
  return false;
118
135
  }
119
136
  }
137
+ /** 获取已经创建的模拟器列表 */
120
138
  getVelaAvdList() {
121
139
  const avdList = [];
122
140
  const files = fs_1.default.readdirSync(this.avdHome);
@@ -131,6 +149,7 @@ class VelaAvdCls {
131
149
  }
132
150
  return avdList;
133
151
  }
152
+ /** 获取模拟器皮肤列表 */
134
153
  getVelaSkinList() {
135
154
  try {
136
155
  const skinList = [];
@@ -10,34 +10,33 @@ declare class CommonInstance {
10
10
  projectPath: string;
11
11
  sdkHome: string;
12
12
  avdHome: string;
13
- adbPort: number;
14
- debugPort: number;
15
13
  velaAvdCls: VelaAvdCls;
16
14
  goldfishProcess: ChildProcess | undefined;
17
15
  isFirstStart: boolean;
18
16
  startOptions: IStartOptions | undefined;
19
17
  projectInfo: IManifest;
20
18
  isRpk: boolean;
19
+ isDistributedApp: boolean;
20
+ sn?: string;
21
21
  constructor(params: INewGoldfishInstanceParams);
22
22
  /** 获取模拟器二进制文件所在位置 */
23
23
  getEmulatorBinPath(): string;
24
24
  /** 在goldfish模拟器中运行快应用 */
25
25
  start(options: IStartOptions): Promise<void>;
26
- /** 在goldfish中启动快应用 */
27
- startupQuickApp(options: IStartOptions): void;
28
- /** 启动goldfish模拟器 */
29
- startGoldfish(options: IStartOptions): Promise<void>;
30
- /** 通过adb连接模拟器 */
31
- connectGoldfish(): Promise<boolean>;
32
- /** 将打包后的文件推到挂载的快应用目录 */
33
- pushRpk(sourceRoot: string): Promise<void>;
26
+ /**
27
+ * 通过adb连接模拟器。
28
+ * 时间限制为 @param timeout 秒,超时则表示连接失败
29
+ * @returns
30
+ */
31
+ connectGoldfish(timeout?: number): Promise<unknown>;
34
32
  /** 杀死进程 */
35
33
  killProcess(currProcess?: ChildProcess): void;
36
34
  /** 停止模拟器并释放相关资源 */
37
35
  stop(): Promise<void>;
38
36
  /** 重启模拟器 */
39
- restart(): void;
37
+ restart(): Promise<void>;
40
38
  /** 创建server */
41
39
  createWebsockeServer(): Promise<void>;
40
+ connectDevice(): Promise<string | void>;
42
41
  }
43
42
  export default CommonInstance;
@@ -41,23 +41,28 @@ const adbMiwt = __importStar(require("@miwt/adb"));
41
41
  const child_process_1 = require("child_process");
42
42
  const os_1 = __importDefault(require("os"));
43
43
  const path_1 = __importDefault(require("path"));
44
- const portfinder_1 = __importDefault(require("portfinder"));
45
44
  const ws_1 = require("ws");
46
45
  const avd_1 = __importDefault(require("../avd"));
47
46
  const constants_1 = require("../static/constants");
48
47
  const utils_1 = require("../utils");
48
+ const fs_extra_1 = __importDefault(require("fs-extra"));
49
49
  /**
50
50
  * CommonInstance
51
51
  */
52
52
  class CommonInstance {
53
53
  constructor(params) {
54
- this.adbPort = 5555;
55
- this.debugPort = 10055;
56
54
  this.isFirstStart = true;
55
+ this.isDistributedApp = false;
57
56
  this.projectPath = params.projectPath;
58
57
  this.sdkHome = params.sdkHome || constants_1.defaultSDKHome;
59
58
  this.avdHome = params.avdHome || constants_1.defaultAvdHome;
60
59
  this.isRpk = params.sourceRoot === './';
60
+ const projectJsonFile = path_1.default.resolve(this.projectPath, '.project.json');
61
+ const projectJsonExist = fs_extra_1.default.existsSync(projectJsonFile);
62
+ if (projectJsonExist) {
63
+ const projectJsonInfo = fs_extra_1.default.readJSONSync(projectJsonFile);
64
+ this.isDistributedApp = projectJsonInfo.projectType === 'distributed';
65
+ }
61
66
  this.velaAvdCls = new avd_1.default({
62
67
  sdkHome: this.sdkHome,
63
68
  avdHome: this.avdHome
@@ -74,154 +79,50 @@ class CommonInstance {
74
79
  }
75
80
  /** 在goldfish模拟器中运行快应用 */
76
81
  start(options) {
77
- return __awaiter(this, void 0, void 0, function* () {
78
- this.startOptions = options;
79
- // 启动模拟器
80
- yield this.startGoldfish(options);
81
- const connected = yield this.connectGoldfish();
82
- if (connected) {
83
- ColorConsole_1.default.log('### Emulator ### Goldfish emulator connected successfully');
84
- if (this.isFirstStart && this.startOptions.serverPort) {
85
- yield this.createWebsockeServer();
86
- }
87
- // adb push快应用到模拟器的/data/app目录
88
- const buildedFilesPath = this.isRpk ? this.projectPath : path_1.default.resolve(this.projectPath, './build');
89
- this.pushRpk(buildedFilesPath);
90
- // 在模拟器中启动快应用
91
- this.startupQuickApp(options);
92
- this.isFirstStart = false;
93
- }
94
- else {
95
- ColorConsole_1.default.throw('### Emulator ### Failed to connect emulator, please check whether the adb is normal');
96
- }
97
- });
98
- }
99
- /** 在goldfish中启动快应用 */
100
- startupQuickApp(options) {
101
- try {
102
- let vappCmd = `adb -s 127.0.0.1:${this.adbPort} shell vapp app/${this.projectInfo.package} &`;
103
- if (options.devtool) {
104
- vappCmd = `adb -s 127.0.0.1:${this.adbPort} shell vapp --jsdebugger=10.0.2.15:101 app/${this.projectInfo.package} &`;
105
- }
106
- ColorConsole_1.default.log(`### Emulator ### Excuting adb cmd: ${vappCmd}`);
107
- // vapp进程会一直pending,不会退出。这里必须加stdio: 'ignore',否则快应用无法运行成功
108
- adbMiwt.execAdbCmdAsync(vappCmd, { stdio: 'ignore', encoding: 'utf-8' });
109
- }
110
- catch (e) {
111
- ColorConsole_1.default.error(`### Emulator ### Failed to startup quickapp: ${e.message}`);
112
- }
113
- }
114
- /** 启动goldfish模拟器 */
115
- startGoldfish(options) {
116
- var _a;
117
- return __awaiter(this, void 0, void 0, function* () {
118
- const { avdName, devtool } = options;
119
- const emulatorBin = this.getEmulatorBinPath();
120
- ColorConsole_1.default.log(`### Emulator ### emulator path: ${emulatorBin}`);
121
- const avdInfo = this.velaAvdCls.getVelaAvdInfo(avdName);
122
- const { avdArch, avdImagePath } = avdInfo;
123
- this.adbPort = yield portfinder_1.default.getPortPromise({ port: this.adbPort });
124
- ColorConsole_1.default.log(`### Emulator ### adb port: ${this.adbPort}`);
125
- if (!avdImagePath) {
126
- return ColorConsole_1.default.throw(`### Emulator ### Unable to find vela image via avd`);
127
- }
128
- const nuttxBinPath = path_1.default.resolve(avdImagePath, 'nuttx');
129
- ColorConsole_1.default.log(`### Emulator ### nuttx path: ${nuttxBinPath}`);
130
- // 端口映射
131
- const adbPortMappingStr = `-network-user-mode-options hostfwd=tcp:127.0.0.1:${this.adbPort}-10.0.2.15:5555`;
132
- let debugPortMappingStr = '';
133
- if (devtool) {
134
- debugPortMappingStr = `-network-user-mode-options hostfwd=tcp:127.0.0.1:${this.debugPort}-10.0.2.15:101`;
135
- }
136
- // 文件系统配置,第一次使用fatfs镜像挂载,后续使用adb push更新应用
137
- const systemImageBin = path_1.default.resolve(this.sdkHome, 'tools/image/system.img');
138
- const dataImageBin = path_1.default.resolve(this.sdkHome, 'tools/image/data.img');
139
- const imageMountStr = `-drive index=0,id=system,if=none,format=raw,file=${systemImageBin} \
140
- -device virtio-blk-device,bus=virtio-mmio-bus.0,drive=system \
141
- -drive index=1,id=userdata,if=none,format=raw,file=${dataImageBin} \
142
- -device virtio-blk-device,bus=virtio-mmio-bus.1,drive=userdata \
143
- -device virtio-snd,bus=virtio-mmio-bus.2 -allow-host-audio -semihosting`;
144
- // vnc配置
145
- let windowStr = '';
146
- let vncStr = '';
147
- if ((_a = this.startOptions) === null || _a === void 0 ? void 0 : _a.vncPort) {
148
- windowStr = '-no-window';
149
- const portSuffix = this.startOptions.vncPort - constants_1.defaultVncPort;
150
- vncStr = `-vnc :${portSuffix}`;
151
- }
152
- const stdioType = options.disableNSH ? 'pipe' : 'inherit';
153
- // 启动goldfish的命令和参数
154
- const cmd = `${emulatorBin} -nuttx -avd ${avdName} -avd-arch ${avdArch} -show-kernel -kernel ${nuttxBinPath} ${adbPortMappingStr} ${debugPortMappingStr} -qemu ${windowStr} ${vncStr} ${imageMountStr}`;
155
- const spawnArgs = cmd.split(' ');
156
- const spawnBin = spawnArgs.shift();
157
- ColorConsole_1.default.log(`### Emulator ### Start CMD: ${cmd}`);
158
- return new Promise((resolve) => {
159
- var _a, _b;
160
- this.goldfishProcess = (0, child_process_1.spawn)(spawnBin, spawnArgs, { stdio: stdioType, shell: true });
161
- if (options.disableNSH) {
162
- (_a = this.goldfishProcess.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (data) => {
163
- console.log(data.toString());
164
- if (data.toString().includes('(NSH)')) {
165
- ColorConsole_1.default.log(`### Emulator ### Goldfish emulator starts successfully`);
166
- resolve();
167
- }
168
- });
169
- (_b = this.goldfishProcess.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (data) => {
170
- console.log(data.toString());
171
- });
172
- }
173
- else {
174
- setTimeout(() => {
175
- ColorConsole_1.default.log(`### Emulator ### Goldfish emulator starts successfully`);
176
- resolve();
177
- }, 2000);
178
- }
179
- this.goldfishProcess.on('exit', (code) => {
180
- ColorConsole_1.default.error(`### Emulator ### Goldfish emulator exited with code ${code}`);
181
- });
182
- });
183
- });
82
+ return __awaiter(this, void 0, void 0, function* () { });
184
83
  }
185
- /** 通过adb连接模拟器 */
186
- connectGoldfish() {
84
+ /**
85
+ * 通过adb连接模拟器。
86
+ * 时间限制为 @param timeout 秒,超时则表示连接失败
87
+ * @returns
88
+ */
89
+ connectGoldfish(timeout = 10) {
187
90
  return __awaiter(this, void 0, void 0, function* () {
188
- let adbConnected = false;
91
+ let adbConnected = false; // adb是否连接成功
92
+ let enableLoop = true; // 是否允许循环,用于终止adb的连接
93
+ let needKill = false;
189
94
  const connectFn = () => __awaiter(this, void 0, void 0, function* () {
190
- const sn = `127.0.0.1:${this.adbPort}`;
191
- while (!adbConnected) {
192
- const adbKillCmd = `adb kill-server`;
193
- ColorConsole_1.default.log(`### Emulator ### Excuting adb cmd: ${adbKillCmd}`);
194
- adbMiwt.execAdbCmdSync(adbKillCmd);
195
- const adbConnectCmd = `adb connect ${sn}`;
196
- ColorConsole_1.default.log(`### Emulator ### Excuting adb cmd: ${adbConnectCmd}`);
197
- const str = adbMiwt.execAdbCmdSync(adbConnectCmd);
95
+ while (enableLoop && !adbConnected) {
96
+ if (needKill) {
97
+ const adbKillCmd = `adb kill-server`;
98
+ ColorConsole_1.default.log(`### Emulator ### Excuting adb cmd: ${adbKillCmd}`);
99
+ yield adbMiwt.execAdbCmdAsync(adbKillCmd);
100
+ }
101
+ const str = yield this.connectDevice();
198
102
  ColorConsole_1.default.log(`### Emulator ### ${str}`);
103
+ // 查询模拟器的状态是否为“device”
199
104
  const devices = yield adbMiwt.getAdbDevices();
200
105
  ColorConsole_1.default.log(`### Emulator ### adb devices: ${JSON.stringify(devices)}`);
201
- adbConnected =
202
- devices.filter((item) => item.sn === sn && item.status === 'device').length > 0;
106
+ const curDev = devices.find((t) => t.sn === this.sn);
107
+ if ((curDev === null || curDev === void 0 ? void 0 : curDev.status) === 'offline')
108
+ needKill = true;
109
+ adbConnected = devices.some((item) => item.sn === this.sn && item.status === 'device');
203
110
  }
204
- Promise.resolve(adbConnected);
111
+ return Promise.resolve(adbConnected);
205
112
  });
206
- yield Promise.race([
113
+ const res = yield Promise.race([
207
114
  connectFn(),
208
115
  new Promise((resolve) => {
209
- setTimeout(() => resolve(false), 600 * 1000);
116
+ setTimeout(() => {
117
+ if (!adbConnected) {
118
+ enableLoop = false;
119
+ }
120
+ // 超时则认为adb没有连接成功
121
+ resolve(false);
122
+ }, timeout * 1000);
210
123
  })
211
124
  ]);
212
- return adbConnected;
213
- });
214
- }
215
- /** 将打包后的文件推到挂载的快应用目录 */
216
- pushRpk(sourceRoot) {
217
- return __awaiter(this, void 0, void 0, function* () {
218
- const sn = `127.0.0.1:${this.adbPort}`;
219
- const { package: appPackageName } = UxFileUtils_1.default.getMainfestInfo(this.projectPath);
220
- const appRunDir = '/data/app';
221
- ColorConsole_1.default.log(`### Emulator ### Pushing ${appPackageName} to ${appRunDir}`);
222
- (0, child_process_1.execSync)(`adb -s ${sn} shell mkdir ${appRunDir}/${appPackageName}`, { stdio: 'ignore' });
223
- yield adbMiwt.execAdbCmdAsync(`adb -s ${sn} push ${sourceRoot}/* ${appRunDir}/${appPackageName}`);
224
- ColorConsole_1.default.log(`### Emulator ### Push ${appPackageName} to ${appRunDir} successfully`);
125
+ return res;
225
126
  });
226
127
  }
227
128
  /** 杀死进程 */
@@ -246,7 +147,7 @@ class CommonInstance {
246
147
  }
247
148
  /** 停止模拟器并释放相关资源 */
248
149
  stop() {
249
- var _a;
150
+ var _a, _b;
250
151
  return __awaiter(this, void 0, void 0, function* () {
251
152
  if (this.goldfishProcess) {
252
153
  // Linux删除goldfishProcess后,子进程仍存在,导致模拟器窗口未关闭
@@ -255,29 +156,34 @@ class CommonInstance {
255
156
  // process.kill(this.goldfishProcess.pid + 1)
256
157
  // }
257
158
  this.killProcess(this.goldfishProcess);
258
- yield (0, utils_1.killProcessByCmd)((_a = this.startOptions) === null || _a === void 0 ? void 0 : _a.avdName);
159
+ if ((_a = this.startOptions) === null || _a === void 0 ? void 0 : _a.avdName) {
160
+ const emulatorProcessFlag = `-avd ${(_b = this.startOptions) === null || _b === void 0 ? void 0 : _b.avdName} -avd-arch`;
161
+ yield (0, utils_1.killProcessByCmd)(emulatorProcessFlag);
162
+ }
259
163
  this.goldfishProcess = undefined;
260
164
  }
261
165
  });
262
166
  }
263
167
  /** 重启模拟器 */
264
168
  restart() {
265
- this.stop();
266
- this.start(this.startOptions);
169
+ return __awaiter(this, void 0, void 0, function* () {
170
+ yield this.stop();
171
+ this.start(this.startOptions);
172
+ });
267
173
  }
268
174
  /** 创建server */
269
175
  createWebsockeServer() {
270
176
  var _a;
271
177
  return __awaiter(this, void 0, void 0, function* () {
272
178
  const wsServer = new ws_1.WebSocketServer({
273
- port: (_a = this.startOptions) === null || _a === void 0 ? void 0 : _a.serverPort,
179
+ port: (_a = this.startOptions) === null || _a === void 0 ? void 0 : _a.serverPort
274
180
  });
275
- wsServer.on('connection', socket => {
181
+ wsServer.on('connection', (socket) => {
276
182
  ColorConsole_1.default.success(`### App Socket server ### Websocket connects to websocket server`);
277
- socket.on('error', err => {
183
+ socket.on('error', (err) => {
278
184
  ColorConsole_1.default.error(`### App Socket server ### Websocket server error: ${err.message}`);
279
185
  });
280
- socket.on('message', data => {
186
+ socket.on('message', (data) => {
281
187
  const message = JSON.parse(data.toString());
282
188
  ColorConsole_1.default.log(`### App Socket server ### Websocket server get data: ${data}`);
283
189
  if (message.type === 'restart') {
@@ -290,5 +196,32 @@ class CommonInstance {
290
196
  });
291
197
  });
292
198
  }
199
+ connectDevice() {
200
+ return __awaiter(this, void 0, void 0, function* () {
201
+ const adbConnectCmd = `adb connect ${this.sn}`;
202
+ ColorConsole_1.default.log(`### Emulator ### Excuting adb cmd: ${adbConnectCmd}`);
203
+ let pending = true;
204
+ const p1 = adbMiwt.execAdbCmdAsync(adbConnectCmd);
205
+ let timer;
206
+ // 超过一定时间还没有连接成功,则 kill-server 后再试
207
+ // 用于处理 adb connect 一直 pending 的情况
208
+ const p2 = new Promise((resolve, reject) => {
209
+ timer = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
210
+ if (pending) {
211
+ const adbKillCmd = `adb kill-server`;
212
+ ColorConsole_1.default.log(`### Emulator ### Excuting adb cmd: ${adbKillCmd}`);
213
+ yield adbMiwt.execAdbCmdAsync(adbKillCmd);
214
+ }
215
+ resolve();
216
+ }), 10 * 1000);
217
+ });
218
+ p1.then((r) => {
219
+ pending = false;
220
+ clearTimeout(timer);
221
+ console.log(r);
222
+ });
223
+ return Promise.race([p1, p2]);
224
+ });
225
+ }
293
226
  }
294
227
  exports.default = CommonInstance;
@@ -3,13 +3,33 @@ import CommonInstance from './common';
3
3
  declare class GoldfishInstance extends CommonInstance {
4
4
  private appRunDir;
5
5
  constructor(params: INewGoldfishInstanceParams);
6
- /** 在goldfish模拟器中运行快应用 */
6
+ /**
7
+ * 1. 启动模拟器
8
+ * 2. 启动成功后,adb连接模拟器
9
+ * 3. 连接成功后,在模拟器中启动快应用
10
+ */
7
11
  start(options: IStartOptions): Promise<void>;
8
- /** 在goldfish中启动快应用 */
12
+ /**
13
+ * 在模拟器中启动快应用
14
+ * 通过vapp命令启动,调试时需额外配置--jsdebugger参数
15
+ * @param options
16
+ */
9
17
  startupQuickApp(options: IStartOptions): Promise<void>;
10
- /** 启动goldfish模拟器 */
18
+ /**
19
+ * 启动模拟器
20
+ * 1. 通过options生成模拟器的启动命令
21
+ * 2. 执行启动命令
22
+ * 3. 判断模拟器是否启动成功
23
+ * 3.1 若disableNSH=true,输出流中匹配到(NSH),认为模拟器启动成功了
24
+ * 3.2 若disableNSH=false,认为2s过后模拟器启动成功了
25
+ * @param options
26
+ * @returns
27
+ */
11
28
  startGoldfish(options: IStartOptions): Promise<void>;
12
- /** 将打包后的文件推到挂载的快应用目录 */
29
+ /**
30
+ * 将目录通过adb push到模拟器中
31
+ * @param sourceRoot
32
+ */
13
33
  pushRpk(sourceRoot: string): Promise<void>;
14
34
  }
15
35
  export default GoldfishInstance;