@aiot-toolkit/emulator 2.0.6-beta.3 → 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.
@@ -33,6 +33,7 @@ export declare const EmulatorEnvVersion: {
33
33
  skins: string;
34
34
  "system-images": string;
35
35
  modem_simulator: string;
36
+ tools: string;
36
37
  };
37
38
  /** 获取镜像下载地址 */
38
39
  export declare function getImageDownloadUrl(): Record<VelaImageType, string>;
@@ -93,9 +93,10 @@ const EmulatorEnvVersion = exports.EmulatorEnvVersion = {
93
93
  name: '模拟器资源版本管理',
94
94
  [_Vvd.SDKParts.EMULATOR]: '0.1.0',
95
95
  [_Vvd.SDKParts.QA]: '0.0.1',
96
- [_Vvd.SDKParts.SKINS]: '0.0.10',
96
+ [_Vvd.SDKParts.SKINS]: '0.0.12',
97
97
  [_Vvd.SDKParts.SYSTEM_IMAGES]: VelaImageVersionList[0].time,
98
- [_Vvd.SDKParts.MODEM_SIMULATOR]: '0.0.3'
98
+ [_Vvd.SDKParts.MODEM_SIMULATOR]: '0.0.3',
99
+ [_Vvd.SDKParts.TOOLS]: '0.0.3'
99
100
  };
100
101
 
101
102
  /** 获取镜像下载地址 */
@@ -123,6 +124,7 @@ function getSDKPartDownloadUrl(type) {
123
124
  case _Vvd.SDKParts.QA:
124
125
  case _Vvd.SDKParts.MODEM_SIMULATOR:
125
126
  case _Vvd.SDKParts.SKINS:
127
+ case _Vvd.SDKParts.TOOLS:
126
128
  return `${baseUrl}/${type}/v${EmulatorEnvVersion[type]}/${type}.zip`;
127
129
  }
128
130
  }
@@ -54,7 +54,7 @@ function resolveLinuxPath() {
54
54
  for (const pattern of linuxPatterns) {
55
55
  if (!pattern) continue;
56
56
  const dir = resolvePath(pattern);
57
- if (dir && _fs.default.existsSync(dir) && _fs.default.lstatSync(dir).isDirectory()) {
57
+ if (dir && _fs.default.existsSync(dir) && _fs.default.statSync(dir).isDirectory()) {
58
58
  return dir;
59
59
  }
60
60
  }
@@ -4,24 +4,31 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.MiniSound5 = void 0;
7
- var _adb = require("@miwt/adb");
7
+ var _adb = _interopRequireWildcard(require("@miwt/adb"));
8
+ var adbMiwt = _adb;
8
9
  var _Vvd = require("../typing/Vvd");
9
10
  var _miwear = require("./miwear5");
11
+ var _util = require("util");
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
14
  class MiniSound5 extends _miwear.VelaMiwear5 {
11
15
  imageType = (() => _Vvd.VelaImageType.VELA_MIWEAR_MINISOUND_5)();
12
16
  appDir = '/data/app';
13
- static emulatorStartedFlag = /\[launchQuickApp.*\] Start main loop/;
17
+ static emulatorStartedFlag = /Boot completed/;
14
18
  static appStartedFlag = /Start main loop/;
15
19
 
16
20
  /**
17
21
  * 使用 pm 安装快应用
18
22
  * @param targeRpk 快应用的rpk文件路径
19
23
  */
20
- install(targeRpk) {
24
+ async install(targeRpk) {
21
25
  const installCmd = `adb -s ${this.sn} shell pm install ${targeRpk}`;
22
26
  this.logger(`Excuting: ${installCmd}`);
23
- const res = (0, _adb.execAdbCmdSync)(installCmd);
24
- this.logger(`Install Res: ${res}`);
27
+ const res = await adbMiwt.execAdbCmdAsync(installCmd);
28
+ await (0, _util.promisify)(process.nextTick)();
29
+ this.logger(`Install result: ${res}`);
30
+ // vela 5 安装成功的日志为:
31
+ // onInstallResult: com.application.watch.demo(success 0)
25
32
  if (res.includes('(success 0)')) {
26
33
  return Promise.resolve();
27
34
  } else {
@@ -64,7 +64,7 @@ class MiwearInstance extends _common.default {
64
64
  function getTimeout(size) {
65
65
  if (!size) return 10 * 1000;
66
66
  const mu = size / 1024 / 1024;
67
- return mu < 1 ? 10 * 1000 : mu < 4 ? 60 * 1000 : 2 * 60 * 1000;
67
+ return mu < 1 ? 20 * 1000 : mu < 4 ? 60 * 1000 : 2 * 60 * 1000;
68
68
  }
69
69
  const timeout = getTimeout(options?.size);
70
70
  let timer = setTimeout(() => {
@@ -12,7 +12,7 @@
12
12
  "hw.camera.back": "None",
13
13
  "hw.camera.front": "None",
14
14
  "hw.cpu.arch": "arm",
15
- "hw.cpu.ncore": 4,
15
+ "hw.cpu.ncore": 2,
16
16
  "hw.dPad": "no",
17
17
  "hw.gps": "yes",
18
18
  "hw.gpu.enabled": "no",
@@ -100,7 +100,8 @@ export declare enum SDKParts {
100
100
  QA = "qa",
101
101
  SKINS = "skins",
102
102
  SYSTEM_IMAGES = "system-images",
103
- MODEM_SIMULATOR = "modem_simulator"
103
+ MODEM_SIMULATOR = "modem_simulator",
104
+ TOOLS = "tools"
104
105
  }
105
106
  export declare enum VELAHOME {
106
107
  SDK = ".vela/sdk",
package/lib/typing/Vvd.js CHANGED
@@ -23,6 +23,7 @@ let SDKParts = exports.SDKParts = /*#__PURE__*/function (SDKParts) {
23
23
  SDKParts["SKINS"] = "skins";
24
24
  SDKParts["SYSTEM_IMAGES"] = "system-images";
25
25
  SDKParts["MODEM_SIMULATOR"] = "modem_simulator";
26
+ SDKParts["TOOLS"] = "tools";
26
27
  return SDKParts;
27
28
  }({});
28
29
  let VELAHOME = exports.VELAHOME = /*#__PURE__*/function (VELAHOME) {
@@ -14,7 +14,6 @@ export declare class GrpcEmulator {
14
14
  connected: boolean;
15
15
  token: string;
16
16
  authMate: Metadata;
17
- deadline: Date;
18
17
  controller: any;
19
18
  screenshotStream?: Readable;
20
19
  logcatStream?: Readable;
@@ -27,8 +27,6 @@ class GrpcEmulator {
27
27
  defaults: true,
28
28
  oneofs: true
29
29
  });
30
- this.deadline = new Date();
31
- this.deadline.setMinutes(this.deadline.getMinutes() + 2);
32
30
  this.controller = (0, _grpcJs.loadPackageDefinition)(packageDefinition).android.emulation.control;
33
31
  const mateInfo = new _grpcJs.Metadata();
34
32
  mateInfo.set(AuthorizationKey, `Bearer ${this.token}`);
@@ -53,8 +51,11 @@ class GrpcEmulator {
53
51
  if (this.connected) {
54
52
  return Promise.resolve(true);
55
53
  }
54
+ const deadline = new Date();
55
+ deadline.setMinutes(deadline.getMinutes() + 2); // 2 minutes timeout
56
+
56
57
  return new Promise((resolve, reject) => {
57
- this.client.waitForReady(this.deadline, err => {
58
+ this.client.waitForReady(deadline, err => {
58
59
  if (err) {
59
60
  this.connected = false;
60
61
  console.error(err);
package/lib/vvd/index.js CHANGED
@@ -368,13 +368,17 @@ class VvdManager {
368
368
  let needUpdate = false;
369
369
 
370
370
  // 检查 ramsize 调整为 1024
371
- if (config['hw.ramSize'] < 1024) {
371
+ if (config['hw.ramSize'] && typeof config['hw.ramSize'] === 'number' && config['hw.ramSize'] < 1024) {
372
372
  needUpdate = true;
373
373
  config['hw.ramSize'] = 1024;
374
374
  }
375
+ // 统一路径分隔符为 /
376
+ const normalizePath = p => p.replace(/\\/g, '/');
377
+
375
378
  // 检查皮肤路径
376
- if (config['skin.path']?.includes('.export_dev/skins')) {
377
- 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')) {
378
382
  // 自定义的皮肤,将自定义皮肤迁移到新的 sdk 目录中
379
383
  const oldUserSkinDir = _path.default.join(_os.default.homedir(), '.export_dev/skins/user');
380
384
  const newUserSkinDir = _path.default.join(this.sdkHome, 'skins', 'user');
@@ -394,13 +398,26 @@ class VvdManager {
394
398
  }
395
399
  }
396
400
  needUpdate = true;
397
- 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;
398
415
  }
399
416
 
400
417
  // 检查镜像路径
401
- 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')) {
402
419
  needUpdate = true;
403
- 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');
404
421
  }
405
422
  if (needUpdate) {
406
423
  await _promises.default.writeFile(configIni, (0, _ini.stringify)(config));
@@ -436,7 +453,7 @@ class VvdManager {
436
453
  // -fsdev local,security_model=none,id=fsdev0,path=${HOST_9PFS_DIR} \
437
454
  // -device virtio-9p-device,id=fs0,fsdev=fsdev0,mount_tag=host `
438
455
 
439
- 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`;
440
457
 
441
458
  // qt windows 配置
442
459
  // 在 docker,wls,等无界面平台上用 -no-window ,否则用 -qt-hide-window
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiot-toolkit/emulator",
3
- "version": "2.0.6-beta.3",
3
+ "version": "2.0.6-beta.4",
4
4
  "description": "vela emulator tool.",
5
5
  "homepage": "",
6
6
  "license": "ISC",
@@ -32,7 +32,7 @@
32
32
  "emulator"
33
33
  ],
34
34
  "dependencies": {
35
- "@aiot-toolkit/shared-utils": "2.0.6-beta.3",
35
+ "@aiot-toolkit/shared-utils": "2.0.6-beta.4",
36
36
  "@grpc/grpc-js": "^1.13.3",
37
37
  "@grpc/proto-loader": "^0.7.13",
38
38
  "@miwt/adb": "0.10.5",
@@ -49,5 +49,5 @@
49
49
  "@types/adm-zip": "^0.5.5",
50
50
  "@types/ini": "^4.1.1"
51
51
  },
52
- "gitHead": "2e2ba4b1d293218736343237d963fe93c5fb27a8"
52
+ "gitHead": "1acc8279ba3c5995aebe3a97a6b33154086f09d6"
53
53
  }