summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlapinskijw <jlapinski.dev@gmail.com>2020-06-04 16:43:31 -0400
committerlapinskijw <jlapinski.dev@gmail.com>2020-06-04 16:43:31 -0400
commit936c91bf64b5f1af683dc0f6cc7a631bbe97c158 (patch)
tree56093ea620c1ec481f644eedcc6ec533b2477cf1
parent0f0cab6a8b7f160a12cf970595cfe3f16d494679 (diff)
downloadsdl_ios-936c91bf64b5f1af683dc0f6cc7a631bbe97c158.tar.gz
updated example app functions that used deprecated methods and fixed inline documentation for new methods
-rw-r--r--Example Apps/Example ObjC/RPCPermissionsManager.m20
-rw-r--r--Example Apps/Example ObjC/VehicleDataManager.m3
-rw-r--r--Example Apps/Example Swift/ProxyManager.swift11
-rw-r--r--Example Apps/Example Swift/RPCPermissionsManager.swift28
-rw-r--r--Example Apps/Example Swift/VehicleDataManager.swift2
-rw-r--r--SmartDeviceLink/SDLPermissionConstants.h9
-rw-r--r--SmartDeviceLink/SDLPermissionManager.h62
-rw-r--r--SmartDeviceLink/SDLPermissionManager.m11
8 files changed, 72 insertions, 74 deletions
diff --git a/Example Apps/Example ObjC/RPCPermissionsManager.m b/Example Apps/Example ObjC/RPCPermissionsManager.m
index dc5cf6dfc..cb45ab76d 100644
--- a/Example Apps/Example ObjC/RPCPermissionsManager.m
+++ b/Example Apps/Example ObjC/RPCPermissionsManager.m
@@ -24,11 +24,11 @@ NS_ASSUME_NONNULL_BEGIN
[self sdlex_checkCurrentPermissionWithManager:manager rpcName:showRPCName];
// Checks if all the RPCs need to create menus are allowed right at this moment
- NSArray<NSString *> *menuRPCNames = @[@"AddCommand", @"CreateInteractionChoiceSet", @"PerformInteraction"];
+ NSArray<SDLRPCFunctionName> *menuRPCNames = @[SDLRPCFunctionNameAddCommand, SDLRPCFunctionNameCreateInteractionChoiceSet, SDLRPCFunctionNamePerformInteraction];
[self sdlex_checkCurrentGroupPermissionsWithManager:manager rpcNames:menuRPCNames];
// Set up an observer for permissions changes to media template releated RPCs. Since the `groupType` is set to all allowed, this block is called when the group permissions changes from all allowed. This block is called immediately when created.
- NSArray<NSString *> *mediaTemplateRPCs = @[@"SetMediaClockTimer", @"SubscribeButton"];
+ NSArray<SDLRPCFunctionName> *mediaTemplateRPCs = @[SDLRPCFunctionNameSetMediaClockTimer, SDLRPCFunctionNameSubscribeButton];
SDLPermissionObserverIdentifier allAllowedObserverId = [self sdlex_subscribeGroupPermissionsWithManager:manager rpcNames:mediaTemplateRPCs groupType:SDLPermissionGroupTypeAllAllowed];
// Stop observing permissions changes for the media template releated RPCs
@@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
+ (BOOL)isDialNumberRPCAllowedWithManager:(SDLManager *)manager {
SDLLogD(@"Checking if app has permission to dial a number");
- return [self sdlex_checkCurrentPermissionWithManager:manager rpcName:@"DialNumber"];
+ return [self sdlex_checkCurrentPermissionWithManager:manager rpcName:SDLRPCFunctionNameDialNumber];
}
#pragma mark - Check Permissions
@@ -60,8 +60,8 @@ NS_ASSUME_NONNULL_BEGIN
* @param rpcName The name of the RPC
* @return True if the RPC can be sent to Core right now, false if not
*/
-+ (BOOL)sdlex_checkCurrentPermissionWithManager:(SDLManager *)manager rpcName:(NSString *)rpcName {
- BOOL isRPCAllowed = [manager.permissionManager isRPCAllowed:rpcName];
++ (BOOL)sdlex_checkCurrentPermissionWithManager:(SDLManager *)manager rpcName:(SDLRPCFunctionName)rpcName {
+ BOOL isRPCAllowed = [manager.permissionManager isRPCPermitted:rpcName];
[self sdlex_logRPCPermission:rpcName isRPCAllowed:isRPCAllowed];
return isRPCAllowed;
}
@@ -73,9 +73,9 @@ NS_ASSUME_NONNULL_BEGIN
* @param rpcNames The names of the RPCs
* @return The current permission status for all the RPCs in the group
*/
-+ (SDLPermissionGroupStatus)sdlex_checkCurrentGroupPermissionsWithManager:(SDLManager *)manager rpcNames:(NSArray<NSString *> *)rpcNames {
- SDLPermissionGroupStatus groupPermissionStatus = [manager.permissionManager groupStatusOfRPCs:rpcNames];
- NSDictionary<NSString *, NSNumber *> *individualPermissionStatuses = [manager.permissionManager statusOfRPCs:rpcNames];
++ (SDLPermissionGroupStatus)sdlex_checkCurrentGroupPermissionsWithManager:(SDLManager *)manager rpcNames:(NSArray<SDLRPCFunctionName> *)rpcNames {
+ SDLPermissionGroupStatus groupPermissionStatus = [manager.permissionManager groupStatusOfRPCNames:rpcNames];
+ NSDictionary<NSString *, NSNumber *> *individualPermissionStatuses = [manager.permissionManager statusOfRPCNames:rpcNames];
[self sdlex_logRPCGroupPermissions:rpcNames groupPermissionStatus:groupPermissionStatus individualPermissionStatuses:individualPermissionStatuses];
return groupPermissionStatus;
}
@@ -90,8 +90,8 @@ NS_ASSUME_NONNULL_BEGIN
* @param groupType The type of changes you want to be notified about for the group
* @return A unique identifier for the subscription. This can be used to later to unsubscribe from the notifications.
*/
-+ (SDLPermissionObserverIdentifier)sdlex_subscribeGroupPermissionsWithManager:(SDLManager *)manager rpcNames:(NSArray<NSString *> *)rpcNames groupType:(SDLPermissionGroupType)groupType {
- SDLPermissionObserverIdentifier observerId = [manager.permissionManager addObserverForRPCs:rpcNames groupType:groupType withHandler:^(NSDictionary<SDLPermissionRPCName,NSNumber<SDLBool> *> * _Nonnull change, SDLPermissionGroupStatus status) {
++ (SDLPermissionObserverIdentifier)sdlex_subscribeGroupPermissionsWithManager:(SDLManager *)manager rpcNames:(NSArray<SDLRPCFunctionName> *)rpcNames groupType:(SDLPermissionGroupType)groupType {
+ SDLPermissionObserverIdentifier observerId = [manager.permissionManager subscribeToRPCs:rpcNames groupType:groupType withHandler:^(NSDictionary<SDLPermissionRPCName,NSNumber<SDLBool> *> * _Nonnull change, SDLPermissionGroupStatus status) {
[self sdlex_logRPCGroupPermissions:rpcNames groupPermissionStatus:status individualPermissionStatuses:change];
}];
return observerId;
diff --git a/Example Apps/Example ObjC/VehicleDataManager.m b/Example Apps/Example ObjC/VehicleDataManager.m
index d4e9a1066..2b9f05a04 100644
--- a/Example Apps/Example ObjC/VehicleDataManager.m
+++ b/Example Apps/Example ObjC/VehicleDataManager.m
@@ -8,6 +8,7 @@
#import "AlertManager.h"
#import "AppConstants.h"
+#import "SDLRPCFunctionNames.h"
#import "SmartDeviceLink.h"
#import "TextValidator.h"
#import "VehicleDataManager.h"
@@ -136,7 +137,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
+ (void)getAllVehicleDataWithManager:(SDLManager *)manager triggerSource:(SDLTriggerSource)triggerSource vehicleDataType:(NSString *)vehicleDataType {
SDLLogD(@"Checking if app has permission to access vehicle data...");
- if (![manager.permissionManager isRPCAllowed:@"GetVehicleData"]) {
+ if (![manager.permissionManager isRPCPermitted:SDLRPCFunctionNameGetVehicleData]) {
[manager sendRequest:[AlertManager alertWithMessageAndCloseButton:@"This app does not have the required permissions to access vehicle data" textField2:nil iconName:nil]];
return;
}
diff --git a/Example Apps/Example Swift/ProxyManager.swift b/Example Apps/Example Swift/ProxyManager.swift
index 8d48bfe39..4238251bf 100644
--- a/Example Apps/Example Swift/ProxyManager.swift
+++ b/Example Apps/Example Swift/ProxyManager.swift
@@ -139,16 +139,7 @@ private extension ProxyManager {
self.vehicleDataManager = VehicleDataManager(sdlManager: self.sdlManager, refreshUIHandler: self.refreshUIHandler)
self.performInteractionManager = PerformInteractionManager(sdlManager: self.sdlManager)
-// RPCPermissionsManager.setupPermissionsCallbacks(with: self.sdlManager)
- let permissionsManager = self.sdlManager.permissionManager
-// permissionsManager.subscribe(toRPCs: [SDLRPCFunctionName.addCommand], groupType: .allAllowed) { (dict, status) in
-// print("SUBSCRIBE TO RPCS CALLED")
-// }
-
- permissionsManager.addObserver(forRPCs: ["PerformInteraction"], groupType: .allAllowed) { (dict, status) in
- print("AddOBSERVER TO RPCS CALLED")
- print("STATUS IS \(dict["PerformInteraction"])")
- }
+ RPCPermissionsManager.setupPermissionsCallbacks(with: self.sdlManager)
SDLLog.d("SDL file manager storage: \(self.sdlManager.fileManager.bytesAvailable / 1024 / 1024) mb")
})
diff --git a/Example Apps/Example Swift/RPCPermissionsManager.swift b/Example Apps/Example Swift/RPCPermissionsManager.swift
index 72cdb8019..0e1efefa0 100644
--- a/Example Apps/Example Swift/RPCPermissionsManager.swift
+++ b/Example Apps/Example Swift/RPCPermissionsManager.swift
@@ -16,15 +16,15 @@ class RPCPermissionsManager {
/// - Parameter manager: The SDL Manager
class func setupPermissionsCallbacks(with manager: SDLManager) {
// Checks if the `SDLShow` RPC is allowed right at this moment
- let showRPCName = "Show"
+ let showRPCName = SDLRPCFunctionName.show
_ = checkCurrentPermission(with: manager, rpcName: showRPCName)
// Checks if all the RPCs need to create menus are allowed right at this moment
- let menuRPCNames = ["AddCommand", "CreateInteractionChoiceSet", "PerformInteraction"]
+ let menuRPCNames = [SDLRPCFunctionName.addCommand, SDLRPCFunctionName.createInteractionChoiceSet, SDLRPCFunctionName.performInteraction]
_ = checkCurrentGroupPermissions(with: manager, rpcNames: menuRPCNames)
// Set up an observer for permissions changes to media template releated RPCs. Since the `groupType` is set to all allowed, this block is called when the group permissions changes from all allowed. This block is called immediately when created.
- let mediaTemplateRPCs = ["SetMediaClockTimer", "SubscribeButton"]
+ let mediaTemplateRPCs = [SDLRPCFunctionName.setMediaClockTimer, SDLRPCFunctionName.subscribeButton]
let allAllowedObserverId = subscribeGroupPermissions(with: manager, rpcNames: mediaTemplateRPCs, groupType: .allAllowed)
// Stop observing permissions changes for the media template releated RPCs
@@ -40,7 +40,7 @@ class RPCPermissionsManager {
/// - Returns: True if allowed, false if not
class func isDialNumberRPCAllowed(with manager: SDLManager) -> Bool {
SDLLog.d("Checking if app has permission to dial a number")
- return checkCurrentPermission(with: manager, rpcName: "DialNumber")
+ return checkCurrentPermission(with: manager, rpcName: SDLRPCFunctionName.dialNumber)
}
}
@@ -51,8 +51,8 @@ private extension RPCPermissionsManager {
///
/// - Parameter manager: The SDL Manager
/// - Returns: true if allowed, false if not
- class func checkCurrentPermission(with manager: SDLManager, rpcName: String) -> Bool {
- let isRPCAllowed = manager.permissionManager.isRPCAllowed(rpcName)
+ class func checkCurrentPermission(with manager: SDLManager, rpcName: SDLRPCFunctionName) -> Bool {
+ let isRPCAllowed = manager.permissionManager.isRPCPermitted(rpcName)
logRPCPermission(rpcName: rpcName, isRPCAllowed: isRPCAllowed)
return isRPCAllowed
}
@@ -61,9 +61,9 @@ private extension RPCPermissionsManager {
///
/// - Parameter manager: The SDL Manager
/// - Returns: The rpc names, the group permission status and the permission status for each rpc in the group
- class func checkCurrentGroupPermissions(with manager: SDLManager, rpcNames: [String]) -> SDLPermissionGroupStatus {
- let groupPermissionStatus = manager.permissionManager.groupStatus(ofRPCs: rpcNames)
- let individualPermissionStatuses = manager.permissionManager.status(ofRPCs: rpcNames)
+ class func checkCurrentGroupPermissions(with manager: SDLManager, rpcNames: [SDLRPCFunctionName]) -> SDLPermissionGroupStatus {
+ let groupPermissionStatus = manager.permissionManager.groupStatus(ofRPCNames: rpcNames)
+ let individualPermissionStatuses = manager.permissionManager.status(ofRPCNames: rpcNames)
logRPCGroupPermissions(rpcNames: rpcNames, groupPermissionStatus: groupPermissionStatus, individualPermissionStatuses: individualPermissionStatuses)
return groupPermissionStatus
}
@@ -74,8 +74,8 @@ private extension RPCPermissionsManager {
/// - manager: The SDL Manager
/// - groupType: The type of changes to get notified about
/// - Returns: A unique id assigned to observer. Use the id to unsubscribe to notifications
- class func subscribeGroupPermissions(with manager: SDLManager, rpcNames: [String], groupType: SDLPermissionGroupType) -> UUID {
- let permissionAllAllowedObserverId = manager.permissionManager.addObserver(forRPCs: rpcNames, groupType: groupType, withHandler: { (individualStatuses, groupStatus) in
+ class func subscribeGroupPermissions(with manager: SDLManager, rpcNames: [SDLRPCFunctionName], groupType: SDLPermissionGroupType) -> UUID {
+ let permissionAllAllowedObserverId = manager.permissionManager.subscribe(toRPCs: rpcNames, groupType: groupType, withHandler: { (individualStatuses, groupStatus) in
self.logRPCGroupPermissions(rpcNames: rpcNames, groupPermissionStatus: groupStatus, individualPermissionStatuses: individualStatuses)
})
@@ -100,7 +100,7 @@ private extension RPCPermissionsManager {
/// - Parameters:
/// - rpcName: The name of the RPC
/// - isRPCAllowed: The permission status for the RPC
- class func logRPCPermission(rpcName: String, isRPCAllowed: Bool) {
+ class func logRPCPermission(rpcName: SDLRPCFunctionName, isRPCAllowed: Bool) {
SDLLog.d("\(rpcName) RPC can be sent to SDL Core? \(isRPCAllowed ? "yes" : "no")")
}
@@ -110,10 +110,10 @@ private extension RPCPermissionsManager {
/// - rpcNames: The names of the RPCs
/// - groupPermissionStatus: The permission status for all RPCs in the group
/// - individualPermissionStatuses: The permission status for each of the RPCs in the group
- class func logRPCGroupPermissions(rpcNames: [String], groupPermissionStatus: SDLPermissionGroupStatus, individualPermissionStatuses: [String:NSNumber]) {
+ class func logRPCGroupPermissions(rpcNames: [SDLRPCFunctionName], groupPermissionStatus: SDLPermissionGroupStatus, individualPermissionStatuses: [SDLRPCFunctionName:NSNumber]) {
SDLLog.d("The group status for \(rpcNames) has changed to: \(groupPermissionStatus)")
for (rpcName, rpcAllowed) in individualPermissionStatuses {
- logRPCPermission(rpcName: rpcName as String, isRPCAllowed: rpcAllowed.boolValue)
+ logRPCPermission(rpcName: rpcName, isRPCAllowed: rpcAllowed.boolValue)
}
}
}
diff --git a/Example Apps/Example Swift/VehicleDataManager.swift b/Example Apps/Example Swift/VehicleDataManager.swift
index 34ac4352c..cae87ecf2 100644
--- a/Example Apps/Example Swift/VehicleDataManager.swift
+++ b/Example Apps/Example Swift/VehicleDataManager.swift
@@ -232,7 +232,7 @@ extension VehicleDataManager {
class func hasPermissionToAccessVehicleData(with manager: SDLManager) -> Bool {
SDLLog.d("Checking if app has permission to access vehicle data...")
- guard manager.permissionManager.isRPCAllowed("GetVehicleData") else {
+ guard manager.permissionManager.isRPCPermitted(SDLRPCFunctionName.getVehicleData) else {
let alert = AlertManager.alertWithMessageAndCloseButton("This app does not have the required permissions to access vehicle data")
manager.send(request: alert)
return false
diff --git a/SmartDeviceLink/SDLPermissionConstants.h b/SmartDeviceLink/SDLPermissionConstants.h
index ea36738cc..09813a557 100644
--- a/SmartDeviceLink/SDLPermissionConstants.h
+++ b/SmartDeviceLink/SDLPermissionConstants.h
@@ -9,6 +9,7 @@
#import <Foundation/Foundation.h>
#import "NSNumber+NumberType.h"
+#import "SDLRPCFunctionNames.h"
NS_ASSUME_NONNULL_BEGIN
@@ -66,4 +67,12 @@ typedef NS_ENUM(NSUInteger, SDLPermissionGroupStatus) {
*/
typedef void (^SDLPermissionsChangedHandler)(NSDictionary<SDLPermissionRPCName, NSNumber *> *_Nonnull change, SDLPermissionGroupStatus status);
+/**
+* The SDLObeservedPermissionsChangedHandler is a block that is passed in to subscribeToRPCs:groupType:withHandler: that will be stored and called when specified permissions change.
+*
+* @param change A dictionary of permission changes containing <key(SDLRPCFunctionName): RPC Name, object(BOOL): YES if the RPC is allowed, NO if it is not allowed>
+* @param status The change made to all of the RPCs in the changedDict. Allowed, if all RPCs are now allowed, Disallowed if all RPCs are now disallowed, or Mixed if some are allowed, and some are disallowed
+*/
+typedef void (^SDLObeservedPermissionsChangedHandler)(NSDictionary<SDLRPCFunctionName, NSNumber *> *_Nonnull change, SDLPermissionGroupStatus status);
+
NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SDLPermissionManager.h b/SmartDeviceLink/SDLPermissionManager.h
index ef7d63020..096c0acae 100644
--- a/SmartDeviceLink/SDLPermissionManager.h
+++ b/SmartDeviceLink/SDLPermissionManager.h
@@ -44,15 +44,15 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return YES if the RPC is allowed at the current HMI level, NO if not
*/
-- (BOOL)isRPCAllowed:(SDLPermissionRPCName)rpcName __deprecated_msg(("Use isRPCNameAllowed: instead"));
+- (BOOL)isRPCAllowed:(SDLPermissionRPCName)rpcName __deprecated_msg(("Use isRPCPermitted: instead"));
/**
-* Determine if an individual RPC is allowed for the current HMI level
-*
-* @param rpcName The name of the RPC to be tested, for example, SDLShow
-*
-* @return YES if the RPC is allowed at the current HMI level, NO if not
-*/
+ * Determine if an individual RPC is allowed for the current HMI level
+ *
+ * @param rpcName The name of the RPC to be tested, for example, SDLRPCFunctionNameShow
+ *
+ * @return YES if the RPC is allowed at the current HMI level, NO if not
+ */
- (BOOL)isRPCPermitted:(SDLRPCFunctionName)rpcName;
/**
@@ -65,11 +65,11 @@ NS_ASSUME_NONNULL_BEGIN
- (SDLPermissionGroupStatus)groupStatusOfRPCs:(NSArray<SDLPermissionRPCName> *)rpcNames __deprecated_msg(("Use groupStatusOfRPCNames: instead"));
/**
-* Determine if all RPCs are allowed for the current HMI level
-*
-* @param rpcNames The RPCs to check
-*
-* @return AllAllowed if all of the permissions are allowed, AllDisallowed if all the permissions are disallowed, Any if some are allowed, and some are disallowed
+ * Determine if all RPCs are allowed for the current HMI level
+ *
+ * @param rpcNames The RPCs to check
+ *
+ * @return AllAllowed if all of the permissions are allowed, AllDisallowed if all the permissions are disallowed, Any if some are allowed, and some are disallowed
*/
- (SDLPermissionGroupStatus)groupStatusOfRPCNames:(NSArray<SDLRPCFunctionName> *)rpcNames;
@@ -83,13 +83,13 @@ NS_ASSUME_NONNULL_BEGIN
- (NSDictionary<SDLPermissionRPCName, NSNumber *> *)statusOfRPCs:(NSArray<SDLPermissionRPCName> *)rpcNames __deprecated_msg(("Use statusOfRPCNames: instead"));
/**
-* Retrieve a dictionary with keys that are the passed in RPC names, and objects of an NSNumber<BOOL> specifying if that RPC is currently allowed
-*
-* @param rpcNames An array of RPC names to check
-*
-* @return A dictionary specifying if the passed in RPC names are currently allowed or not
+ * Retrieve a dictionary with keys that are the passed in RPC names, and objects of an NSNumber<BOOL> specifying if that RPC is currently allowed
+ *
+ * @param rpcNames An array of RPC names to check
+ *
+ * @return A dictionary specifying if the passed in RPC names are currently allowed or not
*/
-- (NSDictionary<SDLPermissionRPCName, NSNumber *> *)statusOfRPCNames:(NSArray<SDLRPCFunctionName> *)rpcNames;
+- (NSDictionary<SDLRPCFunctionName, NSNumber *> *)statusOfRPCNames:(NSArray<SDLRPCFunctionName> *)rpcNames;
/**
* Add an observer for specified RPC names, with a callback that will be called whenever the value changes, as well as immediately with the current status.
@@ -107,19 +107,19 @@ NS_ASSUME_NONNULL_BEGIN
- (SDLPermissionObserverIdentifier)addObserverForRPCs:(NSArray<SDLPermissionRPCName> *)rpcNames groupType:(SDLPermissionGroupType)groupType withHandler:(SDLPermissionsChangedHandler)handler __deprecated_msg(("Use subscribeToRPCs:groupType:withHandler: instead"));
/**
-* Add an observer for specified RPC names, with a callback that will be called whenever the value changes. Unlike addObserverForRPCs:groupType:withHandler:, the callback will not return immediately with the current status and will wait for the permissions changes specified in the groupType param.
-*
-* @warning This block will be captured by the SDLPermissionsManager, be sure to use [weakself/strongself](http://www.logicsector.com/ios/avoiding-objc-retain-cycles-with-weakself-and-strongself-the-easy-way/) if you are referencing self within your observer block.
-*
-* @warning The observer may be called before this method returns, do not attempt to remove the observer from within the observer. That could send `nil` to removeObserverForIdentifier:. If you want functionality like that, call groupStatusOfRPCs: instead.
-*
-* @param rpcNames The RPCs to be observed
-* @param groupType Affects the times that the observer block will be called. If Any, any change to any RPC in rpcNames will cause the observer block to be called. If AllAllowed, the block will be called when: 1. Every RPC in rpcNames becomes allowed 2. The group of rpcNames goes from all being allowed to some or all being disallowed.
-* @param handler The block that will be called whenever permissions change.
-*
-* @return An identifier that can be passed to removeObserverForIdentifer: to remove the observer
-*/
-- (SDLPermissionObserverIdentifier)subscribeToRPCs:(NSArray<SDLRPCFunctionName> *)rpcNames groupType:(SDLPermissionGroupType)groupType withHandler:(SDLPermissionsChangedHandler)handler;
+ * Subscribe to specified RPC names, with a callback that will be called whenever the value changes. Unlike addObserverForRPCs:groupType:withHandler:, the callback will not return immediately with the current status and will wait for the permissions changes specified in the groupType param.
+ *
+ * @warning This block will be captured by the SDLPermissionsManager, be sure to use [weakself/strongself](http://www.logicsector.com/ios/avoiding-objc-retain-cycles-with-weakself-and-strongself-the-easy-way/) if you are referencing self within your observer block.
+ *
+ * @warning The observer may be called before this method returns, do not attempt to remove the observer from within the observer. That could send `nil` to removeObserverForIdentifier:. If you want functionality like that, call groupStatusOfRPCs: instead.
+ *
+ * @param rpcNames The RPCs to be observed
+ * @param groupType Affects the times that the observer block will be called. If Any, any change to any RPC in rpcNames will cause the observer block to be called. If AllAllowed, the block will be called when: 1. Every RPC in rpcNames becomes allowed 2. The group of rpcNames goes from all being allowed to some or all being disallowed.
+ * @param handler The block that will be called whenever permissions change.
+ *
+ * @return An identifier that can be passed to removeObserverForIdentifer: to remove the observer
+ */
+- (SDLPermissionObserverIdentifier)subscribeToRPCs:(NSArray<SDLRPCFunctionName> *)rpcNames groupType:(SDLPermissionGroupType)groupType withHandler:(SDLObeservedPermissionsChangedHandler)handler;
/**
* Remove every current observer
diff --git a/SmartDeviceLink/SDLPermissionManager.m b/SmartDeviceLink/SDLPermissionManager.m
index a0f43f601..9b361684a 100644
--- a/SmartDeviceLink/SDLPermissionManager.m
+++ b/SmartDeviceLink/SDLPermissionManager.m
@@ -79,7 +79,6 @@ NS_ASSUME_NONNULL_BEGIN
return NO;
}
- // to do
SDLPermissionItem *item = self.permissions[rpcName];
return [item.hmiPermissions.allowed containsObject:self.currentHMILevel];
}
@@ -97,7 +96,6 @@ NS_ASSUME_NONNULL_BEGIN
return SDLPermissionGroupStatusUnknown;
}
- // to do double check this
return [self.class sdl_groupStatusOfRPCs:rpcNames withPermissions:[self.permissions copy] hmiLevel:self.currentHMILevel];
}
@@ -151,10 +149,10 @@ NS_ASSUME_NONNULL_BEGIN
return [permissionAllowedDict copy];
}
-- (NSDictionary<SDLPermissionRPCName,NSNumber *> *)statusOfRPCNames:(NSArray<SDLRPCFunctionName> *)rpcNames {
- NSMutableDictionary<SDLPermissionRPCName, NSNumber *> *permissionAllowedDict = [NSMutableDictionary dictionary];
- // to do
- for (NSString *rpcName in rpcNames) {
+- (NSDictionary<SDLRPCFunctionName,NSNumber *> *)statusOfRPCNames:(NSArray<SDLRPCFunctionName> *)rpcNames {
+ NSMutableDictionary<SDLRPCFunctionName, NSNumber *> *permissionAllowedDict = [NSMutableDictionary dictionary];
+
+ for (SDLRPCFunctionName rpcName in rpcNames) {
BOOL allowed = [self isRPCPermitted:rpcName];
permissionAllowedDict[rpcName] = @(allowed);
}
@@ -414,7 +412,6 @@ NS_ASSUME_NONNULL_BEGIN
}
- (BOOL)rpcNameRequiresEncryption:(SDLRPCFunctionName)rpcName {
- // to do
if (self.permissions[rpcName].requireEncryption != nil) {
return self.permissions[rpcName].requireEncryption.boolValue;
}