Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building some internal hooks for automation #33581

Merged
merged 8 commits into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ - (id)strongObject
return aNumber;
}

/* 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;
@end

/* END DRAGONS */

#pragma mark - SubscriptionCallback class declaration
using namespace chip;
using namespace chip::app;
Expand Down Expand Up @@ -936,6 +944,15 @@ - (void)_changeInternalState:(MTRInternalDeviceState)state
_internalDeviceState = state;
if (lastState != state) {
MTR_LOG("%@ internal state change %lu => %lu", self, static_cast<unsigned long>(lastState), static_cast<unsigned long>(state));

/* BEGIN DRAGONS: This is a huge hack for a specific use case, do not rename, remove or modify behavior here */
id<MTRDeviceDelegate> delegate = _weakDelegate.strongObject;
if ([delegate respondsToSelector:@selector(_deviceInternalStateChanged:)]) {
dispatch_async(_delegateQueue, ^{
[(id) delegate _deviceInternalStateChanged:self];
});
}
/* END DRAGONS */
woody-apple marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -3268,6 +3285,31 @@ - (void)removeClientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID

@end

/* 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)

- (BOOL)_deviceHasActiveSubscription
{
std::lock_guard lock(_lock);

return HaveSubscriptionEstablishedRightNow(_internalDeviceState);
}

- (void)_deviceMayBeReachable
{
assertChipStackLockedByCurrentThread();

MTR_LOG("%@ _deviceMayBeReachable called", self);

[self _triggerResubscribeWithReason:"SPI client indicated the device may now be reachable"
nodeLikelyReachable:YES];
}

/* END DRAGONS */

@end

@implementation MTRDevice (Deprecated)

+ (MTRDevice *)deviceWithNodeID:(uint64_t)nodeID deviceController:(MTRDeviceController *)deviceController
Expand Down
Loading