@aiot-toolkit/emulator 2.0.6-beta.2 → 2.0.6-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.
Files changed (39) hide show
  1. package/lib/emulatorutil/constants.d.ts +12 -6
  2. package/lib/emulatorutil/constants.js +50 -19
  3. package/lib/emulatorutil/running.js +1 -1
  4. package/lib/index.d.ts +4 -1
  5. package/lib/index.js +47 -7
  6. package/lib/instance/common.d.ts +4 -2
  7. package/lib/instance/common.js +17 -3
  8. package/lib/instance/index.d.ts +2 -1
  9. package/lib/instance/index.js +4 -2
  10. package/lib/instance/minisound.d.ts +1 -1
  11. package/lib/instance/minisound.js +15 -7
  12. package/lib/instance/miwear.d.ts +1 -1
  13. package/lib/instance/miwear.js +12 -4
  14. package/lib/instance/openSmartspeaker5.d.ts +19 -0
  15. package/lib/instance/openSmartspeaker5.js +70 -0
  16. package/lib/instance/pre.d.ts +1 -1
  17. package/lib/instance/pre.js +3 -1
  18. package/lib/instance/vela5.d.ts +1 -1
  19. package/lib/instance/vela5.js +12 -10
  20. package/lib/static/avdConfigIni.json +1 -1
  21. package/lib/static/proto/emulator_controller.proto +181 -26
  22. package/lib/static/proto/ui_controller_service.proto +147 -0
  23. package/lib/typing/Vvd.d.ts +7 -3
  24. package/lib/typing/Vvd.js +3 -0
  25. package/lib/vvd/grpc/index.d.ts +17 -8
  26. package/lib/vvd/grpc/index.js +126 -29
  27. package/lib/vvd/grpc/types/GrpcClient.d.ts +43 -2
  28. package/lib/vvd/grpc/types/UiControllerClient.d.ts +23 -0
  29. package/lib/vvd/grpc/types/index.d.ts +3 -0
  30. package/lib/vvd/grpc/types/index.js +38 -0
  31. package/lib/vvd/grpc/types/proto-types.d.ts +178 -0
  32. package/lib/vvd/grpc/types/proto-types.js +50 -0
  33. package/lib/vvd/index.d.ts +15 -8
  34. package/lib/vvd/index.js +183 -91
  35. package/package.json +5 -8
  36. package/lib/vvd/grpc/types/KeyEvent.d.ts +0 -19
  37. package/lib/vvd/grpc/types/KeyEvent.js +0 -20
  38. package/lib/vvd/grpc/types/MouseEvent.d.ts +0 -30
  39. /package/lib/vvd/grpc/types/{MouseEvent.js → UiControllerClient.js} +0 -0
@@ -9,10 +9,15 @@ export declare const defaultToolsHome: string;
9
9
  export declare const defaultVncPort = 5900;
10
10
  export declare const defaultAdbPort = 5555;
11
11
  export declare const defaultDebugPort = 10055;
12
- export declare const baseUrl = "https://vela-ide.cnbj3-fusion.mi-fds.com/vela-ide";
13
- export declare const versionUrl = "https://vela-ide.cnbj3-fusion.mi-fds.com/vela-ide/versions.json";
14
- export declare const emulatorBaseUrl = "https://vela-ide.cnbj3-fusion.mi-fds.com/vela-ide/emulator";
15
- export declare const systemImageBaseUrl = "https://vela-ide.cnbj3-fusion.mi-fds.com/vela-ide/system-images";
12
+ /**
13
+ * 获取 Vela Emulator SDK 相关下载地址
14
+ */
15
+ export declare function getSdkUrl(): Promise<{
16
+ baseUrl: string;
17
+ versionUrl: string;
18
+ emulatorBaseUrl: string;
19
+ systemImageBaseUrl: string;
20
+ }>;
16
21
  /**
17
22
  * vela-release-4.0 : vela 4.0 带 miwear
18
23
  * vela-pre-4.0 : vela 4.0 不带 miwear
@@ -33,13 +38,14 @@ export declare const EmulatorEnvVersion: {
33
38
  skins: string;
34
39
  "system-images": string;
35
40
  modem_simulator: string;
41
+ tools: string;
36
42
  };
37
43
  /** 获取镜像下载地址 */
38
- export declare function getImageDownloadUrl(): Record<VelaImageType, string>;
44
+ export declare function getImageDownloadUrl(): Promise<Record<VelaImageType, string>>;
39
45
  /**
40
46
  * 获取各种 SKD 最新版本的下载地址;
41
47
  * 镜像地址默认返回 REL 版本的地址,如果需要获取其他版本,请使用
42
48
  * {@link getImageDownloadUrl}
43
49
  */
44
- export declare function getSDKPartDownloadUrl(type: SDKParts): string;
50
+ export declare function getSDKPartDownloadUrl(type: SDKParts): Promise<string>;
45
51
  export { isVelaImageType, isMiwearImageType, getDefaultImage } from '../shared';
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.emulatorBaseUrl = exports.defaultVvdHome = exports.defaultVncPort = exports.defaultToolsHome = exports.defaultSkinHome = exports.defaultSDKHome = exports.defaultQuickappHome = exports.defaultImageHome = exports.defaultEmulatorHome = exports.defaultDebugPort = exports.defaultAdbPort = exports.baseUrl = exports.VelaImageVersionList = exports.EmulatorEnvVersion = void 0;
6
+ exports.defaultVvdHome = exports.defaultVncPort = exports.defaultToolsHome = exports.defaultSkinHome = exports.defaultSDKHome = exports.defaultQuickappHome = exports.defaultImageHome = exports.defaultEmulatorHome = exports.defaultDebugPort = exports.defaultAdbPort = exports.VelaImageVersionList = exports.EmulatorEnvVersion = void 0;
7
7
  Object.defineProperty(exports, "getDefaultImage", {
8
8
  enumerable: true,
9
9
  get: function () {
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "getDefaultImage", {
12
12
  });
13
13
  exports.getImageDownloadUrl = getImageDownloadUrl;
14
14
  exports.getSDKPartDownloadUrl = getSDKPartDownloadUrl;
15
+ exports.getSdkUrl = getSdkUrl;
15
16
  Object.defineProperty(exports, "isMiwearImageType", {
16
17
  enumerable: true,
17
18
  get: function () {
@@ -24,7 +25,6 @@ Object.defineProperty(exports, "isVelaImageType", {
24
25
  return _shared.isVelaImageType;
25
26
  }
26
27
  });
27
- exports.versionUrl = exports.systemImageBaseUrl = void 0;
28
28
  var _os = _interopRequireDefault(require("os"));
29
29
  var _path = _interopRequireDefault(require("path"));
30
30
  var _Vvd = require("../typing/Vvd");
@@ -41,10 +41,25 @@ const defaultToolsHome = exports.defaultToolsHome = _path.default.resolve(defaul
41
41
  const defaultVncPort = exports.defaultVncPort = 5900;
42
42
  const defaultAdbPort = exports.defaultAdbPort = 5555;
43
43
  const defaultDebugPort = exports.defaultDebugPort = 10055;
44
- const baseUrl = exports.baseUrl = 'https://vela-ide.cnbj3-fusion.mi-fds.com/vela-ide';
45
- const versionUrl = exports.versionUrl = 'https://vela-ide.cnbj3-fusion.mi-fds.com/vela-ide/versions.json';
46
- const emulatorBaseUrl = exports.emulatorBaseUrl = 'https://vela-ide.cnbj3-fusion.mi-fds.com/vela-ide/emulator';
47
- const systemImageBaseUrl = exports.systemImageBaseUrl = 'https://vela-ide.cnbj3-fusion.mi-fds.com/vela-ide/system-images';
44
+
45
+ /**
46
+ * 获取 Vela Emulator SDK 相关下载地址
47
+ */
48
+ async function getSdkUrl() {
49
+ const externalBaseUrl = 'https://vela-ide.cnbj3-fusion.mi-fds.com/vela-ide';
50
+ const internalBaseUrl = 'https://cnbj3-fusion-fds.api.xiaomi.net/vela-ide';
51
+ // 优先使用内网域名,因为云上工程没有外网环境
52
+ let base = internalBaseUrl;
53
+ await fetch(`${base}/versions.json`).catch(() => {
54
+ base = externalBaseUrl;
55
+ });
56
+ return {
57
+ baseUrl: base,
58
+ versionUrl: `${base}/versions.json`,
59
+ emulatorBaseUrl: `${base}/emulator`,
60
+ systemImageBaseUrl: `${base}/system-images`
61
+ };
62
+ }
48
63
 
49
64
  // 不确定vela镜像的发布策略,暂时需要手动更新此列表
50
65
  // 0.0.2和0.0.3版本比较特殊,线上是一个nuttx文件。其他版本都是一个zip包,包含nuttx data.img和vela_source.img
@@ -54,52 +69,63 @@ const systemImageBaseUrl = exports.systemImageBaseUrl = 'https://vela-ide.cnbj3-
54
69
  * vela-dev-0.0.4 : vela 4.0 dev 分支
55
70
  */
56
71
  const VelaImageVersionList = exports.VelaImageVersionList = [{
57
- label: 'vela-miwear-watch-5.0',
72
+ label: 'vela-miwear-watch-5',
58
73
  description: '适用于手表/手环的,带表盘的 vela 5.0 镜像,不可自定义模拟器尺寸',
59
74
  value: _Vvd.VelaImageType.VELA_MIWEAR_WATCH_5,
60
- time: '20250716',
75
+ time: '20260130',
61
76
  hide: false,
62
77
  icon: ''
63
78
  }, {
64
- label: 'vela-watch-5.0',
79
+ label: 'vela-watch-5',
65
80
  description: '适用于手表/手环的,不带表盘的 vela 5.0 镜像,可自定义模拟器尺寸',
66
81
  value: _Vvd.VelaImageType.VELA_WATCH_5,
67
- time: '20250716',
82
+ time: '20260127',
68
83
  hide: false,
69
84
  icon: ''
70
85
  }, {
71
- label: 'vela-miwear-watch-4.0',
86
+ label: 'vela-miwear-watch-4',
72
87
  description: '原 vela-release-4.0 版本,适用于手表/手环的,带表盘的 vela 4.0 镜像,不可自定义模拟器尺寸',
73
88
  value: _Vvd.VelaImageType.REL,
74
89
  time: '20250526',
75
90
  hide: false,
76
91
  icon: ''
77
92
  }, {
78
- label: 'vela-watch-4.0',
93
+ label: 'vela-watch-4',
79
94
  description: '原 vela-pre-4.0 版本,适用于手表/手环的,不带表盘的 vela 4.0 镜像,可自定义模拟器尺寸',
80
95
  value: _Vvd.VelaImageType.PRE,
81
96
  time: '20250225',
82
97
  hide: false,
83
98
  icon: ''
84
99
  }, {
85
- label: 'vela-miwear-minisound-5.0',
100
+ label: 'vela-miwear-minisound-5',
86
101
  description: '适用于音响的 vela-miwear 5.0 镜像,不可自定义模拟器尺寸',
87
102
  value: _Vvd.VelaImageType.VELA_MIWEAR_MINISOUND_5,
88
103
  time: '20250318',
89
104
  hide: true,
90
105
  icon: ''
106
+ }, {
107
+ label: 'openvela-smartspeaker-5',
108
+ description: '适用于音响的 vela-miwear 5.0 镜像,不可自定义模拟器尺寸',
109
+ value: _Vvd.VelaImageType.OPENVELA_SMARTSPEAKER_5,
110
+ time: '20260128',
111
+ hide: true,
112
+ icon: ''
91
113
  }];
92
114
  const EmulatorEnvVersion = exports.EmulatorEnvVersion = {
93
115
  name: '模拟器资源版本管理',
94
- [_Vvd.SDKParts.EMULATOR]: '0.1.0',
116
+ [_Vvd.SDKParts.EMULATOR]: '0.2.0',
95
117
  [_Vvd.SDKParts.QA]: '0.0.1',
96
- [_Vvd.SDKParts.SKINS]: '0.0.10',
118
+ [_Vvd.SDKParts.SKINS]: '0.0.12',
97
119
  [_Vvd.SDKParts.SYSTEM_IMAGES]: VelaImageVersionList[0].time,
98
- [_Vvd.SDKParts.MODEM_SIMULATOR]: '0.0.3'
120
+ [_Vvd.SDKParts.MODEM_SIMULATOR]: '0.0.3',
121
+ [_Vvd.SDKParts.TOOLS]: '0.0.3'
99
122
  };
100
123
 
101
124
  /** 获取镜像下载地址 */
102
- function getImageDownloadUrl() {
125
+ async function getImageDownloadUrl() {
126
+ const {
127
+ systemImageBaseUrl
128
+ } = await getSdkUrl();
103
129
  return VelaImageVersionList.reduce((res, t) => {
104
130
  res[t.value] = `${systemImageBaseUrl}/${t.value}/${t.time}/${t.value}.zip`;
105
131
  return res;
@@ -111,7 +137,11 @@ function getImageDownloadUrl() {
111
137
  * 镜像地址默认返回 REL 版本的地址,如果需要获取其他版本,请使用
112
138
  * {@link getImageDownloadUrl}
113
139
  */
114
- function getSDKPartDownloadUrl(type) {
140
+ async function getSDKPartDownloadUrl(type) {
141
+ const {
142
+ emulatorBaseUrl,
143
+ baseUrl
144
+ } = await getSdkUrl();
115
145
  switch (type) {
116
146
  case _Vvd.SDKParts.EMULATOR:
117
147
  const systemOs = _os.default.platform();
@@ -119,10 +149,11 @@ function getSDKPartDownloadUrl(type) {
119
149
  let hostOs = systemOs === 'win32' ? 'windows' : systemOs;
120
150
  return `${emulatorBaseUrl}/v${EmulatorEnvVersion.emulator}/${hostOs}-${hostArch}.zip`;
121
151
  case _Vvd.SDKParts.SYSTEM_IMAGES:
122
- return getImageDownloadUrl()[(0, _shared.getDefaultImage)()];
152
+ return (await getImageDownloadUrl())[(0, _shared.getDefaultImage)()];
123
153
  case _Vvd.SDKParts.QA:
124
154
  case _Vvd.SDKParts.MODEM_SIMULATOR:
125
155
  case _Vvd.SDKParts.SKINS:
156
+ case _Vvd.SDKParts.TOOLS:
126
157
  return `${baseUrl}/${type}/v${EmulatorEnvVersion[type]}/${type}.zip`;
127
158
  }
128
159
  }
@@ -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
  }
package/lib/index.d.ts CHANGED
@@ -1,7 +1,10 @@
1
- export { VvdManager } from './vvd';
1
+ export * from './vvd';
2
2
  export { getSystemArch, tryRun } from './utils';
3
3
  export * from './instance';
4
4
  export * from './typing/Vvd';
5
5
  export * from './typing/Instance';
6
6
  export * from './emulatorutil';
7
7
  export * from './shared';
8
+ export * from './vvd/grpc/index';
9
+ export * from './vvd/grpc/types';
10
+ export * from './vvd/logcat';
package/lib/index.js CHANGED
@@ -4,16 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  var _exportNames = {
7
- VvdManager: true,
8
7
  getSystemArch: true,
9
8
  tryRun: true
10
9
  };
11
- Object.defineProperty(exports, "VvdManager", {
12
- enumerable: true,
13
- get: function () {
14
- return _vvd.VvdManager;
15
- }
16
- });
17
10
  Object.defineProperty(exports, "getSystemArch", {
18
11
  enumerable: true,
19
12
  get: function () {
@@ -27,6 +20,17 @@ Object.defineProperty(exports, "tryRun", {
27
20
  }
28
21
  });
29
22
  var _vvd = require("./vvd");
23
+ Object.keys(_vvd).forEach(function (key) {
24
+ if (key === "default" || key === "__esModule") return;
25
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
26
+ if (key in exports && exports[key] === _vvd[key]) return;
27
+ Object.defineProperty(exports, key, {
28
+ enumerable: true,
29
+ get: function () {
30
+ return _vvd[key];
31
+ }
32
+ });
33
+ });
30
34
  var _utils = require("./utils");
31
35
  var _instance = require("./instance");
32
36
  Object.keys(_instance).forEach(function (key) {
@@ -87,4 +91,40 @@ Object.keys(_shared).forEach(function (key) {
87
91
  return _shared[key];
88
92
  }
89
93
  });
94
+ });
95
+ var _index = require("./vvd/grpc/index");
96
+ Object.keys(_index).forEach(function (key) {
97
+ if (key === "default" || key === "__esModule") return;
98
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
99
+ if (key in exports && exports[key] === _index[key]) return;
100
+ Object.defineProperty(exports, key, {
101
+ enumerable: true,
102
+ get: function () {
103
+ return _index[key];
104
+ }
105
+ });
106
+ });
107
+ var _types = require("./vvd/grpc/types");
108
+ Object.keys(_types).forEach(function (key) {
109
+ if (key === "default" || key === "__esModule") return;
110
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
111
+ if (key in exports && exports[key] === _types[key]) return;
112
+ Object.defineProperty(exports, key, {
113
+ enumerable: true,
114
+ get: function () {
115
+ return _types[key];
116
+ }
117
+ });
118
+ });
119
+ var _logcat = require("./vvd/logcat");
120
+ Object.keys(_logcat).forEach(function (key) {
121
+ if (key === "default" || key === "__esModule") return;
122
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
123
+ if (key in exports && exports[key] === _logcat[key]) return;
124
+ Object.defineProperty(exports, key, {
125
+ enumerable: true,
126
+ get: function () {
127
+ return _logcat[key];
128
+ }
129
+ });
90
130
  });
@@ -1,3 +1,4 @@
1
+ import 'core-js/actual/promise/with-resolvers';
1
2
  import readline from 'readline';
2
3
  import { IEmulatorInstanceParams } from '../typing/Instance';
3
4
  import { VelaImageType } from '../typing/Vvd';
@@ -5,7 +6,8 @@ import { ChildProcessWithoutNullStreams } from 'child_process';
5
6
  declare abstract class CommonEmulatorInstance {
6
7
  imageType: VelaImageType;
7
8
  appDir: string;
8
- static emulatorStartedFlag: RegExp;
9
+ xmsInitedFlag: RegExp;
10
+ xmsStatus: PromiseWithResolvers<void>;
9
11
  static appInstalledFlag: RegExp;
10
12
  static appInstallFailedFlag: RegExp;
11
13
  static appUninstalledFlag: RegExp;
@@ -13,7 +15,7 @@ declare abstract class CommonEmulatorInstance {
13
15
  static isAppInstalled(...args: any[]): boolean;
14
16
  static isAppInstallFailed(log: string): boolean;
15
17
  static isAppUninstalled(log: string, packageName: string): boolean;
16
- static isEmulatorStarted(log: string): boolean;
18
+ isXmsInited(log: string): boolean;
17
19
  sn: string;
18
20
  vvdName: string;
19
21
  debugPort?: number | string;
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ require("core-js/actual/promise/with-resolvers");
7
8
  var _ColorConsole = _interopRequireDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
8
9
  var _ILog = require("@aiot-toolkit/shared-utils/lib/interface/ILog");
9
10
  var _adb = _interopRequireWildcard(require("@miwt/adb"));
@@ -18,7 +19,9 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
18
19
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
20
  class CommonEmulatorInstance {
20
21
  appDir = '/data/quickapp/app';
21
- static emulatorStartedFlag = /quickapp_rpk_installer_init|rpk installer init done|booting completed|Boot completed/;
22
+
23
+ // 判断 xms 服务是否初始化完成的标志
24
+ xmsInitedFlag = /quickapp_rpk_installer_init|rpk installer init done/;
22
25
  static appInstalledFlag = /InstallState_Finished|install finished/;
23
26
  static appInstallFailedFlag = /uv_mq_read_cb: install prepare failed/;
24
27
  static appUninstalledFlag = /uninstalled app/;
@@ -33,8 +36,8 @@ class CommonEmulatorInstance {
33
36
  static isAppUninstalled(log, packageName) {
34
37
  return new RegExp(this.appUninstalledFlag.source + ':\\s+' + packageName).test(log);
35
38
  }
36
- static isEmulatorStarted(log) {
37
- return this.emulatorStartedFlag.test(log);
39
+ isXmsInited(log) {
40
+ return this.xmsInitedFlag.test(log);
38
41
  }
39
42
  constructor(params) {
40
43
  this.sn = `emulator-${params.serialPort}`;
@@ -71,6 +74,16 @@ class CommonEmulatorInstance {
71
74
  this.stderrReadline = r.stderrReadline;
72
75
  this.disposeReadlines = r.dispose;
73
76
  }
77
+ const {
78
+ resolve,
79
+ reject,
80
+ promise
81
+ } = Promise.withResolvers();
82
+ this.xmsStatus = {
83
+ promise,
84
+ resolve,
85
+ reject
86
+ };
74
87
  }
75
88
 
76
89
  /** 安装应用,留给子类实现 */
@@ -85,6 +98,7 @@ class CommonEmulatorInstance {
85
98
 
86
99
  /** 推送指定文件,返回推送结果 */
87
100
  async push(sourcePath, targetPath) {
101
+ await this.xmsStatus.promise;
88
102
  // 1. adb push应用的rpk
89
103
  const pushCmd = `adb -s ${this.sn} push "${sourcePath}" ${targetPath}`;
90
104
  this.logger(`Excuting: ${pushCmd}`);
@@ -7,7 +7,8 @@ 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
+ import { OpenSmartspeaker5 } from './openSmartspeaker5';
11
+ declare function getInstanceClass(imageType: VelaImageType): typeof GoldfishInstance | typeof MiwearInstance | typeof PreInstance | typeof Vela5Instance | typeof VelaMiwear5 | typeof MiniSound5 | typeof OpenSmartspeaker5;
11
12
  /**
12
13
  * 根据镜像决定使用哪个instance
13
14
  * Vela正式版(4.0) -> MiwearInstance
@@ -43,6 +43,7 @@ var _Vvd = require("../typing/Vvd");
43
43
  var _vela = require("./vela5");
44
44
  var _miwear2 = require("./miwear5");
45
45
  var _minisound = require("./minisound");
46
+ var _openSmartspeaker = require("./openSmartspeaker5");
46
47
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
47
48
  function getInstanceClass(imageType) {
48
49
  const map = {
@@ -51,9 +52,10 @@ function getInstanceClass(imageType) {
51
52
  [_Vvd.VelaImageType.DEV]: _dev.default,
52
53
  [_Vvd.VelaImageType.VELA_WATCH_5]: _vela.Vela5Instance,
53
54
  [_Vvd.VelaImageType.VELA_MIWEAR_WATCH_5]: _miwear2.VelaMiwear5,
54
- [_Vvd.VelaImageType.VELA_MIWEAR_MINISOUND_5]: _minisound.MiniSound5
55
+ [_Vvd.VelaImageType.VELA_MIWEAR_MINISOUND_5]: _minisound.MiniSound5,
56
+ [_Vvd.VelaImageType.OPENVELA_SMARTSPEAKER_5]: _openSmartspeaker.OpenSmartspeaker5
55
57
  };
56
- return map[imageType] || _dev.default;
58
+ return map[imageType] || _miwear2.VelaMiwear5;
57
59
  }
58
60
 
59
61
  /**
@@ -3,7 +3,7 @@ import { VelaMiwear5 } from './miwear5';
3
3
  export declare class MiniSound5 extends VelaMiwear5 {
4
4
  imageType: VelaImageType;
5
5
  appDir: string;
6
- static emulatorStartedFlag: RegExp;
6
+ xmsInitedFlag: RegExp;
7
7
  static appStartedFlag: RegExp;
8
8
  /**
9
9
  * 使用 pm 安装快应用
@@ -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");
8
7
  var _Vvd = require("../typing/Vvd");
9
8
  var _miwear = require("./miwear5");
9
+ var adbMiwt = _interopRequireWildcard(require("@miwt/adb"));
10
+ var _util = require("util");
11
+ 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); }
12
+ 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
13
  class MiniSound5 extends _miwear.VelaMiwear5 {
11
14
  imageType = (() => _Vvd.VelaImageType.VELA_MIWEAR_MINISOUND_5)();
12
15
  appDir = '/data/app';
13
- static emulatorStartedFlag = /\[launchQuickApp.*\] Start main loop/;
16
+ xmsInitedFlag = /AMS/;
14
17
  static appStartedFlag = /Start main loop/;
15
18
 
16
19
  /**
17
20
  * 使用 pm 安装快应用
18
21
  * @param targeRpk 快应用的rpk文件路径
19
22
  */
20
- install(targeRpk) {
23
+ async install(targeRpk) {
24
+ await this.xmsStatus.promise;
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 {
@@ -33,8 +40,9 @@ class MiniSound5 extends _miwear.VelaMiwear5 {
33
40
  * 使用 pm 卸载快应用
34
41
  * @param packageName 快应用的包名
35
42
  */
36
- uninstall(packageName) {
37
- const res = (0, _adb.execAdbCmdSync)(`adb -s ${this.sn} shell pm uninstall ${packageName}`);
43
+ async uninstall(packageName) {
44
+ await this.xmsStatus.promise;
45
+ const res = await adbMiwt.execAdbCmdAsync(`adb -s ${this.sn} shell pm uninstall ${packageName}`);
38
46
  if (res.includes('(success 0)')) {
39
47
  return Promise.resolve();
40
48
  } else {
@@ -5,7 +5,7 @@ import { VelaImageType } from '../typing/Vvd';
5
5
  * 针对 Vela正式版(4.0)的镜像
6
6
  */
7
7
  declare class MiwearInstance extends CommonEmulatorInstance {
8
- static emulatorStartedFlag: RegExp;
8
+ xmsInitedFlag: RegExp;
9
9
  static appInstalledFlag: RegExp;
10
10
  imageType: VelaImageType;
11
11
  appDir: string;
@@ -18,7 +18,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
18
18
  * 针对 Vela正式版(4.0)的镜像
19
19
  */
20
20
  class MiwearInstance extends _common.default {
21
- static emulatorStartedFlag = /quickapp_rpk_installer_init|rpk installer init done/;
21
+ xmsInitedFlag = /quickapp_rpk_installer_init|rpk installer init done/;
22
22
  static appInstalledFlag = /InstallState_Finished|install finished/;
23
23
  imageType = (() => _Vvd.VelaImageType.REL)();
24
24
  appDir = '/data/quickapp/app';
@@ -33,6 +33,8 @@ class MiwearInstance extends _common.default {
33
33
  * @param targeRpk 快应用的rpk文件路径
34
34
  */
35
35
  async install(targeRpk, options) {
36
+ // 等待 xms 服务初始化完成之后才能进行安装
37
+ await this.xmsStatus.promise;
36
38
  const installCmd = `adb -s ${this.sn} shell pm install ${targeRpk}`;
37
39
  this.logger(`Excuting: ${installCmd}`);
38
40
  adbMiwt.execAdbCmd(installCmd);
@@ -64,7 +66,7 @@ class MiwearInstance extends _common.default {
64
66
  function getTimeout(size) {
65
67
  if (!size) return 10 * 1000;
66
68
  const mu = size / 1024 / 1024;
67
- return mu < 1 ? 10 * 1000 : mu < 4 ? 60 * 1000 : 2 * 60 * 1000;
69
+ return mu < 1 ? 20 * 1000 : mu < 4 ? 60 * 1000 : 2 * 60 * 1000;
68
70
  }
69
71
  const timeout = getTimeout(options?.size);
70
72
  let timer = setTimeout(() => {
@@ -85,7 +87,9 @@ class MiwearInstance extends _common.default {
85
87
  * 使用 pm 卸载快应用
86
88
  * @param packageName 快应用的包名
87
89
  */
88
- uninstall(packageName) {
90
+ async uninstall(packageName) {
91
+ // 等待 xms 服务初始化完成之后才能进行安装
92
+ await this.xmsStatus.promise;
89
93
  adbMiwt.execAdbCmd(`adb -s ${this.sn} shell pm uninstall ${packageName}`);
90
94
  return new Promise((resolve, reject) => {
91
95
  const func = msg => {
@@ -107,6 +111,8 @@ class MiwearInstance extends _common.default {
107
111
  /** 使用 am start 启动快应用 */
108
112
  async startApp(packageName) {
109
113
  let debug = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
114
+ // 等待 xms 服务初始化完成之后才能进行安装
115
+ await this.xmsStatus.promise;
110
116
  // 调试模式需要push一个文件至miwear中
111
117
  if (debug) {
112
118
  const debuggerCfgFile = _path.default.join(__dirname, '../static/debugger_ip.cfg');
@@ -119,6 +125,7 @@ class MiwearInstance extends _common.default {
119
125
  await adbMiwt.execAdbCmdAsync(startCmd);
120
126
  }
121
127
  async closeApp(appName) {
128
+ await this.xmsStatus.promise;
122
129
  const stopCmd = `adb -s ${this.sn} shell am stop ${appName}`;
123
130
  this.logger(`Excuting: ${stopCmd}`);
124
131
  await adbMiwt.execAdbCmdAsync(stopCmd);
@@ -128,7 +135,7 @@ class MiwearInstance extends _common.default {
128
135
  await super.reboot();
129
136
  return new Promise((resolve, reject) => {
130
137
  const func = msg => {
131
- if (MiwearInstance.isEmulatorStarted(msg)) {
138
+ if (this.isXmsInited(msg)) {
132
139
  clearTimeout(timer);
133
140
  resolve();
134
141
  }
@@ -142,6 +149,7 @@ class MiwearInstance extends _common.default {
142
149
  });
143
150
  }
144
151
  async reloadApp(appPackageName) {
152
+ await this.xmsStatus.promise;
145
153
  try {
146
154
  // 2. 执行am stop和am start命令
147
155
  const stopCmd = `adb -s ${this.sn} shell am stop ${appPackageName}`;
@@ -0,0 +1,19 @@
1
+ import { VelaImageType } from '../typing/Vvd';
2
+ import { VelaMiwear5 } from './miwear5';
3
+ export declare class OpenSmartspeaker5 extends VelaMiwear5 {
4
+ imageType: VelaImageType;
5
+ appDir: string;
6
+ xmsInitedFlag: 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
+ reloadApp(appPackageName: string): Promise<void>;
19
+ }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.OpenSmartspeaker5 = void 0;
7
+ var _Vvd = require("../typing/Vvd");
8
+ var _utils = require("../utils");
9
+ var _miwear = require("./miwear5");
10
+ var adbMiwt = _interopRequireWildcard(require("@miwt/adb"));
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; }
14
+ class OpenSmartspeaker5 extends _miwear.VelaMiwear5 {
15
+ imageType = (() => _Vvd.VelaImageType.OPENVELA_SMARTSPEAKER_5)();
16
+ appDir = '/data/app';
17
+ xmsInitedFlag = /AMS/;
18
+ static appStartedFlag = /Start main loop/;
19
+
20
+ /**
21
+ * 使用 pm 安装快应用
22
+ * @param targeRpk 快应用的rpk文件路径
23
+ */
24
+ async install(targeRpk) {
25
+ await this.xmsStatus.promise;
26
+ const installCmd = `adb -s ${this.sn} shell pm install ${targeRpk}`;
27
+ this.logger(`Excuting: ${installCmd}`);
28
+ const res = await adbMiwt.execAdbCmdAsync(installCmd);
29
+ await (0, _util.promisify)(process.nextTick)();
30
+ this.logger(`Install result: ${res}`);
31
+ // vela 5 安装成功的日志为:
32
+ // onInstallResult: com.application.watch.demo(success 0)
33
+ if (res.includes('(success 0)')) {
34
+ return Promise.resolve();
35
+ } else {
36
+ return Promise.reject(res);
37
+ }
38
+ }
39
+
40
+ /**
41
+ * 使用 pm 卸载快应用
42
+ * @param packageName 快应用的包名
43
+ */
44
+ async uninstall(packageName) {
45
+ await this.xmsStatus.promise;
46
+ const res = await adbMiwt.execAdbCmdAsync(`adb -s ${this.sn} shell pm uninstall ${packageName}`);
47
+ if (res.includes('(success 0)')) {
48
+ return Promise.resolve();
49
+ } else {
50
+ return Promise.reject(res);
51
+ }
52
+ }
53
+ async reloadApp(appPackageName) {
54
+ await this.xmsStatus.promise;
55
+ try {
56
+ // 2. 执行am stop和am start命令
57
+ const stopCmd = `adb -s ${this.sn} shell am stop ${appPackageName}`;
58
+ await adbMiwt.execAdbCmdAsync(stopCmd);
59
+ this.logger(`Stop ${this.vvdName} ${appPackageName} successfully`);
60
+ // 这里是为了等am stop命令清除资源等
61
+ await (0, _utils.sleep)(1500);
62
+ const startCmd = `adb -s ${this.sn} shell am start ${appPackageName}`;
63
+ await adbMiwt.execAdbCmdAsync(startCmd);
64
+ this.logger(`Start ${this.vvdName} ${appPackageName} successfully`);
65
+ } catch (e) {
66
+ this.logger(`${e}`);
67
+ }
68
+ }
69
+ }
70
+ exports.OpenSmartspeaker5 = OpenSmartspeaker5;
@@ -6,7 +6,7 @@ import CommonEmulatorInstance from './common';
6
6
  declare class PreInstance extends CommonEmulatorInstance {
7
7
  imageType: VelaImageType;
8
8
  appDir: string;
9
- static emulatorStartedFlag: RegExp;
9
+ xmsInitedFlag: RegExp;
10
10
  install(rpkPath: string, opt: {
11
11
  packageName: string;
12
12
  size?: number;
@@ -16,8 +16,10 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
16
16
  class PreInstance extends _common.default {
17
17
  imageType = (() => _Vvd.VelaImageType.PRE)();
18
18
  appDir = '/data/quickapp/app';
19
- static emulatorStartedFlag = /(NSH)/;
19
+ xmsInitedFlag = /(NSH)/;
20
20
  async install(rpkPath, opt) {
21
+ await this.xmsStatus.promise;
22
+
21
23
  // 基于 vapp 启动的应用只需要将 rpk 解压到指定的目录下
22
24
  rpkPath = rpkPath || `${this.appDir}/${opt.packageName}.rpk`;
23
25
  const targetPath = `${this.appDir}/${opt.packageName}`;