-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avoid deadlock during AppMetricaService#onDestroy
- Loading branch information
1 parent
45d08e8
commit efe93d3
Showing
9 changed files
with
325 additions
and
461 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
176 changes: 0 additions & 176 deletions
176
...tics/src/main/java/io/appmetrica/analytics/impl/component/RegularDispatcherComponent.java
This file was deleted.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
analytics/src/main/java/io/appmetrica/analytics/impl/component/RegularDispatcherComponent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package io.appmetrica.analytics.impl.component | ||
|
||
import android.content.Context | ||
import androidx.annotation.VisibleForTesting | ||
import io.appmetrica.analytics.coreutils.internal.logger.YLogger | ||
import io.appmetrica.analytics.impl.CounterReport | ||
import io.appmetrica.analytics.impl.EventsManager | ||
import io.appmetrica.analytics.impl.component.CommonArguments.ReporterArguments | ||
import io.appmetrica.analytics.impl.component.clients.ClientUnit | ||
import io.appmetrica.analytics.impl.component.clients.ComponentUnitFactory | ||
import io.appmetrica.analytics.impl.startup.StartupCenter | ||
import io.appmetrica.analytics.impl.startup.StartupError | ||
import io.appmetrica.analytics.impl.startup.StartupListener | ||
import io.appmetrica.analytics.impl.startup.StartupState | ||
import io.appmetrica.analytics.impl.startup.StartupUnit | ||
|
||
internal class RegularDispatcherComponent<COMPONENT>( | ||
@get:VisibleForTesting val context: Context, | ||
@get:VisibleForTesting val componentId: ComponentId, | ||
sdkConfig: CommonArguments, | ||
componentUnitFactory: ComponentUnitFactory<COMPONENT>, | ||
private val lifecycleManager: ComponentLifecycleManager<ClientUnit?>, | ||
startupCenter: StartupCenter | ||
) : IClientConsumer<ClientUnit?>, | ||
StartupListener, | ||
IDispatcherComponent where COMPONENT : IReportableComponent, COMPONENT : IComponent { | ||
|
||
constructor( | ||
context: Context, | ||
componentId: ComponentId, | ||
sdkConfig: CommonArguments, | ||
componentUnitFactory: ComponentUnitFactory<COMPONENT> | ||
) : this( | ||
context, | ||
componentId, | ||
sdkConfig, | ||
componentUnitFactory, | ||
ComponentLifecycleManager<ClientUnit?>(), | ||
StartupCenter.getInstance() | ||
) | ||
|
||
private val tag = "[RegularDispatcherComponent]" | ||
|
||
private val startupUnit: StartupUnit = | ||
startupCenter.getOrCreateStartupUnit(context, componentId, sdkConfig.startupArguments) | ||
|
||
private val reportingComponent: COMPONENT = componentUnitFactory.createComponentUnit( | ||
context, | ||
componentId, | ||
sdkConfig.componentArguments, | ||
startupUnit | ||
) | ||
|
||
init { | ||
startupCenter.registerStartupListener(componentId, this) | ||
} | ||
|
||
fun handleReport(counterReport: CounterReport, configuration: CommonArguments) { | ||
YLogger.d("%s handle report for componentId: %s; data: %s", tag, componentId, counterReport) | ||
|
||
if (!EventsManager.isEventWithoutAppConfigUpdate(counterReport.type)) { | ||
updateComponentConfig(configuration.componentArguments) | ||
} | ||
|
||
reportingComponent.handleReport(counterReport) | ||
} | ||
|
||
private fun updateComponentConfig(sdkConfig: ReporterArguments) { | ||
YLogger.d("%sUpdate sdk config for componentId: %s; config: %s", tag, componentId, sdkConfig) | ||
reportingComponent.updateSdkConfig(sdkConfig) | ||
} | ||
|
||
override fun connectClient(client: ClientUnit) { | ||
lifecycleManager.connectClient(client) | ||
} | ||
|
||
override fun disconnectClient(client: ClientUnit) { | ||
lifecycleManager.disconnectClient(client) | ||
} | ||
|
||
override fun onStartupChanged(newState: StartupState) { | ||
reportingComponent.onStartupChanged(newState) | ||
} | ||
|
||
override fun onStartupError(error: StartupError, existingState: StartupState?) { | ||
reportingComponent.onStartupError(error, existingState) | ||
} | ||
|
||
override fun updateConfig(arguments: CommonArguments) { | ||
startupUnit.updateConfiguration(arguments.startupArguments) | ||
updateComponentConfig(arguments.componentArguments) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.