@@ -26,9 +26,14 @@ export class AndroidDebugService extends DebugServiceBase implements IPlatformDe
26
26
}
27
27
28
28
public async debugStart ( debugData : IDebugData , debugOptions : IDebugOptions ) : Promise < void > {
29
- const projectData = this . $projectDataService . getProjectData ( debugData . projectDir ) ;
30
29
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 ) ;
32
37
33
38
await this . $devicesService . execute ( action , this . getCanExecuteAction ( debugData . deviceIdentifier ) ) ;
34
39
}
@@ -93,24 +98,29 @@ export class AndroidDebugService extends DebugServiceBase implements IPlatformDe
93
98
94
99
await this . $devicesService . initialize ( { platform : this . platform , deviceId : debugData . deviceIdentifier } ) ;
95
100
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 ) ;
98
108
99
109
const deviceActionResult = await this . $devicesService . execute ( action , this . getCanExecuteAction ( debugData . deviceIdentifier ) ) ;
100
110
return deviceActionResult [ 0 ] . result ;
101
111
}
102
112
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 ) ;
105
115
106
116
if ( debugOptions . start ) {
107
- return await this . attachDebugger ( device . deviceInfo . identifier , appId , debugOptions ) ;
117
+ return await this . attachDebugger ( device . deviceInfo . identifier , appData . appId , debugOptions ) ;
108
118
} else if ( debugOptions . stop ) {
109
119
await this . removePortForwarding ( ) ;
110
120
return null ;
111
121
} 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 ) ;
114
124
}
115
125
}
116
126
@@ -129,22 +139,21 @@ export class AndroidDebugService extends DebugServiceBase implements IPlatformDe
129
139
return this . getChromeDebugUrl ( debugOptions , port ) ;
130
140
}
131
141
132
- private async debugStartCore ( appId : string , debugOptions : IDebugOptions , projectName : string ) : Promise < void > {
142
+ private async debugStartCore ( appData : Mobile . IApplicationData , debugOptions : IDebugOptions ) : Promise < void > {
133
143
// Arguments passed to executeShellCommand must be in array ([]), but it turned out adb shell "arg with intervals" still works correctly.
134
144
// As we need to redirect output of a command on the device, keep using only one argument.
135
145
// 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 ) ;
138
147
139
148
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` ] ) ;
141
150
}
142
151
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` ] ) ;
144
153
145
- await this . device . applicationManager . startApplication ( appId , projectName ) ;
154
+ await this . device . applicationManager . startApplication ( appData ) ;
146
155
147
- await this . waitForDebugger ( appId ) ;
156
+ await this . waitForDebugger ( appData . appId ) ;
148
157
}
149
158
150
159
private async waitForDebugger ( packageName : String ) : Promise < void > {
0 commit comments