Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only sessions with same connectionID as the disconnected accessory should be closed #1453

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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