From 7358711e07d83d504ca2b997f0784bdb88522972 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Wed, 30 Sep 2020 10:08:47 -0700 Subject: [PATCH] Enable screenshot for physical devices Summary: Uses idb to get screenshot for physical devices. Reviewed By: jknoxville Differential Revision: D24017656 fbshipit-source-id: 89ffd17259d6f94d03a1442ffb341b79797f260b --- desktop/app/src/devices/IOSDevice.tsx | 5 ++++- desktop/app/src/init.tsx | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/desktop/app/src/devices/IOSDevice.tsx b/desktop/app/src/devices/IOSDevice.tsx index 992438183..21a388d00 100644 --- a/desktop/app/src/devices/IOSDevice.tsx +++ b/desktop/app/src/devices/IOSDevice.tsx @@ -56,7 +56,10 @@ export default class IOSDevice extends BaseDevice { const tmpImageName = uuid() + '.png'; const tmpDirectory = (electron.app || electron.remote.app).getPath('temp'); const tmpFilePath = path.join(tmpDirectory, tmpImageName); - const command = `xcrun simctl io booted screenshot ${tmpFilePath}`; + const command = + this.deviceType === 'emulator' + ? `xcrun simctl io booted screenshot ${tmpFilePath}` + : `idb screenshot --udid ${this.serial} ${tmpFilePath}`; return promisify(exec)(command) .then(() => promisify(fs.readFile)(tmpFilePath)) .then((buffer) => { diff --git a/desktop/app/src/init.tsx b/desktop/app/src/init.tsx index 1bf8f53c4..98d93cfb6 100644 --- a/desktop/app/src/init.tsx +++ b/desktop/app/src/init.tsx @@ -73,6 +73,7 @@ const AppFrame = () => ( function setProcessState(store: Store) { const settings = store.getState().settingsState; const androidHome = settings.androidHome; + const idbPath = settings.idbPath; if (!process.env.ANDROID_HOME) { process.env.ANDROID_HOME = androidHome; @@ -83,7 +84,9 @@ function setProcessState(store: Store) { process.env.PATH = ['emulator', 'tools', 'platform-tools'] .map((directory) => path.resolve(androidHome, directory)) - .join(':') + `:${process.env.PATH}`; + .join(':') + + `:${idbPath}` + + `:${process.env.PATH}`; window.requestIdleCallback(() => { setupPrefetcher(settings);