Move crash reporting listener to the server

Summary: Changelog: Move crash watcher to the server. Add 'device-crash' event. Add 'device-start-crash-watcher', 'device-stop-crash-watcher' commands. Add 'onDeviceCrash' method to Plugin Client.

Reviewed By: mweststrate

Differential Revision: D33089810

fbshipit-source-id: ed62ee7c1129e5e25af18b444744b0796f567b72
This commit is contained in:
Andrey Goncharov
2021-12-20 11:37:25 -08:00
committed by Facebook GitHub Bot
parent 9fd45b96d2
commit 731749b41f
21 changed files with 519 additions and 426 deletions

View File

@@ -32,6 +32,7 @@ import {
SandyDevicePluginInstance,
Device,
DeviceLogListener,
CrashLogListener,
} from '../plugin/DevicePlugin';
import {BasePluginInstance} from '../plugin/PluginBase';
import {FlipperLib} from '../plugin/FlipperLib';
@@ -553,6 +554,7 @@ function createMockDevice(options?: StartPluginOptions): Device & {
addLogEntry(entry: DeviceLogEntry): void;
} {
const logListeners: (undefined | DeviceLogListener)[] = [];
const crashListeners: (undefined | CrashLogListener)[] = [];
return {
os: 'Android',
deviceType: 'emulator',
@@ -566,6 +568,13 @@ function createMockDevice(options?: StartPluginOptions): Device & {
removeLogListener(idx) {
logListeners[idx as any] = undefined;
},
addCrashListener(cb) {
crashListeners.push(cb);
return (crashListeners.length - 1) as any;
},
removeCrashListener(idx) {
crashListeners[idx as any] = undefined;
},
addLogEntry(entry: DeviceLogEntry) {
logListeners.forEach((f) => f?.(entry));
},