diff --git a/packages/adb-backend-web/src/index.ts b/packages/adb-backend-web/src/index.ts index e4f23fdf..2b7c9b1b 100644 --- a/packages/adb-backend-web/src/index.ts +++ b/packages/adb-backend-web/src/index.ts @@ -23,6 +23,10 @@ export function decodeUtf8(buffer: ArrayBuffer): string { } export default class AdbWebBackend implements AdbBackend { + public static isSupported(): boolean { + return !!window.navigator?.usb; + } + public static async getDevices(): Promise { const devices = await window.navigator.usb.getDevices(); return devices.map(device => new AdbWebBackend(device)); diff --git a/packages/demo/src/connect.tsx b/packages/demo/src/connect.tsx index d91cead9..ae93afaf 100644 --- a/packages/demo/src/connect.tsx +++ b/packages/demo/src/connect.tsx @@ -18,11 +18,18 @@ export default withDisplayName('Connect')(({ device, onDeviceChange, }: ConnectProps): JSX.Element | null => { + const supported = AdbWebBackend.isSupported(); + const { show: showErrorDialog } = useContext(ErrorDialogContext); const [backendOptions, setBackendOptions] = useState([]); const [selectedBackend, setSelectedBackend] = useState(); useEffect(() => { + if (!supported) { + showErrorDialog('Your browser does not support WebUSB standard, which is required for this site to work.\n\nLatest version of Google Chrome (for Windows, macOS, Linux and Android), Microsoft Edge (for Windows and macOS), or other Chromium-based browsers should work.'); + return; + } + async function refresh() { const backendList = await AdbWebBackend.getDevices(); @@ -42,7 +49,6 @@ export default withDisplayName('Connect')(({ }; refresh(); - const watcher = new AdbWebBackendWatcher(refresh); return () => watcher.dispose(); }, []); @@ -141,6 +147,7 @@ export default withDisplayName('Connect')(({ > { API. - The latest version of Google Chrome (or Microsoft Edge) is recommended for best compatibility. + Latest version of Google Chrome (for Windows, macOS, Linux and Android) or Microsoft Edge (for Windows and macOS) is recommended for best compatibility. @@ -71,9 +71,10 @@ export const Intro = withDisplayName('Intro')(() => { Got "Unable to claim interface" error? - Only one software can connect to your device at a time.
- 1. Make sure ADB server is not running (run `adb kill-server` to stop it).
- 2. Make sure no other Android management tools are running + Only one connection to your device can exist simultaneously. Please make sure
+ 1. Native ADB client is not running (run `adb kill-server` to stop it).
+ 2. No other Android management tools are running
+ 3. No other WebADB tabs have already connected to your device.
Got "Access denied" error?