File tree 2 files changed +22
-3
lines changed
2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -237,6 +237,26 @@ - (instancetype)initWithDevice:(FBDevice *)device
237
237
}
238
238
239
239
- (FBFuture<id<FBLaunchedProcess>> *)launchApplication : (FBApplicationLaunchConfiguration *)configuration
240
+ {
241
+ if (configuration.launchMode == FBApplicationLaunchModeFailIfRunning) {
242
+ return [[self processIDWithBundleID: configuration.bundleID] onQueue: self .device.asyncQueue chain: ^ (FBFuture<NSNumber *>* processIdQueryResult) {
243
+ if (processIdQueryResult.state == FBFutureStateDone) {
244
+ return [[FBDeviceControlError
245
+ describeFormat: @" Application %@ already running with pid %@ " , configuration.bundleID, processIdQueryResult.result]
246
+ failFuture ];
247
+ } else if (processIdQueryResult.state == FBFutureStateFailed) {
248
+ return (FBFuture*)[self launchApplicationIgnoreCurrentState: configuration];
249
+ } else {
250
+ return (FBFuture*)processIdQueryResult;
251
+ }
252
+ }];
253
+ }
254
+ return [self launchApplicationIgnoreCurrentState: configuration];
255
+ }
256
+
257
+ #pragma mark Private
258
+
259
+ - (FBFuture<id<FBLaunchedProcess>> *)launchApplicationIgnoreCurrentState : (FBApplicationLaunchConfiguration *)configuration
240
260
{
241
261
return [[[self
242
262
remoteInstrumentsClient ]
@@ -248,8 +268,6 @@ - (instancetype)initWithDevice:(FBDevice *)device
248
268
}];
249
269
}
250
270
251
- #pragma mark Private
252
-
253
271
- (FBFuture<NSNull *> *)killApplicationWithProcessIdentifier : (pid_t )processIdentifier
254
272
{
255
273
return [[self
Original file line number Diff line number Diff line change @@ -140,7 +140,8 @@ - (instancetype)initWithConnection:(FBAMDServiceConnection *)connection channels
140
140
onQueue: self .queue resolveValue: ^ NSNumber * (NSError **error) {
141
141
NSDictionary <NSString *, NSNumber *> *options = @{
142
142
@" StartSuspendedKey" : @(configuration.waitForDebugger ),
143
- @" KillExisting" : @(configuration.launchMode != FBApplicationLaunchModeFailIfRunning),
143
+ // FBApplicationLaunchModeFailIfRunning needs to be taken care of prior to this call.
144
+ @" KillExisting" : @(configuration.launchMode == FBApplicationLaunchModeRelaunchIfRunning),
144
145
};
145
146
ResponsePayload response = [self
146
147
onChannelIdentifier: ProcessControlChannel
You can’t perform that action at this time.
0 commit comments