Moved navigation inside of Android Device

Summary:
It makes more sense for the navigation ability to be inside the Device's class instead of scattered throughout the rest of the app.

I have moved the Android navigation logic inside the AndroidDevice and added a function stub to BaseDevice. I also encoded the URI as an initial safeguard to injection attacks via adb, but will remove this altogether once I enable navigation through the socket connection.

Reviewed By: jknoxville

Differential Revision: D16182374

fbshipit-source-id: be3c6d1cfcbe293583edada1f77c023965dfd12c
This commit is contained in:
Benjamin Elo
2019-07-10 09:04:26 -07:00
committed by Facebook Github Bot
parent ee5091c742
commit 222676eb44
3 changed files with 11 additions and 3 deletions

View File

@@ -28,9 +28,8 @@ const DropdownButton = styled(Button)({
class LocationsButton extends Component<Props> {
goToLocation = (location: string) => {
const {selectedDevice} = this.props;
if (selectedDevice instanceof AndroidDevice) {
const shellCommand = `am start ${location}`;
selectedDevice.adb.shell(selectedDevice.serial, shellCommand);
if (selectedDevice != null) {
selectedDevice.navigateToLocation(location);
}
};

View File

@@ -97,4 +97,9 @@ export default class AndroidDevice extends BaseDevice {
[...this.logEntries],
);
}
navigateToLocation(location: string) {
const shellCommand = `am start ${encodeURI(location)}`;
this.adb.shell(this.serial, shellCommand);
}
}

View File

@@ -139,6 +139,10 @@ export default class BaseDevice {
throw new Error('unimplemented');
}
navigateToLocation(location: string) {
throw new Error('unimplemented');
}
archive(): ?ArchivedDevice {
return null;
}