Back out "Throw error and let user know situation when 'adb shell screenrecord' make error."
Summary:
Original commit changeset: 5caf9df02c95
It backs out the diff as it broke the video recording button in support form.
Bug:
{F227855063}
Reviewed By: passy
Differential Revision: D19742486
fbshipit-source-id: 4a275e6ead919b4f4ed94889545a650c101f89b7
This commit is contained in:
committed by
Facebook Github Bot
parent
1e11d63ba8
commit
4efc2b8400
@@ -102,8 +102,10 @@ class ScreenCaptureButtons extends Component<Props, State> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const videoPath = path.join(CAPTURE_LOCATION, getFileName('mp4'));
|
const videoPath = path.join(CAPTURE_LOCATION, getFileName('mp4'));
|
||||||
await selectedDevice.startScreenCapture(videoPath).catch(e => {
|
await selectedDevice.startScreenCapture(videoPath);
|
||||||
console.error(e);
|
|
||||||
|
this.setState({
|
||||||
|
recording: true,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -112,23 +114,18 @@ class ScreenCaptureButtons extends Component<Props, State> {
|
|||||||
if (!selectedDevice) {
|
if (!selectedDevice) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const path = await selectedDevice.stopScreenCapture().catch(e => {
|
const path = await selectedDevice.stopScreenCapture();
|
||||||
console.error(e);
|
this.setState({
|
||||||
|
recording: false,
|
||||||
});
|
});
|
||||||
path ? openFile(path) : 0;
|
openFile(path);
|
||||||
};
|
};
|
||||||
|
|
||||||
onRecordingClicked = () => {
|
onRecordingClicked = () => {
|
||||||
if (this.state.recording) {
|
if (this.state.recording) {
|
||||||
this.stopRecording();
|
this.stopRecording();
|
||||||
this.setState({
|
|
||||||
recording: false,
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
this.startRecording();
|
this.startRecording();
|
||||||
this.setState({
|
|
||||||
recording: true,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -132,21 +132,6 @@ export default class AndroidDevice extends BaseDevice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async isValidFile(filePath: string): Promise<boolean> {
|
|
||||||
const fileSize = await this.adb
|
|
||||||
.shell(this.serial, `touch "${filePath}" && ls -l "${filePath}"`)
|
|
||||||
.then(adb.util.readAll)
|
|
||||||
.then((output: Buffer) =>
|
|
||||||
output
|
|
||||||
.toString()
|
|
||||||
.trim()
|
|
||||||
.split(' '),
|
|
||||||
)
|
|
||||||
.then(output => Number(output[5]));
|
|
||||||
|
|
||||||
return fileSize > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
async startScreenCapture(destination: string) {
|
async startScreenCapture(destination: string) {
|
||||||
await this.executeShell(
|
await this.executeShell(
|
||||||
`mkdir -p "${DEVICE_RECORDING_DIR}" && echo -n > "${DEVICE_RECORDING_DIR}/.nomedia"`,
|
`mkdir -p "${DEVICE_RECORDING_DIR}" && echo -n > "${DEVICE_RECORDING_DIR}/.nomedia"`,
|
||||||
@@ -155,29 +140,15 @@ export default class AndroidDevice extends BaseDevice {
|
|||||||
this.recordingProcess = this.adb
|
this.recordingProcess = this.adb
|
||||||
.shell(this.serial, `screenrecord --bugreport "${recordingLocation}"`)
|
.shell(this.serial, `screenrecord --bugreport "${recordingLocation}"`)
|
||||||
.then(adb.util.readAll)
|
.then(adb.util.readAll)
|
||||||
.then(
|
|
||||||
output =>
|
|
||||||
new Promise(async (resolve, _) => {
|
|
||||||
const isValid = await this.isValidFile(recordingLocation);
|
|
||||||
if (!isValid) {
|
|
||||||
const outputMessage = output.toString().trim();
|
|
||||||
// throw error immediately
|
|
||||||
throw new Error(
|
|
||||||
'Recording was not properly started: \n' + outputMessage,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
resolve();
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.then(
|
.then(
|
||||||
_ =>
|
_ =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) =>
|
||||||
this.adb.pull(this.serial, recordingLocation).then(stream => {
|
this.adb.pull(this.serial, recordingLocation).then(stream => {
|
||||||
stream.on('end', resolve);
|
stream.on('end', resolve);
|
||||||
stream.on('error', reject);
|
stream.on('error', reject);
|
||||||
stream.pipe(createWriteStream(destination));
|
stream.pipe(createWriteStream(destination));
|
||||||
});
|
}),
|
||||||
}),
|
),
|
||||||
)
|
)
|
||||||
.then(_ => destination);
|
.then(_ => destination);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user