diff options
author | Justin Beharry <justin.beharry@livio.io> | 2022-08-09 12:17:37 -0400 |
---|---|---|
committer | Justin Beharry <justin.beharry@livio.io> | 2022-08-09 12:17:37 -0400 |
commit | 794e7f3f2ee4b6c87afa6f31f1027770551354e2 (patch) | |
tree | 60712d49b0c11f1d642bec80b701fce70ce92c2a /Example Apps/Example Swift | |
parent | 2561046c4088ab92d59a2298e946f76cabc65a73 (diff) | |
download | sdl_ios-794e7f3f2ee4b6c87afa6f31f1027770551354e2.tar.gz |
Disable remote control on IAP, enable only for TCP
-Disable remote control startup
-On IAP show alert when clicking remote control menu item
Diffstat (limited to 'Example Apps/Example Swift')
-rw-r--r-- | Example Apps/Example Swift/MenuManager.swift | 16 | ||||
-rw-r--r-- | Example Apps/Example Swift/ProxyManager.swift | 19 | ||||
-rw-r--r-- | Example Apps/Example Swift/RemoteControlManager.swift | 10 |
3 files changed, 36 insertions, 9 deletions
diff --git a/Example Apps/Example Swift/MenuManager.swift b/Example Apps/Example Swift/MenuManager.swift index 6cb0a76d1..9616a771e 100644 --- a/Example Apps/Example Swift/MenuManager.swift +++ b/Example Apps/Example Swift/MenuManager.swift @@ -210,11 +210,21 @@ private extension MenuManager { /// Menu item that shows remote control example /// - /// - Parameter manager: The SDL Manager + /// - Parameters: + /// - manager: The SDL Manager + /// - remoteManager: The manager for controling and viewing remote control data /// - Returns: A SDLMenuCell object class func menuCellRemoteControl(with manager: SDLManager, remoteManager: RemoteControlManager) -> SDLMenuCell { - var submenuItems = [SDLMenuCell]() + let remoteControlIcon = SDLArtwork(image: UIImage(named: RemoteControlIconName)!.withRenderingMode(.alwaysTemplate), persistent: true, as: .PNG) + + // Clicking on cell shows alert message when remote control permissions are disabled + if (!remoteManager.isPermissionEnabled) { + return SDLMenuCell(title: ACRemoteMenuName, secondaryText: nil, tertiaryText: nil, icon: remoteControlIcon, secondaryArtwork: nil, voiceCommands: nil, handler: { _ in + AlertManager.sendAlert(textField1: AlertRemoteControlPermissionWarningText, sdlManager: manager) + }) + } + var submenuItems = [SDLMenuCell]() // Climate Control Menu submenuItems.append(SDLMenuCell(title: ACRemoteControlClimateMenuName, secondaryText: nil, tertiaryText: nil, icon: nil, secondaryArtwork: nil, voiceCommands: nil, handler: { (triggerSource) in manager.screenManager.changeLayout(SDLTemplateConfiguration(predefinedLayout: .tilesOnly)) { err in @@ -244,7 +254,7 @@ private extension MenuManager { }) })) - return SDLMenuCell(title: ACRemoteMenuName, secondaryText: nil, tertiaryText: nil, icon: SDLArtwork(image: UIImage(named: RemoteControlIconName)!.withRenderingMode(.alwaysTemplate), persistent: true, as: .PNG), secondaryArtwork: nil, submenuLayout: .list, subCells: submenuItems) + return SDLMenuCell(title: ACRemoteMenuName, secondaryText: nil, tertiaryText: nil, icon: remoteControlIcon, secondaryArtwork: nil, submenuLayout: .list, subCells: submenuItems) } } diff --git a/Example Apps/Example Swift/ProxyManager.swift b/Example Apps/Example Swift/ProxyManager.swift index 45ebcd88e..3c081ac13 100644 --- a/Example Apps/Example Swift/ProxyManager.swift +++ b/Example Apps/Example Swift/ProxyManager.swift @@ -28,6 +28,7 @@ class ProxyManager: NSObject { private var performInteractionManager: PerformInteractionManager! private var remoteControlManager: RemoteControlManager! private var firstHMILevelState: SDLHMILevel + private var isRemoteControlEnabled: Bool weak var delegate: ProxyManagerDelegate? @@ -35,6 +36,7 @@ class ProxyManager: NSObject { static let sharedManager = ProxyManager() private override init() { firstHMILevelState = .none + isRemoteControlEnabled = false; super.init() } } @@ -49,6 +51,7 @@ extension ProxyManager { delegate?.didChangeProxyState(ProxyState.searching) sdlManager = SDLManager(configuration: (proxyTransportType == .iap) ? ProxyManager.iapConfiguration : ProxyManager.tcpConfiguration, delegate: self) + self.isRemoteControlEnabled = proxyTransportType == .tcp ? true : false startManager() } @@ -75,7 +78,7 @@ private extension ProxyManager { /// - Returns: A SDLConfiguration object class var iapConfiguration: SDLConfiguration { let lifecycleConfiguration = SDLLifecycleConfiguration(appName: ExampleAppName, fullAppId: ExampleFullAppId) - return setupManagerConfiguration(with: lifecycleConfiguration) + return setupManagerConfiguration(with: lifecycleConfiguration, enableRemote: false) } /// Configures a TCP transport layer with the IP address and port of the remote SDL Core instance. @@ -83,19 +86,25 @@ private extension ProxyManager { /// - Returns: A SDLConfiguration object class var tcpConfiguration: SDLConfiguration { let lifecycleConfiguration = SDLLifecycleConfiguration(appName: ExampleAppName, fullAppId: ExampleFullAppId, ipAddress: AppUserDefaults.shared.ipAddress!, port: UInt16(AppUserDefaults.shared.port!)!) - return setupManagerConfiguration(with: lifecycleConfiguration) + return setupManagerConfiguration(with: lifecycleConfiguration, enableRemote: true) } /// Helper method for setting additional configuration parameters for both TCP and iAP transport layers. /// /// - Parameter lifecycleConfiguration: The transport layer configuration /// - Returns: A SDLConfiguration object - class func setupManagerConfiguration(with lifecycleConfiguration: SDLLifecycleConfiguration) -> SDLConfiguration { + class func setupManagerConfiguration(with lifecycleConfiguration: SDLLifecycleConfiguration, enableRemote: Bool) -> SDLConfiguration { lifecycleConfiguration.shortAppName = ExampleAppNameShort let appIcon = UIImage(named: ExampleAppLogoName)?.withRenderingMode(.alwaysOriginal) lifecycleConfiguration.appIcon = appIcon != nil ? SDLArtwork(image: appIcon!, persistent: true, as: .PNG) : nil lifecycleConfiguration.appType = .default - lifecycleConfiguration.additionalAppTypes = [.remoteControl] + + // On actional hardware, the app requires permissions to do remote control which this example app will not have. + // Only use the remote control type on the TCP connection. + if (enableRemote) { + lifecycleConfiguration.additionalAppTypes = [.remoteControl] + } + lifecycleConfiguration.language = .enUs lifecycleConfiguration.languagesSupported = [.enUs, .esMx, .frCa] lifecycleConfiguration.ttsName = [SDLTTSChunk(text: "S D L", type: .text)] @@ -138,7 +147,7 @@ private extension ProxyManager { self.subscribeButtonManager = SubscribeButtonManager(sdlManager: self.sdlManager) self.vehicleDataManager = VehicleDataManager(sdlManager: self.sdlManager, refreshUIHandler: self.refreshUIHandler) self.performInteractionManager = PerformInteractionManager(sdlManager: self.sdlManager) - self.remoteControlManager = RemoteControlManager(sdlManager: self.sdlManager, homeButtons: self.buttonManager.allScreenSoftButtons()) + self.remoteControlManager = RemoteControlManager(sdlManager: self.sdlManager, permission: self.isRemoteControlEnabled, homeButtons: self.buttonManager.allScreenSoftButtons()) RPCPermissionsManager.setupPermissionsCallbacks(with: self.sdlManager) diff --git a/Example Apps/Example Swift/RemoteControlManager.swift b/Example Apps/Example Swift/RemoteControlManager.swift index 98f3e0cc7..01b66978a 100644 --- a/Example Apps/Example Swift/RemoteControlManager.swift +++ b/Example Apps/Example Swift/RemoteControlManager.swift @@ -18,6 +18,7 @@ class RemoteControlManager { private var hasConsent: Bool? private var climateData: SDLClimateControlData? + public let isPermissionEnabled: Bool public var climateDataString: String { """ AC: \(optionalNumberBoolToString(climateData?.acEnable)) @@ -42,13 +43,20 @@ class RemoteControlManager { /// /// - Parameters: /// - sdlManager: The SDL Manager. + /// - permission: Permission from the proxy manager to access remote control data /// - homeButton: An array of SDLSoftButtonObjects that remote control manager can reset to. - init(sdlManager: SDLManager, homeButtons: [SDLSoftButtonObject]) { + init(sdlManager: SDLManager, permission: Bool, homeButtons: [SDLSoftButtonObject]) { self.sdlManager = sdlManager + self.isPermissionEnabled = permission self.homeButtons = homeButtons } func start() { + if (!self.isPermissionEnabled) { + SDLLog.d("Missing permissions for Remote Control Manager. Example remote control works only on TCP.") + return + } + // Retrieve remote control information and store module ids self.sdlManager.systemCapabilityManager.subscribe(capabilityType: .remoteControl) { (capability, subscribed, error) in guard capability?.remoteControlCapability != nil else { |