Skip to content

Commit

Permalink
Remove subscription establishment bits from the MTRDevice base class. (
Browse files Browse the repository at this point in the history
…#35139)

_setupSubscriptionWithReason was only called from
_reattemptSubscriptionNowIfNeededWithReason.

_reattemptSubscriptionNowIfNeededWithReason was only called from:

* _handleUnsolicitedMessageFromPublisher, which is only called in callbacks set
   up by _setupSubscriptionWithReason.
* _triggerResubscribeWithReason, which only calls it when
   _reattemptingSubscription is YES.  But that's only set to YES in
   _doHandleSubscriptionReset, see next item.
* _doHandleSubscriptionReset, called from:
   * _handleSubscriptionReset: only called from callbacks set up by
     _setupSubscriptionWithReason.
   * _resetSubscriptionWithReasonString: called from unitTestResetSubscription
     and us detecting persisted data corruption in _clusterDataForPath.  But we
     don't actually have persisted data in the MTRDevice base class anymore, so
     that's not reachable.

So _setupSubscriptionWithReason is not reachable and can be removed.  And
unitTestResetSubscription can be made a no-op on the base MTRDevice.  And we can
remove the _resetSubscriptionWithReasonString call in _clusterDataForPath.

Once those are done, the following become unreachable:

* _handleSubscriptionReset
* _handleSubscriptionError
* Writing a nonzero value to _unitTestAttributesReportedSinceLastCheck
* _markDeviceAsUnreachableIfNeverSubscribed
* _handleResubscriptionNeededWithDelay
* _handleSubscriptionEstablished
* _handleUnsolicitedMessageFromPublisher
* _createDataVersionFilterListFromDictionary
* _setupConnectivityMonitoring
* _resetSubscriptionWithReasonString

Once those have been removed, the following become unreachable:

* HadSubscriptionEstablishedOnce
* _stopConnectivityMonitoring
* _doHandleSubscriptionError
* _doHandleSubscriptionReset

Once those have been removed, the following become unreachable:

* _setLastSubscriptionAttemptWait
* Setting _lastSubscriptionFailureTime to non-nil
* _clearSubscriptionPoolWork
* _scheduleSubscriptionPoolWork
* Use of _initialSubscribeStart
* _storePersistedDeviceData
* Use of _connectivityMonitor
* Use of _lastSubscriptionFailureTimeForDescription
* Any code depending on reattemptingSubscription being YES.
* Use of _lastSubscriptionAttemptWait
* Use of _lastSubscriptionAttemptWaitForDescription

Once those have been removed, _reattemptSubscriptionNowIfNeededWithReason is
unreachable and can be removed.

At this point _currentReadClient and _currentSubscriptionCallback are always
nil, so all code conditioned on those can be removed.  Once that's done,
_triggerResubscribeWithReason is a no-op, so it and all calls to it can be
removed.

Since _lastSubscriptionFailureTime is always nil, all code guarded on it not
being nil can be removed, so _readThroughSkipped becomes a no-op and
_lastSubscriptionFailureTime can be removed.

At this point, the following are not reachable:

* NeedToStartSubscriptionSetup
* _changeInternalState

Once those are removed, _internalDeviceStateForDescription is unused, and
_internalDeviceState is always MTRInternalDeviceStateUnsubscribed.  So
HaveSubscriptionEstablishedRightNow() always returns NO and can be removed.

At this point SubscriptionCallback is unused and can also be removed.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Nov 7, 2024
1 parent 490a42a commit 3861885
Showing 1 changed file with 4 additions and 1,040 deletions.
Loading

0 comments on commit 3861885

Please sign in to comment.