Separate device in server and client version [2/n]

Summary:
This stack takes care of handling care of moving all device interactions over the (possible) async channel FlipperServer. The FlipperServer interface (see previous diff) allows listening to specific server events using `on`, and emit commands to be executed by the server by using `exec` (e.g. `exec('take-screenshot', serial) => Promise<buffer>`).

FlipperServerImpl implements this interface on the server side.

The device implementations are split as follows

```
server / backend process:

ServerDevice
- iOSDevice
- AndroidDevice
- MetroDevice
- DummyDevice
- Mac/Windows Device

frontend / ui:

BaseDevice: a normal connected, device, implements device apis as they already existed
- ArchivedDevice (note that this doesn't have a server counterpart)
- TestDevice (for unit tests, with stubbed backend communication)

```

All features of devices are for simplicity unified (since the deviations are small), where specific device types might not implement certain features like taking screenshots or running shell commands.

To avoid making this diff unnecessarily big, some open Todo's will be addressed later in this stack, and it shouldn't be landed alone.

Reviewed By: timur-valiev

Differential Revision: D30909346

fbshipit-source-id: cce0bee94fdd5db59bebe3577a6084219a038719
This commit is contained in:
Michel Weststrate
2021-09-22 09:01:29 -07:00
committed by Facebook GitHub Bot
parent 845d0755f1
commit 2d838efd4d
58 changed files with 869 additions and 396 deletions

View File

@@ -9,7 +9,7 @@
import fs from 'fs';
import path from 'path';
import {BaseDevice, AndroidDevice, IOSDevice, getAppPath} from 'flipper';
import {BaseDevice, getAppPath} from 'flipper';
import {AppMatchPattern} from '../types';
let patternsPath: string | undefined;
@@ -34,9 +34,9 @@ export const getAppMatchPatterns = (
const appName = extractAppNameFromSelectedApp(selectedApp);
if (appName === 'Facebook') {
let filename: string;
if (device instanceof AndroidDevice) {
if (device.os === 'Android') {
filename = 'facebook-match-patterns-android.json';
} else if (device instanceof IOSDevice) {
} else if (device.os === 'iOS') {
filename = 'facebook-match-patterns-ios.json';
} else {
return;