Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dea4e7d

Browse files
committedAug 3, 2024·
start closing off MTRDevice direct use
1 parent 32b706e commit dea4e7d

File tree

1 file changed

+4
-37
lines changed

1 file changed

+4
-37
lines changed
 

‎src/darwin/Framework/CHIP/MTRDevice.mm

+4-37
Original file line numberDiff line numberDiff line change
@@ -500,42 +500,8 @@ @implementation MTRDevice {
500500

501501
- (instancetype)initWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller
502502
{
503-
if (self = [super init]) {
504-
_lock = OS_UNFAIR_LOCK_INIT;
505-
_timeSyncLock = OS_UNFAIR_LOCK_INIT;
506-
_nodeID = [nodeID copy];
507-
_fabricIndex = controller.fabricIndex;
508-
_deviceController = controller;
509-
_queue
510-
= dispatch_queue_create("org.csa-iot.matter.framework.device.workqueue", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
511-
_expectedValueCache = [NSMutableDictionary dictionary];
512-
_asyncWorkQueue = [[MTRAsyncWorkQueue alloc] initWithContext:self];
513-
_state = MTRDeviceStateUnknown;
514-
_internalDeviceState = MTRInternalDeviceStateUnsubscribed;
515-
if (controller.controllerDataStore) {
516-
_persistedClusterData = [[NSCache alloc] init];
517-
} else {
518-
_persistedClusterData = nil;
519-
}
520-
_clusterDataToPersist = nil;
521-
_persistedClusters = [NSMutableSet set];
522-
523-
// If there is a data store, make sure we have an observer to monitor system clock changes, so
524-
// NSDate-based write coalescing could be reset and not get into a bad state.
525-
if (_persistedClusterData) {
526-
mtr_weakify(self);
527-
_systemTimeChangeObserverToken = [[NSNotificationCenter defaultCenter] addObserverForName:NSSystemClockDidChangeNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull notification) {
528-
mtr_strongify(self);
529-
std::lock_guard lock(self->_lock);
530-
[self _resetStorageBehaviorState];
531-
}];
532-
}
533-
534-
_delegates = [NSMutableSet set];
535-
536-
MTR_LOG_DEBUG("%@ init with hex nodeID 0x%016llX", self, _nodeID.unsignedLongLongValue);
537-
}
538-
return self;
503+
MTR_LOG_ERROR("do not call %s on base class", __func__);
504+
return nil;
539505
}
540506

541507
- (void)dealloc
@@ -554,7 +520,8 @@ - (NSString *)description
554520

555521
+ (MTRDevice *)deviceWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller
556522
{
557-
return [controller deviceForNodeID:nodeID];
523+
MTR_LOG_ERROR("do not call %s on base class", __func__);
524+
return nil;
558525
}
559526

560527
#pragma mark - Time Synchronization

0 commit comments

Comments
 (0)
Please sign in to comment.