Fix samsung "run-as" warning (#413)
Summary: During client setup, if no device is found with a matching CSR, and any of those devices errored while trying to find that out, surface that error, instead of a generic 'No matching device found'. This means that the warning about some unusable samsung devices now shows again, instead of a generic message. Pull Request resolved: https://github.com/facebook/flipper/pull/413 Reviewed By: passy Differential Revision: D14891185 Pulled By: jknoxville fbshipit-source-id: 8f4cb4e8e04defb429a4ca915b0dab4725495c87
This commit is contained in:
committed by
Facebook Github Bot
parent
ffc6a5fe18
commit
460260d620
@@ -270,19 +270,23 @@ export default class CertificateProvider {
|
|||||||
csr,
|
csr,
|
||||||
)
|
)
|
||||||
.then(isMatch => {
|
.then(isMatch => {
|
||||||
return {id: device.id, isMatch};
|
return {id: device.id, isMatch, error: null};
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
console.error(
|
console.error(
|
||||||
`Unable to check for matching CSR in ${device.id}:${appName}`,
|
`Unable to check for matching CSR in ${device.id}:${appName}`,
|
||||||
logTag,
|
logTag,
|
||||||
);
|
);
|
||||||
return {id: device.id, isMatch: false};
|
return {id: device.id, isMatch: false, error: e};
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
return Promise.all(deviceMatchList).then(devices => {
|
return Promise.all(deviceMatchList).then(devices => {
|
||||||
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);
|
||||||
|
if (erroredDevice) {
|
||||||
|
throw erroredDevice.error;
|
||||||
|
}
|
||||||
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) {
|
||||||
@@ -337,13 +341,8 @@ export default class CertificateProvider {
|
|||||||
deviceId,
|
deviceId,
|
||||||
processName,
|
processName,
|
||||||
`cat ${directory + csrFileName}`,
|
`cat ${directory + csrFileName}`,
|
||||||
)
|
).then(deviceCsr => {
|
||||||
.then(deviceCsr => {
|
|
||||||
return this.santitizeString(deviceCsr.toString()) === csr;
|
return this.santitizeString(deviceCsr.toString()) === csr;
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.error(err, logTag);
|
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,18 +418,14 @@ export default class CertificateProvider {
|
|||||||
.then(buffer => buffer.toString())
|
.then(buffer => buffer.toString())
|
||||||
.then(output => {
|
.then(output => {
|
||||||
if (output.match(appNotDebuggableRegex)) {
|
if (output.match(appNotDebuggableRegex)) {
|
||||||
const e = new Error(
|
throw new Error(
|
||||||
`Android app ${user} is not debuggable. To use it with Flipper, add android:debuggable="true" to the application section of AndroidManifest.xml`,
|
`Android app ${user} is not debuggable. To use it with Flipper, add android:debuggable="true" to the application section of AndroidManifest.xml`,
|
||||||
);
|
);
|
||||||
this.server.emit('error', e);
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
if (output.toLowerCase().match(operationNotPermittedRegex)) {
|
if (output.toLowerCase().match(operationNotPermittedRegex)) {
|
||||||
const e = new Error(
|
throw new Error(
|
||||||
`Your android device (${deviceId}) does not support the adb shell run-as command. We're tracking this at https://github.com/facebook/flipper/issues/92`,
|
`Your android device (${deviceId}) does not support the adb shell run-as command. We're tracking this at https://github.com/facebook/flipper/issues/92`,
|
||||||
);
|
);
|
||||||
this.server.emit('error', e);
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user