Update adbkit and logcat to maintained librarys
Summary: We were using an old unmaintained/abandonned library for communicating with adb server https://github.com/openstf/adbkit This was giving me issues i couldnt figure out when running flipper server. There is a popular fork written in typescript here https://github.com/DeviceFarmer/adbkit but it uses blue bird for promises. There is a fork of the fork here which i have chosen to use which is the same api as above but with es6 promises, https://github.com/UrielCh/adbkit. Both forks have a slightly different api to the original. In the original library there was a single client and any command directed at a particular device had a serial as the first argument In the new libraries you create a DeviceClient where the serial is baked in and you don't need to supply this argument every time allow-large-files Reviewed By: lblasa Differential Revision: D45569652 fbshipit-source-id: 2a23c0eaa12feaebdccadb3d343e087c0d5708d5
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e2d5cc4607
commit
898e9c3b07
@@ -10,7 +10,7 @@
|
||||
import AndroidDevice from './AndroidDevice';
|
||||
import KaiOSDevice from './KaiOSDevice';
|
||||
import child_process from 'child_process';
|
||||
import {Client as ADBClient, Device} from 'adbkit';
|
||||
import {Client as ADBClient, Device} from '@u4/adbkit';
|
||||
import {join} from 'path';
|
||||
import {FlipperServerImpl} from '../../FlipperServerImpl';
|
||||
import {notNull} from '../../utils/typeUtils';
|
||||
@@ -26,10 +26,7 @@ export class AndroidDeviceManager {
|
||||
this.certificateProvider = new AndroidCertificateProvider(this.adbClient);
|
||||
}
|
||||
|
||||
private createDevice(
|
||||
adbClient: ADBClient,
|
||||
device: Device,
|
||||
): Promise<AndroidDevice | undefined> {
|
||||
private createDevice(device: Device): Promise<AndroidDevice | undefined> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const type =
|
||||
device.type !== 'device' || device.id.startsWith('emulator')
|
||||
@@ -37,7 +34,9 @@ export class AndroidDeviceManager {
|
||||
: 'physical';
|
||||
|
||||
try {
|
||||
const props = await adbClient.getProperties(device.id);
|
||||
const deviceClient = device.getClient();
|
||||
|
||||
const props = await deviceClient.getProperties();
|
||||
try {
|
||||
let name = props['ro.product.model'];
|
||||
const abiString = props['ro.product.cpu.abilist'] || '';
|
||||
@@ -56,7 +55,7 @@ export class AndroidDeviceManager {
|
||||
device.id,
|
||||
type,
|
||||
name,
|
||||
adbClient,
|
||||
deviceClient,
|
||||
abiList,
|
||||
sdkVersion,
|
||||
);
|
||||
@@ -195,7 +194,7 @@ export class AndroidDeviceManager {
|
||||
const devices = await this.adbClient.listDevices();
|
||||
for (const device of devices) {
|
||||
if (device.type !== 'offline') {
|
||||
this.registerDevice(this.adbClient, device);
|
||||
this.registerDevice(device);
|
||||
} else {
|
||||
this.handleOfflineDevice(device);
|
||||
}
|
||||
@@ -237,7 +236,7 @@ export class AndroidDeviceManager {
|
||||
return;
|
||||
}
|
||||
if (device.type !== 'offline') {
|
||||
this.registerDevice(this.adbClient, device);
|
||||
this.registerDevice(device);
|
||||
} else {
|
||||
this.handleOfflineDevice(device);
|
||||
}
|
||||
@@ -247,7 +246,7 @@ export class AndroidDeviceManager {
|
||||
if (device.type === 'offline') {
|
||||
this.flipperServer.unregisterDevice(device.id);
|
||||
} else {
|
||||
this.registerDevice(this.adbClient, device);
|
||||
this.registerDevice(device);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -273,8 +272,8 @@ export class AndroidDeviceManager {
|
||||
);
|
||||
}
|
||||
|
||||
private async registerDevice(adbClient: ADBClient, deviceData: Device) {
|
||||
const androidDevice = await this.createDevice(adbClient, deviceData);
|
||||
private async registerDevice(deviceData: Device) {
|
||||
const androidDevice = await this.createDevice(deviceData);
|
||||
if (!androidDevice) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user