Enable screenshot for physical devices

Summary: Uses idb to get screenshot for physical devices.

Reviewed By: jknoxville

Differential Revision: D24017656

fbshipit-source-id: 89ffd17259d6f94d03a1442ffb341b79797f260b
This commit is contained in:
Pritesh Nandgaonkar
2020-09-30 10:08:47 -07:00
committed by Facebook GitHub Bot
parent a92aa126ae
commit 7358711e07
2 changed files with 8 additions and 2 deletions

View File

@@ -56,7 +56,10 @@ export default class IOSDevice extends BaseDevice {
const tmpImageName = uuid() + '.png'; const tmpImageName = uuid() + '.png';
const tmpDirectory = (electron.app || electron.remote.app).getPath('temp'); const tmpDirectory = (electron.app || electron.remote.app).getPath('temp');
const tmpFilePath = path.join(tmpDirectory, tmpImageName); 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) return promisify(exec)(command)
.then(() => promisify(fs.readFile)(tmpFilePath)) .then(() => promisify(fs.readFile)(tmpFilePath))
.then((buffer) => { .then((buffer) => {

View File

@@ -73,6 +73,7 @@ const AppFrame = () => (
function setProcessState(store: Store) { function setProcessState(store: Store) {
const settings = store.getState().settingsState; const settings = store.getState().settingsState;
const androidHome = settings.androidHome; const androidHome = settings.androidHome;
const idbPath = settings.idbPath;
if (!process.env.ANDROID_HOME) { if (!process.env.ANDROID_HOME) {
process.env.ANDROID_HOME = androidHome; process.env.ANDROID_HOME = androidHome;
@@ -83,7 +84,9 @@ function setProcessState(store: Store) {
process.env.PATH = process.env.PATH =
['emulator', 'tools', 'platform-tools'] ['emulator', 'tools', 'platform-tools']
.map((directory) => path.resolve(androidHome, directory)) .map((directory) => path.resolve(androidHome, directory))
.join(':') + `:${process.env.PATH}`; .join(':') +
`:${idbPath}` +
`:${process.env.PATH}`;
window.requestIdleCallback(() => { window.requestIdleCallback(() => {
setupPrefetcher(settings); setupPrefetcher(settings);