Skip to content

Commit 0b71b04

Browse files
Adding temporary workaround in Darwin for XPC clients not adding delegates (#38159)
* Adding temporary workaround * Restyled by whitespace * Restyled by clang-format --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 79b53e9 commit 0b71b04

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/darwin/Framework/CHIP/MTRDevice_XPC.mm

+7-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ - (NSString *)description
130130
wifi,
131131
thread,
132132
_deviceController.uniqueIdentifier,
133-
(unsigned long) self.state];
133+
(unsigned long) [MTR_SAFE_CAST(self._internalState[kMTRDeviceInternalPropertyDeviceState], NSNumber) unsignedLongValue]];
134134
}
135135

136136
- (nullable NSNumber *)vendorID
@@ -372,8 +372,14 @@ - (void)_updateInternalState:(NSMutableDictionary *)newState
372372

373373
- (MTRDeviceState)state
374374
{
375+
// TEMPORARY WORKAROUND for UNTIL WE HAVE the addDelegate flow fixed
376+
if (![self delegateExists]) {
377+
return MTRDeviceStateReachable;
378+
}
379+
375380
NSNumber * stateNumber = MTR_SAFE_CAST(self._internalState[kMTRDeviceInternalPropertyDeviceState], NSNumber);
376381
switch (static_cast<MTRDeviceState>(stateNumber.unsignedIntegerValue)) {
382+
default:
377383
case MTRDeviceStateUnknown:
378384
return MTRDeviceStateUnknown;
379385

0 commit comments

Comments
 (0)