Package 

Class NetworkStateObserverImpl

  • All Implemented Interfaces:
    com.appsflyer.internal.network.NetworkStateObserver

    
    public final class NetworkStateObserverImpl
     implements NetworkStateObserver
                        

    Observes device connectivity and notifies registered listeners on online/offline transitions.

    Platform-specific observation is encapsulated behind ConnectivityStrategy (Strategy pattern). A concrete strategy is chosen once in createStrategy based on the device API level:

    • isOnline reads a @Volatile field — safe from any thread without locking.

    • handleConnectivityChange is @Synchronized to serialize state transitions, preventing interleaved or out-of-order listener notifications from concurrent callbacks.

    • CopyOnWriteArrayList for listeners — optimized for frequent iteration with rare mutation.

    start → creates and activates the strategy → stop tears it down. Both are idempotent, guarded by an AtomicBoolean.