microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/debugger/android/androidPlatform.ts
34lines · modeblame
e639e7a4Daniel10 years ago | 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"; | |
bc7a32ceJimmy Thomson10 years ago | 5 | import {IMobilePlatform, IDesktopPlatform} from "../platformResolver"; |
eb2a5b33dlebu10 years ago | 6 | import {IRunOptions} from "../launchArgs"; |
| 7 | import {CommandExecutor} from "../../utils/commands/commandExecutor"; | |
| 8 | import {Package} from "../../utils/node/package"; | |
fb8f49fbMeena Kunnathur Balakrishnan10 years ago | 9 | import {ReactNativeCommandExecutor} from "../../utils/reactNativeCommandExecutor"; |
e639e7a4Daniel10 years ago | 10 | |
| 11 | /** | |
| 12 | * Android specific platform implementation for debugging RN applications. | |
| 13 | */ | |
| 14 | export class AndroidPlatform implements IMobilePlatform { | |
bc7a32ceJimmy Thomson10 years ago | 15 | private desktopPlatform: IDesktopPlatform; |
| 16 | | |
| 17 | constructor(desktopPlatform: IDesktopPlatform) { | |
| 18 | this.desktopPlatform = desktopPlatform; | |
| 19 | } | |
| 20 | | |
e639e7a4Daniel10 years ago | 21 | public runApp(runOptions: IRunOptions): Q.Promise<void> { |
e54a23ceMeena Kunnathur Balakrishnan10 years ago | 22 | return new ReactNativeCommandExecutor(runOptions.projectRoot).executeReactNativeCommand("run-android"); |
e639e7a4Daniel10 years ago | 23 | } |
| 24 | | |
| 25 | public enableJSDebuggingMode(runOptions: IRunOptions): Q.Promise<void> { | |
| 26 | let pkg = new Package(runOptions.projectRoot); | |
| 27 | return pkg.name() | |
| 28 | .then(name => { | |
eb2a5b33dlebu10 years ago | 29 | let enableDebugCommand = `adb shell am broadcast -a "com.${name.toLowerCase()}.RELOAD_APP_ACTION" --ez jsproxy true`; |
e639e7a4Daniel10 years ago | 30 | let cexec = new CommandExecutor(runOptions.projectRoot); |
| 31 | return cexec.execute(enableDebugCommand); | |
| 32 | }); | |
| 33 | } | |
| 34 | } |