microsoft/vscode-react-native
Publicmirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable
src/debugger/android/androidPlatform.ts
34lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT license. See LICENSE file in the project root for details. |
| 3 | |
| 4 | import * as Q from "q"; |
| 5 | import {IMobilePlatform} from "../platformResolver"; |
| 6 | import {IRunOptions} from "../launchArgs"; |
| 7 | import {CommandExecutor} from "../../utils/commands/commandExecutor"; |
| 8 | import {Package} from "../../utils/node/package"; |
| 9 | import {IDesktopPlatform} from "../platformResolver"; |
| 10 | |
| 11 | /** |
| 12 | * Android specific platform implementation for debugging RN applications. |
| 13 | */ |
| 14 | export class AndroidPlatform implements IMobilePlatform { |
| 15 | private desktopPlatform: IDesktopPlatform; |
| 16 | |
| 17 | constructor(desktopPlatform: IDesktopPlatform) { |
| 18 | this.desktopPlatform = desktopPlatform; |
| 19 | } |
| 20 | |
| 21 | public runApp(runOptions: IRunOptions): Q.Promise<void> { |
| 22 | return new CommandExecutor(runOptions.projectRoot).spawn(this.desktopPlatform.reactNativeCommandName, ["run-android"]); |
| 23 | } |
| 24 | |
| 25 | public enableJSDebuggingMode(runOptions: IRunOptions): Q.Promise<void> { |
| 26 | let pkg = new Package(runOptions.projectRoot); |
| 27 | return pkg.name() |
| 28 | .then(name => { |
| 29 | let enableDebugCommand = `adb shell am broadcast -a "com.${name.toLowerCase()}.RELOAD_APP_ACTION" --ez jsproxy true`; |
| 30 | let cexec = new CommandExecutor(runOptions.projectRoot); |
| 31 | return cexec.execute(enableDebugCommand); |
| 32 | }); |
| 33 | } |
| 34 | } |