Skip to content

Commit 331eba0

Browse files
committed
Merge pull request #1379 from NativeScript/no-client-command-android
support no-client command on android debug commands
2 parents f47ce41 + 3c3fb19 commit 331eba0

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

lib/services/android-debug-service.ts

+19-15
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ class AndroidDebugService implements IDebugService {
8787
}
8888

8989
private unixSocketForward(local: number, remote: string): IFuture<void> {
90-
return this.device.adb.executeCommand(["forward", `tcp:${local.toString()}`, `localabstract:${remote}`]);
90+
return this.device.adb.executeCommand(["forward", `tcp:${local.toString() }`, `localabstract:${remote}`]);
9191
}
9292

9393
private debugOnDevice(): IFuture<void> {
9494
return (() => {
9595
let packageFile = "";
9696

97-
if(!this.$options.debugBrk && !this.$options.start && !this.$options.getPort && !this.$options.stop) {
97+
if (!this.$options.debugBrk && !this.$options.start && !this.$options.getPort && !this.$options.stop) {
9898
this.$logger.warn("Neither --debug-brk nor --start option was specified. Defaulting to --debug-brk.");
9999
this.$options.debugBrk = true;
100100
}
@@ -110,14 +110,14 @@ class AndroidDebugService implements IDebugService {
110110
this.$logger.out("Using ", packageFile);
111111
}
112112

113-
this.$devicesService.initialize({ platform: this.platform, deviceId: this.$options.device}).wait();
113+
this.$devicesService.initialize({ platform: this.platform, deviceId: this.$options.device }).wait();
114114
let action = (device: Mobile.IAndroidDevice): IFuture<void> => { return this.debugCore(device, packageFile, this.$projectData.projectId); };
115115
this.$devicesService.execute(action).wait();
116116

117117
}).future<void>()();
118118
}
119119

120-
private debugCore(device: Mobile.IAndroidDevice, packageFile: string, packageName: string): IFuture<void> {
120+
private debugCore(device: Mobile.IAndroidDevice, packageFile: string, packageName: string): IFuture<void> {
121121
return (() => {
122122
this.device = device;
123123

@@ -145,9 +145,11 @@ class AndroidDebugService implements IDebugService {
145145
let startDebuggerCommand = ["am", "broadcast", "-a", '\"${packageName}-debug\"', "--ez", "enable", "true"];
146146
this.device.adb.executeShellCommand(startDebuggerCommand).wait();
147147

148-
let port = this.getForwardedLocalDebugPortForPackageName(deviceId, packageName).wait();
149-
this.startDebuggerClient(port).wait();
150-
this.openDebuggerClient(AndroidDebugService.DEFAULT_NODE_INSPECTOR_URL + "?port=" + port);
148+
if (this.$options.client) {
149+
let port = this.getForwardedLocalDebugPortForPackageName(deviceId, packageName).wait();
150+
this.startDebuggerClient(port).wait();
151+
this.openDebuggerClient(AndroidDebugService.DEFAULT_NODE_INSPECTOR_URL + "?port=" + port);
152+
}
151153
}).future<void>()();
152154
}
153155

@@ -157,7 +159,7 @@ class AndroidDebugService implements IDebugService {
157159

158160
private startAppWithDebugger(packageFile: string, packageName: string): IFuture<void> {
159161
return (() => {
160-
if(!this.$options.emulator) {
162+
if (!this.$options.emulator) {
161163
this.device.applicationManager.uninstallApplication(packageName).wait();
162164
this.device.applicationManager.installApplication(packageFile).wait();
163165
}
@@ -167,7 +169,7 @@ class AndroidDebugService implements IDebugService {
167169

168170
public debugStart(): IFuture<void> {
169171
return (() => {
170-
this.$devicesService.initialize({ platform: this.platform, deviceId: this.$options.device}).wait();
172+
this.$devicesService.initialize({ platform: this.platform, deviceId: this.$options.device }).wait();
171173
let action = (device: Mobile.IAndroidDevice): IFuture<void> => {
172174
this.device = device;
173175
return this.debugStartCore();
@@ -185,9 +187,11 @@ class AndroidDebugService implements IDebugService {
185187
this.device.applicationManager.stopApplication(packageName).wait();
186188
this.device.applicationManager.startApplication(packageName).wait();
187189

188-
let localDebugPort = this.getForwardedLocalDebugPortForPackageName(this.device.deviceInfo.identifier, packageName).wait();
189-
this.startDebuggerClient(localDebugPort).wait();
190-
this.openDebuggerClient(AndroidDebugService.DEFAULT_NODE_INSPECTOR_URL + "?port=" + localDebugPort);
190+
if (this.$options.client) {
191+
let localDebugPort = this.getForwardedLocalDebugPortForPackageName(this.device.deviceInfo.identifier, packageName).wait();
192+
this.startDebuggerClient(localDebugPort).wait();
193+
this.openDebuggerClient(AndroidDebugService.DEFAULT_NODE_INSPECTOR_URL + "?port=" + localDebugPort);
194+
}
191195
}).future<void>()();
192196
}
193197

@@ -202,16 +206,16 @@ class AndroidDebugService implements IDebugService {
202206

203207
private openDebuggerClient(url: string): void {
204208
let defaultDebugUI = "chrome";
205-
if(this.$hostInfo.isDarwin) {
209+
if (this.$hostInfo.isDarwin) {
206210
defaultDebugUI = "Google Chrome";
207211
}
208-
if(this.$hostInfo.isLinux) {
212+
if (this.$hostInfo.isLinux) {
209213
defaultDebugUI = "google-chrome";
210214
}
211215

212216
let debugUI = this.$config.ANDROID_DEBUG_UI || defaultDebugUI;
213217
let child = this.$opener.open(url, debugUI);
214-
if(!child) {
218+
if (!child) {
215219
this.$errors.failWithoutHelp(`Unable to open ${debugUI}.`);
216220
}
217221
}

0 commit comments

Comments
 (0)