Skip to content

Commit 32a84b4

Browse files
woody-applerestyled-commitsbzbarsky-apple
authoredMay 24, 2024
Building some internal hooks for automation (#33581)
* Adding dragons.... * Restyled by clang-format * Fixing build * Renaming * Restyled by clang-format * Fixing missing interface * Restyled by clang-format * Update src/darwin/Framework/CHIP/MTRDevice.mm Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> --------- Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
1 parent 3f7ac2a commit 32a84b4

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
 

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

+42
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ - (id)strongObject
101101
return aNumber;
102102
}
103103

104+
/* BEGIN DRAGONS: Note methods here cannot be renamed, and are used by private callers, do not rename, remove or modify behavior here */
105+
106+
@interface NSObject (MatterPrivateForInternalDragonsDoNotFeed)
107+
- (void)_deviceInternalStateChanged:(MTRDevice *)device;
108+
@end
109+
110+
/* END DRAGONS */
111+
104112
#pragma mark - SubscriptionCallback class declaration
105113
using namespace chip;
106114
using namespace chip::app;
@@ -949,6 +957,15 @@ - (void)_changeInternalState:(MTRInternalDeviceState)state
949957
_internalDeviceState = state;
950958
if (lastState != state) {
951959
MTR_LOG("%@ internal state change %lu => %lu", self, static_cast<unsigned long>(lastState), static_cast<unsigned long>(state));
960+
961+
/* BEGIN DRAGONS: This is a huge hack for a specific use case, do not rename, remove or modify behavior here */
962+
id<MTRDeviceDelegate> delegate = _weakDelegate.strongObject;
963+
if ([delegate respondsToSelector:@selector(_deviceInternalStateChanged:)]) {
964+
dispatch_async(_delegateQueue, ^{
965+
[(id) delegate _deviceInternalStateChanged:self];
966+
});
967+
}
968+
/* END DRAGONS */
952969
}
953970
}
954971

@@ -3506,6 +3523,31 @@ - (void)removeClientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID
35063523

35073524
@end
35083525

3526+
/* BEGIN DRAGONS: Note methods here cannot be renamed, and are used by private callers, do not rename, remove or modify behavior here */
3527+
3528+
@implementation MTRDevice (MatterPrivateForInternalDragonsDoNotFeed)
3529+
3530+
- (BOOL)_deviceHasActiveSubscription
3531+
{
3532+
std::lock_guard lock(_lock);
3533+
3534+
return HaveSubscriptionEstablishedRightNow(_internalDeviceState);
3535+
}
3536+
3537+
- (void)_deviceMayBeReachable
3538+
{
3539+
assertChipStackLockedByCurrentThread();
3540+
3541+
MTR_LOG("%@ _deviceMayBeReachable called", self);
3542+
3543+
[self _triggerResubscribeWithReason:"SPI client indicated the device may now be reachable"
3544+
nodeLikelyReachable:YES];
3545+
}
3546+
3547+
/* END DRAGONS */
3548+
3549+
@end
3550+
35093551
@implementation MTRDevice (Deprecated)
35103552

35113553
+ (MTRDevice *)deviceWithNodeID:(uint64_t)nodeID deviceController:(MTRDeviceController *)deviceController

0 commit comments

Comments
 (0)