From b9aaa38f2960291d7790a13d253d86da16658694 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Wed, 20 May 2020 14:18:23 -0400 Subject: [PATCH 01/10] Update SCM to handle `nil` displayCapabilities better * Add extensions for ImageField / TextField to handle passing all image or text fields * Update screen sub-managers to handle `nil` ImageFields / TextFields by not enabling those fields --- SmartDeviceLink-iOS.xcodeproj/project.pbxproj | 44 +++++++++++++------ .../Base.lproj/SDLLockScreen.storyboard | 38 ++++++++-------- SmartDeviceLink/SDLChoiceSetManager.m | 2 +- .../SDLImageField+ScreenManagerExtensions.h | 19 ++++++++ .../SDLImageField+ScreenManagerExtensions.m | 30 +++++++++++++ SmartDeviceLink/SDLMenuManager.m | 14 ++++-- SmartDeviceLink/SDLPreloadChoicesOperation.m | 12 ++--- .../SDLSoftButtonReplaceOperation.m | 2 +- SmartDeviceLink/SDLSystemCapabilityManager.m | 5 +++ SmartDeviceLink/SDLTextAndGraphicManager.m | 38 ++++++++-------- .../SDLTextField+ScreenManagerExtensions.h | 19 ++++++++ .../SDLTextField+ScreenManagerExtensions.m | 26 +++++++++++ ...indowCapability+ScreenManagerExtensions.h} | 2 +- ...indowCapability+ScreenManagerExtensions.m} | 4 +- 14 files changed, 188 insertions(+), 67 deletions(-) create mode 100644 SmartDeviceLink/SDLImageField+ScreenManagerExtensions.h create mode 100644 SmartDeviceLink/SDLImageField+ScreenManagerExtensions.m create mode 100644 SmartDeviceLink/SDLTextField+ScreenManagerExtensions.h create mode 100644 SmartDeviceLink/SDLTextField+ScreenManagerExtensions.m rename SmartDeviceLink/{SDLWindowCapability+ShowManagerExtensions.h => SDLWindowCapability+ScreenManagerExtensions.h} (91%) rename SmartDeviceLink/{SDLWindowCapability+ShowManagerExtensions.m => SDLWindowCapability+ScreenManagerExtensions.m} (93%) diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj index f5d6c5106..378ad6ac0 100644 --- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj +++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj @@ -409,13 +409,17 @@ 1FF7DABA1F75B2A800B46C30 /* SDLFocusableItemLocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FF7DAB91F75B2A800B46C30 /* SDLFocusableItemLocator.h */; }; 1FF7DABC1F75B2BF00B46C30 /* SDLFocusableItemLocator.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FF7DABB1F75B2BF00B46C30 /* SDLFocusableItemLocator.m */; }; 1FF7DAC01F75CF6C00B46C30 /* SDLHapticManagerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FF7DABF1F75CF6C00B46C30 /* SDLHapticManagerSpec.m */; }; - 2B233530232BD8A5002118E5 /* SDLWindowCapability+ShowManagerExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B23352E232BD8A5002118E5 /* SDLWindowCapability+ShowManagerExtensions.h */; }; - 2B233531232BD8A5002118E5 /* SDLWindowCapability+ShowManagerExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B23352F232BD8A5002118E5 /* SDLWindowCapability+ShowManagerExtensions.m */; }; + 2B233530232BD8A5002118E5 /* SDLWindowCapability+ScreenManagerExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B23352E232BD8A5002118E5 /* SDLWindowCapability+ScreenManagerExtensions.h */; }; + 2B233531232BD8A5002118E5 /* SDLWindowCapability+ScreenManagerExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B23352F232BD8A5002118E5 /* SDLWindowCapability+ScreenManagerExtensions.m */; }; 2BF2F84F20ED004000A26EF2 /* SDLAudioStreamingIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BF2F84D20ED004000A26EF2 /* SDLAudioStreamingIndicator.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2BF2F85020ED004000A26EF2 /* SDLAudioStreamingIndicator.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BF2F84E20ED004000A26EF2 /* SDLAudioStreamingIndicator.m */; }; 2BF2F85220ED068200A26EF2 /* SDLAudioStreamingIndicatorSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BF2F85120ED068200A26EF2 /* SDLAudioStreamingIndicatorSpec.m */; }; 332A914F1CED9CC60043824C /* SDLAppInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 332A913D1CED87F80043824C /* SDLAppInfo.m */; }; 332A91501CED9CF10043824C /* SDLAppInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 332A913C1CED87F80043824C /* SDLAppInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 4A99D00E247576B7009B43E6 /* SDLTextField+ScreenManagerExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A99D00C247576B7009B43E6 /* SDLTextField+ScreenManagerExtensions.h */; }; + 4A99D00F247576B7009B43E6 /* SDLTextField+ScreenManagerExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A99D00D247576B7009B43E6 /* SDLTextField+ScreenManagerExtensions.m */; }; + 4A99D0122475773C009B43E6 /* SDLImageField+ScreenManagerExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A99D0102475773C009B43E6 /* SDLImageField+ScreenManagerExtensions.h */; }; + 4A99D0132475773C009B43E6 /* SDLImageField+ScreenManagerExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A99D0112475773C009B43E6 /* SDLImageField+ScreenManagerExtensions.m */; }; 5D00AC671F140F0A004000D9 /* SDLSystemCapabilityType.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D00AC651F140F0A004000D9 /* SDLSystemCapabilityType.h */; settings = {ATTRIBUTES = (Public, ); }; }; 5D00AC681F140F0A004000D9 /* SDLSystemCapabilityType.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D00AC661F140F0A004000D9 /* SDLSystemCapabilityType.m */; }; 5D00AC6B1F141339004000D9 /* SDLSystemCapability.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D00AC691F141339004000D9 /* SDLSystemCapability.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -2120,13 +2124,17 @@ 1FF7DAB91F75B2A800B46C30 /* SDLFocusableItemLocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLFocusableItemLocator.h; sourceTree = ""; }; 1FF7DABB1F75B2BF00B46C30 /* SDLFocusableItemLocator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLFocusableItemLocator.m; sourceTree = ""; }; 1FF7DABF1F75CF6C00B46C30 /* SDLHapticManagerSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLHapticManagerSpec.m; path = ProxySpecs/SDLHapticManagerSpec.m; sourceTree = ""; }; - 2B23352E232BD8A5002118E5 /* SDLWindowCapability+ShowManagerExtensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SDLWindowCapability+ShowManagerExtensions.h"; sourceTree = ""; }; - 2B23352F232BD8A5002118E5 /* SDLWindowCapability+ShowManagerExtensions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SDLWindowCapability+ShowManagerExtensions.m"; sourceTree = ""; }; + 2B23352E232BD8A5002118E5 /* SDLWindowCapability+ScreenManagerExtensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SDLWindowCapability+ScreenManagerExtensions.h"; sourceTree = ""; }; + 2B23352F232BD8A5002118E5 /* SDLWindowCapability+ScreenManagerExtensions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SDLWindowCapability+ScreenManagerExtensions.m"; sourceTree = ""; }; 2BF2F84D20ED004000A26EF2 /* SDLAudioStreamingIndicator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDLAudioStreamingIndicator.h; sourceTree = ""; }; 2BF2F84E20ED004000A26EF2 /* SDLAudioStreamingIndicator.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLAudioStreamingIndicator.m; sourceTree = ""; }; 2BF2F85120ED068200A26EF2 /* SDLAudioStreamingIndicatorSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLAudioStreamingIndicatorSpec.m; sourceTree = ""; }; 332A913C1CED87F80043824C /* SDLAppInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLAppInfo.h; sourceTree = ""; }; 332A913D1CED87F80043824C /* SDLAppInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLAppInfo.m; sourceTree = ""; }; + 4A99D00C247576B7009B43E6 /* SDLTextField+ScreenManagerExtensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SDLTextField+ScreenManagerExtensions.h"; sourceTree = ""; }; + 4A99D00D247576B7009B43E6 /* SDLTextField+ScreenManagerExtensions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SDLTextField+ScreenManagerExtensions.m"; sourceTree = ""; }; + 4A99D0102475773C009B43E6 /* SDLImageField+ScreenManagerExtensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SDLImageField+ScreenManagerExtensions.h"; sourceTree = ""; }; + 4A99D0112475773C009B43E6 /* SDLImageField+ScreenManagerExtensions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SDLImageField+ScreenManagerExtensions.m"; sourceTree = ""; }; 5D00AC651F140F0A004000D9 /* SDLSystemCapabilityType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLSystemCapabilityType.h; sourceTree = ""; }; 5D00AC661F140F0A004000D9 /* SDLSystemCapabilityType.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLSystemCapabilityType.m; sourceTree = ""; }; 5D00AC691F141339004000D9 /* SDLSystemCapability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLSystemCapability.h; sourceTree = ""; }; @@ -4021,6 +4029,7 @@ 5D339CE5207C0651000CC364 /* Menu */, 5D0A737F203F23D10001595D /* Soft Button */, 5D0A737D203F23B30001595D /* Text and Graphic */, + 5D1BF6AA2047429C00D36881 /* Utilities */, 5DAD5F7D204DEDEB0025624C /* SDLScreenManager.h */, 5DAD5F7E204DEDEB0025624C /* SDLScreenManager.m */, ); @@ -4059,7 +4068,6 @@ 5D0A737D203F23B30001595D /* Text and Graphic */ = { isa = PBXGroup; children = ( - 5D1BF6AA2047429C00D36881 /* Utilities */, 5D0A7372203F0C730001595D /* SDLTextAndGraphicManager.h */, 5D0A7373203F0C730001595D /* SDLTextAndGraphicManager.m */, ); @@ -4103,8 +4111,12 @@ 5D1BF6AA2047429C00D36881 /* Utilities */ = { isa = PBXGroup; children = ( - 2B23352E232BD8A5002118E5 /* SDLWindowCapability+ShowManagerExtensions.h */, - 2B23352F232BD8A5002118E5 /* SDLWindowCapability+ShowManagerExtensions.m */, + 4A99D0102475773C009B43E6 /* SDLImageField+ScreenManagerExtensions.h */, + 4A99D0112475773C009B43E6 /* SDLImageField+ScreenManagerExtensions.m */, + 4A99D00C247576B7009B43E6 /* SDLTextField+ScreenManagerExtensions.h */, + 4A99D00D247576B7009B43E6 /* SDLTextField+ScreenManagerExtensions.m */, + 2B23352E232BD8A5002118E5 /* SDLWindowCapability+ScreenManagerExtensions.h */, + 2B23352F232BD8A5002118E5 /* SDLWindowCapability+ScreenManagerExtensions.m */, ); name = Utilities; sourceTree = ""; @@ -5978,11 +5990,6 @@ isa = PBXGroup; children = ( 00E22CE822C2F19700BC6B08 /* Encryption */, - 5DA3F36E1BC4489A0026F2D0 /* SDLManager.h */, - 5DA3F36F1BC4489A0026F2D0 /* SDLManager.m */, - 5D82041C1BCD8E6100D0A41B /* SDLConfiguration.h */, - 5D82041D1BCD8E6100D0A41B /* SDLConfiguration.m */, - 5D2F58071D0717D5001085CE /* SDLManagerDelegate.h */, 5D82042A1BCEA91E00D0A41B /* Files */, 5D1654571D3E79CA00554D93 /* Lifecycle */, 5DBAE0A51D355EE700CE00BF /* Lock Screen */, @@ -5990,6 +5997,11 @@ DA8966E71E56937100413EAB /* Streaming */, 5D0A736F203F0C450001595D /* Screen */, 880E35B12088F73400181259 /* System Capabilities */, + 5DA3F36E1BC4489A0026F2D0 /* SDLManager.h */, + 5DA3F36F1BC4489A0026F2D0 /* SDLManager.m */, + 5D82041C1BCD8E6100D0A41B /* SDLConfiguration.h */, + 5D82041D1BCD8E6100D0A41B /* SDLConfiguration.m */, + 5D2F58071D0717D5001085CE /* SDLManagerDelegate.h */, ); name = Managers; sourceTree = ""; @@ -6899,6 +6911,7 @@ 5D61FD2D1A84238C00846EE7 /* SDLPermissionItem.h in Headers */, 5D61FCD11A84238C00846EE7 /* SDLImageFieldName.h in Headers */, 88B3BF9820DA859800943565 /* SDLFuelType.h in Headers */, + 4A99D00E247576B7009B43E6 /* SDLTextField+ScreenManagerExtensions.h in Headers */, 5DBF062D1E64A93A00A5CF03 /* SDLLogFilter.h in Headers */, 5DCF76F91ACDD7CD00BB647B /* SDLSendLocationResponse.h in Headers */, 5D61FD391A84238C00846EE7 /* SDLPrerecordedSpeech.h in Headers */, @@ -6933,6 +6946,7 @@ 5D61FD0B1A84238C00846EE7 /* SDLOnEncodedSyncPData.h in Headers */, 5D61FC631A84238C00846EE7 /* SDLClusterModeStatus.h in Headers */, 5D61FD371A84238C00846EE7 /* SDLPredefinedLayout.h in Headers */, + 4A99D0122475773C009B43E6 /* SDLImageField+ScreenManagerExtensions.h in Headers */, 008DB36D22EA83E4003F458C /* SDLReleaseInteriorVehicleDataModuleResponse.h in Headers */, 5D61FDE31A84238C00846EE7 /* SDLUnregisterAppInterface.h in Headers */, 5D61FD331A84238C00846EE7 /* SDLPowerModeQualificationStatus.h in Headers */, @@ -7018,7 +7032,7 @@ 5D61FD951A84238C00846EE7 /* SDLShowResponse.h in Headers */, 5D61FCA31A84238C00846EE7 /* SDLEndAudioPassThru.h in Headers */, 88A795D22106787400056542 /* SDLStaticIconName.h in Headers */, - 2B233530232BD8A5002118E5 /* SDLWindowCapability+ShowManagerExtensions.h in Headers */, + 2B233530232BD8A5002118E5 /* SDLWindowCapability+ScreenManagerExtensions.h in Headers */, 5D61FCB11A84238C00846EE7 /* SDLGetDTCs.h in Headers */, 5D61FDFF1A84238C00846EE7 /* SDLVehicleDataEventStatus.h in Headers */, 5D61FC5B1A84238C00846EE7 /* SDLChangeRegistration.h in Headers */, @@ -7465,6 +7479,7 @@ 5D61FDC81A84238C00846EE7 /* SDLTextAlignment.m in Sources */, 5D4631091F21261B0092EFDC /* SDLControlFramePayloadRPCStartServiceAck.m in Sources */, 5D82042E1BCEC32F00D0A41B /* SDLFile.m in Sources */, + 4A99D00F247576B7009B43E6 /* SDLTextField+ScreenManagerExtensions.m in Sources */, 5DA3F3601BC448590026F2D0 /* SDLNotificationConstants.m in Sources */, 5D61FD5A1A84238C00846EE7 /* SDLReadDID.m in Sources */, 1EAA472E20344108000FE74B /* SDLLightStatus.m in Sources */, @@ -7586,13 +7601,14 @@ 5DCF76FA1ACDD7CD00BB647B /* SDLSendLocationResponse.m in Sources */, 5D9FDA8F1F2A7D3400A495C8 /* bson_array.c in Sources */, 5D61FD661A84238C00846EE7 /* SDLResetGlobalPropertiesResponse.m in Sources */, + 4A99D0132475773C009B43E6 /* SDLImageField+ScreenManagerExtensions.m in Sources */, 5D61FCFE1A84238C00846EE7 /* SDLObjectWithPriority.m in Sources */, 5D92937D20B70A3E00FCC775 /* SDLPresentKeyboardOperation.m in Sources */, 9FD334E122DC6E7500F62736 /* SDLCreateWindow.m in Sources */, 5DBF06241E64A83F00A5CF03 /* SDLLogManager.m in Sources */, 5D61FC401A84238C00846EE7 /* SDLAmbientLightStatus.m in Sources */, 9F425ADB22DD983500BE3245 /* SDLDisplayCapability.m in Sources */, - 2B233531232BD8A5002118E5 /* SDLWindowCapability+ShowManagerExtensions.m in Sources */, + 2B233531232BD8A5002118E5 /* SDLWindowCapability+ScreenManagerExtensions.m in Sources */, 88EEC5BC220A327B005AA2F9 /* SDLPublishAppServiceResponse.m in Sources */, 5D61FC951A84238C00846EE7 /* SDLDriverDistractionState.m in Sources */, 5DB996611F28C6ED002D8795 /* SDLControlFramePayloadVideoStartServiceAck.m in Sources */, diff --git a/SmartDeviceLink/Assets/Base.lproj/SDLLockScreen.storyboard b/SmartDeviceLink/Assets/Base.lproj/SDLLockScreen.storyboard index bb41a9a2d..e18e4a98f 100644 --- a/SmartDeviceLink/Assets/Base.lproj/SDLLockScreen.storyboard +++ b/SmartDeviceLink/Assets/Base.lproj/SDLLockScreen.storyboard @@ -1,9 +1,9 @@ - - + + - + @@ -16,18 +16,18 @@ - + - + diff --git a/SmartDeviceLink/SDLChoiceSetManager.m b/SmartDeviceLink/SDLChoiceSetManager.m index 1aaa87e56..a8d3468b7 100644 --- a/SmartDeviceLink/SDLChoiceSetManager.m +++ b/SmartDeviceLink/SDLChoiceSetManager.m @@ -39,7 +39,7 @@ #import "SDLSystemCapability.h" #import "SDLSystemCapabilityManager.h" #import "SDLWindowCapability.h" -#import "SDLWindowCapability+ShowManagerExtensions.h" +#import "SDLWindowCapability+ScreenManagerExtensions.h" NS_ASSUME_NONNULL_BEGIN diff --git a/SmartDeviceLink/SDLImageField+ScreenManagerExtensions.h b/SmartDeviceLink/SDLImageField+ScreenManagerExtensions.h new file mode 100644 index 000000000..6c21266d7 --- /dev/null +++ b/SmartDeviceLink/SDLImageField+ScreenManagerExtensions.h @@ -0,0 +1,19 @@ +// +// SDLImageField+ScreenManagerExtensions.h +// SmartDeviceLink +// +// Created by Joel Fischer on 5/20/20. +// Copyright © 2020 smartdevicelink. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface SDLImageField (ScreenManagerExtensions) + ++ (NSArray *)allImageFields; + +@end + +NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLImageField+ScreenManagerExtensions.m b/SmartDeviceLink/SDLImageField+ScreenManagerExtensions.m new file mode 100644 index 000000000..1c7cc09c1 --- /dev/null +++ b/SmartDeviceLink/SDLImageField+ScreenManagerExtensions.m @@ -0,0 +1,30 @@ +// +// SDLImageField+ScreenManagerExtensions.m +// SmartDeviceLink +// +// Created by Joel Fischer on 5/20/20. +// Copyright © 2020 smartdevicelink. All rights reserved. +// + +#import "SDLImageField+ScreenManagerExtensions.h" + +@implementation SDLImageField (ScreenManagerExtensions) + ++ (NSArray *)sdl_allImageFieldNames { + return @[SDLImageFieldNameAppIcon, SDLImageFieldNameGraphic, SDLImageFieldNameMenuIcon, SDLImageFieldNameTurnIcon, SDLImageFieldNameAlertIcon, SDLImageFieldNameChoiceImage, SDLImageFieldNameCommandIcon, SDLImageFieldNameLocationImage, SDLImageFieldNameSoftButtonImage, SDLImageFieldNameSecondaryGraphic, SDLImageFieldNameShowConstantTBTIcon, SDLImageFieldNameChoiceSecondaryImage, SDLImageFieldNameVoiceRecognitionHelpItem, SDLImageFieldNameShowConstantTBTNextTurnIcon]; +} + ++ (NSArray *)sdl_allImageFileTypes { + return @[SDLFileTypeBMP, SDLFileTypePNG, SDLFileTypeJPEG]; +} + ++ (NSArray *)allImageFields { + NSMutableArray *tempImageFields = [NSMutableArray array]; + for (SDLImageFieldName fieldName in [self sdl_allImageFieldNames]) { + [tempImageFields addObject:[[SDLImageField alloc] initWithName:fieldName imageTypeSupported:[self sdl_allImageFileTypes] imageResolution:nil]]; + } + + return tempImageFields; +} + +@end diff --git a/SmartDeviceLink/SDLMenuManager.m b/SmartDeviceLink/SDLMenuManager.m index 28a70f754..b5d3cbf05 100644 --- a/SmartDeviceLink/SDLMenuManager.m +++ b/SmartDeviceLink/SDLMenuManager.m @@ -38,7 +38,7 @@ #import "SDLShowAppMenu.h" #import "SDLSystemCapabilityManager.h" #import "SDLWindowCapability.h" -#import "SDLWindowCapability+ShowManagerExtensions.h" +#import "SDLWindowCapability+ScreenManagerExtensions.h" #import "SDLVersion.h" #import "SDLVoiceCommand.h" @@ -65,6 +65,7 @@ @interface SDLMenuManager() @property (assign, nonatomic) BOOL hasQueuedUpdate; @property (assign, nonatomic) BOOL waitingOnHMIUpdate; @property (copy, nonatomic) NSArray *waitingUpdateMenuCells; +@property (strong, nonatomic, nullable) SDLWindowCapability *windowCapability; @property (assign, nonatomic) UInt32 lastMenuId; @property (copy, nonatomic) NSArray *oldMenuCells; @@ -119,7 +120,7 @@ - (void)stop { #pragma mark - Setters - (void)setMenuConfiguration:(SDLMenuConfiguration *)menuConfiguration { - NSArray *layoutsAvailable = self.systemCapabilityManager.defaultMainWindowCapability.menuLayoutsAvailable; + NSArray *layoutsAvailable = self.windowCapability.menuLayoutsAvailable; if ([[SDLGlobals sharedGlobals].rpcVersion isLessThanVersion:[SDLVersion versionWithMajor:6 minor:0 patch:0]]) { SDLLogW(@"Menu configurations is only supported on head units with RPC spec version 6.0.0 or later. Currently connected head unit RPC spec version is %@", [SDLGlobals sharedGlobals].rpcVersion); @@ -466,7 +467,7 @@ - (void)sdl_sendUpdatedMenu:(NSArray *)updatedMenu usingMenu:(NSA NSArray *mainMenuCommands = nil; NSArray *subMenuCommands = nil; - if ([self sdl_findAllArtworksToBeUploadedFromCells:self.menuCells].count > 0 || ![self.systemCapabilityManager.defaultMainWindowCapability hasImageFieldOfName:SDLImageFieldNameCommandIcon]) { + if ([self sdl_findAllArtworksToBeUploadedFromCells:self.menuCells].count > 0 || ![self.windowCapability hasImageFieldOfName:SDLImageFieldNameCommandIcon]) { // Send artwork-less menu mainMenuCommands = [self sdl_mainMenuCommandsForCells:updatedMenu withArtwork:NO usingIndexesFrom:menu]; subMenuCommands = [self sdl_subMenuCommandsForCells:updatedMenu withArtwork:NO]; @@ -528,7 +529,7 @@ - (BOOL)sdl_isDynamicMenuUpdateActive:(SDLDynamicMenuUpdatesMode)dynamicMenuUpda #pragma mark Artworks - (NSArray *)sdl_findAllArtworksToBeUploadedFromCells:(NSArray *)cells { - if (![self.systemCapabilityManager.defaultMainWindowCapability hasImageFieldOfName:SDLImageFieldNameCommandIcon]) { + if (![self.windowCapability hasImageFieldOfName:SDLImageFieldNameCommandIcon]) { return @[]; } @@ -688,6 +689,11 @@ - (void)sdl_commandNotification:(SDLRPCNotificationNotification *)notification { [self sdl_callHandlerForCells:self.menuCells command:onCommand]; } +- (void)sdl_displayCapabilityDidUpdate:(SDLSystemCapability *)systemCapability { + // We won't use the object in the parameter but the convenience method of the system capability manager + self.windowCapability = self.systemCapabilityManager.defaultMainWindowCapability; +} + - (void)sdl_hmiStatusNotification:(SDLRPCNotificationNotification *)notification { SDLOnHMIStatus *hmiStatus = (SDLOnHMIStatus *)notification.notification; diff --git a/SmartDeviceLink/SDLPreloadChoicesOperation.m b/SmartDeviceLink/SDLPreloadChoicesOperation.m index 3b96d1f80..82f7435ff 100644 --- a/SmartDeviceLink/SDLPreloadChoicesOperation.m +++ b/SmartDeviceLink/SDLPreloadChoicesOperation.m @@ -19,7 +19,7 @@ #import "SDLImage.h" #import "SDLLogMacros.h" #import "SDLWindowCapability.h" -#import "SDLWindowCapability+ShowManagerExtensions.h" +#import "SDLWindowCapability+ScreenManagerExtensions.h" NS_ASSUME_NONNULL_BEGIN @@ -192,27 +192,27 @@ - (BOOL)sdl_shouldSendChoiceText { } #pragma clang diagnostic pop - return (self.windowCapability.textFields != nil) ? [self.windowCapability hasTextFieldOfName:SDLTextFieldNameMenuName] : YES; + return [self.windowCapability hasTextFieldOfName:SDLTextFieldNameMenuName]; } /// Determine if we should send secondary text. If textFields is nil, we don't know the capabilities and we will send everything. - (BOOL)sdl_shouldSendChoiceSecondaryText { - return (self.windowCapability.textFields != nil) ? [self.windowCapability hasTextFieldOfName:SDLTextFieldNameSecondaryText] : YES; + return [self.windowCapability hasTextFieldOfName:SDLTextFieldNameSecondaryText]; } /// Determine if we should send teriary text. If textFields is nil, we don't know the capabilities and we will send everything. - (BOOL)sdl_shouldSendChoiceTertiaryText { - return (self.windowCapability.textFields != nil) ? [self.windowCapability hasTextFieldOfName:SDLTextFieldNameTertiaryText] : YES; + return [self.windowCapability hasTextFieldOfName:SDLTextFieldNameTertiaryText]; } /// Determine if we should send the primary image. If imageFields is nil, we don't know the capabilities and we will send everything. - (BOOL)sdl_shouldSendChoicePrimaryImage { - return (self.windowCapability.imageFields != nil) ? [self.windowCapability hasImageFieldOfName:SDLImageFieldNameChoiceImage] : YES; + return [self.windowCapability hasImageFieldOfName:SDLImageFieldNameChoiceImage]; } /// Determine if we should send the secondary image. If imageFields is nil, we don't know the capabilities and we will send everything. - (BOOL)sdl_shouldSendChoiceSecondaryImage { - return (self.windowCapability.imageFields != nil) ? [self.windowCapability hasImageFieldOfName:SDLImageFieldNameChoiceSecondaryImage] : YES; + return [self.windowCapability hasImageFieldOfName:SDLImageFieldNameChoiceSecondaryImage]; } #pragma mark - Property Overrides diff --git a/SmartDeviceLink/SDLSoftButtonReplaceOperation.m b/SmartDeviceLink/SDLSoftButtonReplaceOperation.m index 91191f3b0..979bd1bcd 100644 --- a/SmartDeviceLink/SDLSoftButtonReplaceOperation.m +++ b/SmartDeviceLink/SDLSoftButtonReplaceOperation.m @@ -248,7 +248,7 @@ - (void)sdl_sendCurrentStateTextOnlySoftButtonsWithCompletionHandler:(void (^)(B #pragma mark - Images - (BOOL)sdl_artworkNeedsUpload:(SDLArtwork *)artwork { - return (artwork != nil && ![self.fileManager hasUploadedFile:artwork] && !artwork.isStaticIcon); + return (artwork != nil && ![self.fileManager hasUploadedFile:artwork] && self.softButtonCapabilities.imageSupported.boolValue && !artwork.isStaticIcon); } - (BOOL)sdl_currentStateHasImages { diff --git a/SmartDeviceLink/SDLSystemCapabilityManager.m b/SmartDeviceLink/SDLSystemCapabilityManager.m index ea1dee9b5..9d085e100 100644 --- a/SmartDeviceLink/SDLSystemCapabilityManager.m +++ b/SmartDeviceLink/SDLSystemCapabilityManager.m @@ -20,6 +20,7 @@ #import "SDLGetSystemCapabilityResponse.h" #import "SDLGlobals.h" #import "SDLHMICapabilities.h" +#import "SDLImageField+ScreenManagerExtensions.h" #import "SDLLogMacros.h" #import "SDLNavigationCapability.h" #import "SDLNotificationConstants.h" @@ -35,6 +36,8 @@ #import "SDLSetDisplayLayoutResponse.h" #import "SDLSystemCapability.h" #import "SDLSystemCapabilityObserver.h" +#import "SDLTextField+ScreenManagerExtensions.h" +#import "SDLTextFieldName.h" #import "SDLVersion.h" #import "SDLVideoStreamingCapability.h" #import "SDLWindowCapability.h" @@ -208,6 +211,8 @@ - (nullable SDLWindowCapability *)defaultMainWindowCapability { // return if display capabilities don't exist. if (display == nil) { + defaultWindowCapability.textFields = [SDLTextField allTextFields]; + defaultWindowCapability.imageFields = [SDLImageField allImageFields]; displayCapability.windowCapabilities = @[defaultWindowCapability]; return @[displayCapability]; } diff --git a/SmartDeviceLink/SDLTextAndGraphicManager.m b/SmartDeviceLink/SDLTextAndGraphicManager.m index 7da2808e3..d043d214b 100644 --- a/SmartDeviceLink/SDLTextAndGraphicManager.m +++ b/SmartDeviceLink/SDLTextAndGraphicManager.m @@ -27,7 +27,7 @@ #import "SDLSystemCapabilityManager.h" #import "SDLTextField.h" #import "SDLWindowCapability.h" -#import "SDLWindowCapability+ShowManagerExtensions.h" +#import "SDLWindowCapability+ScreenManagerExtensions.h" NS_ASSUME_NONNULL_BEGIN @@ -523,46 +523,46 @@ - (BOOL)sdl_artworkNeedsUpload:(SDLArtwork *)artwork { } - (BOOL)sdl_shouldUpdatePrimaryImage { - BOOL templateSupportsPrimaryArtwork = (self.windowCapability.imageFields != nil) ? [self.windowCapability hasImageFieldOfName:SDLImageFieldNameGraphic] : YES; + BOOL templateSupportsPrimaryArtwork = [self.windowCapability hasImageFieldOfName:SDLImageFieldNameGraphic]; + BOOL graphicMatchesExisting = [self.currentScreenData.graphic.value isEqualToString:self.primaryGraphic.name]; + BOOL graphicExists = (self.primaryGraphic != nil); - return (templateSupportsPrimaryArtwork - && ![self.currentScreenData.graphic.value isEqualToString:self.primaryGraphic.name] - && self.primaryGraphic != nil); + return (templateSupportsPrimaryArtwork && !graphicMatchesExisting && graphicExists); } - (BOOL)sdl_shouldUpdateSecondaryImage { - BOOL templateSupportsSecondaryArtwork = (self.windowCapability.imageFields != nil) ? ([self.windowCapability hasImageFieldOfName:SDLImageFieldNameGraphic] || [self.windowCapability hasImageFieldOfName:SDLImageFieldNameSecondaryGraphic]) : YES; + BOOL templateSupportsSecondaryArtwork = [self.windowCapability hasImageFieldOfName:SDLImageFieldNameSecondaryGraphic]; + BOOL graphicMatchesExisting = [self.currentScreenData.secondaryGraphic.value isEqualToString:self.secondaryGraphic.name]; + BOOL graphicExists = (self.secondaryGraphic != nil); // Cannot detect if there is a secondary image, so we'll just try to detect if there's a primary image and allow it if there is. - return (templateSupportsSecondaryArtwork - && ![self.currentScreenData.secondaryGraphic.value isEqualToString:self.secondaryGraphic.name] - && self.secondaryGraphic != nil); + return (templateSupportsSecondaryArtwork && !graphicMatchesExisting && graphicExists); } - (BOOL)sdl_shouldUpdateMediaTextField { - return (self.windowCapability.textFields != nil) ? [self.windowCapability hasTextFieldOfName:SDLTextFieldNameMediaTrack] : YES; + return [self.windowCapability hasTextFieldOfName:SDLTextFieldNameMediaTrack]; } - (BOOL)sdl_shouldUpdateTitleField { - return (self.windowCapability.textFields != nil) ? [self.windowCapability hasTextFieldOfName:SDLTextFieldNameTemplateTitle] : YES; + return [self.windowCapability hasTextFieldOfName:SDLTextFieldNameTemplateTitle]; } - (NSArray *)sdl_findNonNilTextFields { NSMutableArray *array = [NSMutableArray array]; - self.textField1.length > 0 ? [array addObject:self.textField1] : nil; - self.textField2.length > 0 ? [array addObject:self.textField2] : nil; - self.textField3.length > 0 ? [array addObject:self.textField3] : nil; - self.textField4.length > 0 ? [array addObject:self.textField4] : nil; + (self.textField1.length > 0) ? [array addObject:self.textField1] : nil; + (self.textField2.length > 0) ? [array addObject:self.textField2] : nil; + (self.textField3.length > 0) ? [array addObject:self.textField3] : nil; + (self.textField4.length > 0) ? [array addObject:self.textField4] : nil; return [array copy]; } - (NSArray *)sdl_findNonNilMetadataFields { NSMutableArray *array = [NSMutableArray array]; - self.textField1Type.length > 0 ? [array addObject:self.textField1Type] : nil; - self.textField2Type.length > 0 ? [array addObject:self.textField2Type] : nil; - self.textField3Type.length > 0 ? [array addObject:self.textField3Type] : nil; - self.textField4Type.length > 0 ? [array addObject:self.textField4Type] : nil; + (self.textField1Type.length) > 0 ? [array addObject:self.textField1Type] : nil; + (self.textField2Type.length) > 0 ? [array addObject:self.textField2Type] : nil; + (self.textField3Type.length) > 0 ? [array addObject:self.textField3Type] : nil; + (self.textField4Type.length) > 0 ? [array addObject:self.textField4Type] : nil; return [array copy]; } diff --git a/SmartDeviceLink/SDLTextField+ScreenManagerExtensions.h b/SmartDeviceLink/SDLTextField+ScreenManagerExtensions.h new file mode 100644 index 000000000..310b024bf --- /dev/null +++ b/SmartDeviceLink/SDLTextField+ScreenManagerExtensions.h @@ -0,0 +1,19 @@ +// +// SDLTextField+ScreenManagerExtensions.h +// SmartDeviceLink +// +// Created by Joel Fischer on 5/20/20. +// Copyright © 2020 smartdevicelink. All rights reserved. +// + +#import "SDLTextField.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface SDLTextField (ScreenManagerExtensions) + ++ (NSArray *)allTextFields; + +@end + +NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLTextField+ScreenManagerExtensions.m b/SmartDeviceLink/SDLTextField+ScreenManagerExtensions.m new file mode 100644 index 000000000..a3ec2cb49 --- /dev/null +++ b/SmartDeviceLink/SDLTextField+ScreenManagerExtensions.m @@ -0,0 +1,26 @@ +// +// SDLTextField+ScreenManagerExtensions.m +// SmartDeviceLink +// +// Created by Joel Fischer on 5/20/20. +// Copyright © 2020 smartdevicelink. All rights reserved. +// + +#import "SDLTextField+ScreenManagerExtensions.h" + +@implementation SDLTextField (ScreenManagerExtensions) + ++ (NSArray *)sdl_allTextFieldNames { + return @[SDLTextFieldNameETA, SDLTextFieldNameMenuName, SDLTextFieldNameMenuTitle, SDLTextFieldNameStatusBar, SDLTextFieldNameAlertText1, SDLTextFieldNameAlertText2, SDLTextFieldNameAlertText3, SDLTextFieldNameMainField1, SDLTextFieldNameMainField2, SDLTextFieldNameMainField3, SDLTextFieldNameMainField4, SDLTextFieldNameMediaClock, SDLTextFieldNameMediaTrack, SDLTextFieldNamePhoneNumber, SDLTextFieldNameAddressLines, SDLTextFieldNameLocationName, SDLTextFieldNameSliderFooter, SDLTextFieldNameSliderHeader, SDLTextFieldNameTertiaryText, SDLTextFieldNameSecondaryText, SDLTextFieldNameTemplateTitle, SDLTextFieldNameTotalDistance, SDLTextFieldNameNavigationText1, SDLTextFieldNameNavigationText2, SDLTextFieldNameLocationDescription, SDLTextFieldNameScrollableMessageBody, SDLTextFieldNameInitialInteractionText, SDLTextFieldNameAudioPassThruDisplayText1, SDLTextFieldNameAudioPassThruDisplayText2]; +} + ++ (NSArray *)allTextFields { + NSMutableArray *tempTextFields = [NSMutableArray array]; + for (SDLTextFieldName fieldName in [self sdl_allTextFieldNames]) { + [tempTextFields addObject:[[SDLTextField alloc] initWithName:fieldName characterSet:SDLCharacterSetCID1 width:500 rows:500]]; + } + + return tempTextFields; +} + +@end diff --git a/SmartDeviceLink/SDLWindowCapability+ShowManagerExtensions.h b/SmartDeviceLink/SDLWindowCapability+ScreenManagerExtensions.h similarity index 91% rename from SmartDeviceLink/SDLWindowCapability+ShowManagerExtensions.h rename to SmartDeviceLink/SDLWindowCapability+ScreenManagerExtensions.h index 14bfc9ffa..9321c98cd 100644 --- a/SmartDeviceLink/SDLWindowCapability+ShowManagerExtensions.h +++ b/SmartDeviceLink/SDLWindowCapability+ScreenManagerExtensions.h @@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface SDLWindowCapability (ShowManagerExtensions) +@interface SDLWindowCapability (ScreenManagerExtensions) @property (assign, nonatomic, readonly) NSUInteger maxNumberOfMainFieldLines; diff --git a/SmartDeviceLink/SDLWindowCapability+ShowManagerExtensions.m b/SmartDeviceLink/SDLWindowCapability+ScreenManagerExtensions.m similarity index 93% rename from SmartDeviceLink/SDLWindowCapability+ShowManagerExtensions.m rename to SmartDeviceLink/SDLWindowCapability+ScreenManagerExtensions.m index c6b808e22..441356a83 100644 --- a/SmartDeviceLink/SDLWindowCapability+ShowManagerExtensions.m +++ b/SmartDeviceLink/SDLWindowCapability+ScreenManagerExtensions.m @@ -8,11 +8,11 @@ // Copyright © 2019 smartdevicelink. All rights reserved. // -#import "SDLWindowCapability+ShowManagerExtensions.h" +#import "SDLWindowCapability+ScreenManagerExtensions.h" #import "SDLImageField.h" #import "SDLTextField.h" -@implementation SDLWindowCapability (ShowManagerExtension) +@implementation SDLWindowCapability (ScreenManagerExtensions) - (BOOL)hasTextFieldOfName:(SDLTextFieldName)name { for (SDLTextField *textField in self.textFields) { From 41c455ded59fff0b3a5feaee2bdedfa6ab31d66f Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Wed, 20 May 2020 14:25:34 -0400 Subject: [PATCH 02/10] Add a log --- SmartDeviceLink/SDLMenuManager.m | 1 + 1 file changed, 1 insertion(+) diff --git a/SmartDeviceLink/SDLMenuManager.m b/SmartDeviceLink/SDLMenuManager.m index b5d3cbf05..29a6539ad 100644 --- a/SmartDeviceLink/SDLMenuManager.m +++ b/SmartDeviceLink/SDLMenuManager.m @@ -159,6 +159,7 @@ - (void)setMenuCells:(NSArray *)menuCells { if (self.currentHMILevel == nil || [self.currentHMILevel isEqualToEnum:SDLHMILevelNone] || [self.currentSystemContext isEqualToEnum:SDLSystemContextMenu]) { + SDLLogD(@"Waiting for HMI update to send menu cells"); self.waitingOnHMIUpdate = YES; self.waitingUpdateMenuCells = menuCells; return; From 5bcffaaec203b53f1e455e235c52502ec874e3a6 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Wed, 20 May 2020 16:05:14 -0400 Subject: [PATCH 03/10] Fix text and graphic lines available To align with other changes in this PR --- SmartDeviceLink/SDLTextAndGraphicManager.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SmartDeviceLink/SDLTextAndGraphicManager.m b/SmartDeviceLink/SDLTextAndGraphicManager.m index d043d214b..6324e13e3 100644 --- a/SmartDeviceLink/SDLTextAndGraphicManager.m +++ b/SmartDeviceLink/SDLTextAndGraphicManager.m @@ -312,7 +312,7 @@ - (SDLShow *)sdl_assembleShowText:(SDLShow *)show { NSArray *nonNilFields = [self sdl_findNonNilTextFields]; if (nonNilFields.count == 0) { return show; } - NSUInteger numberOfLines = (self.windowCapability.textFields != nil) ? self.windowCapability.maxNumberOfMainFieldLines : 4; + NSUInteger numberOfLines = self.windowCapability.maxNumberOfMainFieldLines; if (numberOfLines == 1) { show = [self sdl_assembleOneLineShowText:show withShowFields:nonNilFields]; } else if (numberOfLines == 2) { From 980403c72928821c5460ee7df14d15446366a240 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Wed, 20 May 2020 16:05:34 -0400 Subject: [PATCH 04/10] Fix text & graphic tests --- .../DevAPISpecs/SDLTextAndGraphicManagerSpec.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m index fb7298988..3e00ffe37 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m @@ -375,7 +375,7 @@ @interface SDLTextAndGraphicManager() testManager.windowCapability = [[SDLWindowCapability alloc] init]; }); - it(@"should send everything", ^{ + fit(@"should send nothing", ^{ testManager.mediaTrackTextField = textMediaTrack; testManager.title = textTitle; testManager.textField1 = textLine1; @@ -386,12 +386,12 @@ @interface SDLTextAndGraphicManager() testManager.batchUpdates = NO; [testManager updateWithCompletionHandler:nil]; - expect(testManager.inProgressUpdate.mediaTrack).to(equal(textMediaTrack)); - expect(testManager.inProgressUpdate.templateTitle).to(equal(textTitle)); - expect(testManager.inProgressUpdate.mainField1).to(equal(textLine1)); - expect(testManager.inProgressUpdate.mainField2).to(equal(textLine2)); - expect(testManager.inProgressUpdate.mainField3).to(equal(textLine3)); - expect(testManager.inProgressUpdate.mainField4).to(equal(textLine4)); + expect(testManager.inProgressUpdate.mediaTrack).toNot(equal(textMediaTrack)); + expect(testManager.inProgressUpdate.templateTitle).toNot(equal(textTitle)); + expect(testManager.inProgressUpdate.mainField1).toNot(equal(textLine1)); + expect(testManager.inProgressUpdate.mainField2).toNot(equal(textLine2)); + expect(testManager.inProgressUpdate.mainField3).toNot(equal(textLine3)); + expect(testManager.inProgressUpdate.mainField4).toNot(equal(textLine4)); }); }); From 4d2936f468ffa3c5d4f89c65e9f7c61e3b2158a5 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Wed, 20 May 2020 16:26:39 -0400 Subject: [PATCH 05/10] Fix menu manager display capabilities never updating --- SmartDeviceLink/SDLMenuManager.m | 4 ++++ SmartDeviceLink/SDLScreenManager.m | 1 + .../DevAPISpecs/SDLTextAndGraphicManagerSpec.m | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/SmartDeviceLink/SDLMenuManager.m b/SmartDeviceLink/SDLMenuManager.m index 29a6539ad..031a21e5b 100644 --- a/SmartDeviceLink/SDLMenuManager.m +++ b/SmartDeviceLink/SDLMenuManager.m @@ -104,6 +104,10 @@ - (instancetype)initWithConnectionManager:(id)connecti return self; } +- (void)start { + [self.systemCapabilityManager subscribeToCapabilityType:SDLSystemCapabilityTypeDisplays withObserver:self selector:@selector(sdl_displayCapabilityDidUpdate:)]; +} + - (void)stop { _lastMenuId = MenuCellIdMin; _menuCells = @[]; diff --git a/SmartDeviceLink/SDLScreenManager.m b/SmartDeviceLink/SDLScreenManager.m index fac9ca4c0..91c240662 100644 --- a/SmartDeviceLink/SDLScreenManager.m +++ b/SmartDeviceLink/SDLScreenManager.m @@ -52,6 +52,7 @@ - (instancetype)initWithConnectionManager:(id)connecti - (void)startWithCompletionHandler:(void (^)(NSError * _Nullable))handler { [self.textAndGraphicManager start]; [self.softButtonManager start]; + [self.menuManager start]; [self.choiceSetManager start]; handler(nil); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m index 3e00ffe37..5f4944315 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m @@ -375,7 +375,7 @@ @interface SDLTextAndGraphicManager() testManager.windowCapability = [[SDLWindowCapability alloc] init]; }); - fit(@"should send nothing", ^{ + it(@"should send nothing", ^{ testManager.mediaTrackTextField = textMediaTrack; testManager.title = textTitle; testManager.textField1 = textLine1; From b4838a4a98f82b0f1e8d7c5469455c5c517262f8 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Thu, 21 May 2020 14:50:08 -0400 Subject: [PATCH 06/10] Fix number of rows to be max according to the spec --- SmartDeviceLink/SDLTextField+ScreenManagerExtensions.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SmartDeviceLink/SDLTextField+ScreenManagerExtensions.m b/SmartDeviceLink/SDLTextField+ScreenManagerExtensions.m index a3ec2cb49..746c5ae23 100644 --- a/SmartDeviceLink/SDLTextField+ScreenManagerExtensions.m +++ b/SmartDeviceLink/SDLTextField+ScreenManagerExtensions.m @@ -17,7 +17,7 @@ @implementation SDLTextField (ScreenManagerExtensions) + (NSArray *)allTextFields { NSMutableArray *tempTextFields = [NSMutableArray array]; for (SDLTextFieldName fieldName in [self sdl_allTextFieldNames]) { - [tempTextFields addObject:[[SDLTextField alloc] initWithName:fieldName characterSet:SDLCharacterSetCID1 width:500 rows:500]]; + [tempTextFields addObject:[[SDLTextField alloc] initWithName:fieldName characterSet:SDLCharacterSetCID1 width:500 rows:8]]; } return tempTextFields; From e43f36bbf2db4851bfeddbb49a79973339f56185 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Thu, 21 May 2020 14:50:52 -0400 Subject: [PATCH 07/10] Fix menu manager tests --- SmartDeviceLink/SDLMenuManager.h | 7 ++++--- SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/SmartDeviceLink/SDLMenuManager.h b/SmartDeviceLink/SDLMenuManager.h index 54701313b..a17775131 100644 --- a/SmartDeviceLink/SDLMenuManager.h +++ b/SmartDeviceLink/SDLMenuManager.h @@ -30,9 +30,10 @@ typedef void(^SDLMenuUpdateCompletionHandler)(NSError *__nullable error); - (instancetype)initWithConnectionManager:(id)connectionManager fileManager:(SDLFileManager *)fileManager systemCapabilityManager:(SDLSystemCapabilityManager *)systemCapabilityManager; -/** - * Stops the manager. This method is used internally. - */ +/// Starts the manager. This method is used internally. +- (void)start; + +/// Stops the manager. This method is used internally. - (void)stop; @property (strong, nonatomic) SDLMenuConfiguration *menuConfiguration; diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m index ab0640a26..180147ef8 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m @@ -34,6 +34,8 @@ @interface SDLMenuManager() @property (assign, nonatomic) UInt32 lastMenuId; @property (copy, nonatomic) NSArray *oldMenuCells; +- (void)sdl_displayCapabilityDidUpdate:(SDLSystemCapability *)systemCapability; + @end QuickSpecBegin(SDLMenuManagerSpec) @@ -85,6 +87,7 @@ @interface SDLMenuManager() OCMStub(mockSystemCapabilityManager.defaultMainWindowCapability).andReturn(windowCapability); OCMStub(mockSystemCapabilityManager.displays).andReturn(@[displayCapability]); + [testManager sdl_displayCapabilityDidUpdate:nil]; }); it(@"should instantiate correctly", ^{ From f993d7da76927090b6d6f9f8403aa3c5d58091b5 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Thu, 21 May 2020 15:29:45 -0400 Subject: [PATCH 08/10] Text and graphic test fixes --- .../DevAPISpecs/SDLMenuManagerSpec.m | 11 ++--------- .../DevAPISpecs/SDLTextAndGraphicManagerSpec.m | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m index 180147ef8..ff9c4e7bb 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m @@ -30,12 +30,11 @@ @interface SDLMenuManager() @property (assign, nonatomic) BOOL hasQueuedUpdate; @property (assign, nonatomic) BOOL waitingOnHMIUpdate; @property (copy, nonatomic) NSArray *waitingUpdateMenuCells; +@property (strong, nonatomic, nullable) SDLWindowCapability *windowCapability; @property (assign, nonatomic) UInt32 lastMenuId; @property (copy, nonatomic) NSArray *oldMenuCells; -- (void)sdl_displayCapabilityDidUpdate:(SDLSystemCapability *)systemCapability; - @end QuickSpecBegin(SDLMenuManagerSpec) @@ -81,13 +80,7 @@ - (void)sdl_displayCapabilityDidUpdate:(SDLSystemCapability *)systemCapability; windowCapability.imageFields = @[commandIconField]; windowCapability.imageTypeSupported = @[SDLImageTypeDynamic, SDLImageTypeStatic]; windowCapability.menuLayoutsAvailable = @[SDLMenuLayoutList, SDLMenuLayoutTiles]; - - SDLDisplayCapability *displayCapability = [[SDLDisplayCapability alloc] initWithDisplayName:SDLDisplayTypeGeneric]; - displayCapability.windowCapabilities = @[windowCapability]; - - OCMStub(mockSystemCapabilityManager.defaultMainWindowCapability).andReturn(windowCapability); - OCMStub(mockSystemCapabilityManager.displays).andReturn(@[displayCapability]); - [testManager sdl_displayCapabilityDidUpdate:nil]; + testManager.windowCapability = windowCapability; }); it(@"should instantiate correctly", ^{ diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m index 5f4944315..2cd87bb3b 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m @@ -6,6 +6,7 @@ #import "SDLFileManager.h" #import "SDLHMILevel.h" #import "SDLImage.h" +#import "SDLImageField.h" #import "SDLMetadataTags.h" #import "SDLPutFileResponse.h" #import "SDLShow.h" @@ -37,6 +38,8 @@ @interface SDLTextAndGraphicManager() @property (assign, nonatomic) BOOL isDirty; +- (void)sdl_displayCapabilityDidUpdate:(SDLSystemCapability *)systemCapability; + @end QuickSpecBegin(SDLTextAndGraphicManagerSpec) @@ -859,10 +862,21 @@ @interface SDLTextAndGraphicManager() }); }); - context(@"updating images", ^{ + fcontext(@"updating images", ^{ __block NSString *testTextFieldText = @"mainFieldText"; beforeEach(^{ + testManager.windowCapability = [[SDLWindowCapability alloc] init]; + SDLImageField *primaryImageField = [[SDLImageField alloc] init]; + primaryImageField.name = SDLImageFieldNameGraphic; + SDLImageField *secondaryImageField = [[SDLImageField alloc] init]; + secondaryImageField.name = SDLImageFieldNameSecondaryGraphic; + testManager.windowCapability.imageFields = @[primaryImageField, secondaryImageField]; + + SDLTextField *lineOneField = [[SDLTextField alloc] init]; + lineOneField.name = SDLTextFieldNameMainField1; + testManager.windowCapability.textFields = @[lineOneField]; + testManager.batchUpdates = YES; testManager.textField1 = testTextFieldText; }); @@ -888,7 +902,7 @@ @interface SDLTextAndGraphicManager() testManager.windowCapability = [[SDLWindowCapability alloc] init]; }); - it(@"should send everything", ^{ + it(@"should send nothing", ^{ testManager.primaryGraphic = testArtwork; testManager.secondaryGraphic = testArtwork; testManager.batchUpdates = NO; From c7fbf438345d38dd581a4b1c5df5930ffa1f90e5 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Tue, 26 May 2020 09:03:24 -0400 Subject: [PATCH 09/10] Additional test fixes --- .../SDLTextAndGraphicManagerSpec.m | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m index 2cd87bb3b..99aa9dbb5 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m @@ -862,7 +862,7 @@ - (void)sdl_displayCapabilityDidUpdate:(SDLSystemCapability *)systemCapability; }); }); - fcontext(@"updating images", ^{ + context(@"updating images", ^{ __block NSString *testTextFieldText = @"mainFieldText"; beforeEach(^{ @@ -881,6 +881,23 @@ - (void)sdl_displayCapabilityDidUpdate:(SDLSystemCapability *)systemCapability; testManager.textField1 = testTextFieldText; }); + context(@"when imageFields are nil", ^{ + beforeEach(^{ + testManager.windowCapability.imageFields = nil; + }); + + it(@"should send nothing", ^{ + testManager.primaryGraphic = testArtwork; + testManager.secondaryGraphic = testArtwork; + testManager.batchUpdates = NO; + [testManager updateWithCompletionHandler:nil]; + + expect(testManager.inProgressUpdate.graphic).to(beNil()); + expect(testManager.inProgressUpdate.secondaryGraphic).to(beNil()); + expect(testManager.inProgressUpdate.mainField1).to(equal(testTextFieldText)); + }); + }); + context(@"when the image is already on the head unit", ^{ beforeEach(^{ OCMStub([mockFileManager hasUploadedFile:[OCMArg isNotNil]]).andReturn(YES); @@ -896,23 +913,6 @@ - (void)sdl_displayCapabilityDidUpdate:(SDLSystemCapability *)systemCapability; expect(testManager.inProgressUpdate.secondaryGraphic.value).to(equal(testArtworkName)); expect(testManager.inProgressUpdate.mainField1).to(equal(testTextFieldText)); }); - - context(@"when imageFields are nil", ^{ - beforeEach(^{ - testManager.windowCapability = [[SDLWindowCapability alloc] init]; - }); - - it(@"should send nothing", ^{ - testManager.primaryGraphic = testArtwork; - testManager.secondaryGraphic = testArtwork; - testManager.batchUpdates = NO; - [testManager updateWithCompletionHandler:nil]; - - expect(testManager.inProgressUpdate.graphic.value).to(equal(testArtworkName)); - expect(testManager.inProgressUpdate.secondaryGraphic.value).to(equal(testArtworkName)); - expect(testManager.inProgressUpdate.mainField1).to(equal(testTextFieldText)); - }); - }); }); context(@"when the image is a static icon", ^{ From 95075fd55578dceed4f3f89ea9eec9d229787a1d Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Tue, 26 May 2020 10:12:20 -0400 Subject: [PATCH 10/10] Add SCM test --- .../SDLSystemCapabilityManagerSpec.m | 74 +++++++++++++------ 1 file changed, 51 insertions(+), 23 deletions(-) diff --git a/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m b/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m index 4336f7eab..ad77dea1d 100644 --- a/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m +++ b/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m @@ -390,6 +390,12 @@ @interface SDLSystemCapabilityManager () expect(testSystemCapabilityManager.vrCapability).to(beFalse()); expect(testSystemCapabilityManager.audioPassThruCapabilities).to(beNil()); expect(testSystemCapabilityManager.pcmStreamCapability).to(beNil()); + + expect(testSystemCapabilityManager.phoneCapability).to(beNil()); + expect(testSystemCapabilityManager.navigationCapability).to(beNil()); + expect(testSystemCapabilityManager.videoStreamingCapability).to(beNil()); + expect(testSystemCapabilityManager.remoteControlCapability).to(beNil()); + expect(testSystemCapabilityManager.appServicesCapabilities).to(beNil()); }); }); @@ -416,16 +422,13 @@ @interface SDLSystemCapabilityManager () expect(testSystemCapabilityManager.vrCapability).to(beTrue()); expect(testSystemCapabilityManager.audioPassThruCapabilities).to(equal(testAudioPassThruCapabilities)); expect(testSystemCapabilityManager.pcmStreamCapability).to(equal(testPCMStreamCapability)); - }); - }); - afterEach(^{ - // Make sure the system capabilities properties were not inadverdently set - expect(testSystemCapabilityManager.phoneCapability).to(beNil()); - expect(testSystemCapabilityManager.navigationCapability).to(beNil()); - expect(testSystemCapabilityManager.videoStreamingCapability).to(beNil()); - expect(testSystemCapabilityManager.remoteControlCapability).to(beNil()); - expect(testSystemCapabilityManager.appServicesCapabilities).to(beNil()); + expect(testSystemCapabilityManager.phoneCapability).to(beNil()); + expect(testSystemCapabilityManager.navigationCapability).to(beNil()); + expect(testSystemCapabilityManager.videoStreamingCapability).to(beNil()); + expect(testSystemCapabilityManager.remoteControlCapability).to(beNil()); + expect(testSystemCapabilityManager.appServicesCapabilities).to(beNil()); + }); }); }); @@ -456,6 +459,19 @@ @interface SDLSystemCapabilityManager () expect(testSystemCapabilityManager.buttonCapabilities).to(beNil()); expect(testSystemCapabilityManager.presetBankCapabilities).to(beNil()); #pragma clang diagnostic pop + + expect(testSystemCapabilityManager.hmiCapabilities).to(beNil()); + expect(testSystemCapabilityManager.hmiZoneCapabilities).to(beNil()); + expect(testSystemCapabilityManager.speechCapabilities).to(beNil()); + expect(testSystemCapabilityManager.prerecordedSpeechCapabilities).to(beNil()); + expect(testSystemCapabilityManager.vrCapability).to(beFalse()); + expect(testSystemCapabilityManager.audioPassThruCapabilities).to(beNil()); + expect(testSystemCapabilityManager.pcmStreamCapability).to(beNil()); + expect(testSystemCapabilityManager.phoneCapability).to(beNil()); + expect(testSystemCapabilityManager.navigationCapability).to(beNil()); + expect(testSystemCapabilityManager.videoStreamingCapability).to(beNil()); + expect(testSystemCapabilityManager.remoteControlCapability).to(beNil()); + expect(testSystemCapabilityManager.appServicesCapabilities).to(beNil()); }); }); @@ -475,23 +491,35 @@ @interface SDLSystemCapabilityManager () expect(testSystemCapabilityManager.buttonCapabilities).to(equal(testButtonCapabilities)); expect(testSystemCapabilityManager.presetBankCapabilities).to(equal(testPresetBankCapabilities)); #pragma clang diagnostic pop + + expect(testSystemCapabilityManager.hmiCapabilities).to(beNil()); + expect(testSystemCapabilityManager.hmiZoneCapabilities).to(beNil()); + expect(testSystemCapabilityManager.speechCapabilities).to(beNil()); + expect(testSystemCapabilityManager.prerecordedSpeechCapabilities).to(beNil()); + expect(testSystemCapabilityManager.vrCapability).to(beFalse()); + expect(testSystemCapabilityManager.audioPassThruCapabilities).to(beNil()); + expect(testSystemCapabilityManager.pcmStreamCapability).to(beNil()); + expect(testSystemCapabilityManager.phoneCapability).to(beNil()); + expect(testSystemCapabilityManager.navigationCapability).to(beNil()); + expect(testSystemCapabilityManager.videoStreamingCapability).to(beNil()); + expect(testSystemCapabilityManager.remoteControlCapability).to(beNil()); + expect(testSystemCapabilityManager.appServicesCapabilities).to(beNil()); }); }); - afterEach(^{ - // Make sure the other RAIR properties and system capabilities were not inadverdently set - expect(testSystemCapabilityManager.hmiCapabilities).to(beNil()); - expect(testSystemCapabilityManager.hmiZoneCapabilities).to(beNil()); - expect(testSystemCapabilityManager.speechCapabilities).to(beNil()); - expect(testSystemCapabilityManager.prerecordedSpeechCapabilities).to(beNil()); - expect(testSystemCapabilityManager.vrCapability).to(beFalse()); - expect(testSystemCapabilityManager.audioPassThruCapabilities).to(beNil()); - expect(testSystemCapabilityManager.pcmStreamCapability).to(beNil()); - expect(testSystemCapabilityManager.phoneCapability).to(beNil()); - expect(testSystemCapabilityManager.navigationCapability).to(beNil()); - expect(testSystemCapabilityManager.videoStreamingCapability).to(beNil()); - expect(testSystemCapabilityManager.remoteControlCapability).to(beNil()); - expect(testSystemCapabilityManager.appServicesCapabilities).to(beNil()); + describe(@"if the setdisplaylayout has nil displaycapabilities", ^{ + beforeEach(^{ + testSetDisplayLayoutResponse.success = @YES; + testSetDisplayLayoutResponse.displayCapabilities = nil; + SDLRPCResponseNotification *notification = [[SDLRPCResponseNotification alloc] initWithName:SDLDidReceiveSetDisplayLayoutResponse object:self rpcResponse:testSetDisplayLayoutResponse]; + [[NSNotificationCenter defaultCenter] postNotification:notification]; + }); + + it(@"should should save the capabilities", ^{ + // All the text fields and image fields should be available + expect(testSystemCapabilityManager.defaultMainWindowCapability.textFields).to(haveCount(29)); + expect(testSystemCapabilityManager.defaultMainWindowCapability.imageFields).to(haveCount(14)); + }); }); });