From 8ff1411f91fa531860a8387ff15a51152b50958d Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Mon, 29 Jun 2020 07:16:18 -0700 Subject: [PATCH] Fix screen recording on Android 11 Summary: Instead of relying on system blocks used, we use the file size reported by ls. Android 11 seems to be more lazy when it comes to fsync'ing so there's a pretty good chance that if we just check for with `du` or `ls -ls` we will see an "empty" file because it hasn't been written to disk yet. By the normal `ls` output instead, we'll just read the file and see how many bytes it's long, which should be more accurate in all cases. Changelog: Fix screen recording for Android 11 beta Reviewed By: jknoxville Differential Revision: D22283092 fbshipit-source-id: 6d33ca297f1c0734ab4ffc466d9e483aa1a1bdb5 --- desktop/app/src/devices/AndroidDevice.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/desktop/app/src/devices/AndroidDevice.tsx b/desktop/app/src/devices/AndroidDevice.tsx index 8eadf8fdd..47d90e532 100644 --- a/desktop/app/src/devices/AndroidDevice.tsx +++ b/desktop/app/src/devices/AndroidDevice.tsx @@ -141,14 +141,12 @@ export default class AndroidDevice extends BaseDevice { private async isValidFile(filePath: string): Promise { const fileSize = await this.adb - .shell(this.serial, `du "${filePath}"`) + .shell(this.serial, `ls -l "${filePath}"`) .then(adb.util.readAll) - .then((output: Buffer) => output.toString().trim().split('\t')) - .then((x) => Number(x[0])); + .then((output: Buffer) => output.toString().trim().split(' ')) + .then((x) => Number(x[4])); - // 4 is what an empty file (touch file) already takes up, so it's - // definitely not a valid video file. - return fileSize > 4; + return fileSize > 0; } async startScreenCapture(destination: string) {