@@ -3,31 +3,54 @@ import { AndroidDeviceHashService } from "../../common/mobile/android/android-de
33import * as helpers from "../../common/helpers" ;
44import * as path from "path" ;
55import * as net from "net" ;
6+ import { EOL } from "os" ;
67
7- class AndroidLiveSyncService implements INativeScriptDeviceLiveSyncService {
8+ export class AndroidLiveSyncService implements INativeScriptDeviceLiveSyncService {
89 private static BACKEND_PORT = 18182 ;
910 private device : Mobile . IAndroidDevice ;
1011
1112 constructor ( _device : Mobile . IDevice ,
1213 private $mobileHelper : Mobile . IMobileHelper ,
1314 private $injector : IInjector ,
14- private $androidDebugService : IDebugService ,
15+ private $logger : ILogger ,
16+ private $androidDebugService : IPlatformDebugService ,
1517 private $liveSyncProvider : ILiveSyncProvider ) {
1618 this . device = < Mobile . IAndroidDevice > ( _device ) ;
1719 }
1820
19- public get debugService ( ) : IDebugService {
21+ public get debugService ( ) : IPlatformDebugService {
2022 return this . $androidDebugService ;
2123 }
2224
23- public async refreshApplication ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] , forceExecuteFullSync : boolean , projectData : IProjectData ) : Promise < void > {
25+ public async refreshApplication ( deviceAppData : Mobile . IDeviceAppData ,
26+ localToDevicePaths : Mobile . ILocalToDevicePathData [ ] ,
27+ forceExecuteFullSync : boolean ,
28+ projectData : IProjectData ,
29+ outputFilePath ?: string ,
30+ debugData ?: IDebugData ,
31+ debugOptions ?: IOptions ) : Promise < void > {
32+
33+ if ( debugData ) {
34+ // TODO: Move this outside of here
35+ await this . debugService . debugStop ( ) ;
36+
37+ let applicationId = deviceAppData . appIdentifier ;
38+ await deviceAppData . device . applicationManager . stopApplication ( applicationId , projectData . projectName ) ;
39+
40+ debugData . pathToAppPackage = outputFilePath ;
41+ const debugInfo = await this . debugService . debug < string [ ] > ( debugData , debugOptions ) ;
42+ this . printDebugInformation ( debugInfo ) ;
43+
44+ return ;
45+ }
46+
2447 await this . device . adb . executeShellCommand (
2548 [ "chmod" ,
26- "777" ,
27- await deviceAppData . getDeviceProjectRootPath ( ) ,
28- `/data/local/tmp/${ deviceAppData . appIdentifier } ` ,
29- `/data/local/tmp/${ deviceAppData . appIdentifier } /sync` ]
30- ) ;
49+ "777" ,
50+ await deviceAppData . getDeviceProjectRootPath ( ) ,
51+ `/data/local/tmp/${ deviceAppData . appIdentifier } ` ,
52+ `/data/local/tmp/${ deviceAppData . appIdentifier } /sync` ]
53+ ) ;
3154
3255 let canExecuteFastSync = ! forceExecuteFullSync && ! _ . some ( localToDevicePaths , ( localToDevicePath : any ) => ! this . $liveSyncProvider . canExecuteFastSync ( localToDevicePath . getLocalPath ( ) , projectData , deviceAppData . platform ) ) ;
3356
@@ -38,6 +61,12 @@ class AndroidLiveSyncService implements INativeScriptDeviceLiveSyncService {
3861 return this . restartApplication ( deviceAppData ) ;
3962 }
4063
64+ protected printDebugInformation ( information : string [ ] ) : void {
65+ _ . each ( information , i => {
66+ this . $logger . info ( `To start debugging, open the following URL in Chrome:${ EOL } ${ i } ${ EOL } ` . cyan ) ;
67+ } ) ;
68+ }
69+
4170 private async restartApplication ( deviceAppData : Mobile . IDeviceAppData ) : Promise < void > {
4271 let devicePathRoot = `/data/data/${ deviceAppData . appIdentifier } /files` ;
4372 let devicePath = this . $mobileHelper . buildDevicePath ( devicePathRoot , "code_cache" , "secondary_dexes" , "proxyThumb" ) ;
0 commit comments