Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@
"category": "React Native",
"enablement": "!config.security.workspace.trust.enabled || isWorkspaceTrusted"
},
{
"command": "reactNative.selectDevice",
"title": "%reactNative.command.selectDevice.title%",
"category": "React Native",
"enablement": "!config.security.workspace.trust.enabled || isWorkspaceTrusted"
},
{
"command": "reactNative.launchExpoWeb",
"title": "%reactNative.command.launchExpoWeb.title%",
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"reactNative.virtualWorkspaces.description": "Debugging is not possible in virtual workspaces.",
"reactNative.command.launchAndroidSimulator.title": "Launch Android Emulator",
"reactNative.command.launchIOSSimulator.title": "Launch iOS Simulator",
"reactNative.command.selectDevice.title": "Select Device",
"reactNative.command.launchExpoWeb.title": "Expo - Launch ExpoWeb",
"reactNative.command.selectAndInsertDebugConfiguration.title": "Select a React Native debug configuration",
"reactNative.command.runAndroidSimulator.title": "Run Android on Emulator",
Expand Down
1 change: 1 addition & 0 deletions src/common/error/errorStrings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,4 +423,5 @@ export const ERROR_STRINGS = {
[InternalErrorCode.FailedToToggleNetworkView]: "Failed to config network view",
[InternalErrorCode.FailedToRunEasBuild]: "Failed to run eas build",
[InternalErrorCode.FailedToInstallPods]: "Failed to install pods",
[InternalErrorCode.FailedToSelectDevice]: "Failed to select device",
};
1 change: 1 addition & 0 deletions src/common/error/internalErrorCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export enum InternalErrorCode {
FailedToToggleNetworkView = 136,
FailedToRunEasBuild = 137,
FailedToInstallPods = 138,
FailedToSelectDevice = 139,

// Device Deployer errors
IOSDeployNotFound = 201,
Expand Down
3 changes: 0 additions & 3 deletions src/debugger/debugSessionBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { ILaunchArgs, IRunOptions, PlatformType } from "../extension/launchArgs"
import type { AppLauncher } from "../extension/appLauncher";
import { RNPackageVersions } from "../common/projectVersionHelper";
import { OutputChannelLogger } from "../extension/log/OutputChannelLogger";
import { DeviceStatusIndicator } from "../extension/deviceStatusIndicator";
import { RNSession } from "./debugSessionWrapper";

nls.config({
Expand Down Expand Up @@ -234,8 +233,6 @@ export abstract class DebugSessionBase extends LoggingDebugSession {
}
}

DeviceStatusIndicator.hide();

this.cancellationTokenSource.cancel();
this.cancellationTokenSource.dispose();

Expand Down
11 changes: 9 additions & 2 deletions src/extension/android/androidTargetManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,19 @@ export class AndroidTargetManager extends MobileTargetManager {
return this.selectTarget(filter);
}

protected async launchSimulator(emulatorTarget: IMobileTarget): Promise<AndroidTarget> {
public async launchSimulator(
emulatorTarget: IMobileTarget,
coldBoot = false,
): Promise<AndroidTarget> {
return new Promise<AndroidTarget>((resolve, reject) => {
let emulatorLaunchFailed = false;
const emulatorProcess = this.childProcess.spawn(
AndroidTargetManager.EMULATOR_COMMAND,
[AndroidTargetManager.EMULATOR_AVD_START_COMMAND, emulatorTarget.name as string],
[
AndroidTargetManager.EMULATOR_AVD_START_COMMAND,
emulatorTarget.name as string,
...(coldBoot ? ["-no-snapshot-load"] : []),
],
{
detached: true,
},
Expand Down
10 changes: 0 additions & 10 deletions src/extension/appLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import { LaunchScenariosManager } from "./launchScenariosManager";
import { createAdditionalWorkspaceFolder, onFolderAdded } from "./rn-extension";
import { RNProjectObserver } from "./rnProjectObserver";
import { GeneralMobilePlatform } from "./generalMobilePlatform";
import { DeviceStatusIndicator } from "./deviceStatusIndicator";

nls.config({
messageFormat: nls.MessageFormat.bundle,
Expand Down Expand Up @@ -205,7 +204,6 @@ export class AppLauncher {
this.packager.getStatusIndicator().dispose();
void this.packager.stop(true);
this.mobilePlatform.dispose();
DeviceStatusIndicator.hide();
}

public async openFileAtLocation(filename: string, lineNumber: number): Promise<void> {
Expand Down Expand Up @@ -341,14 +339,6 @@ export class AppLauncher {
await this.mobilePlatform.runApp();
}

// Show device name in status bar after app is launched
if (this.mobilePlatform instanceof GeneralMobilePlatform) {
const target = this.mobilePlatform.getResolvedTarget();
if (target?.name) {
DeviceStatusIndicator.show(target.name);
}
}

if (mobilePlatformOptions.isDirect) {
if (launchArgs.useHermesEngine) {
generator.step("mobilePlatform.enableHermesDebuggingMode");
Expand Down
1 change: 1 addition & 0 deletions src/extension/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export * from "./runIos";
export * from "./runMacOs";
export * from "./runWindows";
export * from "./selectAndInsertDebugConfiguration";
export * from "./selectDevice";
export * from "./showDevMenu";
export * from "./startLogCatMonitor";
export * from "./startPackager";
Expand Down
18 changes: 18 additions & 0 deletions src/extension/commands/selectDevice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.

import { ErrorHelper } from "../../common/error/errorHelper";
import { InternalErrorCode } from "../../common/error/internalErrorCode";
import { DeviceSelector } from "../deviceSelector";
import { Command } from "./util/command";

export class SelectDevice extends Command {
codeName = "selectDevice";
label = "Select Device";
requiresProject = false;
error = ErrorHelper.getInternalError(InternalErrorCode.FailedToSelectDevice);

async baseFn(): Promise<void> {
await DeviceSelector.instance?.showPicker();
}
}
Loading
Loading