Clean AndroidCertificateProvider
Summary: Remove debug logs and add re-format other warn logs to have parity with iOS Reviewed By: antonk52 Differential Revision: D47330455 fbshipit-source-id: ac8edde2124bbe99d0ea11f46f3b85dd77b96c7b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f8e51dc847
commit
c15ac08714
@@ -32,24 +32,12 @@ export default class AndroidCertificateProvider extends CertificateProvider {
|
|||||||
appDirectory: string,
|
appDirectory: string,
|
||||||
csr: string,
|
csr: string,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
console.debug(
|
|
||||||
'AndroidCertificateProvider.getTargetDeviceId',
|
|
||||||
appName,
|
|
||||||
appDirectory,
|
|
||||||
csr,
|
|
||||||
);
|
|
||||||
const devicesInAdb = await this.adb.listDevices();
|
const devicesInAdb = await this.adb.listDevices();
|
||||||
if (devicesInAdb.length === 0) {
|
if (devicesInAdb.length === 0) {
|
||||||
throw new Error('No Android devices found');
|
throw new Error('No Android devices found');
|
||||||
}
|
}
|
||||||
const deviceMatchList = devicesInAdb.map(async (device) => {
|
const deviceMatchList = devicesInAdb.map(async (device) => {
|
||||||
try {
|
try {
|
||||||
console.debug(
|
|
||||||
'AndroidCertificateProvider.getTargetDeviceId -> matching device',
|
|
||||||
device.id,
|
|
||||||
appName,
|
|
||||||
appDirectory,
|
|
||||||
);
|
|
||||||
const result = await this.androidDeviceHasMatchingCSR(
|
const result = await this.androidDeviceHasMatchingCSR(
|
||||||
appDirectory,
|
appDirectory,
|
||||||
device.id,
|
device.id,
|
||||||
@@ -59,7 +47,7 @@ export default class AndroidCertificateProvider extends CertificateProvider {
|
|||||||
return {id: device.id, ...result, error: null};
|
return {id: device.id, ...result, error: null};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn(
|
console.warn(
|
||||||
`Unable to check for matching CSR in ${device.id}:${appName}`,
|
`[conn] Unable to check for matching CSR in ${device.id}:${appName}`,
|
||||||
logTag,
|
logTag,
|
||||||
e,
|
e,
|
||||||
);
|
);
|
||||||
@@ -68,6 +56,7 @@ export default class AndroidCertificateProvider extends CertificateProvider {
|
|||||||
});
|
});
|
||||||
const devices = await Promise.all(deviceMatchList);
|
const devices = await Promise.all(deviceMatchList);
|
||||||
const matchingIds = devices.filter((m) => m.isMatch).map((m) => m.id);
|
const matchingIds = devices.filter((m) => m.isMatch).map((m) => m.id);
|
||||||
|
|
||||||
if (matchingIds.length == 0) {
|
if (matchingIds.length == 0) {
|
||||||
const erroredDevice = devices.find((d) => d.error);
|
const erroredDevice = devices.find((d) => d.error);
|
||||||
if (erroredDevice) {
|
if (erroredDevice) {
|
||||||
@@ -76,20 +65,15 @@ export default class AndroidCertificateProvider extends CertificateProvider {
|
|||||||
const foundCsrs = devices
|
const foundCsrs = devices
|
||||||
.filter((d) => d.foundCsr !== null)
|
.filter((d) => d.foundCsr !== null)
|
||||||
.map((d) => (d.foundCsr ? encodeURI(d.foundCsr) : 'null'));
|
.map((d) => (d.foundCsr ? encodeURI(d.foundCsr) : 'null'));
|
||||||
console.warn(`Looking for CSR (url encoded):
|
console.warn(
|
||||||
|
`[conn] Looking for CSR (url encoded):${encodeURI(
|
||||||
${encodeURI(this.santitizeString(csr))}
|
this.santitizeString(csr),
|
||||||
|
)} Found these:${foundCsrs.join('\n\n')}`,
|
||||||
Found these:
|
);
|
||||||
|
|
||||||
${foundCsrs.join('\n\n')}`);
|
|
||||||
throw new Error(`No matching device found for app: ${appName}`);
|
throw new Error(`No matching device found for app: ${appName}`);
|
||||||
}
|
}
|
||||||
if (matchingIds.length > 1) {
|
if (matchingIds.length > 1) {
|
||||||
console.warn(
|
console.warn(`[conn] Multiple devices found for app: ${appName}`);
|
||||||
new Error('[conn] More than one matching device found for CSR'),
|
|
||||||
csr,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return matchingIds[0];
|
return matchingIds[0];
|
||||||
}
|
}
|
||||||
@@ -135,14 +119,7 @@ export default class AndroidCertificateProvider extends CertificateProvider {
|
|||||||
deviceCsr.toString(),
|
deviceCsr.toString(),
|
||||||
csr,
|
csr,
|
||||||
].map((s) => this.santitizeString(s));
|
].map((s) => this.santitizeString(s));
|
||||||
console.debug(
|
|
||||||
'AndroidCertificateProvider.androidDeviceHasMatchingCSR',
|
|
||||||
directory,
|
|
||||||
deviceId,
|
|
||||||
processName,
|
|
||||||
sanitizedDeviceCsr,
|
|
||||||
sanitizedClientCsr,
|
|
||||||
);
|
|
||||||
const isMatch = sanitizedDeviceCsr === sanitizedClientCsr;
|
const isMatch = sanitizedDeviceCsr === sanitizedClientCsr;
|
||||||
return {isMatch: isMatch, foundCsr: sanitizedDeviceCsr};
|
return {isMatch: isMatch, foundCsr: sanitizedDeviceCsr};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user