Fixed a bug where the screenshot of some Android phones was unavailable (#4366)
Summary: The 'screenrecord' command is not in some Android phones e.g OPPO. So 'screenrecord' command can't be used as a basis for determining whether or not you can take a screenshot. Replace it with 'screencap' command to determine whether you can take a screenshot. ## Changelog Fixed a bug where the screenshot of some Android phones was unavailable Pull Request resolved: https://github.com/facebook/flipper/pull/4366 Test Plan: It passed the test on my Mac and OPPO phone Reno2. Reviewed By: ivanmisuno Differential Revision: D42918902 Pulled By: passy fbshipit-source-id: c1f02f075817d90e0d447f466a1168b6ec932e4e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
65f0a81fd1
commit
e2867a74a7
@@ -167,6 +167,17 @@ export default class AndroidDevice
|
||||
}
|
||||
}
|
||||
|
||||
async screenShotAvailable(): Promise<boolean> {
|
||||
try {
|
||||
await this.executeShellOrDie(
|
||||
`[ ! -f /system/bin/screencap ] && echo "File does not exist"`,
|
||||
);
|
||||
return true;
|
||||
} catch (_e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async executeShell(command: string): Promise<string> {
|
||||
return await this.adb
|
||||
.shell(this.serial, command)
|
||||
|
||||
@@ -100,12 +100,10 @@ export class AndroidDeviceManager {
|
||||
// The default way of capturing screenshots through adb does not seem to work
|
||||
// There is a way of getting a screenshot through KaiOS dev tools though
|
||||
if (androidLikeDevice instanceof AndroidDevice) {
|
||||
const screenRecordAvailable =
|
||||
await androidLikeDevice.screenRecordAvailable();
|
||||
androidLikeDevice.info.features.screenCaptureAvailable =
|
||||
screenRecordAvailable;
|
||||
await androidLikeDevice.screenRecordAvailable();
|
||||
androidLikeDevice.info.features.screenshotAvailable =
|
||||
screenRecordAvailable;
|
||||
await androidLikeDevice.screenShotAvailable();
|
||||
}
|
||||
|
||||
resolve(androidLikeDevice);
|
||||
|
||||
Reference in New Issue
Block a user