@aiot-toolkit/emulator 2.0.6-beta.1 → 2.0.6-beta.11

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 (36) hide show
  1. package/lib/emulatorutil/constants.d.ts +12 -6
  2. package/lib/emulatorutil/constants.js +44 -12
  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 +3 -2
  7. package/lib/instance/common.js +16 -3
  8. package/lib/instance/index.js +1 -1
  9. package/lib/instance/minisound.d.ts +1 -1
  10. package/lib/instance/minisound.js +15 -7
  11. package/lib/instance/miwear.d.ts +1 -1
  12. package/lib/instance/miwear.js +12 -4
  13. package/lib/instance/pre.d.ts +1 -1
  14. package/lib/instance/pre.js +3 -1
  15. package/lib/instance/vela5.d.ts +1 -1
  16. package/lib/instance/vela5.js +12 -10
  17. package/lib/static/avdConfigIni.json +1 -1
  18. package/lib/static/proto/emulator_controller.proto +181 -26
  19. package/lib/static/proto/ui_controller_service.proto +147 -0
  20. package/lib/typing/Vvd.d.ts +4 -2
  21. package/lib/typing/Vvd.js +1 -0
  22. package/lib/vvd/grpc/index.d.ts +16 -8
  23. package/lib/vvd/grpc/index.js +125 -29
  24. package/lib/vvd/grpc/types/GrpcClient.d.ts +43 -2
  25. package/lib/vvd/grpc/types/UiControllerClient.d.ts +23 -0
  26. package/lib/vvd/grpc/types/index.d.ts +3 -0
  27. package/lib/vvd/grpc/types/index.js +38 -0
  28. package/lib/vvd/grpc/types/proto-types.d.ts +178 -0
  29. package/lib/vvd/grpc/types/proto-types.js +50 -0
  30. package/lib/vvd/index.d.ts +14 -8
  31. package/lib/vvd/index.js +157 -83
  32. package/package.json +4 -8
  33. package/lib/vvd/grpc/types/KeyEvent.d.ts +0 -19
  34. package/lib/vvd/grpc/types/KeyEvent.js +0 -20
  35. package/lib/vvd/grpc/types/MouseEvent.d.ts +0 -30
  36. /package/lib/vvd/grpc/types/{MouseEvent.js → UiControllerClient.js} +0 -0
@@ -3,18 +3,25 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.GrpcEmulator = exports.AuthorizationKey = void 0;
6
7
  exports.createGrpcClient = createGrpcClient;
7
- exports.default = void 0;
8
8
  var _path = _interopRequireDefault(require("path"));
9
9
  var _protoLoader = require("@grpc/proto-loader");
10
10
  var _grpcError = require("./grpcError");
11
11
  var _grpcJs = require("@grpc/grpc-js");
12
+ var _protoTypes = require("./types/proto-types");
13
+ var _connectivityState = require("@grpc/grpc-js/build/src/connectivity-state");
12
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ // eslint-disable-next-line no-restricted-imports
16
+
17
+ const AuthorizationKey = exports.AuthorizationKey = 'Authorization';
13
18
  class GrpcEmulator {
14
19
  connected = false;
15
20
  constructor(eConf, protoPath) {
21
+ let ip = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '127.0.0.1';
16
22
  this.eConf = eConf;
17
23
  this.protoPath = protoPath;
24
+ this.ip = ip;
18
25
  this.token = eConf['grpc.token'];
19
26
  const packageDefinition = (0, _protoLoader.loadSync)(this.protoPath, {
20
27
  keepCase: true,
@@ -23,51 +30,89 @@ class GrpcEmulator {
23
30
  defaults: true,
24
31
  oneofs: true
25
32
  });
26
- this.deadline = new Date();
27
- this.deadline.setMinutes(this.deadline.getMinutes() + 2);
28
33
  this.controller = (0, _grpcJs.loadPackageDefinition)(packageDefinition).android.emulation.control;
29
34
  const mateInfo = new _grpcJs.Metadata();
30
- mateInfo.set('Authorization', `Bearer ${this.token}`);
35
+ mateInfo.set(AuthorizationKey, `Bearer ${this.token}`);
31
36
  this.authMate = mateInfo;
32
- this.client = new this.controller.EmulatorController(`127.0.0.1:${eConf['grpc.port']}`, _grpcJs.credentials.createInsecure());
37
+ this.client = new this.controller.EmulatorController(`${this.ip}:${eConf['grpc.port']}`, _grpcJs.credentials.createInsecure(), {
38
+ 'grpc.max_receive_message_length': 32 * 1024 * 1024,
39
+ // 32MB
40
+ 'grpc.max_send_message_length': 32 * 1024 * 1024 // 32MB
41
+ });
42
+ this.uiClient = new this.controller.UiController(`127.0.0.1:${eConf['grpc.port']}`, _grpcJs.credentials.createInsecure());
33
43
  }
34
44
  close() {
45
+ this.screenshotStream?.destroy();
46
+ this.logcatStream?.destroy();
47
+ this.client.getChannel().close();
35
48
  this.client.close();
36
49
  }
37
50
  getAuthMeta() {
38
- const token = this.eConf['grpc.token'];
39
- const mateInfo = new _grpcJs.Metadata();
40
- mateInfo.set('Authorization', `Bearer ${token}`);
41
- return mateInfo;
51
+ return this.authMate;
42
52
  }
43
- waitForReady() {
53
+ async waitForReady() {
44
54
  if (this.connected) {
45
- return Promise.resolve(true);
55
+ return true;
46
56
  }
47
- return new Promise((resolve, reject) => {
48
- this.client.waitForReady(this.deadline, err => {
49
- if (err) {
50
- this.connected = false;
51
- console.error(err);
52
- return reject(err);
57
+ const channel = this.client.getChannel();
58
+ const curState = channel.getConnectivityState(true);
59
+ if (curState === _connectivityState.ConnectivityState.READY) {
60
+ return true;
61
+ }
62
+ const {
63
+ resolve,
64
+ reject,
65
+ promise
66
+ } = Promise.withResolvers();
67
+ let count = 0;
68
+ const watcher = () => {
69
+ if (++count >= 5) {
70
+ return reject(new Error('gRPC connection failed'));
71
+ }
72
+ const deadline = new Date();
73
+ deadline.setMinutes(deadline.getMinutes() + 2); // 2 minutes timeout
74
+
75
+ channel.watchConnectivityState(curState, deadline, e => {
76
+ if (e) {
77
+ reject(e);
78
+ }
79
+ const newState = channel.getConnectivityState(true);
80
+ switch (newState) {
81
+ case _connectivityState.ConnectivityState.TRANSIENT_FAILURE:
82
+ reject(new Error('gRPC connection failed'));
83
+ break;
84
+ case _connectivityState.ConnectivityState.READY:
85
+ this.connected = true;
86
+ resolve(true);
87
+ break;
88
+ case _connectivityState.ConnectivityState.SHUTDOWN:
89
+ reject(new Error('gRPC connection shutdown'));
90
+ break;
91
+ case _connectivityState.ConnectivityState.CONNECTING:
92
+ watcher();
93
+ default:
94
+ break;
53
95
  }
54
- this.connected = true;
55
- resolve(true);
56
96
  });
57
- });
97
+ };
98
+ watcher();
99
+ return promise;
58
100
  }
59
- async startStream(onStreamScreenshot) {
101
+ async streamScreenshot(imageFormat) {
60
102
  await this.waitForReady();
61
103
  if (this.screenshotStream) {
62
104
  this.screenshotStream.destroy();
63
105
  }
64
- this.screenshotStream = this.client.streamScreenshot(this.controller.Image, this.authMate);
65
- this.screenshotStream.on('data', response => {
66
- onStreamScreenshot(response.image);
67
- });
68
- this.screenshotStream.on('error', err => {
69
- console.error(err.message);
106
+ const params = imageFormat || {
107
+ format: _protoTypes.ImageFormatType.PNG
108
+ };
109
+ this.screenshotStream = this.client.streamScreenshot(params, this.authMate);
110
+ // don't delete it, otherwise crash process when emulator exit
111
+ this.screenshotStream.on('error', () => {
112
+ // TODO: not care at now
113
+ // console.error('streamScreenshot error:', err)
70
114
  });
115
+ return this.screenshotStream;
71
116
  }
72
117
  getScreenshot() {
73
118
  return new Promise((resolve, reject) => {
@@ -109,9 +154,60 @@ class GrpcEmulator {
109
154
  if (err) console.error(err);
110
155
  });
111
156
  }
157
+ showExtendedControls() {
158
+ let paneIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
159
+ if (!this.uiClient) return Promise.reject('UiController not available');
160
+ return new Promise((resolve, reject) => {
161
+ this.uiClient.showExtendedControls({
162
+ index: paneIndex
163
+ }, this.authMate, (err, response) => {
164
+ if (err) return reject(err);
165
+ resolve(response);
166
+ });
167
+ });
168
+ }
169
+ closeExtendedControls() {
170
+ if (!this.uiClient) return Promise.reject('UiController not available');
171
+ return new Promise((resolve, reject) => {
172
+ this.uiClient.closeExtendedControls({}, this.authMate, (err, response) => {
173
+ if (err) return reject(err);
174
+ resolve(response);
175
+ });
176
+ });
177
+ }
178
+ setSensor(sensorValue) {
179
+ if (!this.client) return Promise.reject('grpc client not available');
180
+ return new Promise((resolve, reject) => {
181
+ this.client.setSensor(sensorValue, this.authMate, (err, response) => {
182
+ if (err) return reject(err);
183
+ resolve(response);
184
+ });
185
+ });
186
+ }
187
+ getSensor(sensorValue) {
188
+ if (!this.client) return Promise.reject('grpc client not available');
189
+ return new Promise((resolve, reject) => {
190
+ this.client.getSensor(sensorValue, this.authMate, (err, response) => {
191
+ if (err) return reject(err);
192
+ resolve(response);
193
+ });
194
+ });
195
+ }
196
+ async streamLogcat(params) {
197
+ await this.waitForReady();
198
+ if (this.logcatStream) {
199
+ this.logcatStream.destroy();
200
+ }
201
+ const logMessage = params || {};
202
+ this.logcatStream = this.client.streamLogcat(logMessage, this.authMate);
203
+ this.logcatStream.on('error', err => {
204
+ console.error('streamLogcat error:', err?.message || err);
205
+ });
206
+ return this.logcatStream;
207
+ }
112
208
  }
113
- exports.default = GrpcEmulator;
209
+ exports.GrpcEmulator = GrpcEmulator;
114
210
  function createGrpcClient(eConf) {
115
- const protoPath = _path.default.join(__dirname, '../../static/proto/emulator_controller.proto');
211
+ const protoPath = [_path.default.resolve(__dirname, '../../static/proto/emulator_controller.proto'), _path.default.resolve(__dirname, '../../static/proto/ui_controller_service.proto')];
116
212
  return new GrpcEmulator(eConf, protoPath);
117
213
  }
@@ -1,4 +1,45 @@
1
- import { Client } from '@grpc/grpc-js';
1
+ import { Client, Metadata, ServiceError, ClientUnaryCall } from '@grpc/grpc-js';
2
+ import type { PhysicalModelValue, ClipData, BatteryState, GpsState, Fingerprint, TouchEvent, PhoneCall, PhoneResponse, SmsMessage, PhoneNumber, EmulatorStatus, ImageFormat, Image, AudioFormat, LogMessage, VmRunState, DisplayConfigurations, BrightnessValue, DisplayMode, RotationRadian, Velocity, Posture, SensorValue, KeyboardEvent, MouseEvent } from './proto-types';
2
3
  export interface GrpcClient extends Client {
3
- [i: string]: any;
4
+ setSensor(request: SensorValue, metadata: Metadata, callback: (error: ServiceError | null, response: {}) => void): ClientUnaryCall;
5
+ getSensor(request: SensorValue, metadata: Metadata, callback: (error: ServiceError | null, response: SensorValue) => void): ClientUnaryCall;
6
+ streamSensor(request: SensorValue, metadata: Metadata): NodeJS.ReadStream;
7
+ setPhysicalModel(request: PhysicalModelValue, metadata: Metadata, callback: (error: ServiceError | null, response: {}) => void): ClientUnaryCall;
8
+ getPhysicalModel(request: PhysicalModelValue, metadata: Metadata, callback: (error: ServiceError | null, response: PhysicalModelValue) => void): ClientUnaryCall;
9
+ streamPhysicalModel(request: PhysicalModelValue, metadata: Metadata): NodeJS.ReadStream;
10
+ setClipboard(request: ClipData, metadata: Metadata, callback: (error: ServiceError | null, response: {}) => void): ClientUnaryCall;
11
+ getClipboard(request: {}, metadata: Metadata, callback: (error: ServiceError | null, response: ClipData) => void): ClientUnaryCall;
12
+ streamClipboard(request: {}, metadata: Metadata): NodeJS.ReadStream;
13
+ setBattery(request: BatteryState, metadata: Metadata, callback: (error: ServiceError | null, response: {}) => void): ClientUnaryCall;
14
+ getBattery(request: {}, metadata: Metadata, callback: (error: ServiceError | null, response: BatteryState) => void): ClientUnaryCall;
15
+ setGps(request: GpsState, metadata: Metadata, callback: (error: ServiceError | null, response: {}) => void): ClientUnaryCall;
16
+ getGps(request: {}, metadata: Metadata, callback: (error: ServiceError | null, response: GpsState) => void): ClientUnaryCall;
17
+ sendFingerprint(request: Fingerprint, metadata: Metadata, callback: (error: ServiceError | null, response: {}) => void): ClientUnaryCall;
18
+ sendKey(request: KeyboardEvent, metadata: Metadata, callback: (error: ServiceError | null, response: {}) => void): ClientUnaryCall;
19
+ sendTouch(request: TouchEvent, metadata: Metadata, callback: (error: ServiceError | null, response: {}) => void): ClientUnaryCall;
20
+ sendMouse(request: MouseEvent, metadata: Metadata, callback: (error: ServiceError | null, response: {}) => void): ClientUnaryCall;
21
+ injectWheel(metadata: Metadata): NodeJS.WritableStream;
22
+ streamInputEvent(metadata: Metadata): NodeJS.WritableStream;
23
+ sendPhone(request: PhoneCall, metadata: Metadata, callback: (error: ServiceError | null, response: PhoneResponse) => void): ClientUnaryCall;
24
+ sendSms(request: SmsMessage, metadata: Metadata, callback: (error: ServiceError | null, response: PhoneResponse) => void): ClientUnaryCall;
25
+ setPhoneNumber(request: PhoneNumber, metadata: Metadata, callback: (error: ServiceError | null, response: PhoneResponse) => void): ClientUnaryCall;
26
+ getStatus(request: {}, metadata: Metadata, callback: (error: ServiceError | null, response: EmulatorStatus) => void): ClientUnaryCall;
27
+ getScreenshot(request: ImageFormat, metadata: Metadata, callback: (error: ServiceError | null, response: Image) => void): ClientUnaryCall;
28
+ streamScreenshot(request: ImageFormat, metadata: Metadata): NodeJS.ReadStream;
29
+ streamAudio(request: AudioFormat, metadata: Metadata): NodeJS.ReadStream;
30
+ injectAudio(metadata: Metadata): NodeJS.WritableStream;
31
+ getLogcat(request: LogMessage, metadata: Metadata, callback: (error: ServiceError | null, response: LogMessage) => void): ClientUnaryCall;
32
+ streamLogcat(request: LogMessage, metadata: Metadata): NodeJS.ReadStream;
33
+ setVmState(request: VmRunState, metadata: Metadata, callback: (error: ServiceError | null, response: {}) => void): ClientUnaryCall;
34
+ getVmState(request: {}, metadata: Metadata, callback: (error: ServiceError | null, response: VmRunState) => void): ClientUnaryCall;
35
+ setDisplayConfigurations(request: DisplayConfigurations, metadata: Metadata, callback: (error: ServiceError | null, response: DisplayConfigurations) => void): ClientUnaryCall;
36
+ getDisplayConfigurations(request: {}, metadata: Metadata, callback: (error: ServiceError | null, response: DisplayConfigurations) => void): ClientUnaryCall;
37
+ streamNotification(request: {}, metadata: Metadata): NodeJS.ReadStream;
38
+ getBrightness(request: BrightnessValue, metadata: Metadata, callback: (error: ServiceError | null, response: BrightnessValue) => void): ClientUnaryCall;
39
+ setBrightness(request: BrightnessValue, metadata: Metadata, callback: (error: ServiceError | null, response: {}) => void): ClientUnaryCall;
40
+ getDisplayMode(request: {}, metadata: Metadata, callback: (error: ServiceError | null, response: DisplayMode) => void): ClientUnaryCall;
41
+ setDisplayMode(request: DisplayMode, metadata: Metadata, callback: (error: ServiceError | null, response: {}) => void): ClientUnaryCall;
42
+ rotateVirtualSceneCamera(request: RotationRadian, metadata: Metadata, callback: (error: ServiceError | null, response: {}) => void): ClientUnaryCall;
43
+ setVirtualSceneCameraVelocity(request: Velocity, metadata: Metadata, callback: (error: ServiceError | null, response: {}) => void): ClientUnaryCall;
44
+ setPosture(request: Posture, metadata: Metadata, callback: (error: ServiceError | null, response: {}) => void): ClientUnaryCall;
4
45
  }
@@ -0,0 +1,23 @@
1
+ import { Metadata, ServiceError, ClientUnaryCall } from '@grpc/grpc-js';
2
+ export interface PaneEntry {
3
+ index: number;
4
+ }
5
+ export interface ThemingStyle {
6
+ style: number;
7
+ }
8
+ export interface ExtendedControlsStatus {
9
+ visibilityChanged: boolean;
10
+ }
11
+ export interface UserConfigEntry {
12
+ key: string;
13
+ value: string;
14
+ }
15
+ export interface UserConfig {
16
+ entries: UserConfigEntry[];
17
+ }
18
+ export interface UiControllerClient {
19
+ showExtendedControls(request: PaneEntry, metadata: Metadata, callback: (error: ServiceError | null, response: ExtendedControlsStatus) => void): ClientUnaryCall;
20
+ closeExtendedControls(request: {}, metadata: Metadata, callback: (error: ServiceError | null, response: ExtendedControlsStatus) => void): ClientUnaryCall;
21
+ setUiTheme(request: ThemingStyle, metadata: Metadata, callback: (error: ServiceError | null, response: {}) => void): ClientUnaryCall;
22
+ getUserConfig(request: {}, metadata: Metadata, callback: (error: ServiceError | null, response: UserConfig) => void): ClientUnaryCall;
23
+ }
@@ -0,0 +1,3 @@
1
+ export * from './GrpcClient';
2
+ export * from './proto-types';
3
+ export * from './UiControllerClient';
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _GrpcClient = require("./GrpcClient");
7
+ Object.keys(_GrpcClient).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _GrpcClient[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _GrpcClient[key];
14
+ }
15
+ });
16
+ });
17
+ var _protoTypes = require("./proto-types");
18
+ Object.keys(_protoTypes).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _protoTypes[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _protoTypes[key];
25
+ }
26
+ });
27
+ });
28
+ var _UiControllerClient = require("./UiControllerClient");
29
+ Object.keys(_UiControllerClient).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _UiControllerClient[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _UiControllerClient[key];
36
+ }
37
+ });
38
+ });
@@ -0,0 +1,178 @@
1
+ export interface PhysicalModelValue {
2
+ target: number;
3
+ status?: number;
4
+ value?: {
5
+ data: number[];
6
+ };
7
+ }
8
+ export interface ClipData {
9
+ text: string;
10
+ }
11
+ export interface BatteryState {
12
+ hasBattery: boolean;
13
+ isPresent: boolean;
14
+ charger: number;
15
+ chargeLevel: number;
16
+ health: number;
17
+ status: number;
18
+ }
19
+ export interface GpsState {
20
+ passiveUpdate: boolean;
21
+ latitude: number;
22
+ longitude: number;
23
+ speed?: number;
24
+ bearing?: number;
25
+ altitude?: number;
26
+ satellites?: number;
27
+ }
28
+ export interface Fingerprint {
29
+ isTouching: boolean;
30
+ touchId: number;
31
+ }
32
+ export interface TouchEvent {
33
+ touches: Array<{
34
+ x: number;
35
+ y: number;
36
+ identifier: number;
37
+ pressure: number;
38
+ touch_major?: number;
39
+ touch_minor?: number;
40
+ expiration?: number;
41
+ }>;
42
+ display?: number;
43
+ }
44
+ export interface PhoneCall {
45
+ operation: number;
46
+ number: string;
47
+ }
48
+ export interface PhoneResponse {
49
+ response: number;
50
+ }
51
+ export interface SmsMessage {
52
+ srcAddress: string;
53
+ text: string;
54
+ }
55
+ export interface PhoneNumber {
56
+ number: string;
57
+ }
58
+ export interface EmulatorStatus {
59
+ version: string;
60
+ uptime: number;
61
+ booted: boolean;
62
+ vmConfig: any;
63
+ hardwareConfig: Record<string, any>;
64
+ }
65
+ export interface ImageFormat {
66
+ format: number;
67
+ rotation?: any;
68
+ width?: number;
69
+ height?: number;
70
+ display?: number;
71
+ transport?: any;
72
+ }
73
+ export interface Image {
74
+ format: ImageFormat;
75
+ image: Buffer;
76
+ seq?: number;
77
+ timestampUs?: number;
78
+ }
79
+ export interface AudioFormat {
80
+ samplingRate: number;
81
+ channels: number;
82
+ format: number;
83
+ mode?: number;
84
+ }
85
+ export interface LogMessage {
86
+ contents?: string;
87
+ start?: number;
88
+ next?: number;
89
+ sort?: number;
90
+ entries?: any[];
91
+ }
92
+ export interface VmRunState {
93
+ state: number;
94
+ }
95
+ export interface DisplayConfigurations {
96
+ displays: any[];
97
+ userConfigurable: number;
98
+ maxDisplays: number;
99
+ }
100
+ export interface BrightnessValue {
101
+ target: number;
102
+ value: number;
103
+ }
104
+ export interface DisplayMode {
105
+ value: number;
106
+ }
107
+ export interface RotationRadian {
108
+ x: number;
109
+ y: number;
110
+ z: number;
111
+ }
112
+ export interface Velocity {
113
+ x: number;
114
+ y: number;
115
+ z: number;
116
+ }
117
+ export interface Posture {
118
+ value: number;
119
+ }
120
+ export interface SensorValue {
121
+ target: number;
122
+ status?: number;
123
+ value?: {
124
+ data: number[];
125
+ };
126
+ }
127
+ export interface KeyboardEvent {
128
+ codeType?: number;
129
+ eventType?: number;
130
+ keyCode?: number | string;
131
+ key?: string;
132
+ text?: string;
133
+ }
134
+ export interface MouseEvent {
135
+ x?: number;
136
+ y?: number;
137
+ buttons?: number;
138
+ display?: number;
139
+ }
140
+ export declare enum SensorType {
141
+ ACCELERATION = 0,
142
+ GYROSCOPE = 1,
143
+ MAGNETIC_FIELD = 2,
144
+ ORIENTATION = 3,
145
+ TEMPERATURE = 4,
146
+ PROXIMITY = 5,
147
+ LIGHT = 6,
148
+ PRESSURE = 7,
149
+ HUMIDITY = 8,
150
+ MAGNETIC_FIELD_UNCALIBRATED = 9,
151
+ GYROSCOPE_UNCALIBRATED = 10,
152
+ HEART_RATE = 14,
153
+ RGBC_LIGHT = 15,
154
+ ACCELERATION_UNCALIBRATED = 17
155
+ }
156
+ export declare enum SensorState {
157
+ OK = 0,
158
+ NO_SERVICE = -3,
159
+ DISABLED = -2,
160
+ UNKNOWN = -1
161
+ }
162
+ export declare enum KeyEventType {
163
+ KEYDOWN = 0,
164
+ KEYUP = 1,
165
+ KEYPRESS = 2
166
+ }
167
+ export declare enum KeyCodeType {
168
+ USB = 0,
169
+ EVDEV = 1,
170
+ XKB = 2,
171
+ WIN = 3,
172
+ MAC = 4
173
+ }
174
+ export declare enum ImageFormatType {
175
+ PNG = 0,
176
+ RGBA8888 = 1,
177
+ RGB888 = 2
178
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SensorType = exports.SensorState = exports.KeyEventType = exports.KeyCodeType = exports.ImageFormatType = void 0;
7
+ let SensorType = exports.SensorType = /*#__PURE__*/function (SensorType) {
8
+ SensorType[SensorType["ACCELERATION"] = 0] = "ACCELERATION";
9
+ SensorType[SensorType["GYROSCOPE"] = 1] = "GYROSCOPE";
10
+ SensorType[SensorType["MAGNETIC_FIELD"] = 2] = "MAGNETIC_FIELD";
11
+ SensorType[SensorType["ORIENTATION"] = 3] = "ORIENTATION";
12
+ SensorType[SensorType["TEMPERATURE"] = 4] = "TEMPERATURE";
13
+ SensorType[SensorType["PROXIMITY"] = 5] = "PROXIMITY";
14
+ SensorType[SensorType["LIGHT"] = 6] = "LIGHT";
15
+ SensorType[SensorType["PRESSURE"] = 7] = "PRESSURE";
16
+ SensorType[SensorType["HUMIDITY"] = 8] = "HUMIDITY";
17
+ SensorType[SensorType["MAGNETIC_FIELD_UNCALIBRATED"] = 9] = "MAGNETIC_FIELD_UNCALIBRATED";
18
+ SensorType[SensorType["GYROSCOPE_UNCALIBRATED"] = 10] = "GYROSCOPE_UNCALIBRATED";
19
+ SensorType[SensorType["HEART_RATE"] = 14] = "HEART_RATE";
20
+ SensorType[SensorType["RGBC_LIGHT"] = 15] = "RGBC_LIGHT";
21
+ SensorType[SensorType["ACCELERATION_UNCALIBRATED"] = 17] = "ACCELERATION_UNCALIBRATED";
22
+ return SensorType;
23
+ }({});
24
+ let SensorState = exports.SensorState = /*#__PURE__*/function (SensorState) {
25
+ SensorState[SensorState["OK"] = 0] = "OK";
26
+ SensorState[SensorState["NO_SERVICE"] = -3] = "NO_SERVICE";
27
+ SensorState[SensorState["DISABLED"] = -2] = "DISABLED";
28
+ SensorState[SensorState["UNKNOWN"] = -1] = "UNKNOWN";
29
+ return SensorState;
30
+ }({});
31
+ let KeyEventType = exports.KeyEventType = /*#__PURE__*/function (KeyEventType) {
32
+ KeyEventType[KeyEventType["KEYDOWN"] = 0] = "KEYDOWN";
33
+ KeyEventType[KeyEventType["KEYUP"] = 1] = "KEYUP";
34
+ KeyEventType[KeyEventType["KEYPRESS"] = 2] = "KEYPRESS";
35
+ return KeyEventType;
36
+ }({});
37
+ let KeyCodeType = exports.KeyCodeType = /*#__PURE__*/function (KeyCodeType) {
38
+ KeyCodeType[KeyCodeType["USB"] = 0] = "USB";
39
+ KeyCodeType[KeyCodeType["EVDEV"] = 1] = "EVDEV";
40
+ KeyCodeType[KeyCodeType["XKB"] = 2] = "XKB";
41
+ KeyCodeType[KeyCodeType["WIN"] = 3] = "WIN";
42
+ KeyCodeType[KeyCodeType["MAC"] = 4] = "MAC";
43
+ return KeyCodeType;
44
+ }({});
45
+ let ImageFormatType = exports.ImageFormatType = /*#__PURE__*/function (ImageFormatType) {
46
+ ImageFormatType[ImageFormatType["PNG"] = 0] = "PNG";
47
+ ImageFormatType[ImageFormatType["RGBA8888"] = 1] = "RGBA8888";
48
+ ImageFormatType[ImageFormatType["RGB888"] = 2] = "RGB888";
49
+ return ImageFormatType;
50
+ }({});
@@ -3,13 +3,24 @@ import { IStartOptions, IStartWithSerialPort } from '../typing/Instance';
3
3
  import { EmulatorConfig } from '../emulatorutil';
4
4
  import { findInstance } from '../instance';
5
5
  import type { DownloadFileOptions } from 'ipull';
6
- import GrpcEmulator from './grpc';
6
+ import { GrpcEmulator } from './grpc';
7
7
  export declare const isHeadlessEnvironment: () => boolean;
8
+ export interface StartVvdRes {
9
+ coldBoot: boolean;
10
+ emulatorInstance: ReturnType<typeof findInstance>;
11
+ /**
12
+ * @deprecated use velaAgent instead
13
+ */
14
+ getAgent: () => GrpcEmulator;
15
+ grpcConfig: EmulatorConfig;
16
+ velaAgent: GrpcEmulator;
17
+ imageType: VelaImageType;
18
+ }
8
19
  export declare class VvdManager {
9
20
  private vvdHome;
10
21
  private sdkHome;
11
22
  binFiles: string[];
12
- constructor(vvdResourcePaths: IVvdResourcePaths);
23
+ constructor(vvdResourcePaths?: IVvdResourcePaths);
13
24
  static getDebuggerCfgFile(): string;
14
25
  /**
15
26
  * 创建Vela端的 VVD ,统一保存在 .vela/vvd 目录下
@@ -53,12 +64,7 @@ export declare class VvdManager {
53
64
  getEmulatorBinPath(sdkHome: string): string;
54
65
  oldEmulatorMigrate(vvdName: string): Promise<void>;
55
66
  getVvdStartCmd(options: IStartOptions | IStartWithSerialPort): Promise<string>;
56
- startVvd(options: IStartOptions | IStartWithSerialPort): Promise<{
57
- coldBoot: boolean;
58
- emulatorInstance: ReturnType<typeof findInstance>;
59
- getAgent: () => GrpcEmulator;
60
- grpcConfig: EmulatorConfig;
61
- }>;
67
+ startVvd(options: IStartOptions | IStartWithSerialPort): Promise<StartVvdRes>;
62
68
  stopVvd(name: string, timeout?: number): Promise<void>;
63
69
  /** 获取模拟器平台的名称,darwin-aarch64 linux-aarch64 windows-x86_64等 */
64
70
  getEmulatorPlatform(): string;