Skip to content

Commit

Permalink
Building some internal hooks for automation (#33581)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people authored May 24, 2024
1 parent 3f7ac2a commit 32a84b4
Showing 1 changed file with 42 additions and 0 deletions.
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 @@ -949,6 +957,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 */
}
}

Expand Down Expand Up @@ -3506,6 +3523,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

0 comments on commit 32a84b4

Please sign in to comment.