Skip to content

Commit

Permalink
Update for v4.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
joeljfischer committed Jun 1, 2017
1 parent a7c11b6 commit 8ae3106
Show file tree
Hide file tree
Showing 22 changed files with 471 additions and 198 deletions.
3 changes: 1 addition & 2 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
Language: Cpp
Language: ObjC

AccessModifierOffset: -2
AlignTrailingComments: false
Expand Down Expand Up @@ -40,6 +40,5 @@ SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# 4.6.0 Release Candidate 1 Release Notes
### Bug Fixes
* Fix setting lifecycle configuration `appType` to `nil`.
* If an array would return `NSNull`, return an empty array instead.
* Removed uses of `@import` for compatibility issues.
* Added some Xcode 8.3 compatibility fixes.
* Fixed reconnection attempts unable to be stopped, or it would crash.
* Fix `SDLMenuParams initWithMenuParams:parentId:position:` improperly setting `position`.
* IAP transport now does read/writes on a background thread.

### Other
* We now use a new podspec: "SmartDeviceLink", and deprecated the current one ("SmartDeviceLink-iOS"), please update your podfiles. This will be necessary for some features in v5.0.

### Known Issues
* When an app is connected over USB, the USB is disconnected, then reconnected, the app will crash.

# 4.5.5 Release Notes
### Bug Fixes
* Added a check for if `SDLManager` is already started and prevent starting it again.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ See the [roadmap](https://github.com/smartdevicelink/sdl_ios/wiki/Roadmap) to se

You can install this library using [Cocoapods](https://cocoapods.org/pods/SmartDeviceLink-iOS). You can get started with Cocoapods by [following their install guide](https://guides.cocoapods.org/using/getting-started.html#getting-started), and learn how to use Cocoapods to install dependencies [by following this guide](https://guides.cocoapods.org/using/using-cocoapods.html).

In your podfile, you want to add `pod 'SmartDeviceLink-iOS', '~> 4.5'`. Then run `pod install` inside your terminal. With Cocoapods, we support iOS 6.0+.
In your podfile, you want to add `pod 'SmartDeviceLink-iOS', '~> 4.6'`. Then run `pod install` inside your terminal. With Cocoapods, we support iOS 6.0+.

##### Carthage

Expand Down
2 changes: 1 addition & 1 deletion SmartDeviceLink-iOS.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "SmartDeviceLink-iOS"
s.version = "4.5.5"
s.version = "4.6.0-rc.1"
s.summary = "Connect your app with cars!"
s.homepage = "https://github.com/smartdevicelink/SmartDeviceLink-iOS"
s.license = { :type => "New BSD", :file => "LICENSE" }
Expand Down
2 changes: 2 additions & 0 deletions SmartDeviceLink-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1909,6 +1909,7 @@
5DBAE0AA1D3588AC00CE00BF /* SDLNotificationDispatcherSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLNotificationDispatcherSpec.m; path = DevAPISpecs/SDLNotificationDispatcherSpec.m; sourceTree = "<group>"; };
5DBAE0AC1D368D1A00CE00BF /* SDLResponseDispatcherSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLResponseDispatcherSpec.m; path = DevAPISpecs/SDLResponseDispatcherSpec.m; sourceTree = "<group>"; };
5DC978251B7A38640012C2F1 /* SDLGlobalsSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLGlobalsSpec.m; path = UtilitiesSpecs/SDLGlobalsSpec.m; sourceTree = "<group>"; };
5DCA93811EE06F790015768E /* SmartDeviceLink.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = SmartDeviceLink.podspec; sourceTree = "<group>"; };
5DCC199E1B8221F3004FFAD9 /* SDLURLSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLURLSession.h; sourceTree = "<group>"; };
5DCC199F1B8221F3004FFAD9 /* SDLURLSession.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLURLSession.m; sourceTree = "<group>"; };
5DCC19A21B822804004FFAD9 /* SDLURLRequestTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLURLRequestTask.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3324,6 +3325,7 @@
5D1665A41CF5D5DA00CC4CA1 /* DEPENDENCIES.md */,
5D1665A51CF5D5DA00CC4CA1 /* LICENSE */,
5D1665A61CF5D5DA00CC4CA1 /* README.md */,
5DCA93811EE06F790015768E /* SmartDeviceLink.podspec */,
5D1665A71CF5D5DA00CC4CA1 /* SmartDeviceLink-iOS.podspec */,
5D61FA1E1A84237100846EE7 /* Supporting Files */,
);
Expand Down
26 changes: 13 additions & 13 deletions SmartDeviceLink/SDLIAPSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import "SDLStreamDelegate.h"
#import "SDLTimer.h"

NSString *const IOStreamThreadName = @"com.smartdevicelink.iostream";
NSString *const IOStreamThreadName = @"com.smartdevicelink.iostream";
NSTimeInterval const streamThreadWaitSecs = 1.0;

@interface SDLIAPSession ()
Expand Down Expand Up @@ -86,7 +86,7 @@ - (BOOL)start {
- (void)stop {
if (self.isDataSession) {
[self.ioStreamThread cancel];

long lWait = dispatch_semaphore_wait(self.canceledSemaphore, dispatch_time(DISPATCH_TIME_NOW, streamThreadWaitSecs * NSEC_PER_SEC));
if (lWait == 0) {
[SDLDebugTool logInfo:@"Stream thread canceled"];
Expand All @@ -107,7 +107,7 @@ - (BOOL)isStopped {
return !self.isOutputStreamOpen && !self.isInputStreamOpen;
}

# pragma mark - data send methods
#pragma mark - data send methods

- (void)sendData:(NSData *)data {
// Enqueue the data for transmission on the IO thread
Expand All @@ -118,7 +118,7 @@ - (BOOL)sdl_dequeueAndWriteToOutputStream:(NSError **)error {
NSOutputStream *ostream = self.easession.outputStream;
NSMutableData *remainder = [self.sendDataQueue frontBuffer];
BOOL allDataWritten = NO;

if (error != nil && remainder != nil && ostream.streamStatus == NSStreamStatusOpen) {
NSInteger bytesRemaining = remainder.length;
NSInteger bytesWritten = [ostream write:remainder.bytes maxLength:bytesRemaining];
Expand Down Expand Up @@ -148,7 +148,7 @@ - (void)sdl_handleOutputStreamWriteError:(NSError *)error {
}
}

# pragma mark - background I/O for data session
#pragma mark - background I/O for data session

// Data session I/O thread
- (void)sdl_accessoryEventLoop {
Expand All @@ -158,7 +158,7 @@ - (void)sdl_accessoryEventLoop {
if (!self.easession) {
return;
}

[self startStream:self.easession.inputStream];
[self startStream:self.easession.outputStream];

Expand Down Expand Up @@ -187,7 +187,7 @@ - (void)sdl_closeSession {
if (!self.easession) {
return;
}

NSString *closeSessionString = [NSString stringWithFormat:@"Close EASession: %tu", self.easession.accessory.connectionID];
[SDLDebugTool logInfo:closeSessionString];

Expand All @@ -211,7 +211,7 @@ - (void)stopStream:(NSStream *)stream {

// When you disconect the cable you get a stream end event and come here but stream is already in closed state.
// Still need to remove from run loop.

NSAssert((self.isDataSession && [[NSThread currentThread] isEqual:self.ioStreamThread]) || [NSThread isMainThread], @"stopStream is being called on the wrong thread!!!");

NSUInteger status1 = stream.streamStatus;
Expand Down Expand Up @@ -272,16 +272,16 @@ - (SDLStreamErrorHandler)streamErroredHandler {

- (SDLStreamHasSpaceHandler)sdl_streamHasSpaceHandler {
__weak typeof(self) weakSelf = self;

return ^(NSStream *stream) {
__strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf.isDataSession){

if (!strongSelf.isDataSession) {
return;
}

NSError *sendErr = nil;

if (![strongSelf sdl_dequeueAndWriteToOutputStream:&sendErr] && sendErr != nil) {
[strongSelf sdl_handleOutputStreamWriteError:sendErr];
}
Expand Down
27 changes: 13 additions & 14 deletions SmartDeviceLink/SDLIAPTransport.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#import "EAAccessoryManager+SDLProtocols.h"
#import "EAAccessory+SDLProtocols.h"
#import "EAAccessoryManager+SDLProtocols.h"
#import "SDLDebugTool.h"
#import "SDLGlobals.h"
#import "SDLIAPSession.h"
#import "SDLIAPTransport.h"
#import "SDLIAPTransport.h"
#import "SDLSiphonServer.h"
#import "SDLStreamDelegate.h"
#import "SDLTimer.h"
Expand Down Expand Up @@ -77,7 +76,7 @@ - (void)sdl_startEventListening {
selector:@selector(sdl_applicationWillEnterForeground:)
name:UIApplicationWillEnterForegroundNotification
object:nil];

[[EAAccessoryManager sharedAccessoryManager] registerForLocalNotifications];
}

Expand All @@ -104,9 +103,9 @@ - (void)sdl_accessoryDisconnected:(NSNotification *)notification {
// Only check for the data session, the control session is handled separately
EAAccessory *accessory = [notification.userInfo objectForKey:EAAccessoryKey];
if (accessory.connectionID != self.session.accessory.connectionID) {
[SDLDebugTool logInfo:@"Accessory connection ID mismatch!!!" withType:SDLDebugType_Transport_iAP toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName];
[SDLDebugTool logInfo:@"Accessory connection ID mismatch!!!" withType:SDLDebugType_Transport_iAP toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName];
}
if ([accessory.serialNumber isEqualToString:self.session.accessory.serialNumber]){
if ([accessory.serialNumber isEqualToString:self.session.accessory.serialNumber]) {
self.sessionSetupInProgress = NO;
[self disconnect];
[self.delegate onTransportDisconnected];
Expand Down Expand Up @@ -154,15 +153,15 @@ - (void)disconnect {

- (BOOL)sdl_connectAccessory:(EAAccessory *)accessory {
BOOL connecting = NO;

if ([accessory supportsProtocol:controlProtocolString]) {
[self sdl_createIAPControlSessionWithAccessory:accessory];
connecting = YES;
} else if ([accessory supportsProtocol:legacyProtocolString]) {
[self sdl_createIAPDataSessionWithAccessory:accessory forProtocol:legacyProtocolString];
connecting = YES;
}

return connecting;
}

Expand All @@ -173,11 +172,11 @@ - (void)sdl_establishSessionWithAccessory:(EAAccessory *)accessory {
self.retryCounter++;
EAAccessory *sdlAccessory = accessory;
// If we are being called from sdl_connectAccessory, the EAAccessoryDidConnectNotification will contain the SDL accessory to connect to and we can connect without searching the accessory manager's connected accessory list. Otherwise, we fall through to a search.
if (sdlAccessory != nil && [self sdl_connectAccessory:sdlAccessory]){
if (sdlAccessory != nil && [self sdl_connectAccessory:sdlAccessory]) {
// Connection underway, exit
return;
}

// Determine if we can start a multi-app session or a legacy (single-app) session
if ((sdlAccessory = [EAAccessoryManager findAccessoryForProtocol:controlProtocolString])) {
[self sdl_createIAPControlSessionWithAccessory:sdlAccessory];
Expand All @@ -188,7 +187,7 @@ - (void)sdl_establishSessionWithAccessory:(EAAccessory *)accessory {
[SDLDebugTool logInfo:@"No accessory supporting a required sync protocol was found."];
self.sessionSetupInProgress = NO;
}

} else {
// We are beyond the number of retries allowed
[SDLDebugTool logInfo:@"Create session retries exhausted."];
Expand Down Expand Up @@ -266,7 +265,7 @@ - (void)sdl_createIAPDataSessionWithAccessory:(EAAccessory *)accessory forProtoc
- (void)sdl_retryEstablishSession {
// Current strategy disallows automatic retries.
self.sessionSetupInProgress = NO;
if (self.session != nil){
if (self.session != nil) {
[self.session stop];
self.session.delegate = nil;
self.session = nil;
Expand Down Expand Up @@ -310,7 +309,7 @@ - (void)sendData:(NSData *)data {
if (self.session == nil || !self.session.accessory.connected) {
return;
}

[self.session sendData:data];
}

Expand Down Expand Up @@ -362,7 +361,7 @@ - (SDLStreamHasBytesHandler)sdl_controlStreamHasBytesHandlerForAccessory:(EAAcce

// Determine protocol string of the data session, then create that data session
NSString *indexedProtocolString = [NSString stringWithFormat:@"%@%@", indexedProtocolStringPrefix, @(buf[0])];
if (accessory.isConnected){
if (accessory.isConnected) {
dispatch_async(dispatch_get_main_queue(), ^{
[strongSelf sdl_createIAPDataSessionWithAccessory:accessory forProtocol:indexedProtocolString];
});
Expand Down Expand Up @@ -416,7 +415,7 @@ - (SDLStreamHasBytesHandler)sdl_dataStreamHasBytesHandler {
uint8_t buf[[SDLGlobals globals].maxMTUSize];
while (istream.streamStatus == NSStreamStatusOpen && istream.hasBytesAvailable) {
// It is necessary to check the stream status and whether there are bytes available because the dataStreamHasBytesHandler is executed on the IO thread and the accessory disconnect notification arrives on the main thread, causing data to be passed to the delegate while the main thread is tearing down the transport.

NSInteger bytesRead = [istream read:buf maxLength:[SDLGlobals globals].maxMTUSize];
NSData *dataIn = [NSData dataWithBytes:buf length:bytesRead];

Expand Down
14 changes: 7 additions & 7 deletions SmartDeviceLink/SDLLifecycleManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ - (void)startWithReadyHandler:(SDLManagerReadyBlock)readyHandler {
[SDLDebugTool logFormat:@"Warning: SDL has already been started, this attempt will be ignored."];
return;
}

self.readyHandler = [readyHandler copy];

[self.lifecycleStateMachine transitionToState:SDLLifecycleStateStarted];
Expand Down Expand Up @@ -148,7 +148,7 @@ - (SDLState *)lifecycleState {
+ (NSDictionary<SDLState *, SDLAllowableStateTransitions *> *)sdl_stateTransitionDictionary {
return @{
SDLLifecycleStateStopped: @[SDLLifecycleStateStarted],
SDLLifecycleStateStarted : @[SDLLifecycleStateConnected, SDLLifecycleStateStopped, SDLLifecycleStateReconnecting],
SDLLifecycleStateStarted: @[SDLLifecycleStateConnected, SDLLifecycleStateStopped, SDLLifecycleStateReconnecting],
SDLLifecycleStateReconnecting: @[SDLLifecycleStateStarted, SDLLifecycleStateStopped],
SDLLifecycleStateConnected: @[SDLLifecycleStateStopped, SDLLifecycleStateReconnecting, SDLLifecycleStateRegistered],
SDLLifecycleStateRegistered: @[SDLLifecycleStateStopped, SDLLifecycleStateReconnecting, SDLLifecycleStateSettingUpManagers],
Expand All @@ -161,7 +161,7 @@ - (SDLState *)lifecycleState {
}

- (void)didEnterStateStarted {
// Start up the internal proxy object
// Start up the internal proxy object
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (self.configuration.lifecycleConfig.tcpDebugMode) {
Expand Down Expand Up @@ -277,7 +277,7 @@ - (void)didEnterStateSettingUpAppIcon {
}];
}

- (void)didEnterStateSettingUpHMI{
- (void)didEnterStateSettingUpHMI {
// We want to make sure we've gotten a SDLOnHMIStatus notification
if (self.hmiLevel == nil) {
// If nil, return and wait until we get a notification
Expand Down Expand Up @@ -420,7 +420,7 @@ - (NSNumber *)sdl_getNextCorrelationId {
return @(++self.lastCorrelationId);
}

+ (BOOL)sdl_checkNotification:(NSNotification *)notification containsKindOfClass:(Class)class {
+ (BOOL)sdl_checkNotification:(NSNotification *)notification containsKindOfClass:(Class) class {
NSAssert([notification.userInfo[SDLNotificationUserInfoObject] isKindOfClass:class], @"A notification was sent with an unanticipated object");
if (![notification.userInfo[SDLNotificationUserInfoObject] isKindOfClass:class]) {
return NO;
Expand All @@ -429,7 +429,7 @@ + (BOOL)sdl_checkNotification:(NSNotification *)notification containsKindOfClass
return YES;
}

+ (void)sdl_updateLoggingWithFlags : (SDLLogOutput)logFlags {
+ (void)sdl_updateLoggingWithFlags : (SDLLogOutput)logFlags {
if (logFlags == SDLLogOutputNone) {
[SDLDebugTool disable];
return;
Expand Down Expand Up @@ -478,7 +478,7 @@ - (void)hmiStatusDidChange:(SDLRPCNotificationNotification *)notification {
SDLOnHMIStatus *hmiStatusNotification = notification.notification;
SDLHMILevel *oldHMILevel = self.hmiLevel;
self.hmiLevel = hmiStatusNotification.hmiLevel;

if ([self.lifecycleStateMachine isCurrentState:SDLLifecycleStateSettingUpHMI]) {
[self.lifecycleStateMachine transitionToState:SDLLifecycleStateReady];
}
Expand Down
8 changes: 4 additions & 4 deletions SmartDeviceLink/SDLMutableDataQueue.h
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// SDLMutableDataQueue.h
//
//
//
// Created by David Switzer on 3/2/17.
//
Expand All @@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
@return NSMutableData containing the buffer at the head of the queue or nil if
the queue is empty
*/
- (NSMutableData * _Nullable)frontBuffer;
- (NSMutableData *_Nullable)frontBuffer;


/**
Expand All @@ -47,12 +47,12 @@ NS_ASSUME_NONNULL_BEGIN
/**
Gets the number of buffers currently enqueued
*/
@property(nonatomic, assign, readonly) NSUInteger count;
@property (nonatomic, assign, readonly) NSUInteger count;

/**
A flag indicating whether the buffer at the head of the queue has been dequeued at least once.
*/
@property(nonatomic, assign, readonly, getter=isFrontBufferDequeued) BOOL frontDequeued;
@property (nonatomic, assign, readonly, getter=isFrontBufferDequeued) BOOL frontDequeued;

NS_ASSUME_NONNULL_END

Expand Down
Loading

0 comments on commit 8ae3106

Please sign in to comment.