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

Moving more stuff out of the MTRDevice #36090

Closed
Closed
Show file tree
Hide file tree
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
30 changes: 1 addition & 29 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -541,35 +541,7 @@ - (BOOL)deviceUsesThread
// method will need to be updated to reflect that.
- (BOOL)_deviceUsesThread
{
os_unfair_lock_assert_owner(&self->_lock);

#ifdef DEBUG
// Note: This is a hack to allow our unit tests to test the subscription pooling behavior we have implemented for thread, so we mock devices to be a thread device
__block BOOL pretendThreadEnabled = NO;
[self _callFirstDelegateSynchronouslyWithBlock:^(id testDelegate) {
if ([testDelegate respondsToSelector:@selector(unitTestPretendThreadEnabled:)]) {
pretendThreadEnabled = [testDelegate unitTestPretendThreadEnabled:self];
}
}];
if (pretendThreadEnabled) {
return YES;
}
#endif

MTRClusterPath * networkCommissioningClusterPath = [MTRClusterPath clusterPathWithEndpointID:@(kRootEndpointId) clusterID:@(MTRClusterIDTypeNetworkCommissioningID)];
MTRDeviceClusterData * networkCommissioningClusterData = [self _clusterDataForPath:networkCommissioningClusterPath];
NSNumber * networkCommissioningClusterFeatureMapValueNumber = networkCommissioningClusterData.attributes[@(MTRClusterGlobalAttributeFeatureMapID)][MTRValueKey];

if (networkCommissioningClusterFeatureMapValueNumber == nil)
return NO;
if (![networkCommissioningClusterFeatureMapValueNumber isKindOfClass:[NSNumber class]]) {
MTR_LOG_ERROR("%@ Unexpected NetworkCommissioning FeatureMap value %@", self, networkCommissioningClusterFeatureMapValueNumber);
return NO;
}

uint32_t networkCommissioningClusterFeatureMapValue = static_cast<uint32_t>(networkCommissioningClusterFeatureMapValueNumber.unsignedLongValue);

return (networkCommissioningClusterFeatureMapValue & MTRNetworkCommissioningFeatureThreadNetworkInterface) != 0 ? YES : NO;
return NO;
}

- (NSDictionary<MTRClusterPath *, MTRDeviceClusterData *> *)_clusterDataToPersistSnapshot
Expand Down
5 changes: 0 additions & 5 deletions src/darwin/Framework/CHIP/MTRDevice_Concrete.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1646,11 +1646,6 @@ - (void)_scheduleClusterDataPersistence
}
[_mostRecentReportTimes addObject:[NSDate now]];

{
std::lock_guard lock(_descriptionLock);
_mostRecentReportTimeForDescription = [_mostRecentReportTimes lastObject];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this being removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just copied and pasted the base implementation into concrete, please fix :)

}

// Calculate running average and update multiplier - need at least 2 items to calculate intervals
if (_mostRecentReportTimes.count > 2) {
NSTimeInterval cumulativeIntervals = 0;
Expand Down
37 changes: 37 additions & 0 deletions src/darwin/Framework/CHIP/MTRDevice_XPC.mm
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,41 @@ - (void)downloadLogOfType:(MTRDiagnosticLogType)type
// Not Supported via XPC
// - (oneway void)downloadLogOfType:(MTRDiagnosticLogType)type nodeID:(NSNumber *)nodeID timeout:(NSTimeInterval)timeout completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion;

#pragma mark - Storage Overrides

- (NSDictionary<MTRClusterPath *, MTRDeviceClusterData *> *)_clusterDataToPersistSnapshot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the goal is to not have persistence at all in MTRDevice_XPC, then we should just rip it out of MTRDevice, not do this, I think....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have at it :)

{
return nil;
}

- (BOOL)_dataStoreExists
{
return NO;
}

- (void)_persistClusterData
{
}

- (BOOL)_deviceIsReportingExcessively
{
return NO;
}

- (void)_persistClusterDataAsNeeded
{
}

- (void)_scheduleClusterDataPersistence
{
}

- (void)_resetStorageBehaviorState
{
}

- (void)setStorageBehaviorConfiguration:(MTRDeviceStorageBehaviorConfiguration *)storageBehaviorConfiguration
{
}

@end
Loading