@aiot-toolkit/emulator 2.0.2-beta.6 → 2.0.2-beta.7

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.
@@ -133,7 +133,7 @@ class CommonInstance {
133
133
  }
134
134
  /** 停止模拟器并释放相关资源 */
135
135
  stop() {
136
- var _a;
136
+ var _a, _b;
137
137
  return __awaiter(this, void 0, void 0, function* () {
138
138
  if (this.goldfishProcess) {
139
139
  // Linux删除goldfishProcess后,子进程仍存在,导致模拟器窗口未关闭
@@ -142,7 +142,10 @@ class CommonInstance {
142
142
  // process.kill(this.goldfishProcess.pid + 1)
143
143
  // }
144
144
  this.killProcess(this.goldfishProcess);
145
- yield (0, utils_1.killProcessByCmd)((_a = this.startOptions) === null || _a === void 0 ? void 0 : _a.avdName);
145
+ if ((_a = this.startOptions) === null || _a === void 0 ? void 0 : _a.avdName) {
146
+ const emulatorProcessFlag = `-avd ${(_b = this.startOptions) === null || _b === void 0 ? void 0 : _b.avdName} -avd-arch`;
147
+ yield (0, utils_1.killProcessByCmd)(emulatorProcessFlag);
148
+ }
146
149
  this.goldfishProcess = undefined;
147
150
  }
148
151
  });
@@ -45,6 +45,7 @@ const ws_1 = __importStar(require("ws"));
45
45
  const constants_1 = require("../static/constants");
46
46
  const utils_1 = require("../utils");
47
47
  const common_1 = __importDefault(require("./common"));
48
+ const dayjs_1 = __importDefault(require("dayjs"));
48
49
  const MAX_RECONNECT_COUNT = 8;
49
50
  /**
50
51
  * MiwearInstance
@@ -116,15 +117,30 @@ class MiwearInstance extends common_1.default {
116
117
  if (devtool) {
117
118
  portMappingStr += `,hostfwd=tcp:127.0.0.1:${options.debugPort}-10.0.2.15:101`;
118
119
  }
119
- // 文件系统配置,第一次使用fatfs镜像挂载,后续使用adb push更新应用
120
- const systemImageBin = path_1.default.resolve(avdImagePath, 'vela_resource.bin');
121
- const dataImageBin = path_1.default.resolve(avdImagePath, 'vela_data.bin');
122
- const coreBin = path_1.default.resolve(avdImagePath, 'coredump.core');
123
- const imageMountStr = `-drive index=0,id=system,if=none,format=raw,file=${systemImageBin} \
120
+ // 设备挂载节点
121
+ const systemImageBin = path_1.default.resolve(avdImagePath, 'vela_resource.bin'); // 只读
122
+ const dataImageBin = path_1.default.resolve(avdImagePath, 'vela_data.bin'); // 可读可写
123
+ const coreBin = path_1.default.resolve(avdImagePath, 'coredump.core'); // 只读
124
+ // 复制可写文件到AVD目录下(多模拟器实例时需要)
125
+ const dataImageBinInAvd = path_1.default.join(this.avdHome, `${avdName}.avd`, 'vela_data.bin');
126
+ if (!fs_extra_1.default.existsSync(dataImageBinInAvd)) {
127
+ // vela_data.bin不存在时直接copy
128
+ fs_extra_1.default.copyFileSync(dataImageBin, dataImageBinInAvd);
129
+ }
130
+ else {
131
+ // vela_data.bin存在时,如果.export里的时间晚于avd里的时候,说明更新了镜像,需要重新copy
132
+ const statsInAvd = fs_extra_1.default.statSync(dataImageBinInAvd);
133
+ const stats = fs_extra_1.default.statSync(dataImageBin);
134
+ if ((0, dayjs_1.default)(stats.mtime).isAfter(statsInAvd.mtime)) {
135
+ fs_extra_1.default.copyFileSync(dataImageBin, dataImageBinInAvd);
136
+ }
137
+ }
138
+ // 挂载节点配置,只读文件加入read-only标识
139
+ const imageMountStr = `-drive index=0,id=system,if=none,format=raw,file=${systemImageBin},read-only \
124
140
  -device virtio-blk-device,bus=virtio-mmio-bus.0,drive=system \
125
- -drive index=1,id=userdata,if=none,format=raw,file=${dataImageBin} \
141
+ -drive index=1,id=userdata,if=none,format=raw,file=${dataImageBinInAvd} \
126
142
  -device virtio-blk-device,bus=virtio-mmio-bus.1,drive=userdata \
127
- -drive index=2,id=vendor,if=none,format=raw,file=${coreBin} \
143
+ -drive index=2,id=vendor,if=none,format=raw,file=${coreBin},read-only \
128
144
  -device virtio-blk-device,bus=virtio-mmio-bus.4,drive=vendor \
129
145
  -device virtio-snd,bus=virtio-mmio-bus.2 -allow-host-audio -semihosting`;
130
146
  // vnc配置
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiot-toolkit/emulator",
3
- "version": "2.0.2-beta.6",
3
+ "version": "2.0.2-beta.7",
4
4
  "description": "vela emulator tool.",
5
5
  "homepage": "",
6
6
  "license": "ISC",
@@ -35,8 +35,8 @@
35
35
  "emulator"
36
36
  ],
37
37
  "dependencies": {
38
- "@aiot-toolkit/aiotpack": "2.0.2-beta.6",
39
- "@aiot-toolkit/shared-utils": "2.0.2-beta.6",
38
+ "@aiot-toolkit/aiotpack": "2.0.2-beta.7",
39
+ "@aiot-toolkit/shared-utils": "2.0.2-beta.7",
40
40
  "find-process": "^1.4.7",
41
41
  "portfinder": "^1.0.32"
42
42
  },
@@ -44,5 +44,5 @@
44
44
  "@types/fs-extra": "^11.0.4",
45
45
  "fs-extra": "^11.2.0"
46
46
  },
47
- "gitHead": "b9b99afff176075380c2ec95b43797d696c393c1"
47
+ "gitHead": "dc37f9f6fbef3895d17b54ad41274c66f154f670"
48
48
  }