From a6f44fd715a5084d6832b7d922914552c417a2e6 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 26 Sep 2024 19:16:30 -0400 Subject: [PATCH] Get rid of MTRBaseDevice use in MTRDevice. (#35797) There is no MTRBaseDevice allowed unless our MTRDevice is actually MTRDevice_Concrete. --- src/darwin/Framework/CHIP/MTRDevice.mm | 30 +++++++++------------- src/darwin/Framework/CHIP/MTRDevice_XPC.mm | 1 + 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm index 552c99c7e873b4..812c389e311115 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -1141,12 +1141,10 @@ - (void)openCommissioningWindowWithSetupPasscode:(NSNumber *)setupPasscode queue:(dispatch_queue_t)queue completion:(MTRDeviceOpenCommissioningWindowHandler)completion { - auto * baseDevice = [self newBaseDevice]; - [baseDevice openCommissioningWindowWithSetupPasscode:setupPasscode - discriminator:discriminator - duration:duration - queue:queue - completion:completion]; + MTR_ABSTRACT_METHOD(); + dispatch_async(queue, ^{ + completion(nil, [MTRError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE]); + }); } - (void)openCommissioningWindowWithDiscriminator:(NSNumber *)discriminator @@ -1154,8 +1152,10 @@ - (void)openCommissioningWindowWithDiscriminator:(NSNumber *)discriminator queue:(dispatch_queue_t)queue completion:(MTRDeviceOpenCommissioningWindowHandler)completion { - auto * baseDevice = [self newBaseDevice]; - [baseDevice openCommissioningWindowWithDiscriminator:discriminator duration:duration queue:queue completion:completion]; + MTR_ABSTRACT_METHOD(); + dispatch_async(queue, ^{ + completion(nil, [MTRError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE]); + }); } - (void)downloadLogOfType:(MTRDiagnosticLogType)type @@ -1163,11 +1163,10 @@ - (void)downloadLogOfType:(MTRDiagnosticLogType)type queue:(dispatch_queue_t)queue completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion { - auto * baseDevice = [self newBaseDevice]; - [baseDevice downloadLogOfType:type - timeout:timeout - queue:queue - completion:completion]; + MTR_ABSTRACT_METHOD(); + dispatch_async(queue, ^{ + completion(nil, [MTRError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE]); + }); } #pragma mark - Cache management @@ -1286,11 +1285,6 @@ - (BOOL)deviceCachePrimed return _deviceCachePrimed; } -- (MTRBaseDevice *)newBaseDevice -{ - return [MTRBaseDevice deviceWithNodeID:self.nodeID controller:self.deviceController]; -} - #pragma mark Log Help - (nullable NSNumber *)_informationalNumberAtAttributePath:(MTRAttributePath *)attributePath diff --git a/src/darwin/Framework/CHIP/MTRDevice_XPC.mm b/src/darwin/Framework/CHIP/MTRDevice_XPC.mm index 015736e179c2c4..7806546768b4f2 100644 --- a/src/darwin/Framework/CHIP/MTRDevice_XPC.mm +++ b/src/darwin/Framework/CHIP/MTRDevice_XPC.mm @@ -266,6 +266,7 @@ - (void)_invokeCommandWithEndpointID:(NSNumber *)endpointID // Not Supported via XPC //- (oneway void)deviceController:(NSUUID *)controller nodeID:(NSNumber *)nodeID openCommissioningWindowWithSetupPasscode:(NSNumber *)setupPasscode discriminator:(NSNumber *)discriminator duration:(NSNumber *)duration completion:(MTRDeviceOpenCommissioningWindowHandler)completion; +//- (oneway void)deviceController:(NSUUID *)controller nodeID:(NSNumber *)nodeID openCommissioningWindowWithDiscriminator:(NSNumber *)discriminator duration:(NSNumber *)duration completion:(MTRDeviceOpenCommissioningWindowHandler)completion; // Not Supported via XPC // - (oneway void)downloadLogOfType:(MTRDiagnosticLogType)type nodeID:(NSNumber *)nodeID timeout:(NSTimeInterval)timeout completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion;