Set device features on device initialization
Summary: 1. Identify if device supports screenshots/screen recording when it is created. 2. Disable screen recording/screenshot buttons when they are not supported Reviewed By: passy Differential Revision: D34611133 fbshipit-source-id: 82ad2d67e4af482d9becf7995187667b5d99bc36
This commit is contained in:
committed by
Facebook GitHub Bot
parent
04e7c7282b
commit
6c74f2dd18
@@ -45,6 +45,10 @@ export default class ArchivedDevice extends BaseDevice {
|
||||
os: options.os,
|
||||
serial: options.serial,
|
||||
icon: 'box',
|
||||
features: {
|
||||
screenCaptureAvailable: false,
|
||||
screenshotAvailable: false,
|
||||
},
|
||||
},
|
||||
);
|
||||
this.connected.set(false);
|
||||
|
||||
@@ -235,32 +235,15 @@ export default class BaseDevice implements Device {
|
||||
return this.flipperServer.exec('device-navigate', this.serial, location);
|
||||
}
|
||||
|
||||
async screenshotAvailable(): Promise<boolean> {
|
||||
if (this.isArchived) {
|
||||
return false;
|
||||
}
|
||||
return this.flipperServer.exec('device-supports-screenshot', this.serial);
|
||||
}
|
||||
|
||||
async screenshot(): Promise<Uint8Array> {
|
||||
if (this.isArchived) {
|
||||
return new Uint8Array();
|
||||
async screenshot(): Promise<Uint8Array | undefined> {
|
||||
if (!this.description.features.screenshotAvailable || this.isArchived) {
|
||||
return;
|
||||
}
|
||||
return Base64.toUint8Array(
|
||||
await this.flipperServer.exec('device-take-screenshot', this.serial),
|
||||
);
|
||||
}
|
||||
|
||||
async screenCaptureAvailable(): Promise<boolean> {
|
||||
if (this.isArchived) {
|
||||
return false;
|
||||
}
|
||||
return this.flipperServer.exec(
|
||||
'device-supports-screencapture',
|
||||
this.serial,
|
||||
);
|
||||
}
|
||||
|
||||
async startScreenCapture(destination: string): Promise<void> {
|
||||
return this.flipperServer.exec(
|
||||
'device-start-screencapture',
|
||||
|
||||
@@ -26,6 +26,10 @@ export class TestDevice extends BaseDevice {
|
||||
title,
|
||||
os,
|
||||
specs,
|
||||
features: {
|
||||
screenCaptureAvailable: false,
|
||||
screenshotAvailable: false,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user