@@ -26,9 +26,14 @@ export class AndroidDebugService extends DebugServiceBase implements IPlatformDe
2626 }
2727
2828 public async debugStart ( debugData : IDebugData , debugOptions : IDebugOptions ) : Promise < void > {
29- const projectData = this . $projectDataService . getProjectData ( debugData . projectDir ) ;
3029 await this . $devicesService . initialize ( { platform : this . platform , deviceId : debugData . deviceIdentifier } ) ;
31- const action = ( device : Mobile . IAndroidDevice ) : Promise < void > => this . debugStartCore ( debugData . applicationIdentifier , debugOptions , projectData . projectName ) ;
30+ const projectData = this . $projectDataService . getProjectData ( debugData . projectDir ) ;
31+ const appData : Mobile . IApplicationData = {
32+ appId : debugData . applicationIdentifier ,
33+ projectName : projectData . projectName
34+ } ;
35+
36+ const action = ( device : Mobile . IAndroidDevice ) : Promise < void > => this . debugStartCore ( appData , debugOptions ) ;
3237
3338 await this . $devicesService . execute ( action , this . getCanExecuteAction ( debugData . deviceIdentifier ) ) ;
3439 }
@@ -93,24 +98,29 @@ export class AndroidDebugService extends DebugServiceBase implements IPlatformDe
9398
9499 await this . $devicesService . initialize ( { platform : this . platform , deviceId : debugData . deviceIdentifier } ) ;
95100
96- const packageName = this . $projectDataService . getProjectData ( debugData . projectDir ) . projectName ;
97- const action = ( device : Mobile . IAndroidDevice ) : Promise < string > => this . debugCore ( device , packageFile , debugData . applicationIdentifier , packageName , debugOptions ) ;
101+ const projectName = this . $projectDataService . getProjectData ( debugData . projectDir ) . projectName ;
102+ const appData : Mobile . IApplicationData = {
103+ appId : debugData . applicationIdentifier ,
104+ projectName
105+ } ;
106+
107+ const action = ( device : Mobile . IAndroidDevice ) : Promise < string > => this . debugCore ( device , packageFile , appData , debugOptions ) ;
98108
99109 const deviceActionResult = await this . $devicesService . execute ( action , this . getCanExecuteAction ( debugData . deviceIdentifier ) ) ;
100110 return deviceActionResult [ 0 ] . result ;
101111 }
102112
103- private async debugCore ( device : Mobile . IAndroidDevice , packageFile : string , appId : string , packageName : string , debugOptions : IDebugOptions ) : Promise < string > {
104- await this . printDebugPort ( device . deviceInfo . identifier , appId ) ;
113+ private async debugCore ( device : Mobile . IAndroidDevice , packageFile : string , appData : Mobile . IApplicationData , debugOptions : IDebugOptions ) : Promise < string > {
114+ await this . printDebugPort ( device . deviceInfo . identifier , appData . appId ) ;
105115
106116 if ( debugOptions . start ) {
107- return await this . attachDebugger ( device . deviceInfo . identifier , appId , debugOptions ) ;
117+ return await this . attachDebugger ( device . deviceInfo . identifier , appData . appId , debugOptions ) ;
108118 } else if ( debugOptions . stop ) {
109119 await this . removePortForwarding ( ) ;
110120 return null ;
111121 } else {
112- await this . debugStartCore ( appId , debugOptions , packageName ) ;
113- return await this . attachDebugger ( device . deviceInfo . identifier , appId , debugOptions ) ;
122+ await this . debugStartCore ( appData , debugOptions ) ;
123+ return await this . attachDebugger ( device . deviceInfo . identifier , appData . appId , debugOptions ) ;
114124 }
115125 }
116126
@@ -129,22 +139,21 @@ export class AndroidDebugService extends DebugServiceBase implements IPlatformDe
129139 return this . getChromeDebugUrl ( debugOptions , port ) ;
130140 }
131141
132- private async debugStartCore ( appId : string , debugOptions : IDebugOptions , projectName : string ) : Promise < void > {
142+ private async debugStartCore ( appData : Mobile . IApplicationData , debugOptions : IDebugOptions ) : Promise < void > {
133143 // Arguments passed to executeShellCommand must be in array ([]), but it turned out adb shell "arg with intervals" still works correctly.
134144 // As we need to redirect output of a command on the device, keep using only one argument.
135145 // We could rewrite this with two calls - touch and rm -f , but -f flag is not available on old Android, so rm call will fail when file does not exist.
136-
137- await this . device . applicationManager . stopApplication ( appId ) ;
146+ await this . device . applicationManager . stopApplication ( appData ) ;
138147
139148 if ( debugOptions . debugBrk ) {
140- await this . device . adb . executeShellCommand ( [ `cat /dev/null > /data/local/tmp/${ appId } -debugbreak` ] ) ;
149+ await this . device . adb . executeShellCommand ( [ `cat /dev/null > /data/local/tmp/${ appData . appId } -debugbreak` ] ) ;
141150 }
142151
143- await this . device . adb . executeShellCommand ( [ `cat /dev/null > /data/local/tmp/${ appId } -debugger-started` ] ) ;
152+ await this . device . adb . executeShellCommand ( [ `cat /dev/null > /data/local/tmp/${ appData . appId } -debugger-started` ] ) ;
144153
145- await this . device . applicationManager . startApplication ( appId , projectName ) ;
154+ await this . device . applicationManager . startApplication ( appData ) ;
146155
147- await this . waitForDebugger ( appId ) ;
156+ await this . waitForDebugger ( appData . appId ) ;
148157 }
149158
150159 private async waitForDebugger ( packageName : String ) : Promise < void > {
0 commit comments