Cleaned up deviceType enum

Summary:
The device type enum was mixing two different concepts (emulator vs physical) and (archived vs not), and we already have a separate `isArchived` field. So cleaned this up to not leak it into sandy.

If anybody can think of any unforeseen consequences of this, lemme know :)

Reviewed By: jknoxville

Differential Revision: D22763506

fbshipit-source-id: bd2f7dbd1d2d2e6942ba7c6ddd8dc91ee34d591d
This commit is contained in:
Michel Weststrate
2020-08-04 07:44:56 -07:00
committed by Facebook GitHub Bot
parent fbb1c78184
commit d538b66088
10 changed files with 36 additions and 45 deletions

View File

@@ -32,10 +32,14 @@ export type LogLevel =
| 'fatal';
export interface Device {
isArchived: boolean;
readonly isArchived: boolean;
readonly os: string;
readonly deviceType: DeviceType;
onLogEntry(cb: DeviceLogListener): () => void;
}
export type DeviceType = 'emulator' | 'physical';
export type DevicePluginPredicate = (device: Device) => boolean;
export type DevicePluginFactory = (client: DevicePluginClient) => object;
@@ -48,7 +52,9 @@ export interface DevicePluginClient extends BasePluginClient {
* Wrapper interface around BaseDevice in Flipper
*/
export interface RealFlipperDevice {
os: string;
isArchived: boolean;
deviceType: DeviceType;
addLogListener(callback: DeviceLogListener): Symbol;
removeLogListener(id: Symbol): void;
addLogEntry(entry: DeviceLogEntry): void;
@@ -69,9 +75,11 @@ export class SandyDevicePluginInstance extends BasePluginInstance {
) {
super(definition, initialStates);
const device: Device = {
get isArchived() {
return realDevice.isArchived;
},
// N.B. we model OS as string, not as enum, to make custom device types possible in the future
os: realDevice.os,
isArchived: realDevice.isArchived,
deviceType: realDevice.deviceType,
onLogEntry(cb) {
const handle = realDevice.addLogListener(cb);
return () => {