Decouple CertificateProvider and adb/idb client intialization

Summary:
Previously CertificateProvider initialized ADB and provided config to IDB. As result, AndroidDeviceManager and iOSDeviceManager indirectly depended on CertificateProvider.

With this diff we:
1. Make idbConfig resemble adbClient.
2. Make AndroidDeviceManager and iOSDeviceManager initialize their own clients
3. Fix server crash when one of the clients couldn't be initialized. The reason for the crash is CertificateProvider.prototype.init which is no longer needed.

Reviewed By: passy

Differential Revision: D33711652

fbshipit-source-id: 055b5625ed993827b65396f4af5157808479242b
This commit is contained in:
Andrey Goncharov
2022-01-26 03:57:46 -08:00
committed by Facebook GitHub Bot
parent 1255621cba
commit da618fd3f3
9 changed files with 101 additions and 72 deletions

View File

@@ -10,9 +10,7 @@
import AndroidDevice from './AndroidDevice';
import KaiOSDevice from './KaiOSDevice';
import child_process from 'child_process';
import {getAdbClient} from './adbClient';
import which from 'which';
import {promisify} from 'util';
import {setAdbClient} from './adbClient';
import {Client as ADBClient, Device} from 'adbkit';
import {join} from 'path';
import {FlipperServerImpl} from '../../FlipperServerImpl';
@@ -172,7 +170,13 @@ export class AndroidDeviceManager {
async watchAndroidDevices() {
try {
const client = await getAdbClient(getFlipperServerConfig().settings);
const client = await setAdbClient(getFlipperServerConfig().settings);
if (!client) {
throw new Error(
'AndroidDeviceManager.watchAndroidDevices -> adb not initialized',
);
}
client
.trackDevices()
.then((tracker) => {