@aiot-toolkit/emulator 2.0.6-beta.2 → 2.0.6-beta.4

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/lib/vvd/index.js CHANGED
@@ -62,12 +62,13 @@ exports.isHeadlessEnvironment = isHeadlessEnvironment;
62
62
  class VvdManager {
63
63
  // 需要复制的文件
64
64
  binFiles = ['system.img', 'data.img', 'coredump.core', 'vela_data.bin', 'vela_resource.bin', 'vela_system.bin'];
65
- constructor(vvdResourcePaths) {
65
+ constructor() {
66
+ let vvdResourcePaths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
66
67
  const {
67
- vvdHome: avdHome,
68
+ vvdHome,
68
69
  sdkHome
69
70
  } = vvdResourcePaths;
70
- this.vvdHome = avdHome || _constants.defaultVvdHome;
71
+ this.vvdHome = vvdHome || _constants.defaultVvdHome;
71
72
  this.sdkHome = sdkHome || _constants.defaultSDKHome;
72
73
  if (!_fs.default.existsSync(this.vvdHome)) {
73
74
  _fs.default.mkdirSync(this.vvdHome, {
@@ -181,7 +182,7 @@ class VvdManager {
181
182
  skin: '',
182
183
  imageDir: '',
183
184
  customLcdRadius: '',
184
- imageType: _Vvd.VelaImageType.REL
185
+ imageType: _Vvd.VelaImageType.VELA_MIWEAR_WATCH_5
185
186
  };
186
187
  let currVvdDir = this.getVvdDir(vvdName);
187
188
  const configIni = _path.default.resolve(currVvdDir, 'config.ini');
@@ -196,7 +197,7 @@ class VvdManager {
196
197
  vvdInfo.imageDir = config['image.sysdir.2'];
197
198
  vvdInfo.customImagePath = config['image.sysdir.1'];
198
199
  vvdInfo.customLcdRadius = config['ide.lcd.radius'];
199
- vvdInfo.imageType = config['ide.image.type'];
200
+ if (config['ide.image.type']) vvdInfo.imageType = config['ide.image.type'];
200
201
  if (vvdInfo.skin) {
201
202
  try {
202
203
  vvdInfo.skinInfo = this.getSkinInfo(vvdInfo.skin, config['skin.path']);
@@ -238,7 +239,12 @@ class VvdManager {
238
239
  const matcher = fileName.match(regex);
239
240
  if (matcher) {
240
241
  const avdName = matcher[1];
241
- const avdInfo = this.getVvdInfo(avdName);
242
+ let avdInfo;
243
+ try {
244
+ avdInfo = this.getVvdInfo(avdName);
245
+ } catch (error) {
246
+ continue;
247
+ }
242
248
  avdList.push(avdInfo);
243
249
  }
244
250
  }
@@ -362,13 +368,17 @@ class VvdManager {
362
368
  let needUpdate = false;
363
369
 
364
370
  // 检查 ramsize 调整为 1024
365
- if (config['hw.ramSize'] < 1024) {
371
+ if (config['hw.ramSize'] && typeof config['hw.ramSize'] === 'number' && config['hw.ramSize'] < 1024) {
366
372
  needUpdate = true;
367
373
  config['hw.ramSize'] = 1024;
368
374
  }
375
+ // 统一路径分隔符为 /
376
+ const normalizePath = p => p.replace(/\\/g, '/');
377
+
369
378
  // 检查皮肤路径
370
- if (config['skin.path']?.includes('.export_dev/skins')) {
371
- if (config['skin.path'].includes('.export_dev/skins/user')) {
379
+ const skinPath = config['skin.path'];
380
+ if (skinPath && normalizePath(skinPath.toString())?.includes('.export_dev/skins')) {
381
+ if (normalizePath(skinPath.toString())?.includes('.export_dev/skins/user')) {
372
382
  // 自定义的皮肤,将自定义皮肤迁移到新的 sdk 目录中
373
383
  const oldUserSkinDir = _path.default.join(_os.default.homedir(), '.export_dev/skins/user');
374
384
  const newUserSkinDir = _path.default.join(this.sdkHome, 'skins', 'user');
@@ -388,13 +398,26 @@ class VvdManager {
388
398
  }
389
399
  }
390
400
  needUpdate = true;
391
- config['skin.path'] = config['skin.path'].replace('.export_dev/skins', '.vela/sdk/skins');
401
+ config['skin.path'] = normalizePath(skinPath.toString()).replace('.export_dev/skins', '.vela/sdk/skins');
402
+ }
403
+
404
+ // 迁移 原来 user 目录中的 xiaomi_band_10
405
+ if (skinPath && normalizePath(skinPath.toString())?.endsWith('/user/xiaomi_band_10')) {
406
+ _ColorConsole.default.log('migrate user/xiaomi_band_10 to builtin/xiaomi_band_10');
407
+ config['skin.path'] = normalizePath(skinPath.toString()).replace('/user/xiaomi_band_10', '/builtin/xiaomi_band_10');
408
+ needUpdate = true;
409
+ }
410
+
411
+ // 检查 hw.cpu.ncore
412
+ if (config['hw.cpu.ncore'] && typeof config['hw.cpu.ncore'] === 'number' && config['hw.cpu.ncore'] > 2) {
413
+ needUpdate = true;
414
+ config['hw.cpu.ncore'] = 2;
392
415
  }
393
416
 
394
417
  // 检查镜像路径
395
- if (config['image.sysdir.2']?.includes('.export_dev/system-images')) {
418
+ if (config['image.sysdir.2'] && normalizePath(config['image.sysdir.2'].toString())?.includes('.export_dev/system-images')) {
396
419
  needUpdate = true;
397
- config['image.sysdir.2'] = config['image.sysdir.2'].replace('.export_dev/system-images', '.vela/sdk/system-images');
420
+ config['image.sysdir.2'] = normalizePath(config['image.sysdir.2'].toString()).replace('.export_dev/system-images', '.vela/sdk/system-images');
398
421
  }
399
422
  if (needUpdate) {
400
423
  await _promises.default.writeFile(configIni, (0, _ini.stringify)(config));
@@ -430,7 +453,7 @@ class VvdManager {
430
453
  // -fsdev local,security_model=none,id=fsdev0,path=${HOST_9PFS_DIR} \
431
454
  // -device virtio-9p-device,id=fs0,fsdev=fsdev0,mount_tag=host `
432
455
 
433
- const qemuOption = `-device virtio-snd,bus=virtio-mmio-bus.2 -allow-host-audio -semihosting`;
456
+ const qemuOption = `-device virtio-snd,bus=virtio-mmio-bus.2 -allow-host-audio -semihosting -smp 2`;
434
457
 
435
458
  // qt windows 配置
436
459
  // 在 docker,wls,等无界面平台上用 -no-window ,否则用 -qt-hide-window
@@ -452,7 +475,8 @@ class VvdManager {
452
475
  const cmd = `${emulatorBin} -vela -avd ${options.vvdName} ${serialStr} -show-kernel ${portMappingStr} ${windowOption} ${grpcStr} ${verboseOption} -qemu ${qemuOption}`;
453
476
  const vvdInfo = this.getVvdInfo(vvdName);
454
477
  await this.oldEmulatorMigrate(vvdName);
455
- if (!vvdInfo.imageDir) {
478
+ const imageDir = vvdInfo.customImagePath || vvdInfo.imageDir;
479
+ if (!imageDir) {
456
480
  const errMsg = `${vvdName} is not supported`;
457
481
  _ColorConsole.default.throw(errMsg);
458
482
  throw new Error(errMsg);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiot-toolkit/emulator",
3
- "version": "2.0.6-beta.2",
3
+ "version": "2.0.6-beta.4",
4
4
  "description": "vela emulator tool.",
5
5
  "homepage": "",
6
6
  "license": "ISC",
@@ -23,10 +23,6 @@
23
23
  "type": "git",
24
24
  "url": ""
25
25
  },
26
- "author": {
27
- "name": "juancao816",
28
- "email": "caojuan2019@163.com"
29
- },
30
26
  "engines": {
31
27
  "node": ">=12.0"
32
28
  },
@@ -36,10 +32,10 @@
36
32
  "emulator"
37
33
  ],
38
34
  "dependencies": {
39
- "@aiot-toolkit/shared-utils": "2.0.6-beta.2",
35
+ "@aiot-toolkit/shared-utils": "2.0.6-beta.4",
40
36
  "@grpc/grpc-js": "^1.13.3",
41
37
  "@grpc/proto-loader": "^0.7.13",
42
- "@miwt/adb": "0.10.1",
38
+ "@miwt/adb": "0.10.5",
43
39
  "adm-zip": "^0.5.16",
44
40
  "dayjs": "^1.11.12",
45
41
  "find-process": "^1.4.7",
@@ -53,5 +49,5 @@
53
49
  "@types/adm-zip": "^0.5.5",
54
50
  "@types/ini": "^4.1.1"
55
51
  },
56
- "gitHead": "d0057f9e62ac191d21445787667217cfa4aff1e9"
52
+ "gitHead": "1acc8279ba3c5995aebe3a97a6b33154086f09d6"
57
53
  }
@@ -1,19 +0,0 @@
1
- export declare enum KeyEventType {
2
- KEYDOWN = 0,
3
- KEYUP = 1,
4
- KEYPRESS = 2
5
- }
6
- export declare enum KeyCodeType {
7
- USB = 0,
8
- EVDEV = 1,
9
- XKB = 2,
10
- WIN = 3,
11
- MAC = 4
12
- }
13
- export interface GrpcKeyboardEvent {
14
- codeType?: KeyCodeType;
15
- eventType?: KeyEventType;
16
- keyCode?: number | string;
17
- key?: string;
18
- text?: string;
19
- }
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.KeyEventType = exports.KeyCodeType = void 0;
7
- let KeyEventType = exports.KeyEventType = /*#__PURE__*/function (KeyEventType) {
8
- KeyEventType[KeyEventType["KEYDOWN"] = 0] = "KEYDOWN";
9
- KeyEventType[KeyEventType["KEYUP"] = 1] = "KEYUP";
10
- KeyEventType[KeyEventType["KEYPRESS"] = 2] = "KEYPRESS";
11
- return KeyEventType;
12
- }({});
13
- let KeyCodeType = exports.KeyCodeType = /*#__PURE__*/function (KeyCodeType) {
14
- KeyCodeType[KeyCodeType["USB"] = 0] = "USB";
15
- KeyCodeType[KeyCodeType["EVDEV"] = 1] = "EVDEV";
16
- KeyCodeType[KeyCodeType["XKB"] = 2] = "XKB";
17
- KeyCodeType[KeyCodeType["WIN"] = 3] = "WIN";
18
- KeyCodeType[KeyCodeType["MAC"] = 4] = "MAC";
19
- return KeyCodeType;
20
- }({});
@@ -1,30 +0,0 @@
1
- export interface MouseEvent {
2
- /**
3
- * The horizontal coordinate. This is the physical location on the
4
- * screen For example 0 indicates the leftmost coordinate.
5
- */
6
- x?: number;
7
- /**
8
- * The vertical coordinate. This is the physical location on the screen
9
- * For example 0 indicates the top left coordinate.
10
- */
11
- y?: number;
12
- /**
13
- * Indicates which buttons are pressed.
14
- * 0: No button was pressed
15
- * 1: Primary button (left)
16
- * 2: Secondary button (right)
17
- */
18
- buttons?: number;
19
- /**
20
- * The display device where the mouse event occurred.
21
- * Omitting or using the value 0 indicates the main display.
22
- */
23
- display?: number;
24
- }
25
- export interface MouseEventOutput {
26
- x: number;
27
- y: number;
28
- buttons: number;
29
- display: number;
30
- }