Skip to content

Commit

Permalink
Merge pull request #1453 from smartdevicelink/bugfix/issue_1431_multi…
Browse files Browse the repository at this point in the history
…ple_phones_disconnect_bug

Only sessions with same connectionID as the disconnected accessory should be closed
  • Loading branch information
joeljfischer committed Oct 21, 2019
2 parents 1a61b70 + 49fda95 commit f63401e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions SmartDeviceLink/SDLIAPTransport.m
Expand Up @@ -140,10 +140,18 @@ - (void)sdl_accessoryDisconnected:(NSNotification *)notification {
SDLLogV(@"Accessory (%@, %@), disconnected, but no session is in progress.", accessory.name, accessory.serialNumber);
[self sdl_closeSessions];
} else if (self.dataSession.isSessionInProgress) {
if (self.dataSession.connectionID != accessory.connectionID) {
SDLLogD(@"Accessory's connectionID, %lu, does not match the connectionID of the current data session, %lu. Another phone disconnected from the head unit. The session will not be closed.", accessory.connectionID, self.dataSession.connectionID);
return;
}
// The data session has been established. Tell the delegate that the transport has disconnected. The lifecycle manager will destroy and create a new transport object.
SDLLogV(@"Accessory (%@, %@) disconnected during a data session", accessory.name, accessory.serialNumber);
[self sdl_destroyTransport];
} else if (self.controlSession.isSessionInProgress) {
if (self.controlSession.connectionID != accessory.connectionID) {
SDLLogD(@"Accessory's connectionID, %lu, does not match the connectionID of the current control session, %lu. Another phone disconnected from the head unit. The session will not be closed.", accessory.connectionID, self.controlSession.connectionID);
return;
}
// The data session has yet to be established so the transport has not yet connected. DO NOT unregister for notifications from the accessory.
SDLLogV(@"Accessory (%@, %@) disconnected during a control session", accessory.name, accessory.serialNumber);
[self sdl_closeSessions];
Expand Down

0 comments on commit f63401e

Please sign in to comment.