android-emulator-webrtc 1.0.17 → 2.0.1
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/README.md +93 -204
- package/dist/components/emulator/emulator.d.ts +64 -0
- package/dist/components/emulator/emulator.js +161 -173
- package/dist/components/emulator/net/emulator_status.d.ts +45 -0
- package/dist/components/emulator/net/emulator_status.js +35 -42
- package/dist/components/emulator/net/logcat.js +37 -54
- package/dist/components/emulator/net/logger.d.ts +7 -0
- package/dist/components/emulator/net/logger.js +20 -0
- package/dist/components/emulator/net/ws_jsep_protocol_driver.d.ts +213 -0
- package/dist/components/emulator/net/ws_jsep_protocol_driver.js +640 -0
- package/dist/components/emulator/views/event_handler.d.ts +37 -0
- package/dist/components/emulator/views/event_handler.js +274 -260
- package/dist/components/emulator/views/webrtc_view.d.ts +27 -0
- package/dist/components/emulator/views/webrtc_view.js +42 -25
- package/dist/index.d.ts +8 -0
- package/dist/index.js +0 -7
- package/dist/proto/emulator_controller_pb.d.ts +1 -0
- package/dist/proto/emulator_controller_pb.js +146 -287
- package/dist/src/components/emulator/emulator.d.ts +64 -0
- package/dist/src/components/emulator/net/emulator_status.d.ts +45 -0
- package/dist/src/components/emulator/net/logger.d.ts +7 -0
- package/dist/src/components/emulator/net/ws_jsep_protocol_driver.d.ts +213 -0
- package/dist/src/components/emulator/views/event_handler.d.ts +37 -0
- package/dist/src/components/emulator/views/webrtc_view.d.ts +27 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/proto/emulator_controller_pb.d.ts +1 -0
- package/package.json +17 -18
- package/proto/emulator_controller.proto +746 -181
- package/.vscode/launch.json +0 -21
- package/.vscode/settings.json +0 -3
- package/CONTRIBUTING.md +0 -28
- package/Makefile +0 -123
- package/android-emulator-webrtc.code-workspace +0 -7
- package/api_descriptor.pb +0 -0
- package/babel.config.js +0 -16
- package/cloudbuild.yaml +0 -41
- package/cloudbuilders/.gcloudignore +0 -1
- package/cloudbuilders/Dockerfile +0 -20
- package/cloudbuilders/README.md +0 -29
- package/cloudbuilders/cloudbuild.yaml +0 -19
- package/dist/components/emulator/net/jsep_protocol_driver.js +0 -365
- package/dist/components/emulator/views/resizing_component.js +0 -86
- package/dist/components/emulator/views/simple_png_view.js +0 -111
- package/dist/proto/emulator_controller_grpc_web_pb.js +0 -1601
- package/dist/proto/emulator_web_client.js +0 -176
- package/dist/proto/rtc_service_grpc_web_pb.js +0 -231
- package/dist/proto/rtc_service_pb.js +0 -338
- package/emulator/index.js +0 -1
- package/eslint_prefix.py +0 -37
- package/gen_md_doc.js +0 -40
- package/npmrc.enc +0 -0
- package/proto/rtc_service.proto +0 -117
- package/protoc-plugin/Makefile +0 -31
- package/protoc-plugin/grpc_generator.cc +0 -1755
- package/src/components/emulator/emulator.js +0 -217
- package/src/components/emulator/net/emulator_status.js +0 -94
- package/src/components/emulator/net/jsep_protocol_driver.js +0 -364
- package/src/components/emulator/net/logcat.js +0 -155
- package/src/components/emulator/views/event_handler.js +0 -268
- package/src/components/emulator/views/resizing_component.js +0 -65
- package/src/components/emulator/views/simple_png_view.js +0 -106
- package/src/components/emulator/views/webrtc_view.js +0 -146
- package/src/index.js +0 -20
- package/src/proto/emulator_web_client.js +0 -140
- package/test/cloudbuild.yaml +0 -41
- package/test/emulator.test.js +0 -125
- package/test/event_handler.test.js +0 -91
- package/test/fake_events.js +0 -50
- package/test/jsep_protocol_driver.test.js +0 -228
- package/test/resizing_component.test.js +0 -37
- package/test/simple_png_view.test.js +0 -145
- package/test/touch_event_handler.test.js +0 -118
package/README.md
CHANGED
|
@@ -1,252 +1,141 @@
|
|
|
1
1
|
# android-emulator-webrtc
|
|
2
2
|
|
|
3
|
-
This contains
|
|
4
|
-
intended to be used with an [envoy proxy](https://blog.envoyproxy.io/envoy-and-grpc-web-a-fresh-new-alternative-to-rest-6504ce7eb880)
|
|
5
|
-
that is connected to a running emulator.
|
|
3
|
+
This package contains React components and utilities to display and interact with an Android Emulator from the browser. It is designed to interface with an Emulator Gateway using REST and WebSockets (removing gRPC-web and Envoy proxy requirements).
|
|
6
4
|
|
|
7
|
-
See the [
|
|
8
|
-
an emulator that is accessible via the web.
|
|
5
|
+
See the [Server Protocol Specification](docs/protocol.md) for details on how to implement the gateway.
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
See the [android container](https://github.com/google/android-emulator-container-scripts) scripts for an example on how to run an emulator that is accessible via the web.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
11
10
|
npm install --save android-emulator-webrtc
|
|
12
11
|
```
|
|
13
12
|
|
|
14
|
-
[Full reference](#full-reference)
|
|
15
|
-
|
|
16
13
|
## Features
|
|
17
14
|
|
|
18
|
-
- Display and interact with
|
|
19
|
-
-
|
|
20
|
-
-
|
|
15
|
+
- Display and interact with a remote Android Emulator over the web.
|
|
16
|
+
- Real-time WebRTC video and audio streaming.
|
|
17
|
+
- Fully interactive mouse, touch, and keyboard event forwarding.
|
|
18
|
+
- Reconnection support with exponential backoff for WebSocket and WebRTC failures.
|
|
19
|
+
- Native TypeScript support with built-in type definitions.
|
|
21
20
|
|
|
22
21
|
---
|
|
23
22
|
|
|
24
23
|
## Usage
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
```js
|
|
29
|
-
import { Emulator } from "android-emulator-webrtc/emulator";
|
|
30
|
-
|
|
31
|
-
class EmulatorScreen extends React.Component {
|
|
32
|
-
render() {
|
|
33
|
-
return <Emulator uri="https://my.emulator" />;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
```
|
|
25
|
+
### Simple Connection
|
|
37
26
|
|
|
38
|
-
|
|
27
|
+
You can connect to a remote unsecured emulator as follows using a modern React functional component:
|
|
39
28
|
|
|
40
|
-
|
|
29
|
+
```tsx
|
|
30
|
+
import React from "react";
|
|
31
|
+
import { Emulator } from "android-emulator-webrtc";
|
|
41
32
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
function EmulatorScreen() {
|
|
34
|
+
return (
|
|
35
|
+
<div style={{ width: "360px", height: "640px", background: "#000" }}>
|
|
36
|
+
<Emulator
|
|
37
|
+
uri="localhost:8080"
|
|
38
|
+
onStateChange={(state) => console.log("State:", state)}
|
|
39
|
+
onError={(err) => console.error("Error:", err)}
|
|
40
|
+
/>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
46
43
|
}
|
|
47
44
|
```
|
|
48
45
|
|
|
49
|
-
|
|
46
|
+
### Secure Connection
|
|
50
47
|
|
|
51
|
-
|
|
48
|
+
To connect to a secure endpoint, provide an `auth` service object that implements the required authentication hooks:
|
|
52
49
|
|
|
53
|
-
```
|
|
54
|
-
import
|
|
50
|
+
```tsx
|
|
51
|
+
import React from "react";
|
|
52
|
+
import { Emulator } from "android-emulator-webrtc";
|
|
55
53
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
const myAuthService = {
|
|
55
|
+
// Returns headers to be sent with REST requests (e.g. GPS updates)
|
|
56
|
+
authHeader: () => {
|
|
57
|
+
return { Authorization: "Bearer my-session-token" };
|
|
58
|
+
},
|
|
59
|
+
// Callback invoked when a 401 Unauthorized is encountered
|
|
60
|
+
unauthorized: () => {
|
|
61
|
+
console.log("Token expired or unauthorized. Redirecting to login...");
|
|
59
62
|
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
function SecureEmulatorScreen() {
|
|
66
|
+
return (
|
|
67
|
+
<Emulator
|
|
68
|
+
uri="https://my-secure-gateway.com"
|
|
69
|
+
auth={myAuthService}
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
60
72
|
}
|
|
61
73
|
```
|
|
62
74
|
|
|
63
75
|
---
|
|
64
76
|
|
|
65
|
-
##
|
|
66
|
-
|
|
67
|
-
## Emulator
|
|
68
|
-
|
|
69
|
-
A React component that displays a remote android emulator.
|
|
70
|
-
|
|
71
|
-
The emulator will mount a png or webrtc view component to display the current state
|
|
72
|
-
of the emulator. It will translate mouse events on this component and send them
|
|
73
|
-
to the actual emulator.
|
|
74
|
-
|
|
75
|
-
#### Authentication Service
|
|
76
|
-
|
|
77
|
-
The authentication service should implement the following methods:
|
|
78
|
-
|
|
79
|
-
- `authHeader()` which must return a set of headers that should be send along with a request.
|
|
80
|
-
- `unauthorized()` a function that gets called when a 401 was received.
|
|
81
|
-
|
|
82
|
-
#### Type of view
|
|
77
|
+
## Reference
|
|
83
78
|
|
|
84
|
-
|
|
85
|
-
webrtc implementation. The png view will request screenshots, which are
|
|
86
|
-
very slow, and require the envoy proxy. You should not use this for remote emulators.
|
|
79
|
+
### `<Emulator />`
|
|
87
80
|
|
|
88
|
-
|
|
81
|
+
A React component that displays the remote Android Emulator screen and forwards user input.
|
|
89
82
|
|
|
90
|
-
|
|
91
|
-
You can use this to send physical hardwar events to the emulator for example:
|
|
83
|
+
#### Props
|
|
92
84
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
85
|
+
| Prop | Type | Default | Required | Description |
|
|
86
|
+
| :--- | :---: | :---: | :---: | :--- |
|
|
87
|
+
| **uri** | `string` | | :white_check_mark: | Endpoint where the emulator gateway is reachable (e.g. `host:port` or `http(s)://host:port`). |
|
|
88
|
+
| **auth** | `object` | `null` | :x: | An authentication service object implementing `authHeader()` and `unauthorized()`. |
|
|
89
|
+
| **muted** | `boolean` | `true` | :x: | Whether the audio stream should be muted. |
|
|
90
|
+
| **volume** | `number` | `1.0` | :x: | Audio playback volume between `0.0` (muted) and `1.0` (100%). |
|
|
91
|
+
| **width** | `number` | | :x: | Width of the component in pixels. Defaults to `100%`. |
|
|
92
|
+
| **height** | `number` | | :x: | Height of the component in pixels. Defaults to `100%`. |
|
|
93
|
+
| **gps** | `object` | | :x: | An object containing `{ latitude, longitude, altitude, heading, speed }` to update the emulator's mock location. |
|
|
94
|
+
| **onStateChange** | `function` | | :x: | Callback invoked on WebRTC connection state changes: `"connecting"`, `"connected"`, or `"disconnected"`. |
|
|
95
|
+
| **onAudioStateChange** | `function` | | :x: | Callback invoked when the audio track becomes available (`true`) or unavailable (`false`). |
|
|
96
|
+
| **onError** | `function` | | :x: | Callback invoked when a WebSocket, WebRTC, or GPS update error occurs. |
|
|
99
97
|
|
|
100
|
-
|
|
101
|
-
| ---------------------- | :---------------------: | :-----------------------------------------------: | :----------------: | ----------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
102
|
-
| **auth** | `Object` | `null` | :x: | The authentication service to use, or null for no authentication. |
|
|
103
|
-
| **height** | `Number` | | :x: | The height of the component |
|
|
104
|
-
| **muted** | `Boolean` | `true` | :x: | True if the audio should be disabled. This is only relevant when using the webrtc engine. |
|
|
105
|
-
| **onAudioStateChange** | `Function` | `(s) => { console.log("emulator audio: " + s); }` | :x: | Called when the audio becomes (un)available. True if audio is available, false otherwise. |
|
|
106
|
-
| **onError** | `Function` | `(e) => { console.error(e); }` | :x: | Callback that will be invoked in case of gRPC errors. |
|
|
107
|
-
| **onStateChange** | `Function` | `(s) => { console.log("emulator state: " + s); }` | :x: | Called upon state change, one of ["connecting", "connected", "disconnected"] |
|
|
108
|
-
| **gps** | | | :x: | A [GeolocationCoordinates](https://developer.mozilla.org/en-US/docs/Web/API/GeolocationCoordinates) like object indicating where the device is. |
|
|
109
|
-
| **poll** | `Boolean` | `false` | :x: | True if polling should be used, only set this to true if you are using the go webgrpc proxy. |
|
|
110
|
-
| **uri** | `String` | | :white_check_mark: | gRPC Endpoint where we can reach the emulator. |
|
|
111
|
-
| **view** | `Enum("webrtc", "png")` | `"webrtc"` | :x: | The underlying view used to display the emulator, one of ["webrtc", "png"] |
|
|
112
|
-
| **volume** | `Number` | `1.0` | :x: | Volume between [0, 1] when audio is enabled. 0 is muted, 1.0 is 100% |
|
|
113
|
-
| **width** | `Number` | | :x: | The width of the component |
|
|
98
|
+
#### Imperative Methods
|
|
114
99
|
|
|
115
|
-
|
|
116
|
-
will not play and will throw an error, which is currently not handled.
|
|
100
|
+
By passing a `ref` to the `<Emulator />` component, you can access the following helper methods:
|
|
117
101
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
102
|
+
* **`sendKey(key: string)`**: Simulates a physical hardware button press on the device.
|
|
103
|
+
|
|
104
|
+
Common hardware key names:
|
|
105
|
+
* `"GoHome"` — Go to the home screen.
|
|
106
|
+
* `"GoBack"` — Go back to the previous screen.
|
|
107
|
+
* `"AppSwitch"` — Open the recent apps switcher.
|
|
108
|
+
* `"Power"` — Press the power button.
|
|
109
|
+
* `"AudioVolumeUp"` — Increase the device volume.
|
|
110
|
+
* `"AudioVolumeDown"` — Decrease the device volume.
|
|
121
111
|
|
|
122
112
|
---
|
|
123
113
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
## EmulatorStatus
|
|
127
|
-
|
|
128
|
-
**Kind**: global class
|
|
129
|
-
|
|
130
|
-
- [EmulatorStatus](#EmulatorStatus)
|
|
131
|
-
- [new EmulatorStatus()](#new_EmulatorStatus_new)
|
|
132
|
-
- [.getStatus](#EmulatorStatus.getStatus)
|
|
133
|
-
- [.updateStatus](#EmulatorStatus.updateStatus)
|
|
134
|
-
|
|
135
|
-
<a name="new_EmulatorStatus_new"></a>
|
|
136
|
-
|
|
137
|
-
### new EmulatorStatus()
|
|
138
|
-
|
|
139
|
-
Gets the status of the emulator, parsing the hardware config into something
|
|
140
|
-
easy to digest.
|
|
141
|
-
|
|
142
|
-
| Param | Type | Description |
|
|
143
|
-
| ------------- | --------------------------------------------- | --------------------- |
|
|
144
|
-
| uriOrEmulator | <code>string/EmulatorControllerService</code> | uri to gRPC endpoint. |
|
|
145
|
-
| auth | <code>object</code> | authorization class. |
|
|
146
|
-
|
|
147
|
-
<a name="EmulatorStatus.getStatus"></a>
|
|
148
|
-
|
|
149
|
-
### EmulatorStatus.getStatus
|
|
150
|
-
|
|
151
|
-
Gets the cached status.
|
|
152
|
-
|
|
153
|
-
**Kind**: static property of [<code>EmulatorStatus</code>](#EmulatorStatus)
|
|
154
|
-
<a name="EmulatorStatus.updateStatus"></a>
|
|
155
|
-
|
|
156
|
-
### EmulatorStatus.updateStatus
|
|
157
|
-
|
|
158
|
-
Retrieves the current status from the emulator.
|
|
159
|
-
|
|
160
|
-
**Kind**: static property of [<code>EmulatorStatus</code>](#EmulatorStatus)
|
|
114
|
+
### `EmulatorStatus`
|
|
161
115
|
|
|
162
|
-
|
|
163
|
-
| -------- | --------------------- | ----------------------------------------------------------- |
|
|
164
|
-
| fnNotify | <code>Callback</code> | when the status is available, returns the retrieved status. |
|
|
165
|
-
| cache | <code>boolean</code> | True if the cache can be used. |
|
|
116
|
+
A utility class used to query and cache the hardware configuration and status of the remote emulator.
|
|
166
117
|
|
|
167
|
-
|
|
118
|
+
```typescript
|
|
119
|
+
import { EmulatorStatus } from "android-emulator-webrtc";
|
|
168
120
|
|
|
169
|
-
|
|
121
|
+
const statusService = new EmulatorStatus("http://localhost:8080/api/v1/emulator/status", myAuthService);
|
|
170
122
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
- `start` whenever the start method was called.
|
|
178
|
-
- `data` whenever new data became available.
|
|
179
|
-
- `end` whenever the stream is finished, either because it was stopped, or due to an error.
|
|
180
|
-
|
|
181
|
-
**Kind**: global class
|
|
182
|
-
|
|
183
|
-
- [Logcat](#Logcat)
|
|
184
|
-
- [new Logcat(uriOrEmulator, auth)](#new_Logcat_new)
|
|
185
|
-
- [.on](#Logcat.on)
|
|
186
|
-
- [.off](#Logcat.off)
|
|
187
|
-
- [.stop](#Logcat.stop)
|
|
188
|
-
- [.start](#Logcat.start)
|
|
189
|
-
|
|
190
|
-
<a name="new_Logcat_new"></a>
|
|
191
|
-
|
|
192
|
-
### new Logcat(uriOrEmulator, auth)
|
|
193
|
-
|
|
194
|
-
Creates a logcat stream.
|
|
195
|
-
|
|
196
|
-
The authentication service should implement the following methods:
|
|
197
|
-
|
|
198
|
-
- `authHeader()` which must return a set of headers that should be send along with a request.
|
|
199
|
-
- `unauthorized()` a function that gets called when a 401 was received.
|
|
200
|
-
|
|
201
|
-
| Param | Type |
|
|
202
|
-
| ------------- | ------------------- |
|
|
203
|
-
| uriOrEmulator | <code>object</code> |
|
|
204
|
-
| auth | <code>object</code> |
|
|
205
|
-
|
|
206
|
-
<a name="Logcat.on"></a>
|
|
207
|
-
|
|
208
|
-
### Logcat.on
|
|
209
|
-
|
|
210
|
-
Register a listener.
|
|
211
|
-
|
|
212
|
-
**Kind**: static property of [<code>Logcat</code>](#Logcat)
|
|
213
|
-
|
|
214
|
-
| Param | Type | Description |
|
|
215
|
-
| ----- | --------------------- | -------------------------------------- |
|
|
216
|
-
| name | <code>string</code> | Name of the event. |
|
|
217
|
-
| fn | <code>Callback</code> | Function to notify on the given event. |
|
|
218
|
-
|
|
219
|
-
<a name="Logcat.off"></a>
|
|
220
|
-
|
|
221
|
-
### Logcat.off
|
|
222
|
-
|
|
223
|
-
Removes a listener.
|
|
224
|
-
|
|
225
|
-
**Kind**: static property of [<code>Logcat</code>](#Logcat)
|
|
226
|
-
|
|
227
|
-
| Param | Type | Description |
|
|
228
|
-
| ----- | --------------------- | -------------------------------------- |
|
|
229
|
-
| name | <code>string</code> | Name of the event. |
|
|
230
|
-
| fn | <code>Callback</code> | Function to notify on the given event. |
|
|
231
|
-
|
|
232
|
-
<a name="Logcat.stop"></a>
|
|
233
|
-
|
|
234
|
-
### Logcat.stop
|
|
235
|
-
|
|
236
|
-
Cancel the currently active logcat stream.
|
|
237
|
-
|
|
238
|
-
**Kind**: static property of [<code>Logcat</code>](#Logcat)
|
|
239
|
-
<a name="Logcat.start"></a>
|
|
123
|
+
// Fetch the status
|
|
124
|
+
statusService.updateStatus((status) => {
|
|
125
|
+
console.log("Device Screen Width:", status.hardwareConfig?.["hw.lcd.width"]);
|
|
126
|
+
console.log("Device Screen Height:", status.hardwareConfig?.["hw.lcd.height"]);
|
|
127
|
+
}, true); // Set to true to use cached status if available
|
|
128
|
+
```
|
|
240
129
|
|
|
241
|
-
|
|
130
|
+
---
|
|
242
131
|
|
|
243
|
-
|
|
132
|
+
### `logger`
|
|
244
133
|
|
|
245
|
-
|
|
134
|
+
The logger instance used internally by the library. You can use it to configure the library's log level:
|
|
246
135
|
|
|
247
|
-
|
|
136
|
+
```typescript
|
|
137
|
+
import { logger } from "android-emulator-webrtc";
|
|
248
138
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
| refreshRate | <code>number</code> | polling interval, or 0 if you wish to use streaming. |
|
|
139
|
+
// Enable verbose WebRTC and signaling debug logs in the console
|
|
140
|
+
logger.setLevel("debug");
|
|
141
|
+
```
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface EmulatorProps {
|
|
3
|
+
/** Endpoint where we can reach the emulator gateway (host:port or http(s)://host:port). */
|
|
4
|
+
uri: string;
|
|
5
|
+
/** The authentication service to use, or null for no authentication. */
|
|
6
|
+
auth?: any;
|
|
7
|
+
/** True if the audio should be disabled. */
|
|
8
|
+
muted?: boolean;
|
|
9
|
+
/** Volume between [0, 1] when audio is enabled. 0 is muted, 1.0 is 100% */
|
|
10
|
+
volume?: number;
|
|
11
|
+
/** Called upon state change, one of ["connecting", "connected", "disconnected"] */
|
|
12
|
+
onStateChange?: (state: string) => void;
|
|
13
|
+
/** Called when the audio becomes (un)available. True if audio is available, false otherwise. */
|
|
14
|
+
onAudioStateChange?: (audio: boolean) => void;
|
|
15
|
+
/** The width of the component */
|
|
16
|
+
width?: number;
|
|
17
|
+
/** The height of the component */
|
|
18
|
+
height?: number;
|
|
19
|
+
/** A [GeolocationCoordinates](https://developer.mozilla.org/en-US/docs/Web/API/GeolocationCoordinates) like object indicating where the device is. */
|
|
20
|
+
gps?: {
|
|
21
|
+
latitude: number;
|
|
22
|
+
longitude: number;
|
|
23
|
+
altitude?: number;
|
|
24
|
+
heading?: number;
|
|
25
|
+
speed?: number;
|
|
26
|
+
};
|
|
27
|
+
/** Callback that will be invoked in case of errors. */
|
|
28
|
+
onError?: (error: any) => void;
|
|
29
|
+
}
|
|
30
|
+
export interface EmulatorRef {
|
|
31
|
+
sendKey(key: string): void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A React component that displays a remote android emulator.
|
|
35
|
+
*
|
|
36
|
+
* The emulator will mount a webrtc view component to display the current state
|
|
37
|
+
* of the emulator. It will translate mouse and touch events on this component and send them
|
|
38
|
+
* to the actual emulator over WebRTC Data Channels.
|
|
39
|
+
*
|
|
40
|
+
* #### Authentication Service
|
|
41
|
+
*
|
|
42
|
+
* The authentication service should implement the following methods:
|
|
43
|
+
*
|
|
44
|
+
* - `authHeader()` which must return a set of headers that should be send along with a request.
|
|
45
|
+
* - `unauthorized()` a function that gets called when a 401 was received.
|
|
46
|
+
*
|
|
47
|
+
* Note that chrome will not autoplay the video if it is not muted and no interaction
|
|
48
|
+
* with the page has taken place. See https://developers.google.com/web/updates/2017/09/autoplay-policy-changes.
|
|
49
|
+
*
|
|
50
|
+
* #### Pressing hardware buttons
|
|
51
|
+
*
|
|
52
|
+
* This component has a method `sendKey` that sends a key to the emulator.
|
|
53
|
+
* You can use this to send physical button events to the emulator for example:
|
|
54
|
+
*
|
|
55
|
+
* "AudioVolumeDown" - Decreases the audio volume.
|
|
56
|
+
* "AudioVolumeUp" - Increases the audio volume.
|
|
57
|
+
* "Power" - The Power button or key, turn off the device.
|
|
58
|
+
* "AppSwitch" - Should bring up the application switcher dialog.
|
|
59
|
+
* "GoHome" - Go to the home screen.
|
|
60
|
+
* "GoBack" - Open the previous screen you were looking at.
|
|
61
|
+
*
|
|
62
|
+
*/
|
|
63
|
+
declare const Emulator: React.ForwardRefExoticComponent<EmulatorProps & React.RefAttributes<EmulatorRef>>;
|
|
64
|
+
export default Emulator;
|