From 4cb82c1f1dc1e2d1dcc48f29bdae231868b23790 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Tue, 18 Dec 2018 03:15:48 -0800 Subject: [PATCH] Avoid media indexing on Android Summary: Record Android screen captures into a separate directory with a `.nomedia` file to avoid it from getting indexed before it gets removed after being pulled. Reviewed By: danielbuechele Differential Revision: D13465448 fbshipit-source-id: 4449ff3a927cc8621b015b018d2b743cedc4ce8c --- src/chrome/ScreenCaptureButtons.js | 32 ++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/chrome/ScreenCaptureButtons.js b/src/chrome/ScreenCaptureButtons.js index 9ff9ad732..523f376c2 100644 --- a/src/chrome/ScreenCaptureButtons.js +++ b/src/chrome/ScreenCaptureButtons.js @@ -155,13 +155,27 @@ class ScreenCaptureButtons extends Component { const videoPath = path.join(CAPTURE_LOCATION, getFileName('mp4')); this.videoPath = videoPath; if (selectedDevice instanceof AndroidDevice) { + const devicePath = '/sdcard/flipper_recorder'; + this.setState({ recording: true, }); + this.executeShell( selectedDevice, - `screenrecord --bugreport /sdcard/video.mp4`, + `mkdir -p "${devicePath}" && touch "${devicePath}/.nomedia"`, ) + .then(output => { + if (output) { + throw output; + } + }) + .then(() => + this.executeShell( + selectedDevice, + `screenrecord --bugreport "${devicePath}/video.mp4"`, + ), + ) .then(output => { if (output) { throw output; @@ -174,17 +188,19 @@ class ScreenCaptureButtons extends Component { }); }) .then( - (): Promise => { - return this.pullFromDevice( + (): Promise => + this.pullFromDevice( selectedDevice, - `/sdcard/video.mp4`, + `${devicePath}/video.mp4`, videoPath, - ); - }, + ), ) .then(openFile) - .then(() => { - this.executeShell(selectedDevice, `rm /sdcard/video.mp4`); + .then(() => this.executeShell(selectedDevice, `rm -rf "${devicePath}"`)) + .then(output => { + if (output) { + throw output; + } }) .then(() => { this.setState({