Skip to content

Commit 3efd38a

Browse files
committed
Add an API for checking if subscriptions are allowed and check that in _setUpSubscription
1 parent aa96777 commit 3efd38a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/darwin/Framework/CHIP/MTRDevice.mm

+11-2
Original file line numberDiff line numberDiff line change
@@ -685,13 +685,16 @@ - (void)_setDSTOffsets:(NSArray<MTRTimeSynchronizationClusterDSTOffsetStruct *>
685685
#define MTR_DEVICE_SUBSCRIPTION_MAX_INTERVAL_MIN (10 * 60) // 10 minutes (for now)
686686
#define MTR_DEVICE_SUBSCRIPTION_MAX_INTERVAL_MAX (60 * 60) // 60 minutes
687687

688+
-(BOOL)_subscriptionsAllowed {
689+
return ![_deviceController isKindOfClass:MTRDeviceControllerOverXPC.class];
690+
}
691+
688692
- (void)setDelegate:(id<MTRDeviceDelegate>)delegate queue:(dispatch_queue_t)queue
689693
{
690694
MTR_LOG_INFO("%@ setDelegate %@", self, delegate);
691695

692696
// We should not set up a subscription for device controllers over XPC.
693-
BOOL setUpSubscription = ![_deviceController isKindOfClass:MTRDeviceControllerOverXPC.class];
694-
;
697+
BOOL setUpSubscription = [self _subscriptionsAllowed];
695698

696699
// For unit testing only
697700
#ifdef DEBUG
@@ -1690,6 +1693,12 @@ - (void)_setupSubscription
16901693
{
16911694
os_unfair_lock_assert_owner(&self->_lock);
16921695

1696+
if (![self _subscriptionsAllowed])
1697+
{
1698+
MTR_LOG("_setupSubscription: Subscriptions not allowed. Do not set up subscription");
1699+
return;
1700+
}
1701+
16931702
#ifdef DEBUG
16941703
id delegate = _weakDelegate.strongObject;
16951704
Optional<System::Clock::Seconds32> maxIntervalOverride;

0 commit comments

Comments
 (0)