summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2017-12-19 16:52:42 -0500
committerJoel Fischer <joeljfischer@gmail.com>2017-12-19 16:52:42 -0500
commitcc96a14bcf922b3d42d721f2d4d03fc13da5ab94 (patch)
tree6c024adf4def9b354d0363a72770890a82973e28
parent37382e4b80ae9a8142729c5b1a492674e0dc5bb9 (diff)
parentaa7ffe5f8fc6da080a311f3ff1608f3ec48419e2 (diff)
downloadsdl_ios-cc96a14bcf922b3d42d721f2d4d03fc13da5ab94.tar.gz
Merge branch 'develop' into feature/issue_794_CarWindow
# Conflicts: # SmartDeviceLink/SDLLockScreenPresenter.m
-rw-r--r--SmartDeviceLink/SDLIAPTransport.m11
-rw-r--r--SmartDeviceLink/SDLLockScreenViewController.m64
-rw-r--r--SmartDeviceLink/SDLNotificationConstants.m2
-rw-r--r--SmartDeviceLink/SDLNotificationDispatcher.h1
-rw-r--r--SmartDeviceLink/SDLNotificationDispatcher.m30
-rw-r--r--SmartDeviceLink/SDLProxy.m15
6 files changed, 67 insertions, 56 deletions
diff --git a/SmartDeviceLink/SDLIAPTransport.m b/SmartDeviceLink/SDLIAPTransport.m
index 953cafddf..b24f8a12f 100644
--- a/SmartDeviceLink/SDLIAPTransport.m
+++ b/SmartDeviceLink/SDLIAPTransport.m
@@ -139,8 +139,6 @@ int const ProtocolIndexTimeoutSeconds = 10;
* @param notification Contains information about the connected accessory
*/
- (void)sdl_accessoryConnected:(NSNotification *)notification {
- EAAccessory *accessory = notification.userInfo[EAAccessoryKey];
-
double retryDelay = self.retryDelay;
SDLLogD(@"Accessory Connected (%@), Opening in %0.03fs", notification.userInfo[EAAccessoryKey], retryDelay);
@@ -149,7 +147,7 @@ int const ProtocolIndexTimeoutSeconds = 10;
[self sdl_backgroundTaskStart];
}
- [self performSelector:@selector(sdl_connect:) withObject:accessory afterDelay:retryDelay];
+ [self performSelector:@selector(sdl_connect:) withObject:nil afterDelay:retryDelay];
}
/**
@@ -428,7 +426,10 @@ int const ProtocolIndexTimeoutSeconds = 10;
// Control Session Opened
if ([ControlProtocolString isEqualToString:session.protocol]) {
SDLLogD(@"Control Session Established");
- [self.protocolIndexTimer start];
+
+ if (!self.session) {
+ [self.protocolIndexTimer start];
+ }
}
// Data Session Opened
@@ -504,7 +505,6 @@ int const ProtocolIndexTimeoutSeconds = 10;
SDLLogD(@"Control Stream will switch to protocol %@", indexedProtocolString);
// Destroy the control session
- [strongSelf.protocolIndexTimer cancel];
dispatch_sync(dispatch_get_main_queue(), ^{
[strongSelf.controlSession stop];
strongSelf.controlSession.streamDelegate = nil;
@@ -514,6 +514,7 @@ int const ProtocolIndexTimeoutSeconds = 10;
if (accessory.isConnected) {
dispatch_async(dispatch_get_main_queue(), ^{
[strongSelf sdl_createIAPDataSessionWithAccessory:accessory forProtocol:indexedProtocolString];
+ [strongSelf.protocolIndexTimer cancel];
});
}
};
diff --git a/SmartDeviceLink/SDLLockScreenViewController.m b/SmartDeviceLink/SDLLockScreenViewController.m
index f0ef044a0..d399c2a44 100644
--- a/SmartDeviceLink/SDLLockScreenViewController.m
+++ b/SmartDeviceLink/SDLLockScreenViewController.m
@@ -75,37 +75,39 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Layout
- (void)sdl_layoutViews {
- UIColor *iconColor = [self.class sdl_accentColorBasedOnColor:self.backgroundColor];
-
- self.sdlIconImageView.image = [self.class sdl_imageWithName:@"sdl_logo_black"];
- self.sdlIconImageView.tintColor = iconColor;
-
- self.arrowUpImageView.image = [self.class sdl_imageWithName:@"lock_arrow_up_black"];
- self.arrowUpImageView.tintColor = iconColor;
-
- self.arrowDownImageView.image = [self.class sdl_imageWithName:@"lock_arrow_down_black"];
- self.arrowDownImageView.tintColor = iconColor;
-
- self.lockedLabel.textColor = iconColor;
-
- if (self.vehicleIcon != nil && self.appIcon != nil) {
- [self sdl_setVehicleAndAppIconsLayout];
- } else if (self.vehicleIcon != nil) {
- [self sdl_setVehicleIconOnlyLayout];
- } else if (self.appIcon != nil) {
- [self sdl_setAppIconOnlyLayout];
- } else {
- [self sdl_setNoIconsLayout];
- }
-
- // HAX: The autolayout doesn't scale for 4s, so hide a view so it doesn't look like garbage.
- if (CGRectGetHeight([UIScreen mainScreen].bounds) == 480) {
- self.sdlIconImageView.hidden = YES;
- } else {
- self.sdlIconImageView.hidden = NO;
- }
-
- [self.view layoutIfNeeded];
+ dispatch_async(dispatch_get_main_queue(), ^{
+ UIColor *iconColor = [self.class sdl_accentColorBasedOnColor:self.backgroundColor];
+
+ self.sdlIconImageView.image = [self.class sdl_imageWithName:@"sdl_logo_black"];
+ self.sdlIconImageView.tintColor = iconColor;
+
+ self.arrowUpImageView.image = [self.class sdl_imageWithName:@"lock_arrow_up_black"];
+ self.arrowUpImageView.tintColor = iconColor;
+
+ self.arrowDownImageView.image = [self.class sdl_imageWithName:@"lock_arrow_down_black"];
+ self.arrowDownImageView.tintColor = iconColor;
+
+ self.lockedLabel.textColor = iconColor;
+
+ if (self.vehicleIcon != nil && self.appIcon != nil) {
+ [self sdl_setVehicleAndAppIconsLayout];
+ } else if (self.vehicleIcon != nil) {
+ [self sdl_setVehicleIconOnlyLayout];
+ } else if (self.appIcon != nil) {
+ [self sdl_setAppIconOnlyLayout];
+ } else {
+ [self sdl_setNoIconsLayout];
+ }
+
+ // HAX: The autolayout doesn't scale for 4s, so hide a view so it doesn't look like garbage.
+ if (CGRectGetHeight([UIScreen mainScreen].bounds) == 480) {
+ self.sdlIconImageView.hidden = YES;
+ } else {
+ self.sdlIconImageView.hidden = NO;
+ }
+
+ [self.view layoutIfNeeded];
+ });
}
- (void)sdl_setVehicleAndAppIconsLayout {
diff --git a/SmartDeviceLink/SDLNotificationConstants.m b/SmartDeviceLink/SDLNotificationConstants.m
index 813a07ca6..864524205 100644
--- a/SmartDeviceLink/SDLNotificationConstants.m
+++ b/SmartDeviceLink/SDLNotificationConstants.m
@@ -8,6 +8,8 @@
#import "SDLNotificationConstants.h"
+/// These notifications will be returned on a background serial queue
+
SDLNotificationUserInfoKey const SDLNotificationUserInfoObject = @"SDLNotificationUserInfoObject";
diff --git a/SmartDeviceLink/SDLNotificationDispatcher.h b/SmartDeviceLink/SDLNotificationDispatcher.h
index d189ef990..ba5089a25 100644
--- a/SmartDeviceLink/SDLNotificationDispatcher.h
+++ b/SmartDeviceLink/SDLNotificationDispatcher.h
@@ -28,7 +28,6 @@ NS_ASSUME_NONNULL_BEGIN
* @param info The object to be send along in the `userInfo` dictionary.
*/
- (void)postNotificationName:(NSString *)name infoObject:(nullable id)info;
-
- (void)postRPCResponseNotification:(NSString *)name response:(__kindof SDLRPCResponse *)response;
- (void)postRPCNotificationNotification:(NSString *)name notification:(__kindof SDLRPCNotification *)rpcNotification;
diff --git a/SmartDeviceLink/SDLNotificationDispatcher.m b/SmartDeviceLink/SDLNotificationDispatcher.m
index 142286400..a28befb68 100644
--- a/SmartDeviceLink/SDLNotificationDispatcher.m
+++ b/SmartDeviceLink/SDLNotificationDispatcher.m
@@ -18,29 +18,35 @@ NS_ASSUME_NONNULL_BEGIN
@implementation SDLNotificationDispatcher
+- (instancetype)init {
+ self = [super init];
+ if (!self) { return nil; }
+
+ return self;
+}
+
- (void)postNotificationName:(NSString *)name infoObject:(nullable id)infoObject {
NSDictionary<NSString *, id> *userInfo = nil;
if (infoObject != nil) {
userInfo = @{SDLNotificationUserInfoObject: infoObject};
}
-
- dispatch_async(dispatch_get_main_queue(), ^{
- [[NSNotificationCenter defaultCenter] postNotificationName:name object:self userInfo:userInfo];
- });
+
+ // Runs on `com.sdl.rpcProcessingQueue`
+ [[NSNotificationCenter defaultCenter] postNotificationName:name object:self userInfo:userInfo];
}
- (void)postRPCResponseNotification:(NSString *)name response:(__kindof SDLRPCResponse *)response {
- dispatch_async(dispatch_get_main_queue(), ^{
- SDLRPCResponseNotification *notification = [[SDLRPCResponseNotification alloc] initWithName:name object:self rpcResponse:response];
- [[NSNotificationCenter defaultCenter] postNotification:notification];
- });
+ SDLRPCResponseNotification *notification = [[SDLRPCResponseNotification alloc] initWithName:name object:self rpcResponse:response];
+
+ // Runs on `com.sdl.rpcProcessingQueue`
+ [[NSNotificationCenter defaultCenter] postNotification:notification];
}
- (void)postRPCNotificationNotification:(NSString *)name notification:(__kindof SDLRPCNotification *)rpcNotification {
- dispatch_async(dispatch_get_main_queue(), ^{
- SDLRPCNotificationNotification *notification = [[SDLRPCNotificationNotification alloc] initWithName:name object:self rpcNotification:rpcNotification];
- [[NSNotificationCenter defaultCenter] postNotification:notification];
- });
+ SDLRPCNotificationNotification *notification = [[SDLRPCNotificationNotification alloc] initWithName:name object:self rpcNotification:rpcNotification];
+
+ // Runs on `com.sdl.rpcProcessingQueue`
+ [[NSNotificationCenter defaultCenter] postNotification:notification];
}
#pragma mark - SDLProxyListener Delegate Methods
diff --git a/SmartDeviceLink/SDLProxy.m b/SmartDeviceLink/SDLProxy.m
index 06ba1e0e9..6aab9ab24 100644
--- a/SmartDeviceLink/SDLProxy.m
+++ b/SmartDeviceLink/SDLProxy.m
@@ -56,6 +56,7 @@ static float DefaultConnectionTimeout = 45.0;
@property (nullable, nonatomic, strong) SDLDisplayCapabilities *displayCapabilities;
@property (nonatomic, strong) NSMutableDictionary<SDLVehicleMake *, Class> *securityManagers;
@property (nonatomic, strong) NSURLSession* urlSession;
+@property (strong, nonatomic) dispatch_queue_t rpcProcessingQueue;
@end
@@ -68,6 +69,7 @@ static float DefaultConnectionTimeout = 45.0;
SDLLogD(@"Framework Version: %@", self.proxyVersion);
_debugConsoleGroupName = @"default";
_lsm = [[SDLLockScreenStatusManager alloc] init];
+ _rpcProcessingQueue = dispatch_queue_create("com.sdl.rpcProcessingQueue", DISPATCH_QUEUE_SERIAL);
_mutableProxyListeners = [NSMutableSet setWithObject:theDelegate];
_securityManagers = [NSMutableDictionary dictionary];
@@ -629,13 +631,12 @@ static float DefaultConnectionTimeout = 45.0;
}
- (void)invokeMethodOnDelegates:(SEL)aSelector withObject:(nullable id)object {
- dispatch_async(dispatch_get_main_queue(), ^{
- @autoreleasepool {
- for (id<SDLProxyListener> listener in self.proxyListeners) {
- if ([listener respondsToSelector:aSelector]) {
- // HAX: http://stackoverflow.com/questions/7017281/performselector-may-cause-a-leak-because-its-selector-is-unknown
- ((void (*)(id, SEL, id))[(NSObject *)listener methodForSelector:aSelector])(listener, aSelector, object);
- }
+ // Occurs on the protocol receive serial queue
+ dispatch_async(_rpcProcessingQueue, ^{
+ for (id<SDLProxyListener> listener in self.proxyListeners) {
+ if ([listener respondsToSelector:aSelector]) {
+ // HAX: http://stackoverflow.com/questions/7017281/performselector-may-cause-a-leak-because-its-selector-is-unknown
+ ((void (*)(id, SEL, id))[(NSObject *)listener methodForSelector:aSelector])(listener, aSelector, object);
}
}
});