microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/debugger/android/androidPlatform.ts
31lines · 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"; | |
f8d32439dlebu10 years ago | 5 | import {IAppPlatform} from "../platformResolver"; |
eb2a5b33dlebu10 years ago | 6 | import {IRunOptions} from "../launchArgs"; |
b0061ac6Meena Kunnathur Balakrishnan10 years ago | 7 | import {CommandExecutor} from "../../common/commandExecutor"; |
| 8 | import {Package} from "../../common/node/package"; | |
8953be57dlebu10 years ago | 9 | import {PackageNameResolver} from "../../common/android/packageNameResolver"; |
e639e7a4Daniel10 years ago | 10 | |
| 11 | /** | |
| 12 | * Android specific platform implementation for debugging RN applications. | |
| 13 | */ | |
f8d32439dlebu10 years ago | 14 | export class AndroidPlatform implements IAppPlatform { |
bc7a32ceJimmy Thomson10 years ago | 15 | |
e639e7a4Daniel10 years ago | 16 | public runApp(runOptions: IRunOptions): Q.Promise<void> { |
f8d32439dlebu10 years ago | 17 | return new CommandExecutor(runOptions.projectRoot).spawnAndWaitReactCommand("run-android"); |
e639e7a4Daniel10 years ago | 18 | } |
| 19 | | |
| 20 | public enableJSDebuggingMode(runOptions: IRunOptions): Q.Promise<void> { | |
| 21 | let pkg = new Package(runOptions.projectRoot); | |
8953be57dlebu10 years ago | 22 | |
e639e7a4Daniel10 years ago | 23 | return pkg.name() |
2010d4e2dlebu10 years ago | 24 | .then(appName => new PackageNameResolver(appName).resolvePackageName(runOptions.projectRoot)) |
8953be57dlebu10 years ago | 25 | .then(packageName => { |
| 26 | let enableDebugCommand = `adb shell am broadcast -a "${packageName.toLowerCase()}.RELOAD_APP_ACTION" --ez jsproxy true`; | |
e639e7a4Daniel10 years ago | 27 | let cexec = new CommandExecutor(runOptions.projectRoot); |
| 28 | return cexec.execute(enableDebugCommand); | |
| 29 | }); | |
| 30 | } | |
| 31 | } |