Skip to content

Commit 6927fab

Browse files
Move some APIs that are only used on MTRDeviceController_Concrete to that interface.
Now that MTRDeviceControllerFactory only works with MTRDeviceController_Concrete, we can move some APIs from MTRDeviceController_Internal to MTRDeviceController_Concrete.
1 parent 8750c55 commit 6927fab

File tree

3 files changed

+25
-69
lines changed

3 files changed

+25
-69
lines changed

src/darwin/Framework/CHIP/MTRDeviceController.mm

-44
Original file line numberDiff line numberDiff line change
@@ -320,20 +320,6 @@ - (void)_controllerResumed
320320
// Subclass hook; nothing to do.
321321
}
322322

323-
- (BOOL)matchesPendingShutdownControllerWithOperationalCertificate:(nullable MTRCertificateDERBytes)operationalCertificate andRootCertificate:(nullable MTRCertificateDERBytes)rootCertificate
324-
{
325-
// TODO: Once the factory knows it's dealing with MTRDeviceController_Concrete, this can be removed, and its
326-
// declaration moved to MTRDeviceController_Concrete.
327-
return NO;
328-
}
329-
330-
- (void)clearPendingShutdown
331-
{
332-
// TODO: Once the factory knows it's dealing with MTRDeviceController_Concrete, this can be removed, and its
333-
// declaration moved to MTRDeviceController_Concrete.
334-
MTR_ABSTRACT_METHOD();
335-
}
336-
337323
- (void)shutdown
338324
{
339325
MTR_ABSTRACT_METHOD();
@@ -1085,36 +1071,6 @@ - (nullable NSNumber *)compressedFabricID
10851071
return storedValue.has_value() ? @(storedValue.value()) : nil;
10861072
}
10871073

1088-
- (CHIP_ERROR)isRunningOnFabric:(chip::FabricTable *)fabricTable
1089-
fabricIndex:(chip::FabricIndex)fabricIndex
1090-
isRunning:(BOOL *)isRunning
1091-
{
1092-
assertChipStackLockedByCurrentThread();
1093-
1094-
if (![self isRunning]) {
1095-
*isRunning = NO;
1096-
return CHIP_NO_ERROR;
1097-
}
1098-
1099-
const chip::FabricInfo * otherFabric = fabricTable->FindFabricWithIndex(fabricIndex);
1100-
if (!otherFabric) {
1101-
// Should not happen...
1102-
return CHIP_ERROR_INCORRECT_STATE;
1103-
}
1104-
1105-
if (_cppCommissioner->GetFabricId() != otherFabric->GetFabricId()) {
1106-
*isRunning = NO;
1107-
return CHIP_NO_ERROR;
1108-
}
1109-
1110-
chip::Crypto::P256PublicKey ourRootPublicKey, otherRootPublicKey;
1111-
ReturnErrorOnFailure(_cppCommissioner->GetRootPublicKey(ourRootPublicKey));
1112-
ReturnErrorOnFailure(fabricTable->FetchRootPubkey(otherFabric->GetFabricIndex(), otherRootPublicKey));
1113-
1114-
*isRunning = (ourRootPublicKey.Matches(otherRootPublicKey));
1115-
return CHIP_NO_ERROR;
1116-
}
1117-
11181074
- (void)invalidateCASESessionForNode:(chip::NodeId)nodeID;
11191075
{
11201076
auto block = ^{

src/darwin/Framework/CHIP/MTRDeviceController_Concrete.h

+25
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,21 @@ NS_ASSUME_NONNULL_BEGIN
7070
*/
7171
- (void)deinitFromFactory;
7272

73+
/**
74+
* Check whether this controller is running on the given fabric, as represented
75+
* by the provided FabricTable and fabric index. The provided fabric table may
76+
* not be the same as the fabric table this controller is using. This method
77+
* MUST be called from the Matter work queue.
78+
*
79+
* Might return failure, in which case we don't know whether it's running on the
80+
* given fabric. Otherwise it will set *isRunning to the right boolean value.
81+
*
82+
* Only MTRDeviceControllerFactory should be calling this.
83+
*/
84+
- (CHIP_ERROR)isRunningOnFabric:(chip::FabricTable *)fabricTable
85+
fabricIndex:(chip::FabricIndex)fabricIndex
86+
isRunning:(BOOL *)isRunning;
87+
7388
/**
7489
* Takes an assertion to keep the controller running. If `-[MTRDeviceController shutdown]` is called while an assertion
7590
* is held, the shutdown will be honored only after all assertions are released. Invoking this method multiple times increases
@@ -84,6 +99,16 @@ NS_ASSUME_NONNULL_BEGIN
8499
*/
85100
- (void)removeRunAssertion;
86101

102+
/**
103+
* This method returns TRUE if this controller matches the fabric reference and node ID as listed in the parameters.
104+
*/
105+
- (BOOL)matchesPendingShutdownControllerWithOperationalCertificate:(nullable MTRCertificateDERBytes)operationalCertificate andRootCertificate:(nullable MTRCertificateDERBytes)rootCertificate;
106+
107+
/**
108+
* Clear any pending shutdown request.
109+
*/
110+
- (void)clearPendingShutdown;
111+
87112
@end
88113

89114
NS_ASSUME_NONNULL_END

src/darwin/Framework/CHIP/MTRDeviceController_Internal.h

-25
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,6 @@ NS_ASSUME_NONNULL_BEGIN
121121
*/
122122
@property (nonatomic, retain, nullable) NSData * rootPublicKey;
123123

124-
/**
125-
* Check whether this controller is running on the given fabric, as represented
126-
* by the provided FabricTable and fabric index. The provided fabric table may
127-
* not be the same as the fabric table this controller is using. This method
128-
* MUST be called from the Matter work queue.
129-
*
130-
* Might return failure, in which case we don't know whether it's running on the
131-
* given fabric. Otherwise it will set *isRunning to the right boolean value.
132-
*
133-
* Only MTRDeviceControllerFactory should be calling this.
134-
*/
135-
- (CHIP_ERROR)isRunningOnFabric:(chip::FabricTable *)fabricTable
136-
fabricIndex:(chip::FabricIndex)fabricIndex
137-
isRunning:(BOOL *)isRunning;
138-
139124
/**
140125
* Ensure we have a CASE session to the given node ID and then call the provided
141126
* connection callback. This may be called on any queue (including the Matter
@@ -265,16 +250,6 @@ NS_ASSUME_NONNULL_BEGIN
265250
*/
266251
- (void)directlyGetSessionForNode:(chip::NodeId)nodeID completion:(MTRInternalDeviceConnectionCallback)completion;
267252

268-
/**
269-
* This method returns TRUE if this controller matches the fabric reference and node ID as listed in the parameters.
270-
*/
271-
- (BOOL)matchesPendingShutdownControllerWithOperationalCertificate:(nullable MTRCertificateDERBytes)operationalCertificate andRootCertificate:(nullable MTRCertificateDERBytes)rootCertificate;
272-
273-
/**
274-
* Clear any pending shutdown request.
275-
*/
276-
- (void)clearPendingShutdown;
277-
278253
@end
279254

280255
/**

0 commit comments

Comments
 (0)