Crash reporter plugin
Summary: This diff adds a static function `onRegisterDevice` which is being called whenever an device gets registered. This callback is used to add loglisterner for android. I even moved the logic of iOS from `onRegisterPlugin` to this callback. The reason for not adding android log listener in `onRegisterPlugin` was that there were cases when baseDevice was not yet registered before calling `onRegisterPlugin`. For android, I want the instance of `BaseDevice` so that I can add logListener on it. Reviewed By: danielbuechele Differential Revision: D13563282 fbshipit-source-id: b5be40f3dbc808bdaeabae28423c563cf2345a22
This commit is contained in:
committed by
Facebook Github Bot
parent
c6efea991d
commit
0048fc6e4a
@@ -11,6 +11,7 @@ import promiseRetry from 'promise-retry';
|
||||
import type {Store} from '../reducers/index.js';
|
||||
import type BaseDevice from '../devices/BaseDevice';
|
||||
import type Logger from '../fb-stubs/Logger.js';
|
||||
import {registerDeviceCallbackOnPlugins} from '../utils/onRegisterDevice.js';
|
||||
const adb = require('adbkit-fb');
|
||||
|
||||
function createDevice(adbClient, device): Promise<AndroidDevice> {
|
||||
@@ -165,6 +166,13 @@ export default (store: Store, logger: Logger) => {
|
||||
type: 'REGISTER_DEVICE',
|
||||
payload: androidDevice,
|
||||
});
|
||||
|
||||
registerDeviceCallbackOnPlugins(
|
||||
store,
|
||||
store.getState().plugins.devicePlugins,
|
||||
store.getState().plugins.clientPlugins,
|
||||
androidDevice,
|
||||
);
|
||||
}
|
||||
|
||||
async function unregisterDevices(deviceIds: Array<string>) {
|
||||
|
||||
@@ -18,7 +18,7 @@ import IOSDevice from '../devices/IOSDevice';
|
||||
import iosUtil from '../fb-stubs/iOSContainerUtility';
|
||||
import isProduction from '../utils/isProduction.js';
|
||||
import GK from '../fb-stubs/GK';
|
||||
|
||||
import {registerDeviceCallbackOnPlugins} from '../utils/onRegisterDevice.js';
|
||||
type iOSSimulatorDevice = {|
|
||||
state: 'Booted' | 'Shutdown' | 'Shutting Down',
|
||||
availability?: string,
|
||||
@@ -70,10 +70,17 @@ function queryDevices(store: Store, logger: Logger): Promise<void> {
|
||||
name: name,
|
||||
serial: udid,
|
||||
});
|
||||
const iOSDevice = new IOSDevice(udid, type, name);
|
||||
store.dispatch({
|
||||
type: 'REGISTER_DEVICE',
|
||||
payload: new IOSDevice(udid, type, name),
|
||||
payload: iOSDevice,
|
||||
});
|
||||
registerDeviceCallbackOnPlugins(
|
||||
store,
|
||||
store.getState().plugins.devicePlugins,
|
||||
store.getState().plugins.clientPlugins,
|
||||
iOSDevice,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,26 +56,6 @@ export default (store: Store, logger: Logger) => {
|
||||
store.dispatch(addFailedPlugins(failedPlugins));
|
||||
store.dispatch(registerPlugins(initialPlugins));
|
||||
|
||||
initialPlugins.forEach(p => {
|
||||
if (p.onRegisterPlugin) {
|
||||
p.onRegisterPlugin(store, (pluginKey: string, newPluginState: any) => {
|
||||
const persistedState = getPersistedState(
|
||||
pluginKey,
|
||||
p,
|
||||
store.getState().pluginStates,
|
||||
);
|
||||
if (newPluginState && newPluginState !== persistedState) {
|
||||
store.dispatch(
|
||||
setPluginState({
|
||||
pluginKey: pluginKey,
|
||||
state: newPluginState,
|
||||
}),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
let state: ?State = null;
|
||||
store.subscribe(() => {
|
||||
const newState = store.getState().plugins;
|
||||
|
||||
Reference in New Issue
Block a user