Reuse adb client in certificate provider
Summary: Avoid making duplicate clients, and this one uses a more reliable creation method. Reviewed By: passy Differential Revision: D14241448 fbshipit-source-id: 95846a373335818758c8c4a282ed4db26b62d986
This commit is contained in:
committed by
Facebook Github Bot
parent
99bb43fe32
commit
6dc2215753
@@ -9,7 +9,6 @@ import type {Logger} from '../fb-interfaces/Logger';
|
||||
import {RecurringError} from './errors';
|
||||
import {promisify} from 'util';
|
||||
const fs = require('fs');
|
||||
const adb = require('adbkit-fb');
|
||||
import {
|
||||
openssl,
|
||||
isInstalled as opensslInstalled,
|
||||
@@ -20,7 +19,8 @@ const tmpFile = promisify(tmp.file);
|
||||
const tmpDir = promisify(tmp.dir);
|
||||
import iosUtil from '../fb-stubs/iOSContainerUtility';
|
||||
import {reportPlatformFailures} from './metrics';
|
||||
import adbConfig from './adbConfig';
|
||||
import {getAdbClient} from './adbClient';
|
||||
const adb = require('adbkit-fb');
|
||||
|
||||
// Desktop file paths
|
||||
const os = require('os');
|
||||
@@ -71,13 +71,13 @@ export type SecureServerConfig = {|
|
||||
*/
|
||||
export default class CertificateProvider {
|
||||
logger: Logger;
|
||||
adb: any;
|
||||
adb: Promise<any>;
|
||||
certificateSetup: Promise<void>;
|
||||
server: Server;
|
||||
|
||||
constructor(server: Server, logger: Logger) {
|
||||
this.logger = logger;
|
||||
this.adb = adb.createClient(adbConfig());
|
||||
this.adb = getAdbClient();
|
||||
this.certificateSetup = reportPlatformFailures(
|
||||
this.ensureServerCertExists(),
|
||||
'ensureServerCertExists',
|
||||
@@ -260,7 +260,9 @@ export default class CertificateProvider {
|
||||
deviceCsrFilePath: string,
|
||||
csr: string,
|
||||
): Promise<string> {
|
||||
return this.adb.listDevices().then((devices: Array<{id: string}>) => {
|
||||
return this.adb
|
||||
.then(client => client.listDevices())
|
||||
.then((devices: Array<{id: string}>) => {
|
||||
const deviceMatchList = devices.map(device =>
|
||||
this.androidDeviceHasMatchingCSR(
|
||||
deviceCsrFilePath,
|
||||
@@ -417,7 +419,9 @@ export default class CertificateProvider {
|
||||
);
|
||||
}
|
||||
return this.adb
|
||||
.shell(deviceId, `echo '${command}' | run-as '${user}'`)
|
||||
.then(client =>
|
||||
client.shell(deviceId, `echo '${command}' | run-as '${user}'`),
|
||||
)
|
||||
.then(adb.util.readAll)
|
||||
.then(buffer => buffer.toString())
|
||||
.then(output => {
|
||||
|
||||
Reference in New Issue
Block a user