diff --git a/examples/darwin-framework-tool/commands/bdx/DownloadLogCommand.mm b/examples/darwin-framework-tool/commands/bdx/DownloadLogCommand.mm index b105b6cb3098c8..893d4baaee7b2b 100644 --- a/examples/darwin-framework-tool/commands/bdx/DownloadLogCommand.mm +++ b/examples/darwin-framework-tool/commands/bdx/DownloadLogCommand.mm @@ -28,7 +28,7 @@ ChipLogProgress(chipTool, "Downloading logs from node 0x" ChipLogFormatX64, ChipLogValueX64(mNodeId)); MTRDeviceController * commissioner = CurrentCommissioner(); - auto * device = [MTRDevice deviceWithNodeID:@(mNodeId) controller:commissioner]; + auto * device = [MTRDeviceConcrete deviceWithNodeID:@(mNodeId) controller:commissioner]; auto logType = static_cast(mLogType); auto queue = dispatch_queue_create("com.chip.bdx.downloader", DISPATCH_QUEUE_SERIAL); diff --git a/examples/darwin-framework-tool/commands/pairing/OpenCommissioningWindowCommand.mm b/examples/darwin-framework-tool/commands/pairing/OpenCommissioningWindowCommand.mm index b774b1a971b48a..d04db9f1eb1c7c 100644 --- a/examples/darwin-framework-tool/commands/pairing/OpenCommissioningWindowCommand.mm +++ b/examples/darwin-framework-tool/commands/pairing/OpenCommissioningWindowCommand.mm @@ -25,7 +25,7 @@ { mWorkQueue = dispatch_queue_create("com.chip.open_commissioning_window", DISPATCH_QUEUE_SERIAL); auto * controller = CurrentCommissioner(); - auto * device = [MTRDevice deviceWithNodeID:mNodeId deviceController:controller]; + auto * device = [MTRDeviceConcrete deviceWithNodeID:mNodeId deviceController:controller]; auto * self = this; if (mCommissioningWindowOption == 0) { diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice_Internal.h b/src/darwin/Framework/CHIP/MTRBaseDevice_Internal.h index 4ebc454925a4a4..9bf414e594ab6e 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice_Internal.h +++ b/src/darwin/Framework/CHIP/MTRBaseDevice_Internal.h @@ -74,12 +74,12 @@ static inline MTRTransportType MTRMakeTransportType(chip::Transport::Type type) @property (nonatomic, assign, readonly) BOOL isPASEDevice; /** - * Controller that that this MTRDevice was gotten from. + * Controller that that this MTRDeviceConcrete was gotten from. */ @property (nonatomic, strong, readonly) MTRDeviceController * deviceController; /** - * Node id for this MTRDevice. If this device represents a CASE session, this + * Node id for this MTRDeviceConcrete. If this device represents a CASE session, this * is set to the node ID of the target node. If this device represents a PASE * session, this is set to the device id of the PASE device. */ diff --git a/src/darwin/Framework/CHIP/MTRBaseSubscriptionCallback.h b/src/darwin/Framework/CHIP/MTRBaseSubscriptionCallback.h index 9edd153fd2410c..27c38c39c86c7f 100644 --- a/src/darwin/Framework/CHIP/MTRBaseSubscriptionCallback.h +++ b/src/darwin/Framework/CHIP/MTRBaseSubscriptionCallback.h @@ -35,10 +35,10 @@ /** * This file defines a base class for subscription callbacks used by - * MTRBaseDevice and MTRDevice. This base class handles everything except the + * MTRBaseDevice and MTRDeviceConcrete. This base class handles everything except the * actual conversion from the incoming data to the desired data and the dispatch * of callbacks to the relevant client queues. Its callbacks are called on the - * Matter queue. This allows MTRDevice and MTRBaseDevice to do any necessary + * Matter queue. This allows MTRDeviceConcrete and MTRBaseDevice to do any necessary * sync cleanup work before dispatching to the client callbacks on the client * queue. * diff --git a/src/darwin/Framework/CHIP/MTRCluster.h b/src/darwin/Framework/CHIP/MTRCluster.h index b3543d67b30281..d85b135edf4715 100644 --- a/src/darwin/Framework/CHIP/MTRCluster.h +++ b/src/darwin/Framework/CHIP/MTRCluster.h @@ -29,7 +29,7 @@ typedef void (^MTRStatusCompletion)(NSError * _Nullable error); typedef void (^MTRSubscriptionEstablishedHandler)(void); @class MTRBaseDevice; -@class MTRDevice; +@class MTRDeviceConcrete; NS_ASSUME_NONNULL_BEGIN @@ -63,7 +63,7 @@ MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) /** * The device this cluster object is associated with. */ -@property (nonatomic, strong, readonly) MTRDevice * device; +@property (nonatomic, strong, readonly) MTRDeviceConcrete * device; @end /** @@ -139,7 +139,7 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) * * This setting is only relevant to some consumers of MTRReadParams. One of * those consumers is readAttributeWithEndpointID:clusterID:attributeID:params: - * on MTRDevice. + * on MTRDeviceConcrete. */ @property (nonatomic, assign, getter=shouldAssumeUnknownAttributesReportable) BOOL assumeUnknownAttributesReportable MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6)); diff --git a/src/darwin/Framework/CHIP/MTRCluster.mm b/src/darwin/Framework/CHIP/MTRCluster.mm index 9bcb38e4cbac99..2f18aac73b655f 100644 --- a/src/darwin/Framework/CHIP/MTRCluster.mm +++ b/src/darwin/Framework/CHIP/MTRCluster.mm @@ -50,7 +50,7 @@ - (instancetype)initWithDevice:(MTRBaseDevice *)device endpointID:(NSNumber *)en @implementation MTRGenericCluster -- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue +- (instancetype)initWithDevice:(MTRDeviceConcrete *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue { if (self = [super initWithEndpointID:endpointID queue:queue]) { _device = device; diff --git a/src/darwin/Framework/CHIP/MTRCluster_Internal.h b/src/darwin/Framework/CHIP/MTRCluster_Internal.h index 78e4c491f6c999..a457b693d6e5bf 100644 --- a/src/darwin/Framework/CHIP/MTRCluster_Internal.h +++ b/src/darwin/Framework/CHIP/MTRCluster_Internal.h @@ -19,7 +19,7 @@ #import #import -#import +#import #import "MTRBaseDevice_Internal.h" @@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN @end @interface MTRGenericCluster () -- (instancetype)initWithDevice:(MTRDevice *)device +- (instancetype)initWithDevice:(MTRDeviceConcrete *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue; @end diff --git a/src/darwin/Framework/CHIP/MTRDevice.h b/src/darwin/Framework/CHIP/MTRDeviceConcrete.h similarity index 93% rename from src/darwin/Framework/CHIP/MTRDevice.h rename to src/darwin/Framework/CHIP/MTRDeviceConcrete.h index 1c31cbc26a661b..5703c255e61088 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.h +++ b/src/darwin/Framework/CHIP/MTRDeviceConcrete.h @@ -32,20 +32,20 @@ typedef NS_ENUM(NSUInteger, MTRDeviceState) { @protocol MTRDeviceDelegate; MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) -@interface MTRDevice : NSObject +@interface MTRDeviceConcrete : NSObject - (instancetype)init NS_UNAVAILABLE; + (instancetype)new NS_UNAVAILABLE; /** * TODO: Document usage better * - * Directly instantiate a MTRDevice with a MTRDeviceController as a shim. + * Directly instantiate a MTRDeviceConcrete with a MTRDeviceController as a shim. * * All device-specific information would be stored on the device controller, and * retrieved when performing actions using a combination of MTRBaseDevice * and MTRAsyncCallbackQueue. */ -+ (MTRDevice *)deviceWithNodeID:(NSNumber *)nodeID ++ (MTRDeviceConcrete *)deviceWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); /** @@ -121,7 +121,7 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) * * The delegate will be called on the provided queue, for attribute reports, event reports, and device state changes. * - * MTRDevice holds a weak reference to the delegate object. + * MTRDeviceConcrete holds a weak reference to the delegate object. */ - (void)addDelegate:(id)delegate queue:(dispatch_queue_t)queue MTR_AVAILABLE(ios(18.0), macos(15.0), watchos(11.0), tvos(18.0)); @@ -136,7 +136,7 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) * * Calling addDelegate: again with the same delegate object will update the interested paths for attributes and events for this delegate. * - * MTRDevice holds a weak reference to the delegate object. + * MTRDeviceConcrete holds a weak reference to the delegate object. */ - (void)addDelegate:(id)delegate queue:(dispatch_queue_t)queue interestedPathsForAttributes:(NSArray * _Nullable)interestedPathsForAttributes interestedPathsForEvents:(NSArray * _Nullable)interestedPathsForEvents MTR_AVAILABLE(ios(18.0), macos(15.0), watchos(11.0), tvos(18.0)); @@ -405,10 +405,10 @@ MTR_EXTERN NSString * const MTRDataVersionKey MTR_AVAILABLE(ios(17.6), macos(14. /** * @param state The current state of the device */ -- (void)device:(MTRDevice *)device stateChanged:(MTRDeviceState)state; +- (void)device:(MTRDeviceConcrete *)device stateChanged:(MTRDeviceState)state; /** - * Notifies delegate of attribute reports from the MTRDevice + * Notifies delegate of attribute reports from the MTRDeviceConcrete * * @param attributeReport An array of response-value objects as described in MTRDeviceResponseHandler * @@ -420,10 +420,10 @@ MTR_EXTERN NSString * const MTRDataVersionKey MTR_AVAILABLE(ios(17.6), macos(14. * * MTRDataVersionKey : NSNumber-wrapped uin32_t. */ -- (void)device:(MTRDevice *)device receivedAttributeReport:(NSArray *> *)attributeReport; +- (void)device:(MTRDeviceConcrete *)device receivedAttributeReport:(NSArray *> *)attributeReport; /** - * Notifies delegate of event reports from the MTRDevice + * Notifies delegate of event reports from the MTRDeviceConcrete * * @param eventReport An array of response-value objects as described in MTRDeviceResponseHandler * @@ -440,7 +440,7 @@ MTR_EXTERN NSString * const MTRDataVersionKey MTR_AVAILABLE(ios(17.6), macos(14. * Only one of MTREventTimestampDateKey and MTREventSystemUpTimeKey will be present, depending on the value for * MTREventTimeTypeKey. */ -- (void)device:(MTRDevice *)device receivedEventReport:(NSArray *> *)eventReport; +- (void)device:(MTRDeviceConcrete *)device receivedEventReport:(NSArray *> *)eventReport; @optional /** @@ -449,33 +449,33 @@ MTR_EXTERN NSString * const MTRDataVersionKey MTR_AVAILABLE(ios(17.6), macos(14. * This can be used as a hint that now is a good time to send commands to the * device, especially if the device is sleepy and might not be active very often. */ -- (void)deviceBecameActive:(MTRDevice *)device MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +- (void)deviceBecameActive:(MTRDeviceConcrete *)device MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); /** * Notifies delegate when the device attribute cache has been primed with initial configuration data of the device * - * This is called when the MTRDevice object goes from not knowing the device to having cached the first attribute reports that include basic mandatory information, e.g. Descriptor clusters. + * This is called when the MTRDeviceConcrete object goes from not knowing the device to having cached the first attribute reports that include basic mandatory information, e.g. Descriptor clusters. * * The intention is that after this is called, the client should be able to call read for mandatory attributes and likely expect non-nil values. */ -- (void)deviceCachePrimed:(MTRDevice *)device MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6)); +- (void)deviceCachePrimed:(MTRDeviceConcrete *)device MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6)); /** - * This is called when the MTRDevice object detects a change in the device configuration. + * This is called when the MTRDeviceConcrete object detects a change in the device configuration. * * Device configuration is the set of functionality implemented by the device. * */ -- (void)deviceConfigurationChanged:(MTRDevice *)device MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6)); +- (void)deviceConfigurationChanged:(MTRDeviceConcrete *)device MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6)); @end -@interface MTRDevice (Deprecated) +@interface MTRDeviceConcrete (Deprecated) /** - * Deprecated MTRDevice APIs. + * Deprecated MTRDeviceConcrete APIs. */ -+ (MTRDevice *)deviceWithNodeID:(uint64_t)nodeID ++ (MTRDeviceConcrete *)deviceWithNodeID:(uint64_t)nodeID deviceController:(MTRDeviceController *)deviceController MTR_DEPRECATED( "Please use deviceWithNodeID:controller:", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDeviceConcrete.mm similarity index 98% rename from src/darwin/Framework/CHIP/MTRDevice.mm rename to src/darwin/Framework/CHIP/MTRDeviceConcrete.mm index b8ef8694825e1f..ce999d19f4e0b1 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceConcrete.mm @@ -67,7 +67,7 @@ // Consider moving utility classes to their own file #pragma mark - Utility Classes -// container of MTRDevice delegate weak reference, its queue, and its interested paths for attribute reports +// container of MTRDeviceConcrete delegate weak reference, its queue, and its interested paths for attribute reports MTR_DIRECT_MEMBERS @interface MTRDeviceDelegateInfo : NSObject { @private @@ -155,7 +155,7 @@ - (BOOL)callDelegateSynchronouslyWithBlock:(void (^)(id))bloc /* BEGIN DRAGONS: Note methods here cannot be renamed, and are used by private callers, do not rename, remove or modify behavior here */ @interface NSObject (MatterPrivateForInternalDragonsDoNotFeed) -- (void)_deviceInternalStateChanged:(MTRDevice *)device; +- (void)_deviceInternalStateChanged:(MTRDeviceConcrete *)device; @end /* END DRAGONS */ @@ -193,7 +193,7 @@ - (void)_deviceInternalStateChanged:(MTRDevice *)device; CHIP_ERROR OnResubscriptionNeeded(chip::app::ReadClient * apReadClient, CHIP_ERROR aTerminationCause) override; - // Copied from ReadClient and customized for MTRDevice resubscription time reset + // Copied from ReadClient and customized for MTRDeviceConcrete resubscription time reset uint32_t ComputeTimeTillNextSubscription(); uint32_t mResubscriptionNumRetries = 0; }; @@ -366,7 +366,7 @@ - (BOOL)isEqual:(id)object // better behavior. #define MTRDEVICE_SUBSCRIPTION_LATENCY_NEW_VALUE_WEIGHT (1.0 / 3.0) -@interface MTRDevice () +@interface MTRDeviceConcrete () @property (nonatomic, readonly) os_unfair_lock lock; // protects the caches and device state // protects against concurrent time updates by guarding timeUpdateScheduled flag which manages time updates scheduling, // and protects device calls to setUTCTime and setDSTOffset @@ -423,20 +423,20 @@ @interface MTRDevice () // Declaring selector so compiler won't complain about testing and calling it in _handleReportEnd #ifdef DEBUG @protocol MTRDeviceUnitTestDelegate -- (void)unitTestReportEndForDevice:(MTRDevice *)device; -- (BOOL)unitTestShouldSetUpSubscriptionForDevice:(MTRDevice *)device; -- (BOOL)unitTestShouldSkipExpectedValuesForWrite:(MTRDevice *)device; -- (NSNumber *)unitTestMaxIntervalOverrideForSubscription:(MTRDevice *)device; -- (BOOL)unitTestForceAttributeReportsIfMatchingCache:(MTRDevice *)device; -- (BOOL)unitTestPretendThreadEnabled:(MTRDevice *)device; -- (void)unitTestSubscriptionPoolDequeue:(MTRDevice *)device; -- (void)unitTestSubscriptionPoolWorkComplete:(MTRDevice *)device; -- (void)unitTestClusterDataPersisted:(MTRDevice *)device; -- (BOOL)unitTestSuppressTimeBasedReachabilityChanges:(MTRDevice *)device; +- (void)unitTestReportEndForDevice:(MTRDeviceConcrete *)device; +- (BOOL)unitTestShouldSetUpSubscriptionForDevice:(MTRDeviceConcrete *)device; +- (BOOL)unitTestShouldSkipExpectedValuesForWrite:(MTRDeviceConcrete *)device; +- (NSNumber *)unitTestMaxIntervalOverrideForSubscription:(MTRDeviceConcrete *)device; +- (BOOL)unitTestForceAttributeReportsIfMatchingCache:(MTRDeviceConcrete *)device; +- (BOOL)unitTestPretendThreadEnabled:(MTRDeviceConcrete *)device; +- (void)unitTestSubscriptionPoolDequeue:(MTRDeviceConcrete *)device; +- (void)unitTestSubscriptionPoolWorkComplete:(MTRDeviceConcrete *)device; +- (void)unitTestClusterDataPersisted:(MTRDeviceConcrete *)device; +- (BOOL)unitTestSuppressTimeBasedReachabilityChanges:(MTRDeviceConcrete *)device; @end #endif -@implementation MTRDevice { +@implementation MTRDeviceConcrete { #ifdef DEBUG NSUInteger _unitTestAttributesReportedSinceLastCheck; #endif @@ -543,16 +543,16 @@ - (void)dealloc [[NSNotificationCenter defaultCenter] removeObserver:_systemTimeChangeObserverToken]; // TODO: retain cycle and clean up https://github.com/project-chip/connectedhomeip/issues/34267 - MTR_LOG("MTRDevice dealloc: %p", self); + MTR_LOG("MTRDeviceConcrete dealloc: %p", self); } - (NSString *)description { return [NSString - stringWithFormat:@"[fabric: %u, nodeID: 0x%016llX]", self, _fabricIndex, _nodeID.unsignedLongLongValue]; + stringWithFormat:@"[fabric: %u, nodeID: 0x%016llX]", self, _fabricIndex, _nodeID.unsignedLongLongValue]; } -+ (MTRDevice *)deviceWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller ++ (MTRDeviceConcrete *)deviceWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller { return [controller deviceForNodeID:nodeID]; } @@ -624,7 +624,7 @@ - (void)_scheduleNextUpdate:(UInt64)nextUpdateInSeconds if (self) { [self _performScheduledTimeUpdate]; } else { - MTR_LOG_DEBUG("%@ MTRDevice no longer valid. No Timer Scheduled will be scheduled for a Device Time Update.", self); + MTR_LOG_DEBUG("%@ MTRDeviceConcrete no longer valid. No Timer Scheduled will be scheduled for a Device Time Update.", self); return; } }); @@ -657,7 +657,7 @@ - (void)_performScheduledTimeUpdate } // Device must not be invalidated if (!self.timeUpdateScheduled) { - MTR_LOG_DEBUG("%@ Device Time Update is no longer scheduled, MTRDevice may have been invalidated.", self); + MTR_LOG_DEBUG("%@ Device Time Update is no longer scheduled, MTRDeviceConcrete may have been invalidated.", self); return; } self.timeUpdateScheduled = NO; @@ -859,7 +859,7 @@ - (void)_addDelegate:(id)delegate queue:(dispatch_queue_t)que [self _scheduleSubscriptionPoolWork:^{ std::lock_guard lock(self->_lock); [self _setupSubscriptionWithReason:@"delegate is set and scheduled subscription is happening"]; - } inNanoseconds:0 description:@"MTRDevice setDelegate first subscription"]; + } inNanoseconds:0 description:@"MTRDeviceConcrete setDelegate first subscription"]; } else { [self _setupSubscriptionWithReason:@"delegate is set and subscription is needed"]; } @@ -1475,7 +1475,7 @@ - (void)_doHandleSubscriptionReset:(NSNumber * _Nullable)retryDelay int64_t resubscriptionDelayNs = static_cast(secondsToWait * NSEC_PER_SEC); if ([self _deviceUsesThread]) { // For Thread-enabled devices, schedule the _reattemptSubscriptionNowIfNeededWithReason call to run in the subscription pool - [self _scheduleSubscriptionPoolWork:resubscriptionBlock inNanoseconds:resubscriptionDelayNs description:@"MTRDevice resubscription"]; + [self _scheduleSubscriptionPoolWork:resubscriptionBlock inNanoseconds:resubscriptionDelayNs description:@"MTRDeviceConcrete resubscription"]; } else { // For non-Thread-enabled devices, just call the resubscription block after the specified time dispatch_after(dispatch_time(DISPATCH_TIME_NOW, resubscriptionDelayNs), self.queue, resubscriptionBlock); @@ -2424,7 +2424,7 @@ - (void)_setupSubscriptionWithReason:(NSString *)reason } // This marks begin of initial subscription to the device (before CASE is established). The end is only marked after successfully setting - // up the subscription since it is always retried as long as the MTRDevice is kept running. + // up the subscription since it is always retried as long as the MTRDeviceConcrete is kept running. MATTER_LOG_METRIC_BEGIN(kMetricMTRDeviceInitialSubscriptionSetup); // Call directlyGetSessionForNode because the subscription setup already goes through the subscription pool queue @@ -2847,7 +2847,7 @@ static BOOL AttributeHasChangesOmittedQuality(MTRAttributePath * attributePath) } *stop = NO; }]; - [workItem setReadyHandler:^(MTRDevice * self, NSInteger retryCount, MTRAsyncWorkCompletionBlock completion) { + [workItem setReadyHandler:^(MTRDeviceConcrete * self, NSInteger retryCount, MTRAsyncWorkCompletionBlock completion) { // Sanity check if (readRequests.count == 0) { MTR_LOG_ERROR("Read attribute work item [%llu] contained no read requests", workItemID); @@ -2988,7 +2988,7 @@ - (void)writeAttributeWithEndpointID:(NSNumber *)endpointID *isDuplicate = NO; *stop = YES; }]; - [workItem setReadyHandler:^(MTRDevice * self, NSInteger retryCount, MTRAsyncWorkCompletionBlock completion) { + [workItem setReadyHandler:^(MTRDeviceConcrete * self, NSInteger retryCount, MTRAsyncWorkCompletionBlock completion) { MTRBaseDevice * baseDevice = [self newBaseDevice]; // Make sure to use writeRequests here, because that's what our batching // handler will modify as needed. @@ -3122,7 +3122,7 @@ - (void)_invokeCommandWithEndpointID:(NSNumber *)endpointID *isDuplicate = NO; *stop = YES; }]; - [workItem setReadyHandler:^(MTRDevice * self, NSInteger retryCount, MTRAsyncWorkCompletionBlock workCompletion) { + [workItem setReadyHandler:^(MTRDeviceConcrete * self, NSInteger retryCount, MTRAsyncWorkCompletionBlock workCompletion) { auto workDone = ^(NSArray *> * _Nullable values, NSError * _Nullable error) { dispatch_async(queue, ^{ completion(values, error); @@ -4138,7 +4138,7 @@ - (void)_addInformationalAttributesToCurrentMetricScope /* BEGIN DRAGONS: Note methods here cannot be renamed, and are used by private callers, do not rename, remove or modify behavior here */ -@implementation MTRDevice (MatterPrivateForInternalDragonsDoNotFeed) +@implementation MTRDeviceConcrete (MatterPrivateForInternalDragonsDoNotFeed) - (BOOL)_deviceHasActiveSubscription { @@ -4162,9 +4162,9 @@ - (void)_deviceMayBeReachable @end -@implementation MTRDevice (Deprecated) +@implementation MTRDeviceConcrete (Deprecated) -+ (MTRDevice *)deviceWithNodeID:(uint64_t)nodeID deviceController:(MTRDeviceController *)deviceController ++ (MTRDeviceConcrete *)deviceWithNodeID:(uint64_t)nodeID deviceController:(MTRDeviceController *)deviceController { return [self deviceWithNodeID:@(nodeID) controller:deviceController]; } diff --git a/src/darwin/Framework/CHIP/MTRDeviceController.h b/src/darwin/Framework/CHIP/MTRDeviceController.h index eaae1fcf7d4c6a..1744499489b730 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController.h +++ b/src/darwin/Framework/CHIP/MTRDeviceController.h @@ -314,14 +314,14 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) - (BOOL)openPairingWindow:(uint64_t)deviceID duration:(NSUInteger)duration error:(NSError * __autoreleasing *)error - MTR_DEPRECATED("Please use MTRDevice or MTRBaseDevice openCommissioningWindowWithSetupPasscode", ios(16.1, 16.4), + MTR_DEPRECATED("Please use MTRDeviceConcrete or MTRBaseDevice openCommissioningWindowWithSetupPasscode", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); - (nullable NSString *)openPairingWindowWithPIN:(uint64_t)deviceID duration:(NSUInteger)duration discriminator:(NSUInteger)discriminator setupPIN:(NSUInteger)setupPIN error:(NSError * __autoreleasing *)error - MTR_DEPRECATED("Please use MTRDevice or MTRBaseDevice openCommissioningWindowWithSetupPasscode", ios(16.1, 16.4), + MTR_DEPRECATED("Please use MTRDeviceConcrete or MTRBaseDevice openCommissioningWindowWithSetupPasscode", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); - (nullable NSData *)computePaseVerifier:(uint32_t)setupPincode diff --git a/src/darwin/Framework/CHIP/MTRDeviceController.mm b/src/darwin/Framework/CHIP/MTRDeviceController.mm index 2e4bb6d4fb0400..0dd5ee071ea2cf 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceController.mm @@ -308,7 +308,7 @@ - (void)shutdown // Clean up from a state where startup was called. - (void)cleanupAfterStartup { - // Invalidate our MTRDevice instances before we shut down our secure + // Invalidate our MTRDeviceConcrete instances before we shut down our secure // sessions and whatnot, so they don't start trying to resubscribe when we // do the secure session shutdowns. Since we don't want to hold the lock // while calling out into arbitrary invalidation code, snapshot the list of @@ -319,7 +319,7 @@ - (void)cleanupAfterStartup [_nodeIDToDeviceMap removeAllObjects]; os_unfair_lock_unlock(&_deviceMapLock); - for (MTRDevice * device in devices) { + for (MTRDeviceConcrete * device in devices) { [device invalidate]; } [self stopBrowseForCommissionables]; @@ -612,7 +612,7 @@ - (BOOL)startup:(MTRDeviceControllerStartupParamsInternal *)startupParams } if (_controllerDataStore) { - // If the storage delegate supports the bulk read API, then a dictionary of nodeID => cluster data dictionary would be passed to the handler. Otherwise this would be a no-op, and stored attributes for MTRDevice objects will be loaded lazily in -deviceForNodeID:. + // If the storage delegate supports the bulk read API, then a dictionary of nodeID => cluster data dictionary would be passed to the handler. Otherwise this would be a no-op, and stored attributes for MTRDeviceConcrete objects will be loaded lazily in -deviceForNodeID:. [_controllerDataStore fetchAttributeDataForAllDevices:^(NSDictionary *> * _Nonnull clusterDataByNode) { MTR_LOG("%@ Loaded attribute values for %lu nodes from storage for controller uuid %@", self, static_cast(clusterDataByNode.count), self->_uniqueIdentifier); @@ -620,7 +620,7 @@ - (BOOL)startup:(MTRDeviceControllerStartupParamsInternal *)startupParams NSMutableArray * deviceList = [NSMutableArray array]; for (NSNumber * nodeID in clusterDataByNode) { NSDictionary * clusterData = clusterDataByNode[nodeID]; - MTRDevice * device = [self _setupDeviceForNodeID:nodeID prefetchedClusterData:clusterData]; + MTRDeviceConcrete * device = [self _setupDeviceForNodeID:nodeID prefetchedClusterData:clusterData]; MTR_LOG("%@ Loaded %lu cluster data from storage for %@", self, static_cast(clusterData.count), device); [deviceList addObject:device]; @@ -984,11 +984,11 @@ - (MTRBaseDevice *)baseDeviceForNodeID:(NSNumber *)nodeID } // If prefetchedClusterData is not provided, load attributes individually from controller data store -- (MTRDevice *)_setupDeviceForNodeID:(NSNumber *)nodeID prefetchedClusterData:(NSDictionary *)prefetchedClusterData +- (MTRDeviceConcrete *)_setupDeviceForNodeID:(NSNumber *)nodeID prefetchedClusterData:(NSDictionary *)prefetchedClusterData { os_unfair_lock_assert_owner(&_deviceMapLock); - MTRDevice * deviceToReturn = [[MTRDevice alloc] initWithNodeID:nodeID controller:self]; + MTRDeviceConcrete * deviceToReturn = [[MTRDeviceConcrete alloc] initWithNodeID:nodeID controller:self]; // If we're not running, don't add the device to our map. That would // create a cycle that nothing would break. Just return the device, // which will be in exactly the state it would be in if it were created @@ -1023,10 +1023,10 @@ - (MTRDevice *)_setupDeviceForNodeID:(NSNumber *)nodeID prefetchedClusterData:(N return deviceToReturn; } -- (MTRDevice *)deviceForNodeID:(NSNumber *)nodeID +- (MTRDeviceConcrete *)deviceForNodeID:(NSNumber *)nodeID { std::lock_guard lock(_deviceMapLock); - MTRDevice * deviceToReturn = [_nodeIDToDeviceMap objectForKey:nodeID]; + MTRDeviceConcrete * deviceToReturn = [_nodeIDToDeviceMap objectForKey:nodeID]; if (!deviceToReturn) { deviceToReturn = [self _setupDeviceForNodeID:nodeID prefetchedClusterData:nil]; } @@ -1034,11 +1034,11 @@ - (MTRDevice *)deviceForNodeID:(NSNumber *)nodeID return deviceToReturn; } -- (void)removeDevice:(MTRDevice *)device +- (void)removeDevice:(MTRDeviceConcrete *)device { std::lock_guard lock(_deviceMapLock); auto * nodeID = device.nodeID; - MTRDevice * deviceToRemove = [_nodeIDToDeviceMap objectForKey:nodeID]; + MTRDeviceConcrete * deviceToRemove = [_nodeIDToDeviceMap objectForKey:nodeID]; if (deviceToRemove == device) { [deviceToRemove invalidate]; [_nodeIDToDeviceMap removeObjectForKey:nodeID]; @@ -1281,8 +1281,8 @@ - (BOOL)checkIsRunning:(NSError * __autoreleasing *)error - (void)getSessionForNode:(chip::NodeId)nodeID completion:(MTRInternalDeviceConnectionCallback)completion { - // Get the corresponding MTRDevice object to determine if the case/subscription pool is to be used - MTRDevice * device = [self deviceForNodeID:@(nodeID)]; + // Get the corresponding MTRDeviceConcrete object to determine if the case/subscription pool is to be used + MTRDeviceConcrete * device = [self deviceForNodeID:@(nodeID)]; // In the case that this device is known to use thread, queue this with subscription attempts as well, to // help with throttling Thread traffic. @@ -1503,7 +1503,7 @@ - (void)operationalInstanceAdded:(chip::NodeId)nodeID // Don't use deviceForNodeID here, because we don't want to create the // device if it does not already exist. os_unfair_lock_lock(&_deviceMapLock); - MTRDevice * device = [_nodeIDToDeviceMap objectForKey:@(nodeID)]; + MTRDeviceConcrete * device = [_nodeIDToDeviceMap objectForKey:@(nodeID)]; os_unfair_lock_unlock(&_deviceMapLock); if (device == nil) { diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerDataStore.h b/src/darwin/Framework/CHIP/MTRDeviceControllerDataStore.h index 826fd1821f7640..b7d2974fd5642a 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerDataStore.h +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerDataStore.h @@ -70,7 +70,7 @@ typedef void (^MTRDeviceControllerDataStoreClusterDataHandler)(NSDictionary *)getStoredClusterDataForNodeID:(NSNumber *)nodeID; - (nullable MTRDeviceClusterData *)getStoredClusterDataForNodeID:(NSNumber *)nodeID endpointID:(NSNumber *)endpointID clusterID:(NSNumber *)clusterID; @@ -82,7 +82,7 @@ typedef void (^MTRDeviceControllerDataStoreClusterDataHandler)(NSDictionary * concurrentSubscriptionPool; @@ -262,15 +262,15 @@ NS_ASSUME_NONNULL_BEGIN - (nullable NSNumber *)neededReadPrivilegeForClusterID:(NSNumber *)clusterID attributeID:(NSNumber *)attributeID; #pragma mark - Device-specific data and SDK access -// DeviceController will act as a central repository for this opaque dictionary that MTRDevice manages -- (MTRDevice *)deviceForNodeID:(NSNumber *)nodeID; -- (void)removeDevice:(MTRDevice *)device; +// DeviceController will act as a central repository for this opaque dictionary that MTRDeviceConcrete manages +- (MTRDeviceConcrete *)deviceForNodeID:(NSNumber *)nodeID; +- (void)removeDevice:(MTRDeviceConcrete *)device; - (NSNumber * _Nullable)syncGetCompressedFabricID; /** * Since getSessionForNode now enqueues by the subscription pool for Thread - * devices, MTRDevice needs a direct non-queued access because it already + * devices, MTRDeviceConcrete needs a direct non-queued access because it already * makes use of the subscription pool. */ - (void)directlyGetSessionForNode:(chip::NodeId)nodeID completion:(MTRInternalDeviceConnectionCallback)completion; diff --git a/src/darwin/Framework/CHIP/MTRDeviceStorageBehaviorConfiguration.h b/src/darwin/Framework/CHIP/MTRDeviceStorageBehaviorConfiguration.h index 7e66e4d9052f73..bdaba0e025630b 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceStorageBehaviorConfiguration.h +++ b/src/darwin/Framework/CHIP/MTRDeviceStorageBehaviorConfiguration.h @@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN /** - * Class that configures how MTRDevice objects persist their attributes to storage, so as to not + * Class that configures how MTRDeviceConcrete objects persist their attributes to storage, so as to not * overwhelm the underlying storage system. */ MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6)) @@ -51,12 +51,12 @@ MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6)) /** * Storage behavior with values in the allowed range: * - * Each time a report comes in, MTRDevice will wait reportToPersistDelayTime before persisting the - * changes to storage. If another report comes in during this internal, MTRDevice will wait another + * Each time a report comes in, MTRDeviceConcrete will wait reportToPersistDelayTime before persisting the + * changes to storage. If another report comes in during this internal, MTRDeviceConcrete will wait another * reportToPersistDelayTime interval, until reportToPersistDelayTimeMax is reached, at which * point all the changes so far will be written to storage. * - * MTRDevice will also track recentReportTimesMaxCount number of report times. If the running + * MTRDeviceConcrete will also track recentReportTimesMaxCount number of report times. If the running * average time between reports dips below timeBetweenReportsTooShortThreshold, a portion of the * reportToPersistenceDelayMaxMultiplier will be applied to both the reportToPersistenceDelayTime * and reportToPersistenceDelayTimeMax. The multiplier will reach the max when the average time diff --git a/src/darwin/Framework/CHIP/MTRDevice_Internal.h b/src/darwin/Framework/CHIP/MTRDevice_Internal.h index 1416aa29dfac29..b82e426618723b 100644 --- a/src/darwin/Framework/CHIP/MTRDevice_Internal.h +++ b/src/darwin/Framework/CHIP/MTRDevice_Internal.h @@ -17,7 +17,7 @@ #import #import -#import +#import #import "MTRAsyncWorkQueue.h" #import "MTRDefines_Internal.h" @@ -65,7 +65,7 @@ MTR_TESTABLE - (nullable instancetype)initWithDataVersion:(NSNumber * _Nullable)dataVersion attributes:(NSDictionary * _Nullable)attributes; @end -@interface MTRDevice () +@interface MTRDeviceConcrete () - (instancetype)initWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller; // Called from MTRClusters for writes and commands @@ -102,7 +102,7 @@ MTR_TESTABLE // Queue used for various internal bookkeeping work. @property (nonatomic) dispatch_queue_t queue; -@property (nonatomic, readonly) MTRAsyncWorkQueue * asyncWorkQueue; +@property (nonatomic, readonly) MTRAsyncWorkQueue * asyncWorkQueue; // Method to insert persisted cluster data // Contains data version information and attribute values. @@ -117,7 +117,7 @@ MTR_TESTABLE - (void)setStorageBehaviorConfiguration:(MTRDeviceStorageBehaviorConfiguration *)storageBehaviorConfiguration; -// Returns whether this MTRDevice uses Thread for communication +// Returns whether this MTRDeviceConcrete uses Thread for communication - (BOOL)deviceUsesThread; @end diff --git a/src/darwin/Framework/CHIP/MTRMetricKeys.h b/src/darwin/Framework/CHIP/MTRMetricKeys.h index 42064b7f049394..42e07280fd58f5 100644 --- a/src/darwin/Framework/CHIP/MTRMetricKeys.h +++ b/src/darwin/Framework/CHIP/MTRMetricKeys.h @@ -91,7 +91,7 @@ constexpr Tracing::MetricKey kMetricBLEDevicesRemoved = "dwnfw_ble_devices_remov // Unexpected C quality attribute update outside of priming constexpr Tracing::MetricKey kMetricUnexpectedCQualityUpdate = "dwnpm_bad_c_attr_update"; -// Setup from darwin MTRDevice for initial subscription to a device +// Setup from darwin MTRDeviceConcrete for initial subscription to a device constexpr Tracing::MetricKey kMetricMTRDeviceInitialSubscriptionSetup = "dwnpm_dev_initial_subscription_setup"; } // namespace DarwinFramework diff --git a/src/darwin/Framework/CHIP/Matter.h b/src/darwin/Framework/CHIP/Matter.h index 3c0ec41443303c..6dd87d52317e72 100644 --- a/src/darwin/Framework/CHIP/Matter.h +++ b/src/darwin/Framework/CHIP/Matter.h @@ -37,7 +37,7 @@ #import #import #import -#import +#import #import #import #import diff --git a/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt b/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt index c73e8aeb70d023..5748a4d75ba2e7 100644 --- a/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt @@ -147,7 +147,7 @@ MTR{{cluster}}Cluster{{command}}Params (isSupported (compatClusterNameRemapping name)))}} @implementation MTRCluster{{compatClusterNameRemapping name}} (Deprecated) -- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +- (instancetype)initWithDevice:(MTRDeviceConcrete *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue { return [self initWithDevice:device endpointID:@(endpoint) queue:queue]; } diff --git a/src/darwin/Framework/CHIP/templates/MTRClusters.zapt b/src/darwin/Framework/CHIP/templates/MTRClusters.zapt index ebcd299d0871f4..26a6e5365df626 100644 --- a/src/darwin/Framework/CHIP/templates/MTRClusters.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRClusters.zapt @@ -83,7 +83,7 @@ NS_ASSUME_NONNULL_BEGIN * for command invocations if commands are added to this cluster. {{/zcl_commands}} */ -- (instancetype _Nullable)initWithDevice:(MTRDevice *)device +- (instancetype _Nullable)initWithDevice:(MTRDeviceConcrete *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue {{availability (asUpperCamelCase name preserveAcronyms=true) minimalRelease="267F4B03-3256-4056-A62D-5237640FDCFE"}}; @@ -108,7 +108,7 @@ NS_ASSUME_NONNULL_BEGIN (isSupported (compatClusterNameRemapping name)))}} @interface MTRCluster{{compatClusterNameRemapping name}} (Deprecated) -- (nullable instancetype)initWithDevice:(MTRDevice *)device +- (nullable instancetype)initWithDevice:(MTRDeviceConcrete *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue {{availability (compatClusterNameRemapping name) deprecatedRelease="267F4B03-3256-4056-A62D-5237640FDCFE" deprecationMessage="Please use initWithDevice:endpoindID:queue:"}}; diff --git a/src/darwin/Framework/CHIPTests/MTRAsyncCallbackQueueTests.m b/src/darwin/Framework/CHIPTests/MTRAsyncCallbackQueueTests.m index bf8041ccd10fbc..97c5d0717ee52f 100644 --- a/src/darwin/Framework/CHIPTests/MTRAsyncCallbackQueueTests.m +++ b/src/darwin/Framework/CHIPTests/MTRAsyncCallbackQueueTests.m @@ -34,7 +34,7 @@ - (void)testRunItem MTRAsyncCallbackQueueWorkItem * workItem1 = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)]; __block int counter = 0; - MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * _Nonnull device, NSUInteger retryCount) { + MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDeviceConcrete * _Nonnull device, NSUInteger retryCount) { counter++; [expectation fulfill]; [workItem1 endWork]; @@ -65,7 +65,7 @@ - (void)testRunItemsSerialized MTRAsyncCallbackQueueWorkItem * workItem1 = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)]; __block int counter = 0; - MTRAsyncCallbackReadyHandler readyHandler1 = ^(MTRDevice * _Nonnull device, NSUInteger retryCount) { + MTRAsyncCallbackReadyHandler readyHandler1 = ^(MTRDeviceConcrete * _Nonnull device, NSUInteger retryCount) { sleep(1); counter++; [workItem1 endWork]; @@ -77,7 +77,7 @@ - (void)testRunItemsSerialized MTRAsyncCallbackQueueWorkItem * workItem2 = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)]; - MTRAsyncCallbackReadyHandler readyHandler2 = ^(MTRDevice * _Nonnull device, NSUInteger retryCount) { + MTRAsyncCallbackReadyHandler readyHandler2 = ^(MTRDeviceConcrete * _Nonnull device, NSUInteger retryCount) { // expect this to have waited until workItem1's sleep(1) finished and incremented counter if (counter == 1) { [expectation fulfill]; @@ -104,7 +104,7 @@ - (void)testRunItemsRetry MTRAsyncCallbackQueueWorkItem * workItem1 = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)]; __block int counter = 0; - MTRAsyncCallbackReadyHandler readyHandler1 = ^(MTRDevice * _Nonnull device, NSUInteger retryCount) { + MTRAsyncCallbackReadyHandler readyHandler1 = ^(MTRDeviceConcrete * _Nonnull device, NSUInteger retryCount) { sleep(1); counter++; @@ -122,7 +122,7 @@ - (void)testRunItemsRetry MTRAsyncCallbackQueueWorkItem * workItem2 = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)]; - MTRAsyncCallbackReadyHandler readyHandler2 = ^(MTRDevice * _Nonnull device, NSUInteger retryCount) { + MTRAsyncCallbackReadyHandler readyHandler2 = ^(MTRDeviceConcrete * _Nonnull device, NSUInteger retryCount) { // expect this to have waited until workItem1's sleep(1) finished and incremented counter twice if (counter == 2) { [expectation fulfill]; @@ -149,7 +149,7 @@ - (void)testRunItemsAfterDrain MTRAsyncCallbackQueueWorkItem * workItem1 = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)]; - MTRAsyncCallbackReadyHandler readyHandler1 = ^(MTRDevice * _Nonnull device, NSUInteger retryCount) { + MTRAsyncCallbackReadyHandler readyHandler1 = ^(MTRDeviceConcrete * _Nonnull device, NSUInteger retryCount) { [workItem1 endWork]; [expectation1 fulfill]; }; @@ -162,7 +162,7 @@ - (void)testRunItemsAfterDrain MTRAsyncCallbackQueueWorkItem * workItem2 = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)]; - MTRAsyncCallbackReadyHandler readyHandler2 = ^(MTRDevice * _Nonnull device, NSUInteger retryCount) { + MTRAsyncCallbackReadyHandler readyHandler2 = ^(MTRDeviceConcrete * _Nonnull device, NSUInteger retryCount) { [expectation2 fulfill]; [workItem2 endWork]; }; @@ -186,7 +186,7 @@ - (void)testRunItemNoHandlers [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)]; __block int counter = 0; - MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * _Nonnull device, NSUInteger retryCount) { + MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDeviceConcrete * _Nonnull device, NSUInteger retryCount) { counter++; [workItem2 endWork]; [expectation fulfill]; @@ -214,7 +214,7 @@ - (void)testInvalidation MTRAsyncCallbackQueueWorkItem * workItem1 = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)]; - MTRAsyncCallbackReadyHandler readyHandler1 = ^(MTRDevice * _Nonnull device, NSUInteger retryCount) { + MTRAsyncCallbackReadyHandler readyHandler1 = ^(MTRDeviceConcrete * _Nonnull device, NSUInteger retryCount) { // Give the code enqueing the other items a chance to run, so they can // actually get canceled. sleep(1); @@ -228,7 +228,7 @@ - (void)testInvalidation MTRAsyncCallbackQueueWorkItem * workItem2 = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)]; - MTRAsyncCallbackReadyHandler readyHandler2 = ^(MTRDevice * _Nonnull device, NSUInteger retryCount) { + MTRAsyncCallbackReadyHandler readyHandler2 = ^(MTRDeviceConcrete * _Nonnull device, NSUInteger retryCount) { // This should never get called. XCTAssertFalse(YES); [workItem2 endWork]; @@ -239,7 +239,7 @@ - (void)testInvalidation MTRAsyncCallbackQueueWorkItem * workItem3 = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)]; - MTRAsyncCallbackReadyHandler readyHandler3 = ^(MTRDevice * _Nonnull device, NSUInteger retryCount) { + MTRAsyncCallbackReadyHandler readyHandler3 = ^(MTRDeviceConcrete * _Nonnull device, NSUInteger retryCount) { // This should never get called. XCTAssertFalse(YES); [workItem3 endWork]; diff --git a/src/darwin/Framework/CHIPTests/MTRBackwardsCompatTests.m b/src/darwin/Framework/CHIPTests/MTRBackwardsCompatTests.m index 840c29f0c2a805..c71374d64cc746 100644 --- a/src/darwin/Framework/CHIPTests/MTRBackwardsCompatTests.m +++ b/src/darwin/Framework/CHIPTests/MTRBackwardsCompatTests.m @@ -616,7 +616,7 @@ - (void)test018_MTRClusters sig = [MTRClusterOnOff instanceMethodSignatureForSelector:@selector(initWithDevice:endpoint:queue:)]; CHECK_RETURN_TYPE(sig, MTRClusterOnOff *); - CHECK_ARGUMENT(sig, 0, MTRDevice *); + CHECK_ARGUMENT(sig, 0, MTRDeviceConcrete *); CHECK_ARGUMENT(sig, 1, uint16_t); CHECK_ARGUMENT(sig, 2, dispatch_queue_t); @@ -718,28 +718,28 @@ - (void)test023_MTRDevice { NSMethodSignature * sig; - sig = [MTRDevice methodSignatureForSelector:@selector(deviceWithNodeID:deviceController:)]; - CHECK_RETURN_TYPE(sig, MTRDevice *); + sig = [MTRDeviceConcrete methodSignatureForSelector:@selector(deviceWithNodeID:deviceController:)]; + CHECK_RETURN_TYPE(sig, MTRDeviceConcrete *); CHECK_ARGUMENT(sig, 0, uint64_t); CHECK_ARGUMENT(sig, 1, MTRDeviceController *); - __auto_type * instance = [MTRDevice deviceWithNodeID:1 deviceController:sController]; + __auto_type * instance = [MTRDeviceConcrete deviceWithNodeID:1 deviceController:sController]; CHECK_READONLY_PROPERTY(instance, state, MTRDeviceState); - sig = [MTRDevice instanceMethodSignatureForSelector:@selector(setDelegate:queue:)]; + sig = [MTRDeviceConcrete instanceMethodSignatureForSelector:@selector(setDelegate:queue:)]; CHECK_RETURN_TYPE(sig, void); CHECK_ARGUMENT(sig, 0, id); CHECK_ARGUMENT(sig, 1, dispatch_queue_t); - sig = [MTRDevice instanceMethodSignatureForSelector:@selector(readAttributeWithEndpointID:clusterID:attributeID:params:)]; + sig = [MTRDeviceConcrete instanceMethodSignatureForSelector:@selector(readAttributeWithEndpointID:clusterID:attributeID:params:)]; CHECK_RETURN_TYPE(sig, NSDictionary *); CHECK_ARGUMENT(sig, 0, NSNumber *); CHECK_ARGUMENT(sig, 1, NSNumber *); CHECK_ARGUMENT(sig, 2, NSNumber *); CHECK_ARGUMENT(sig, 3, MTRReadParams *); - sig = [MTRDevice instanceMethodSignatureForSelector:@selector + sig = [MTRDeviceConcrete instanceMethodSignatureForSelector:@selector (writeAttributeWithEndpointID:clusterID:attributeID:value:expectedValueInterval:timedWriteTimeout:)]; CHECK_RETURN_TYPE(sig, void); CHECK_ARGUMENT(sig, 0, NSNumber *); @@ -749,7 +749,7 @@ - (void)test023_MTRDevice CHECK_ARGUMENT(sig, 4, NSNumber *); CHECK_ARGUMENT(sig, 5, NSNumber *); - sig = [MTRDevice instanceMethodSignatureForSelector:@selector + sig = [MTRDeviceConcrete instanceMethodSignatureForSelector:@selector (invokeCommandWithEndpointID: clusterID:commandID:commandFields:expectedValues:expectedValueInterval:timedInvokeTimeout :clientQueue:completion:)]; @@ -764,7 +764,7 @@ - (void)test023_MTRDevice CHECK_ARGUMENT(sig, 7, dispatch_queue_t); CHECK_ARGUMENT(sig, 8, MTRDeviceResponseHandler); - sig = [MTRDevice instanceMethodSignatureForSelector:@selector + sig = [MTRDeviceConcrete instanceMethodSignatureForSelector:@selector (openCommissioningWindowWithSetupPasscode:discriminator:duration:queue:completion:)]; CHECK_RETURN_TYPE(sig, void); CHECK_ARGUMENT(sig, 0, NSNumber *); diff --git a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m index da059fc505de8c..1abdd52aac2199 100644 --- a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m +++ b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m @@ -131,7 +131,7 @@ @interface MTRDeviceTests : XCTestCase + (void)checkAttributeReportTriggersConfigurationChanged:(MTRAttributeIDType)attributeId clusterId:(MTRClusterIDType)clusterId endpointId:(NSNumber *)endpointId - device:(MTRDevice *)device + device:(MTRDeviceConcrete *)device delegate:(MTRDeviceTestDelegate *)delegate dataVersion:(NSNumber *)dataVersion attributeReport:(NSArray *> *)attributeReport @@ -231,10 +231,10 @@ - (void)setUp - (void)tearDown { - // Make sure our MTRDevice instances, which are stateful, do not keep that + // Make sure our MTRDeviceConcrete instances, which are stateful, do not keep that // state between different tests. if (sController != nil) { - __auto_type * device = [MTRDevice deviceWithNodeID:@(kDeviceId) controller:sController]; + __auto_type * device = [MTRDeviceConcrete deviceWithNodeID:@(kDeviceId) controller:sController]; [sController removeDevice:device]; } @@ -1439,7 +1439,7 @@ - (void)test016_FailedSubscribeWithCacheReadDuringFailure - (void)test017_TestMTRDeviceBasics { - __auto_type * device = [MTRDevice deviceWithNodeID:kDeviceId deviceController:sController]; + __auto_type * device = [MTRDeviceConcrete deviceWithNodeID:kDeviceId deviceController:sController]; dispatch_queue_t queue = dispatch_get_main_queue(); // Given reachable state becomes true before underlying OnSubscriptionEstablished callback, this expectation is necessary but @@ -1620,7 +1620,7 @@ - (void)test017_TestMTRDeviceBasics XCTAssertEqualObjects(getOnOffValue(), onOffValue); // Test if errors are properly received - // TODO: We might stop reporting these altogether from MTRDevice, and then + // TODO: We might stop reporting these altogether from MTRDeviceConcrete, and then // this test will need updating. __auto_type * readThroughForUnknownAttributesParams = [[MTRReadParams alloc] init]; readThroughForUnknownAttributesParams.assumeUnknownAttributesReportable = NO; @@ -1769,7 +1769,7 @@ - (void)test018_SubscriptionErrorWhenNotResubscribing - (void)test019_MTRDeviceMultipleCommands { - __auto_type * device = [MTRDevice deviceWithNodeID:kDeviceId deviceController:sController]; + __auto_type * device = [MTRDeviceConcrete deviceWithNodeID:kDeviceId deviceController:sController]; dispatch_queue_t queue = dispatch_get_main_queue(); __auto_type * opcredsCluster = [[MTRClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:queue]; @@ -1835,7 +1835,7 @@ - (void)test019_MTRDeviceMultipleCommands }]; XCTestExpectation * offExpectation = [self expectationWithDescription:@"Off command executed"]; - // Send this one via MTRDevice, to test that codepath. + // Send this one via MTRDeviceConcrete, to test that codepath. [device invokeCommandWithEndpointID:@(1) clusterID:@(MTRClusterIDTypeOnOffID) commandID:@(MTRCommandIDTypeClusterOnOffCommandOffID) @@ -2607,7 +2607,7 @@ - (void)test027_AttestationChallenge [self waitForExpectations:@[ attestationRequestedViaBaseDevice ] timeout:kTimeoutInSeconds]; - __auto_type * device = [MTRDevice deviceWithNodeID:kDeviceId deviceController:sController]; + __auto_type * device = [MTRDeviceConcrete deviceWithNodeID:kDeviceId deviceController:sController]; __auto_type * cluster = [[MTRClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:queue]; XCTestExpectation * attestationRequestedViaCluster = [self expectationWithDescription:@"Invoked AttestationRequest via cluster"]; [cluster attestationRequestWithParams:params expectedValues:nil expectedValueInterval:nil completion:^(MTROperationalCredentialsClusterAttestationResponseParams * _Nullable data, NSError * _Nullable error) { @@ -2703,7 +2703,7 @@ - (void)test028_TimeZoneAndDST - (void)test029_MTRDeviceWriteCoalescing { - __auto_type * device = [MTRDevice deviceWithNodeID:kDeviceId deviceController:sController]; + __auto_type * device = [MTRDeviceConcrete deviceWithNodeID:kDeviceId deviceController:sController]; dispatch_queue_t queue = dispatch_get_main_queue(); // Given reachable state becomes true before underlying OnSubscriptionEstablished callback, this expectation is necessary but @@ -3022,7 +3022,7 @@ - (void)test030_DeviceAndClusterProperties { dispatch_queue_t queue = dispatch_get_main_queue(); - __auto_type * device = [MTRDevice deviceWithNodeID:@(kDeviceId) controller:sController]; + __auto_type * device = [MTRDeviceConcrete deviceWithNodeID:@(kDeviceId) controller:sController]; XCTAssertEqual(device.deviceController, sController); XCTAssertEqualObjects(device.nodeID, @(kDeviceId)); @@ -3036,7 +3036,7 @@ - (void)test031_MTRDeviceAttributeCacheLocalTestStorage dispatch_queue_t queue = dispatch_get_main_queue(); // Get the subscription primed - __auto_type * device = [MTRDevice deviceWithNodeID:@(kDeviceId) controller:sController]; + __auto_type * device = [MTRDeviceConcrete deviceWithNodeID:@(kDeviceId) controller:sController]; NSTimeInterval baseTestDelayTime = 1; MTRDeviceStorageBehaviorConfiguration * config = [MTRDeviceStorageBehaviorConfiguration @@ -3076,7 +3076,7 @@ - (void)test031_MTRDeviceAttributeCacheLocalTestStorage // Now remove device, resubscribe, and see that it succeeds [sController removeDevice:device]; - device = [MTRDevice deviceWithNodeID:@(kDeviceId) controller:sController]; + device = [MTRDeviceConcrete deviceWithNodeID:@(kDeviceId) controller:sController]; XCTestExpectation * resubGotReportsExpectation = [self expectationWithDescription:@"Attribute and Event reports have been received for resubscription"]; XCTestExpectation * gotClusterDataPersisted2 = [self expectationWithDescription:@"Cluster data persisted 2"]; @@ -3103,7 +3103,7 @@ - (void)test031_MTRDeviceAttributeCacheLocalTestStorage XCTAssertTrue(attributesReportedWithSecondSubscription < attributesReportedWithFirstSubscription); - // 1) MTRDevice actually gets some attributes reported more than once + // 1) MTRDeviceConcrete actually gets some attributes reported more than once // 2) Some attributes do change on resubscribe // * With all-clusts-app as of 2024-02-10, out of 1287 persisted attributes, still 450 attributes were reported with filter // And so conservatively, assert that data version filters save at least 300 entries. @@ -3162,12 +3162,12 @@ - (void)test032_MTRPathClassesEncoding } // Helper API to test if changes in an attribute with a path specified by endpointId, clusterId and attributeId trigger -// device configuration changed callbacks for a given MTRDevice. This API creates a fake attribute report for the given attribute path -// and injects it into MTRDevice to exercise and test the delegate's device configuration changed callback. +// device configuration changed callbacks for a given MTRDeviceConcrete. This API creates a fake attribute report for the given attribute path +// and injects it into MTRDeviceConcrete to exercise and test the delegate's device configuration changed callback. + (void)checkAttributeReportTriggersConfigurationChanged:(MTRAttributeIDType)attributeId clusterId:(MTRClusterIDType)clusterId endpointId:(NSNumber *)endpointId - device:(MTRDevice *)device + device:(MTRDeviceConcrete *)device delegate:(MTRDeviceTestDelegate *)delegate dataVersion:(NSNumber *)dataVersion attributeReport:(NSArray *> *)attributeReport @@ -3246,7 +3246,7 @@ + (void)checkAttributeReportTriggersConfigurationChanged:(MTRAttributeIDType)att - (void)test033_TestMTRDeviceDeviceConfigurationChanged { - __auto_type * device = [MTRDevice deviceWithNodeID:kDeviceId deviceController:sController]; + __auto_type * device = [MTRDeviceConcrete deviceWithNodeID:kDeviceId deviceController:sController]; dispatch_queue_t queue = dispatch_get_main_queue(); // Check if subscription is set up and initial reports are received. @@ -3628,9 +3628,9 @@ - (void)test034_TestMTRDeviceHistoricalEvents [self waitForExpectations:@[ firstSubscriptionExpectation ] timeout:kTimeoutInSeconds]; - // Now set up our MTRDevice and do a subscribe. Make sure all the events we + // Now set up our MTRDeviceConcrete and do a subscribe. Make sure all the events we // get are marked "historical". - __auto_type * device = [MTRDevice deviceWithNodeID:kDeviceId deviceController:sController]; + __auto_type * device = [MTRDeviceConcrete deviceWithNodeID:kDeviceId deviceController:sController]; XCTestExpectation * secondSubscriptionExpectation = [self expectationWithDescription:@"Second subscription established"]; XCTestExpectation * gotFirstReportsExpectation = [self expectationWithDescription:@"First Attribute and Event reports have been received"]; @@ -3665,7 +3665,7 @@ - (void)test034_TestMTRDeviceHistoricalEvents eventReportsReceived = 0; - device = [MTRDevice deviceWithNodeID:kDeviceId deviceController:sController]; + device = [MTRDeviceConcrete deviceWithNodeID:kDeviceId deviceController:sController]; XCTestExpectation * thirdSubscriptionExpectation = [self expectationWithDescription:@"Third subscription established"]; XCTestExpectation * gotSecondReportsExpectation = [self expectationWithDescription:@"Second Attribute and Event reports have been received"]; @@ -3694,7 +3694,7 @@ - (void)test035_TestMTRDeviceSubscriptionNotEstablishedOverXPC return nil; }]; - __auto_type * device = [MTRDevice deviceWithNodeID:kDeviceId deviceController:remoteController]; + __auto_type * device = [MTRDeviceConcrete deviceWithNodeID:kDeviceId deviceController:remoteController]; dispatch_queue_t queue = dispatch_get_main_queue(); XCTestExpectation * subscriptionExpectation = [self expectationWithDescription:@"Subscription has been set up"]; @@ -3734,7 +3734,7 @@ - (void)test036_TestStorageBehaviorConfiguration NSDictionary * storedClusterDataAfterClear = [sController.controllerDataStore getStoredClusterDataForNodeID:@(kDeviceId)]; XCTAssertEqual(storedClusterDataAfterClear.count, 0); - __auto_type * device = [MTRDevice deviceWithNodeID:kDeviceId deviceController:sController]; + __auto_type * device = [MTRDeviceConcrete deviceWithNodeID:kDeviceId deviceController:sController]; __auto_type * delegate = [[MTRDeviceTestDelegateWithSubscriptionSetupOverride alloc] init]; __block os_unfair_lock lock = OS_UNFAIR_LOCK_INIT; @@ -3879,7 +3879,7 @@ - (void)test036_TestStorageBehaviorConfiguration [NSDate dateWithTimeIntervalSinceNow:-(baseTestDelayTime * 0.3)], ]]]; - // Inject final report that makes MTRDevice recalculate delay with multiplier + // Inject final report that makes MTRDeviceConcrete recalculate delay with multiplier [device unitTestInjectAttributeReport:[self _testAttributeReportWithValue:currentTestValue++] fromSubscription:YES]; [self waitForExpectations:@[ dataPersisted3 ] timeout:60]; @@ -3918,7 +3918,7 @@ - (void)test036_TestStorageBehaviorConfiguration [NSDate dateWithTimeIntervalSinceNow:-(baseTestDelayTime * 0.1)], ]]]; - // Inject report that makes MTRDevice detect the device is reporting excessively + // Inject report that makes MTRDeviceConcrete detect the device is reporting excessively [device unitTestInjectAttributeReport:[self _testAttributeReportWithValue:currentTestValue++] fromSubscription:YES]; // Now keep reporting excessively for base delay time max times max multiplier, plus a bit more @@ -3940,7 +3940,7 @@ - (void)test036_TestStorageBehaviorConfiguration [NSDate dateWithTimeIntervalSinceNow:-(baseTestDelayTime * 10)], ]]]; - // And inject a report to trigger MTRDevice to recalculate that this device is no longer + // And inject a report to trigger MTRDeviceConcrete to recalculate that this device is no longer // reporting excessively [device unitTestInjectAttributeReport:[self _testAttributeReportWithValue:currentTestValue++] fromSubscription:YES]; @@ -3954,15 +3954,15 @@ - (void)test037_MTRDeviceMultipleDelegatesGetReports { dispatch_queue_t queue = dispatch_get_main_queue(); - // First start with clean slate by removing the MTRDevice and clearing the persisted cache - __auto_type * device = [MTRDevice deviceWithNodeID:@(kDeviceId) controller:sController]; + // First start with clean slate by removing the MTRDeviceConcrete and clearing the persisted cache + __auto_type * device = [MTRDeviceConcrete deviceWithNodeID:@(kDeviceId) controller:sController]; [sController removeDevice:device]; [sController.controllerDataStore clearAllStoredClusterData]; NSDictionary * storedClusterDataAfterClear = [sController.controllerDataStore getStoredClusterDataForNodeID:@(kDeviceId)]; XCTAssertEqual(storedClusterDataAfterClear.count, 0); // Now recreate device and get subscription primed - device = [MTRDevice deviceWithNodeID:@(kDeviceId) controller:sController]; + device = [MTRDeviceConcrete deviceWithNodeID:@(kDeviceId) controller:sController]; XCTestExpectation * gotReportEnd1 = [self expectationWithDescription:@"Report end for delegate 1"]; __auto_type * delegate1 = [[MTRDeviceTestDelegate alloc] init]; __weak __auto_type weakDelegate1 = delegate1; @@ -3991,13 +3991,13 @@ - (void)test037_MTRDeviceMultipleDelegatesGetReports // Wait just long enough for 1 report [self waitForExpectations:@[ gotAReport2 ] timeout:60]; - // Verify that at this point MTRDevice is still seeing 2 delegates + // Verify that at this point MTRDeviceConcrete is still seeing 2 delegates XCTAssertEqual([device unitTestNonnullDelegateCount], 2); } [self waitForExpectations:@[ gotReportEnd1 ] timeout:60]; - // Verify that once the entire report comes in from all-clusters, that delegate2 had been dealloced, and MTRDevice no longer sees it + // Verify that once the entire report comes in from all-clusters, that delegate2 had been dealloced, and MTRDeviceConcrete no longer sees it XCTAssertEqual([device unitTestNonnullDelegateCount], 1); } @@ -4026,15 +4026,15 @@ - (void)test038_MTRDeviceMultipleDelegatesInterestedPaths { dispatch_queue_t queue = dispatch_get_main_queue(); - // First start with clean slate by removing the MTRDevice and clearing the persisted cache - __auto_type * device = [MTRDevice deviceWithNodeID:@(kDeviceId) controller:sController]; + // First start with clean slate by removing the MTRDeviceConcrete and clearing the persisted cache + __auto_type * device = [MTRDeviceConcrete deviceWithNodeID:@(kDeviceId) controller:sController]; [sController removeDevice:device]; [sController.controllerDataStore clearAllStoredClusterData]; NSDictionary * storedClusterDataAfterClear = [sController.controllerDataStore getStoredClusterDataForNodeID:@(kDeviceId)]; XCTAssertEqual(storedClusterDataAfterClear.count, 0); // Now recreate device and get subscription primed - device = [MTRDevice deviceWithNodeID:@(kDeviceId) controller:sController]; + device = [MTRDeviceConcrete deviceWithNodeID:@(kDeviceId) controller:sController]; XCTestExpectation * gotReportEnd1 = [self expectationWithDescription:@"Report end for delegate 1"]; __auto_type * delegate1 = [[MTRDeviceTestDelegateWithSubscriptionSetupOverride alloc] init]; diff --git a/src/darwin/Framework/CHIPTests/MTROTAProviderTests.m b/src/darwin/Framework/CHIPTests/MTROTAProviderTests.m index 3c8cad690ad83b..b051380b104c3a 100644 --- a/src/darwin/Framework/CHIPTests/MTROTAProviderTests.m +++ b/src/darwin/Framework/CHIPTests/MTROTAProviderTests.m @@ -77,14 +77,14 @@ @interface MTROTAProviderTests : MTRTestCase - (NSString *)createImageFromRawImage:(NSString *)rawImage withVersion:(NSNumber *)version; -- (MTRDevice *)commissionDeviceWithPayload:(NSString *)payloadString nodeID:(NSNumber *)nodeID; +- (MTRDeviceConcrete *)commissionDeviceWithPayload:(NSString *)payloadString nodeID:(NSNumber *)nodeID; @end @interface MTROTARequestorAppRunner : MTRTestServerAppRunner @property (nonatomic, copy) NSString * downloadFilePath; - (instancetype)initWithPayload:(NSString *)payload testcase:(MTROTAProviderTests *)testcase; -- (MTRDevice *)commissionWithNodeID:(NSNumber *)nodeID; +- (MTRDeviceConcrete *)commissionWithNodeID:(NSNumber *)nodeID; @end @implementation MTROTARequestorAppRunner { @@ -92,7 +92,7 @@ @implementation MTROTARequestorAppRunner { NSString * _payload; } -- (MTRDevice *)commissionWithNodeID:(NSNumber *)nodeID +- (MTRDeviceConcrete *)commissionWithNodeID:(NSNumber *)nodeID { return [_testcase commissionDeviceWithPayload:_payload nodeID:nodeID]; } @@ -598,7 +598,7 @@ - (void)tearDown sOTAProviderDelegate.transferEndHandler = nil; } -- (MTRDevice *)commissionDeviceWithPayload:(NSString *)payloadString nodeID:(NSNumber *)nodeID +- (MTRDeviceConcrete *)commissionDeviceWithPayload:(NSString *)payloadString nodeID:(NSNumber *)nodeID { XCTestExpectation * expectation = [self expectationWithDescription:[NSString stringWithFormat:@"Commissioning Complete for %@", nodeID]]; @@ -620,7 +620,7 @@ - (MTRDevice *)commissionDeviceWithPayload:(NSString *)payloadString nodeID:(NSN [_commissionedNodeIDs addObject:nodeID]; - return [MTRDevice deviceWithNodeID:nodeID controller:sController]; + return [MTRDeviceConcrete deviceWithNodeID:nodeID controller:sController]; } - (void)initStack @@ -708,7 +708,7 @@ - (void)test000_SetUp // tests. } -- (XCTestExpectation *)announceProviderToDevice:(MTRDevice *)device +- (XCTestExpectation *)announceProviderToDevice:(MTRDeviceConcrete *)device { dispatch_queue_t queue = dispatch_get_main_queue(); @@ -1475,7 +1475,7 @@ - (void)test007_DoBDXTransferIncrementalOtaUpdate - (void)test008_TestWriteDefaultOTAProviders { __auto_type * runner = [[MTROTARequestorAppRunner alloc] initWithPayload:kOnboardingPayload1 testcase:self]; - MTRDevice * device = [runner commissionWithNodeID:@(kDeviceId1)]; + MTRDeviceConcrete * device = [runner commissionWithNodeID:@(kDeviceId1)]; dispatch_queue_t queue = dispatch_get_main_queue(); @@ -1550,7 +1550,7 @@ - (void)test008_TestWriteDefaultOTAProviders } { - // Now test with MTRDevice + // Now test with MTRDeviceConcrete __auto_type * delegate = [[MTRDeviceTestDelegate alloc] init]; // Make sure we don't have expected value notifications confusing our // attribute reports. diff --git a/src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m b/src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m index db8bd300df94e1..56b4a21aa7ea46 100644 --- a/src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m +++ b/src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m @@ -1433,7 +1433,7 @@ - (void)doDataStoreMTRDeviceTestWithStorageDelegate:(id *)getEndpointArrayFromPartsList:(MTRDeviceDataValueDictionary)partsList forDevice:(MTRDevice *)device +- (NSMutableArray *)getEndpointArrayFromPartsList:(MTRDeviceDataValueDictionary)partsList forDevice:(MTRDeviceConcrete *)device { // Initialize the endpoint array with endpoint 0. NSMutableArray * endpoints = [NSMutableArray arrayWithObject:@0]; @@ -2980,7 +2980,7 @@ - (void)testMTRDeviceResetSubscription // We should have established CASE using our operational key. XCTAssertEqual(operationalKeys.signatureCount, 1); - __auto_type * device = [MTRDevice deviceWithNodeID:deviceID controller:controller]; + __auto_type * device = [MTRDeviceConcrete deviceWithNodeID:deviceID controller:controller]; __auto_type * delegate = [[MTRDeviceTestDelegate alloc] init]; XCTestExpectation * subscriptionExpectation1 = [self expectationWithDescription:@"Subscription has been set up 1"]; diff --git a/src/darwin/Framework/CHIPTests/MTRSwiftDeviceTests.swift b/src/darwin/Framework/CHIPTests/MTRSwiftDeviceTests.swift index 1e1ee92e480ad4..6aba69ae01ad97 100644 --- a/src/darwin/Framework/CHIPTests/MTRSwiftDeviceTests.swift +++ b/src/darwin/Framework/CHIPTests/MTRSwiftDeviceTests.swift @@ -63,7 +63,7 @@ class MTRSwiftDeviceTestDelegate : NSObject, MTRDeviceDelegate { onReachable = handler } - func device(_ device: MTRDevice, stateChanged state : MTRDeviceState) { + func device(_ device: MTRDeviceConcrete, stateChanged state : MTRDeviceState) { if (state == MTRDeviceState.reachable) { onReachable() } else { @@ -71,28 +71,28 @@ class MTRSwiftDeviceTestDelegate : NSObject, MTRDeviceDelegate { } } - func device(_ device : MTRDevice, receivedAttributeReport attributeReport : [[ String: Any ]]) + func device(_ device : MTRDeviceConcrete, receivedAttributeReport attributeReport : [[ String: Any ]]) { onAttributeDataReceived?(attributeReport) } - func device(_ device : MTRDevice, receivedEventReport eventReport : [[ String : Any ]]) + func device(_ device : MTRDeviceConcrete, receivedEventReport eventReport : [[ String : Any ]]) { onEventDataReceived?(eventReport) } - @objc func unitTestReportEnd(forDevice : MTRDevice) + @objc func unitTestReportEnd(forDevice : MTRDeviceConcrete) { onReportEnd?() } - @objc func unitTestMaxIntervalOverrideForSubscription(_ device : MTRDevice) -> NSNumber + @objc func unitTestMaxIntervalOverrideForSubscription(_ device : MTRDeviceConcrete) -> NSNumber { // Make sure our subscriptions time out in finite time. return 2; // seconds } - @objc func unitTestSuppressTimeBasedReachabilityChanges(_ device : MTRDevice) -> Bool + @objc func unitTestSuppressTimeBasedReachabilityChanges(_ device : MTRDeviceConcrete) -> Bool { // Allowing time-based reachability changes just makes the tests // non-deterministic and can lead to random failures. Suppress them @@ -183,7 +183,7 @@ class MTRSwiftDeviceTests : XCTestCase { func test017_TestMTRDeviceBasics() { - let device = MTRDevice(nodeID: DeviceConstants.deviceID as NSNumber, controller:sController!) + let device = MTRDeviceConcrete(nodeID: DeviceConstants.deviceID as NSNumber, controller:sController!) let queue = DispatchQueue.main // Given reachable state becomes true before underlying OnSubscriptionEstablished callback, this expectation is necessary but @@ -483,7 +483,7 @@ class MTRSwiftDeviceTests : XCTestCase { func test019_MTRDeviceMultipleCommands() async { - let device = MTRDevice(nodeID: DeviceConstants.deviceID as NSNumber, controller:sController!) + let device = MTRDeviceConcrete(nodeID: DeviceConstants.deviceID as NSNumber, controller:sController!) let queue = DispatchQueue.main let opcredsCluster = MTRClusterOperationalCredentials(device: device, endpointID: 0, queue: queue)! @@ -578,7 +578,7 @@ class MTRSwiftDeviceTests : XCTestCase { func test030_DeviceAndClusterProperties() { let queue = DispatchQueue.main - let device = MTRDevice(nodeID: DeviceConstants.deviceID as NSNumber, controller:sController!) + let device = MTRDeviceConcrete(nodeID: DeviceConstants.deviceID as NSNumber, controller:sController!) XCTAssertEqual(device.deviceController, sController) XCTAssertEqual(device.__nodeID, DeviceConstants.deviceID as NSNumber) diff --git a/src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m b/src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m index e8a25fc054a7f1..db6edfce94c5e9 100644 --- a/src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m +++ b/src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m @@ -475,27 +475,27 @@ @interface MTRXPCDeviceTestDelegate : NSObject @end @implementation MTRXPCDeviceTestDelegate -- (void)device:(MTRDevice *)device stateChanged:(MTRDeviceState)state +- (void)device:(MTRDeviceConcrete *)device stateChanged:(MTRDeviceState)state { } -- (void)device:(MTRDevice *)device receivedAttributeReport:(NSArray *> *)attributeReport +- (void)device:(MTRDeviceConcrete *)device receivedAttributeReport:(NSArray *> *)attributeReport { if (self.onAttributeDataReceived != nil) { self.onAttributeDataReceived(attributeReport); } } -- (void)device:(MTRDevice *)device receivedEventReport:(NSArray *> *)eventReport +- (void)device:(MTRDeviceConcrete *)device receivedEventReport:(NSArray *> *)eventReport { } -- (BOOL)unitTestShouldSetUpSubscriptionForDevice:(MTRDevice *)device +- (BOOL)unitTestShouldSetUpSubscriptionForDevice:(MTRDeviceConcrete *)device { return NO; } -- (BOOL)unitTestShouldSkipExpectedValuesForWrite:(MTRDevice *)device +- (BOOL)unitTestShouldSkipExpectedValuesForWrite:(MTRDeviceConcrete *)device { return YES; } @@ -1732,7 +1732,7 @@ - (void)test014_TimedInvokeCommand - (void)test015_MTRDeviceInteraction { - __auto_type * device = [MTRDevice deviceWithNodeID:@(kDeviceId) controller:mDeviceController]; + __auto_type * device = [MTRDeviceConcrete deviceWithNodeID:@(kDeviceId) controller:mDeviceController]; dispatch_queue_t queue = dispatch_get_main_queue(); __auto_type * delegate = [[MTRXPCDeviceTestDelegate alloc] init]; diff --git a/src/darwin/Framework/CHIPTests/TestHelpers/MTRDeviceTestDelegate.m b/src/darwin/Framework/CHIPTests/TestHelpers/MTRDeviceTestDelegate.m index 740f5f71cf8b7c..50bb493819ecb4 100644 --- a/src/darwin/Framework/CHIPTests/TestHelpers/MTRDeviceTestDelegate.m +++ b/src/darwin/Framework/CHIPTests/TestHelpers/MTRDeviceTestDelegate.m @@ -17,7 +17,7 @@ #import "MTRDeviceTestDelegate.h" @implementation MTRDeviceTestDelegate -- (void)device:(MTRDevice *)device stateChanged:(MTRDeviceState)state +- (void)device:(MTRDeviceConcrete *)device stateChanged:(MTRDeviceState)state { if (state == MTRDeviceStateReachable && self.onReachable != nil) { self.onReachable(); @@ -26,84 +26,84 @@ - (void)device:(MTRDevice *)device stateChanged:(MTRDeviceState)state } } -- (void)device:(MTRDevice *)device receivedAttributeReport:(NSArray *> *)attributeReport +- (void)device:(MTRDeviceConcrete *)device receivedAttributeReport:(NSArray *> *)attributeReport { if (self.onAttributeDataReceived != nil) { self.onAttributeDataReceived(attributeReport); } } -- (void)device:(MTRDevice *)device receivedEventReport:(NSArray *> *)eventReport +- (void)device:(MTRDeviceConcrete *)device receivedEventReport:(NSArray *> *)eventReport { if (self.onEventDataReceived != nil) { self.onEventDataReceived(eventReport); } } -- (void)unitTestReportEndForDevice:(MTRDevice *)device +- (void)unitTestReportEndForDevice:(MTRDeviceConcrete *)device { if (self.onReportEnd != nil) { self.onReportEnd(); } } -- (NSNumber *)unitTestMaxIntervalOverrideForSubscription:(MTRDevice *)device +- (NSNumber *)unitTestMaxIntervalOverrideForSubscription:(MTRDeviceConcrete *)device { // Make sure our subscriptions time out in finite time. return @(2); // seconds } -- (void)deviceCachePrimed:(MTRDevice *)device +- (void)deviceCachePrimed:(MTRDeviceConcrete *)device { if (self.onDeviceCachePrimed != nil) { self.onDeviceCachePrimed(); } } -- (BOOL)unitTestShouldSkipExpectedValuesForWrite:(MTRDevice *)device +- (BOOL)unitTestShouldSkipExpectedValuesForWrite:(MTRDeviceConcrete *)device { return self.skipExpectedValuesForWrite; } -- (BOOL)unitTestForceAttributeReportsIfMatchingCache:(MTRDevice *)device +- (BOOL)unitTestForceAttributeReportsIfMatchingCache:(MTRDeviceConcrete *)device { return self.forceAttributeReportsIfMatchingCache; } -- (void)deviceConfigurationChanged:(MTRDevice *)device +- (void)deviceConfigurationChanged:(MTRDeviceConcrete *)device { if (self.onDeviceConfigurationChanged != nil) { self.onDeviceConfigurationChanged(); } } -- (BOOL)unitTestPretendThreadEnabled:(MTRDevice *)device +- (BOOL)unitTestPretendThreadEnabled:(MTRDeviceConcrete *)device { return self.pretendThreadEnabled; } -- (void)unitTestSubscriptionPoolDequeue:(MTRDevice *)device +- (void)unitTestSubscriptionPoolDequeue:(MTRDeviceConcrete *)device { if (self.onSubscriptionPoolDequeue != nil) { self.onSubscriptionPoolDequeue(); } } -- (void)unitTestSubscriptionPoolWorkComplete:(MTRDevice *)device +- (void)unitTestSubscriptionPoolWorkComplete:(MTRDeviceConcrete *)device { if (self.onSubscriptionPoolWorkComplete != nil) { self.onSubscriptionPoolWorkComplete(); } } -- (void)unitTestClusterDataPersisted:(MTRDevice *)device +- (void)unitTestClusterDataPersisted:(MTRDeviceConcrete *)device { if (self.onClusterDataPersisted != nil) { self.onClusterDataPersisted(); } } -- (BOOL)unitTestSuppressTimeBasedReachabilityChanges:(MTRDevice *)device +- (BOOL)unitTestSuppressTimeBasedReachabilityChanges:(MTRDeviceConcrete *)device { // Allowing time-based reachability changes just makes the tests // non-deterministic and can lead to random failures. Suppress them @@ -116,7 +116,7 @@ - (BOOL)unitTestSuppressTimeBasedReachabilityChanges:(MTRDevice *)device @implementation MTRDeviceTestDelegateWithSubscriptionSetupOverride -- (BOOL)unitTestShouldSetUpSubscriptionForDevice:(MTRDevice *)device +- (BOOL)unitTestShouldSetUpSubscriptionForDevice:(MTRDeviceConcrete *)device { return !_skipSetupSubscription; } diff --git a/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestDeclarations.h b/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestDeclarations.h index 46d6c61e950f2d..f6ebdb16a85839 100644 --- a/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestDeclarations.h +++ b/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestDeclarations.h @@ -41,11 +41,11 @@ NS_ASSUME_NONNULL_BEGIN // Declare internal methods for testing @interface MTRDeviceController (Test) + (void)forceLocalhostAdvertisingOnly; -- (void)removeDevice:(MTRDevice *)device; +- (void)removeDevice:(MTRDeviceConcrete *)device; @property (nonatomic, readonly, nullable) id controllerDataStore; @end -@interface MTRDevice (Test) +@interface MTRDeviceConcrete (Test) - (BOOL)_attributeDataValue:(NSDictionary *)one isEqualToDataValue:(NSDictionary *)theOther; - (NSMutableArray *)arrayOfNumbersFromAttributeValue:(MTRDeviceDataValueDictionary)dataDictionary; @end @@ -62,7 +62,7 @@ NS_ASSUME_NONNULL_BEGIN + (id)CHIPEncodeAndDecodeNSObject:(id)object; @end -@interface MTRDevice (TestDebug) +@interface MTRDeviceConcrete (TestDebug) - (void)unitTestInjectEventReport:(NSArray *> *)eventReport; - (void)unitTestInjectAttributeReport:(NSArray *> *)attributeReport fromSubscription:(BOOL)isFromSubscription; - (NSUInteger)unitTestAttributesReportedSinceLastCheck; diff --git a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj index 055a6c9efbcc3e..ea0eec486a71d5 100644 --- a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj +++ b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj @@ -260,8 +260,8 @@ 754F3DF427FBB94B00E60580 /* MTREventTLVValueDecoder_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 754F3DF327FBB94B00E60580 /* MTREventTLVValueDecoder_Internal.h */; }; 7560FD1C27FBBD3F005E85B3 /* MTREventTLVValueDecoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7560FD1B27FBBD3F005E85B3 /* MTREventTLVValueDecoder.mm */; }; 7596A83E28751220004DAE0E /* MTRBaseClusters_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596A83D28751220004DAE0E /* MTRBaseClusters_Internal.h */; }; - 7596A84428762729004DAE0E /* MTRDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596A84228762729004DAE0E /* MTRDevice.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 7596A84528762729004DAE0E /* MTRDevice.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7596A84328762729004DAE0E /* MTRDevice.mm */; }; + 7596A84428762729004DAE0E /* MTRDeviceConcrete.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596A84228762729004DAE0E /* MTRDeviceConcrete.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 7596A84528762729004DAE0E /* MTRDeviceConcrete.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7596A84328762729004DAE0E /* MTRDeviceConcrete.mm */; }; 7596A84828762783004DAE0E /* MTRAsyncCallbackWorkQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596A84628762783004DAE0E /* MTRAsyncCallbackWorkQueue.h */; settings = {ATTRIBUTES = (Public, ); }; }; 7596A84928762783004DAE0E /* MTRAsyncCallbackWorkQueue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7596A84728762783004DAE0E /* MTRAsyncCallbackWorkQueue.mm */; }; 7596A84B287636C1004DAE0E /* MTRDevice_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596A84A287636C1004DAE0E /* MTRDevice_Internal.h */; }; @@ -686,8 +686,8 @@ 754F3DF327FBB94B00E60580 /* MTREventTLVValueDecoder_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTREventTLVValueDecoder_Internal.h; sourceTree = ""; }; 7560FD1B27FBBD3F005E85B3 /* MTREventTLVValueDecoder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTREventTLVValueDecoder.mm; sourceTree = ""; }; 7596A83D28751220004DAE0E /* MTRBaseClusters_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRBaseClusters_Internal.h; sourceTree = ""; }; - 7596A84228762729004DAE0E /* MTRDevice.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRDevice.h; sourceTree = ""; }; - 7596A84328762729004DAE0E /* MTRDevice.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRDevice.mm; sourceTree = ""; }; + 7596A84228762729004DAE0E /* MTRDeviceConcrete.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRDeviceConcrete.h; sourceTree = ""; }; + 7596A84328762729004DAE0E /* MTRDeviceConcrete.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRDeviceConcrete.mm; sourceTree = ""; }; 7596A84628762783004DAE0E /* MTRAsyncCallbackWorkQueue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRAsyncCallbackWorkQueue.h; sourceTree = ""; }; 7596A84728762783004DAE0E /* MTRAsyncCallbackWorkQueue.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRAsyncCallbackWorkQueue.mm; sourceTree = ""; }; 7596A84A287636C1004DAE0E /* MTRDevice_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRDevice_Internal.h; sourceTree = ""; }; @@ -1299,8 +1299,8 @@ 3DECCB732934C21B00585AEC /* MTRDefines.h */, 3DFCB32A2966827F00332B35 /* MTRDefines_Internal.h */, 7596A84A287636C1004DAE0E /* MTRDevice_Internal.h */, - 7596A84228762729004DAE0E /* MTRDevice.h */, - 7596A84328762729004DAE0E /* MTRDevice.mm */, + 7596A84228762729004DAE0E /* MTRDeviceConcrete.h */, + 7596A84328762729004DAE0E /* MTRDeviceConcrete.mm */, 88EBF8CB27FABDD500686BC1 /* MTRDeviceAttestationDelegate.h */, 7534F12728BFF20300390851 /* MTRDeviceAttestationDelegate_Internal.h */, 7534F12628BFF20300390851 /* MTRDeviceAttestationDelegate.mm */, @@ -1631,7 +1631,7 @@ 88E07D612B9A89A4005FD53E /* MTRMetricKeys.h in Headers */, 3D4733B32BE2D1DA003DC19B /* MTRUtilities.h in Headers */, B2E0D7B1245B0B5C003C5B48 /* Matter.h in Headers */, - 7596A84428762729004DAE0E /* MTRDevice.h in Headers */, + 7596A84428762729004DAE0E /* MTRDeviceConcrete.h in Headers */, B2E0D7B8245B0B5C003C5B48 /* MTRSetupPayload.h in Headers */, 1E4D654F29C208DD00BC3478 /* MTRCommissionableBrowser.h in Headers */, 3D843756294AD25A0070D20A /* MTRCertificateInfo.h in Headers */, @@ -2008,7 +2008,7 @@ 51D0B1272B617246006E3511 /* MTRServerEndpoint.mm in Sources */, 3DECCB722934AFE200585AEC /* MTRLogging.mm in Sources */, 51C659DA2BA3787500C54922 /* MTRTimeUtils.mm in Sources */, - 7596A84528762729004DAE0E /* MTRDevice.mm in Sources */, + 7596A84528762729004DAE0E /* MTRDeviceConcrete.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };