@aiot-toolkit/emulator 2.0.6-beta.1 → 2.0.6-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/lib/emulatorutil/constants.d.ts +12 -6
- package/lib/emulatorutil/constants.js +44 -12
- package/lib/emulatorutil/running.js +1 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.js +47 -7
- package/lib/instance/common.d.ts +3 -2
- package/lib/instance/common.js +16 -3
- package/lib/instance/index.js +1 -1
- package/lib/instance/minisound.d.ts +1 -1
- package/lib/instance/minisound.js +15 -7
- package/lib/instance/miwear.d.ts +1 -1
- package/lib/instance/miwear.js +12 -4
- package/lib/instance/pre.d.ts +1 -1
- package/lib/instance/pre.js +3 -1
- package/lib/instance/vela5.d.ts +1 -1
- package/lib/instance/vela5.js +12 -10
- package/lib/static/avdConfigIni.json +1 -1
- package/lib/static/proto/emulator_controller.proto +181 -26
- package/lib/static/proto/ui_controller_service.proto +147 -0
- package/lib/typing/Vvd.d.ts +4 -2
- package/lib/typing/Vvd.js +1 -0
- package/lib/vvd/grpc/index.d.ts +16 -8
- package/lib/vvd/grpc/index.js +125 -29
- package/lib/vvd/grpc/types/GrpcClient.d.ts +43 -2
- package/lib/vvd/grpc/types/UiControllerClient.d.ts +23 -0
- package/lib/vvd/grpc/types/index.d.ts +3 -0
- package/lib/vvd/grpc/types/index.js +38 -0
- package/lib/vvd/grpc/types/proto-types.d.ts +178 -0
- package/lib/vvd/grpc/types/proto-types.js +50 -0
- package/lib/vvd/index.d.ts +14 -8
- package/lib/vvd/index.js +157 -83
- package/package.json +4 -8
- package/lib/vvd/grpc/types/KeyEvent.d.ts +0 -19
- package/lib/vvd/grpc/types/KeyEvent.js +0 -20
- package/lib/vvd/grpc/types/MouseEvent.d.ts +0 -30
- /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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export declare
|
|
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.
|
|
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,9 +25,9 @@ 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
|
+
var _https = _interopRequireDefault(require("https"));
|
|
30
31
|
var _Vvd = require("../typing/Vvd");
|
|
31
32
|
var _utils = require("../utils");
|
|
32
33
|
var _shared = require("../shared");
|
|
@@ -41,10 +42,32 @@ const defaultToolsHome = exports.defaultToolsHome = _path.default.resolve(defaul
|
|
|
41
42
|
const defaultVncPort = exports.defaultVncPort = 5900;
|
|
42
43
|
const defaultAdbPort = exports.defaultAdbPort = 5555;
|
|
43
44
|
const defaultDebugPort = exports.defaultDebugPort = 10055;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 获取 Vela Emulator SDK 相关下载地址
|
|
48
|
+
*/
|
|
49
|
+
async function getSdkUrl() {
|
|
50
|
+
const externalBaseUrl = 'https://vela-ide.cnbj3-fusion.mi-fds.com/vela-ide';
|
|
51
|
+
const internalBaseUrl = 'https://cnbj3-fusion-fds.api.xiaomi.net/vela-ide';
|
|
52
|
+
// 优先使用内网域名,因为云上工程没有外网环境
|
|
53
|
+
let base = internalBaseUrl;
|
|
54
|
+
await new Promise(resolve => {
|
|
55
|
+
_https.default.get(`${base}/versions.json`, {
|
|
56
|
+
timeout: 2000
|
|
57
|
+
}, res => {
|
|
58
|
+
if (res.statusCode !== 200) {
|
|
59
|
+
base = externalBaseUrl;
|
|
60
|
+
}
|
|
61
|
+
resolve();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
baseUrl: base,
|
|
66
|
+
versionUrl: `${base}/versions.json`,
|
|
67
|
+
emulatorBaseUrl: `${base}/emulator`,
|
|
68
|
+
systemImageBaseUrl: `${base}/system-images`
|
|
69
|
+
};
|
|
70
|
+
}
|
|
48
71
|
|
|
49
72
|
// 不确定vela镜像的发布策略,暂时需要手动更新此列表
|
|
50
73
|
// 0.0.2和0.0.3版本比较特殊,线上是一个nuttx文件。其他版本都是一个zip包,包含nuttx data.img和vela_source.img
|
|
@@ -91,15 +114,19 @@ const VelaImageVersionList = exports.VelaImageVersionList = [{
|
|
|
91
114
|
}];
|
|
92
115
|
const EmulatorEnvVersion = exports.EmulatorEnvVersion = {
|
|
93
116
|
name: '模拟器资源版本管理',
|
|
94
|
-
[_Vvd.SDKParts.EMULATOR]: '0.
|
|
117
|
+
[_Vvd.SDKParts.EMULATOR]: '0.2.0',
|
|
95
118
|
[_Vvd.SDKParts.QA]: '0.0.1',
|
|
96
|
-
[_Vvd.SDKParts.SKINS]: '0.0.
|
|
119
|
+
[_Vvd.SDKParts.SKINS]: '0.0.12',
|
|
97
120
|
[_Vvd.SDKParts.SYSTEM_IMAGES]: VelaImageVersionList[0].time,
|
|
98
|
-
[_Vvd.SDKParts.MODEM_SIMULATOR]: '0.0.3'
|
|
121
|
+
[_Vvd.SDKParts.MODEM_SIMULATOR]: '0.0.3',
|
|
122
|
+
[_Vvd.SDKParts.TOOLS]: '0.0.3'
|
|
99
123
|
};
|
|
100
124
|
|
|
101
125
|
/** 获取镜像下载地址 */
|
|
102
|
-
function getImageDownloadUrl() {
|
|
126
|
+
async function getImageDownloadUrl() {
|
|
127
|
+
const {
|
|
128
|
+
systemImageBaseUrl
|
|
129
|
+
} = await getSdkUrl();
|
|
103
130
|
return VelaImageVersionList.reduce((res, t) => {
|
|
104
131
|
res[t.value] = `${systemImageBaseUrl}/${t.value}/${t.time}/${t.value}.zip`;
|
|
105
132
|
return res;
|
|
@@ -111,7 +138,11 @@ function getImageDownloadUrl() {
|
|
|
111
138
|
* 镜像地址默认返回 REL 版本的地址,如果需要获取其他版本,请使用
|
|
112
139
|
* {@link getImageDownloadUrl}
|
|
113
140
|
*/
|
|
114
|
-
function getSDKPartDownloadUrl(type) {
|
|
141
|
+
async function getSDKPartDownloadUrl(type) {
|
|
142
|
+
const {
|
|
143
|
+
emulatorBaseUrl,
|
|
144
|
+
baseUrl
|
|
145
|
+
} = await getSdkUrl();
|
|
115
146
|
switch (type) {
|
|
116
147
|
case _Vvd.SDKParts.EMULATOR:
|
|
117
148
|
const systemOs = _os.default.platform();
|
|
@@ -119,10 +150,11 @@ function getSDKPartDownloadUrl(type) {
|
|
|
119
150
|
let hostOs = systemOs === 'win32' ? 'windows' : systemOs;
|
|
120
151
|
return `${emulatorBaseUrl}/v${EmulatorEnvVersion.emulator}/${hostOs}-${hostArch}.zip`;
|
|
121
152
|
case _Vvd.SDKParts.SYSTEM_IMAGES:
|
|
122
|
-
return getImageDownloadUrl()[(0, _shared.getDefaultImage)()];
|
|
153
|
+
return (await getImageDownloadUrl())[(0, _shared.getDefaultImage)()];
|
|
123
154
|
case _Vvd.SDKParts.QA:
|
|
124
155
|
case _Vvd.SDKParts.MODEM_SIMULATOR:
|
|
125
156
|
case _Vvd.SDKParts.SKINS:
|
|
157
|
+
case _Vvd.SDKParts.TOOLS:
|
|
126
158
|
return `${baseUrl}/${type}/v${EmulatorEnvVersion[type]}/${type}.zip`;
|
|
127
159
|
}
|
|
128
160
|
}
|
|
@@ -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.
|
|
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
|
|
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
|
});
|
package/lib/instance/common.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ import { ChildProcessWithoutNullStreams } from 'child_process';
|
|
|
5
5
|
declare abstract class CommonEmulatorInstance {
|
|
6
6
|
imageType: VelaImageType;
|
|
7
7
|
appDir: string;
|
|
8
|
-
|
|
8
|
+
xmsInitedFlag: RegExp;
|
|
9
|
+
xmsStatus: PromiseWithResolvers<void>;
|
|
9
10
|
static appInstalledFlag: RegExp;
|
|
10
11
|
static appInstallFailedFlag: RegExp;
|
|
11
12
|
static appUninstalledFlag: RegExp;
|
|
@@ -13,7 +14,7 @@ declare abstract class CommonEmulatorInstance {
|
|
|
13
14
|
static isAppInstalled(...args: any[]): boolean;
|
|
14
15
|
static isAppInstallFailed(log: string): boolean;
|
|
15
16
|
static isAppUninstalled(log: string, packageName: string): boolean;
|
|
16
|
-
|
|
17
|
+
isXmsInited(log: string): boolean;
|
|
17
18
|
sn: string;
|
|
18
19
|
vvdName: string;
|
|
19
20
|
debugPort?: number | string;
|
package/lib/instance/common.js
CHANGED
|
@@ -18,7 +18,9 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
18
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
19
|
class CommonEmulatorInstance {
|
|
20
20
|
appDir = '/data/quickapp/app';
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
// 判断 xms 服务是否初始化完成的标志
|
|
23
|
+
xmsInitedFlag = /quickapp_rpk_installer_init|rpk installer init done/;
|
|
22
24
|
static appInstalledFlag = /InstallState_Finished|install finished/;
|
|
23
25
|
static appInstallFailedFlag = /uv_mq_read_cb: install prepare failed/;
|
|
24
26
|
static appUninstalledFlag = /uninstalled app/;
|
|
@@ -33,8 +35,8 @@ class CommonEmulatorInstance {
|
|
|
33
35
|
static isAppUninstalled(log, packageName) {
|
|
34
36
|
return new RegExp(this.appUninstalledFlag.source + ':\\s+' + packageName).test(log);
|
|
35
37
|
}
|
|
36
|
-
|
|
37
|
-
return this.
|
|
38
|
+
isXmsInited(log) {
|
|
39
|
+
return this.xmsInitedFlag.test(log);
|
|
38
40
|
}
|
|
39
41
|
constructor(params) {
|
|
40
42
|
this.sn = `emulator-${params.serialPort}`;
|
|
@@ -71,6 +73,16 @@ class CommonEmulatorInstance {
|
|
|
71
73
|
this.stderrReadline = r.stderrReadline;
|
|
72
74
|
this.disposeReadlines = r.dispose;
|
|
73
75
|
}
|
|
76
|
+
const {
|
|
77
|
+
resolve,
|
|
78
|
+
reject,
|
|
79
|
+
promise
|
|
80
|
+
} = Promise.withResolvers();
|
|
81
|
+
this.xmsStatus = {
|
|
82
|
+
promise,
|
|
83
|
+
resolve,
|
|
84
|
+
reject
|
|
85
|
+
};
|
|
74
86
|
}
|
|
75
87
|
|
|
76
88
|
/** 安装应用,留给子类实现 */
|
|
@@ -85,6 +97,7 @@ class CommonEmulatorInstance {
|
|
|
85
97
|
|
|
86
98
|
/** 推送指定文件,返回推送结果 */
|
|
87
99
|
async push(sourcePath, targetPath) {
|
|
100
|
+
await this.xmsStatus.promise;
|
|
88
101
|
// 1. adb push应用的rpk
|
|
89
102
|
const pushCmd = `adb -s ${this.sn} push "${sourcePath}" ${targetPath}`;
|
|
90
103
|
this.logger(`Excuting: ${pushCmd}`);
|
package/lib/instance/index.js
CHANGED
|
@@ -53,7 +53,7 @@ function getInstanceClass(imageType) {
|
|
|
53
53
|
[_Vvd.VelaImageType.VELA_MIWEAR_WATCH_5]: _miwear2.VelaMiwear5,
|
|
54
54
|
[_Vvd.VelaImageType.VELA_MIWEAR_MINISOUND_5]: _minisound.MiniSound5
|
|
55
55
|
};
|
|
56
|
-
return map[imageType] ||
|
|
56
|
+
return map[imageType] || _miwear2.VelaMiwear5;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
@@ -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
|
-
|
|
16
|
+
xmsInitedFlag = /Boot completed/;
|
|
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 =
|
|
24
|
-
|
|
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
|
-
|
|
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 {
|
package/lib/instance/miwear.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { VelaImageType } from '../typing/Vvd';
|
|
|
5
5
|
* 针对 Vela正式版(4.0)的镜像
|
|
6
6
|
*/
|
|
7
7
|
declare class MiwearInstance extends CommonEmulatorInstance {
|
|
8
|
-
|
|
8
|
+
xmsInitedFlag: RegExp;
|
|
9
9
|
static appInstalledFlag: RegExp;
|
|
10
10
|
imageType: VelaImageType;
|
|
11
11
|
appDir: string;
|
package/lib/instance/miwear.js
CHANGED
|
@@ -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
|
-
|
|
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 ?
|
|
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 (
|
|
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}`;
|
package/lib/instance/pre.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import CommonEmulatorInstance from './common';
|
|
|
6
6
|
declare class PreInstance extends CommonEmulatorInstance {
|
|
7
7
|
imageType: VelaImageType;
|
|
8
8
|
appDir: string;
|
|
9
|
-
|
|
9
|
+
xmsInitedFlag: RegExp;
|
|
10
10
|
install(rpkPath: string, opt: {
|
|
11
11
|
packageName: string;
|
|
12
12
|
size?: number;
|
package/lib/instance/pre.js
CHANGED
|
@@ -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
|
-
|
|
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}`;
|
package/lib/instance/vela5.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { VelaImageType } from '../typing/Vvd';
|
|
2
2
|
import MiwearInstance from './miwear';
|
|
3
3
|
export declare class Vela5Instance extends MiwearInstance {
|
|
4
|
-
|
|
4
|
+
xmsInitedFlag: RegExp;
|
|
5
5
|
static appStartedFlag: RegExp;
|
|
6
6
|
imageType: VelaImageType;
|
|
7
7
|
appDir: string;
|
package/lib/instance/vela5.js
CHANGED
|
@@ -14,7 +14,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
14
14
|
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; }
|
|
15
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
class Vela5Instance extends _miwear.default {
|
|
17
|
-
|
|
17
|
+
xmsInitedFlag = /booting completed|Boot completed/;
|
|
18
18
|
static appStartedFlag = /Start main loop/;
|
|
19
19
|
imageType = (() => _Vvd.VelaImageType.VELA_WATCH_5)();
|
|
20
20
|
appDir = '/data/app';
|
|
@@ -24,6 +24,7 @@ class Vela5Instance extends _miwear.default {
|
|
|
24
24
|
* @param targeRpk 快应用的rpk文件路径
|
|
25
25
|
*/
|
|
26
26
|
async install(targeRpk) {
|
|
27
|
+
await this.xmsStatus.promise;
|
|
27
28
|
const installCmd = `adb -s ${this.sn} shell pm install ${targeRpk}`;
|
|
28
29
|
this.logger(`Excuting: ${installCmd}`);
|
|
29
30
|
const res = await adbMiwt.execAdbCmdAsync(installCmd);
|
|
@@ -40,10 +41,16 @@ class Vela5Instance extends _miwear.default {
|
|
|
40
41
|
|
|
41
42
|
/** 使用 am start 启动快应用 */
|
|
42
43
|
async startApp(packageName) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
return new Promise(async (resolve, reject) => {
|
|
45
|
+
let timer = setTimeout(() => {
|
|
46
|
+
this.stdoutReadline.off('line', func);
|
|
47
|
+
this.logger(`Start ${packageName} for ${this.vvdName} timeout`);
|
|
48
|
+
reject('Timeout');
|
|
49
|
+
}, 15 * 1000);
|
|
50
|
+
await this.xmsStatus.promise;
|
|
51
|
+
const startCmd = `adb -s ${this.sn} shell am start ${packageName}`;
|
|
52
|
+
this.logger(`Excuting: ${startCmd}`);
|
|
53
|
+
await adbMiwt.execAdbCmdAsync(startCmd);
|
|
47
54
|
const clearFn = () => {
|
|
48
55
|
clearTimeout(timer);
|
|
49
56
|
this.stdoutReadline.off('line', func);
|
|
@@ -62,11 +69,6 @@ class Vela5Instance extends _miwear.default {
|
|
|
62
69
|
reject(_shared.RpkStartFailedReason.getManifestFailed);
|
|
63
70
|
}
|
|
64
71
|
};
|
|
65
|
-
let timer = setTimeout(() => {
|
|
66
|
-
this.stdoutReadline.off('line', func);
|
|
67
|
-
this.logger(`Start ${packageName} for ${this.vvdName} timeout`);
|
|
68
|
-
reject('Timeout');
|
|
69
|
-
}, 8 * 1000);
|
|
70
72
|
this.stdoutReadline.on('line', func);
|
|
71
73
|
});
|
|
72
74
|
}
|