@@ -13,7 +13,8 @@ export class AndroidDebugService extends DebugServiceBase implements IPlatformDe
1313 private $logger : ILogger ,
1414 private $androidDeviceDiscovery : Mobile . IDeviceDiscovery ,
1515 private $androidProcessService : Mobile . IAndroidProcessService ,
16- private $net : INet ) {
16+ private $net : INet ,
17+ private $projectDataService : IProjectDataService ) {
1718 super ( device , $devicesService ) ;
1819 }
1920
@@ -25,8 +26,9 @@ export class AndroidDebugService extends DebugServiceBase implements IPlatformDe
2526 }
2627
2728 public async debugStart ( debugData : IDebugData , debugOptions : IDebugOptions ) : Promise < void > {
29+ const projectData = this . $projectDataService . getProjectData ( debugData . projectDir ) ;
2830 await this . $devicesService . initialize ( { platform : this . platform , deviceId : debugData . deviceIdentifier } ) ;
29- const action = ( device : Mobile . IAndroidDevice ) : Promise < void > => this . debugStartCore ( debugData . applicationIdentifier , debugOptions ) ;
31+ const action = ( device : Mobile . IAndroidDevice ) : Promise < void > => this . debugStartCore ( debugData . applicationIdentifier , debugOptions , projectData . projectName ) ;
3032
3133 await this . $devicesService . execute ( action , this . getCanExecuteAction ( debugData . deviceIdentifier ) ) ;
3234 }
@@ -91,23 +93,24 @@ export class AndroidDebugService extends DebugServiceBase implements IPlatformDe
9193
9294 await this . $devicesService . initialize ( { platform : this . platform , deviceId : debugData . deviceIdentifier } ) ;
9395
94- const action = ( device : Mobile . IAndroidDevice ) : Promise < string > => this . debugCore ( device , packageFile , debugData . applicationIdentifier , debugOptions ) ;
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 ) ;
9598
9699 const deviceActionResult = await this . $devicesService . execute ( action , this . getCanExecuteAction ( debugData . deviceIdentifier ) ) ;
97100 return deviceActionResult [ 0 ] . result ;
98101 }
99102
100- private async debugCore ( device : Mobile . IAndroidDevice , packageFile : string , packageName : string , debugOptions : IDebugOptions ) : Promise < string > {
101- await this . printDebugPort ( device . deviceInfo . identifier , packageName ) ;
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 ) ;
102105
103106 if ( debugOptions . start ) {
104- return await this . attachDebugger ( device . deviceInfo . identifier , packageName , debugOptions ) ;
107+ return await this . attachDebugger ( device . deviceInfo . identifier , appId , debugOptions ) ;
105108 } else if ( debugOptions . stop ) {
106109 await this . removePortForwarding ( ) ;
107110 return null ;
108111 } else {
109- await this . debugStartCore ( packageName , debugOptions ) ;
110- return await this . attachDebugger ( device . deviceInfo . identifier , packageName , debugOptions ) ;
112+ await this . debugStartCore ( appId , debugOptions , packageName ) ;
113+ return await this . attachDebugger ( device . deviceInfo . identifier , appId , debugOptions ) ;
111114 }
112115 }
113116
@@ -126,22 +129,22 @@ export class AndroidDebugService extends DebugServiceBase implements IPlatformDe
126129 return this . getChromeDebugUrl ( debugOptions , port ) ;
127130 }
128131
129- private async debugStartCore ( packageName : string , debugOptions : IDebugOptions ) : Promise < void > {
132+ private async debugStartCore ( appId : string , debugOptions : IDebugOptions , projectName : string ) : Promise < void > {
130133 // Arguments passed to executeShellCommand must be in array ([]), but it turned out adb shell "arg with intervals" still works correctly.
131134 // As we need to redirect output of a command on the device, keep using only one argument.
132135 // 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.
133136
134- await this . device . applicationManager . stopApplication ( packageName ) ;
137+ await this . device . applicationManager . stopApplication ( appId ) ;
135138
136139 if ( debugOptions . debugBrk ) {
137- await this . device . adb . executeShellCommand ( [ `cat /dev/null > /data/local/tmp/${ packageName } -debugbreak` ] ) ;
140+ await this . device . adb . executeShellCommand ( [ `cat /dev/null > /data/local/tmp/${ appId } -debugbreak` ] ) ;
138141 }
139142
140- await this . device . adb . executeShellCommand ( [ `cat /dev/null > /data/local/tmp/${ packageName } -debugger-started` ] ) ;
143+ await this . device . adb . executeShellCommand ( [ `cat /dev/null > /data/local/tmp/${ appId } -debugger-started` ] ) ;
141144
142- await this . device . applicationManager . startApplication ( packageName ) ;
145+ await this . device . applicationManager . startApplication ( appId , projectName ) ;
143146
144- await this . waitForDebugger ( packageName ) ;
147+ await this . waitForDebugger ( appId ) ;
145148 }
146149
147150 private async waitForDebugger ( packageName : String ) : Promise < void > {
0 commit comments