
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
android-emulator-webrtc
Advanced tools
This contains a set of React components that can be used to interact with the android emulator from the browser. It is intended to be used with an envoy proxy that is connected to a running emulator.
See the android container scripts for an example on how to run an emulator that is accessible via the web.
npm install --save android-emulator-webrtc
You can connect to remote unsecured emulator as follows:
import { Emulator } from "android-emulator-webrtc/emulator";
class EmulatorScreen extends React.Component {
render() {
return <Emulator uri="https://my.emulator" />;
}
}
In order to connect to a secure endpoint you will have to provide an authorization service that provides the following functions:
authHeader()
which must return a set of headers that should be send along with a request. For example: authHeader = () => {
return { Authorization: 'Some Token' };
};
}
unauthorized()
a function that gets called when a 401 was received. Here you can provide logic to handle token refresh, re-login etc.For example:
import { Emulator } from "android-emulator-webrtc/emulator";
class EmulatorScreen extends React.Component {
render() {
return <Emulator uri="https://my.emulator" auth={my_auth_object} />;
}
}
A React component that displays a remote android emulator.
The emulator will mount a png or webrtc view component to display the current state of the emulator. It will translate mouse events on this component and send them to the actual emulator.
The authentication service should implement the following methods:
authHeader()
which must return a set of headers that should be send along with a request.unauthorized()
a function that gets called when a 401 was received.You usually want this to be webrtc as this will make use of the efficient webrtc implementation. The png view will request screenshots, which are very slow, and require the envoy proxy. You should not use this for remote emulators.
This component has a method sendKey
to sends a key to the emulator.
You can use this to send physical hardwar events to the emulator for example:
"AudioVolumeDown" - Decreases the audio volume. "AudioVolumeUp" - Increases the audio volume. "Power" - The Power button or key, turn off the device. "AppSwitch" - Should bring up the application switcher dialog. "GoHome" - Go to the home screen. "GoBack" - Open the previous screen you were looking at.
prop | type | default | required | description |
---|---|---|---|---|
auth | Object | null | :x: | The authentication service to use, or null for no authentication. |
height | Number | :x: | The height of the component | |
muted | Boolean | true | :x: | True if the audio should be disabled. This is only relevant when using the webrtc engine. |
onAudioStateChange | Function | (s) => { console.log("emulator audio: " + s); } | :x: | Called when the audio becomes (un)available. True if audio is available, false otherwise. |
onError | Function | (e) => { console.error(e); } | :x: | Callback that will be invoked in case of gRPC errors. |
onStateChange | Function | (s) => { console.log("emulator state: " + s); } | :x: | Called upon state change, one of ["connecting", "connected", "disconnected"] |
gps | :x: | A GeolocationCoordinates like object indicating where the device is. | ||
poll | Boolean | false | :x: | True if polling should be used, only set this to true if you are using the go webgrpc proxy. |
uri | String | :white_check_mark: | gRPC Endpoint where we can reach the emulator. | |
view | Enum("webrtc", "png") | "webrtc" | :x: | The underlying view used to display the emulator, one of ["webrtc", "png"] |
volume | Number | 1.0 | :x: | Volume between [0, 1] when audio is enabled. 0 is muted, 1.0 is 100% |
width | Number | :x: | The width of the component |
Note: The user must have interacted with the page before you can set the volume to "unmuted" (muted = false). Otherwise the video will not play and will throw an error, which is currently not handled.
Note: The volume is the volume of the video element that is displayed, this is not the actual volume used inside the emulator. You can change the audio inside the emulator by sending the proper keys as documented above, or follow the steps in the support document on how to change the audio volume.
Kind: global class
Gets the status of the emulator, parsing the hardware config into something easy to digest.
Param | Type | Description |
---|---|---|
uriOrEmulator | string/EmulatorControllerService | uri to gRPC endpoint. |
auth | object | authorization class. |
Gets the cached status.
Kind: static property of EmulatorStatus
Retrieves the current status from the emulator.
Kind: static property of EmulatorStatus
Param | Type | Description |
---|---|---|
fnNotify | Callback | when the status is available, returns the retrieved status. |
cache | boolean | True if the cache can be used. |
Observe the logcat stream from the emulator.
Streaming is done by either polling the emulator endpoint or making a streaming call.
It will send out the following events:
start
whenever the start method was called.data
whenever new data became available.end
whenever the stream is finished, either because it was stopped, or due to an error.Kind: global class
Creates a logcat stream.
The authentication service should implement the following methods:
authHeader()
which must return a set of headers that should be send along with a request.unauthorized()
a function that gets called when a 401 was received.Param | Type |
---|---|
uriOrEmulator | object |
auth | object |
Register a listener.
Kind: static property of Logcat
Param | Type | Description |
---|---|---|
name | string | Name of the event. |
fn | Callback | Function to notify on the given event. |
Removes a listener.
Kind: static property of Logcat
Param | Type | Description |
---|---|---|
name | string | Name of the event. |
fn | Callback | Function to notify on the given event. |
Cancel the currently active logcat stream.
Kind: static property of Logcat
Requests the logcat stream, invoking the callback when a log line arrives.
Note: Streaming can cause serious UI delays, so best not to use it.
Kind: static property of Logcat
Param | Type | Description |
---|---|---|
fnNotify | Callback | when a new log line arrives. |
refreshRate | number | polling interval, or 0 if you wish to use streaming. |
FAQs
Android Emulator WebRTC module
The npm package android-emulator-webrtc receives a total of 317 weekly downloads. As such, android-emulator-webrtc popularity was classified as not popular.
We found that android-emulator-webrtc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.