Skip to content

Commit

Permalink
start all services separately and remove unsued startupService reference
Browse files Browse the repository at this point in the history
  • Loading branch information
jinliu9508 committed Jun 20, 2024
1 parent e3c6532 commit e7353a2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,14 @@ class ServiceProvider(
}
}

// schedule to start all startable services separate threads
fun scheduleStartServices() {
synchronized(serviceMap) {
val provider = this
for (serviceReg in serviceMap!![IStartableService::class.java]!!) {
// we can directly start services that were previously resolved
if (serviceReg.isResolved()) {
val service = serviceReg.resolve(this) as IStartableService
coroutineScope.launch {
val service = serviceReg.resolve(provider) as IStartableService
service.start()
} else {
val provider = this
// resolve and schedule to start the startable services that were not used during
// the initialization process
coroutineScope.launch {
val service = serviceReg.resolve(provider) as IStartableService
service.start()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ abstract class ServiceRegistration<T> {
}

abstract fun resolve(provider: IServiceProvider): Any?

abstract fun isResolved(): Boolean
}

/**
Expand Down Expand Up @@ -95,10 +93,6 @@ class ServiceRegistrationReflection<T>(
return obj
}

override fun isResolved(): Boolean {
return obj != null
}

private fun doesHaveAllParameters(
constructor: Constructor<*>,
provider: IServiceProvider,
Expand Down Expand Up @@ -147,10 +141,6 @@ class ServiceRegistrationSingleton<T>(
private var obj: T,
) : ServiceRegistration<T>() {
override fun resolve(provider: IServiceProvider): Any? = obj

override fun isResolved(): Boolean {
return obj != null
}
}

/**
Expand All @@ -174,8 +164,4 @@ class ServiceRegistrationLambda<T>(

return obj
}

override fun isResolved(): Boolean {
return obj != null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import com.onesignal.core.internal.preferences.impl.PreferencesService
import com.onesignal.core.internal.purchases.impl.TrackAmazonPurchase
import com.onesignal.core.internal.purchases.impl.TrackGooglePurchase
import com.onesignal.core.internal.startup.IStartableService
import com.onesignal.core.internal.startup.StartupService
import com.onesignal.core.internal.time.ITime
import com.onesignal.core.internal.time.impl.Time
import com.onesignal.inAppMessages.IInAppMessagesManager
Expand All @@ -54,7 +53,6 @@ internal class CoreModule : IModule {
builder.register<DeviceService>().provides<IDeviceService>()
builder.register<Time>().provides<ITime>()
builder.register<DatabaseProvider>().provides<IDatabaseProvider>()
builder.register<StartupService>().provides<StartupService>()
builder.register<InstallIdService>().provides<IInstallIdService>()

// Params (Config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import com.onesignal.core.internal.preferences.PreferenceOneSignalKeys
import com.onesignal.core.internal.preferences.PreferenceStoreFix
import com.onesignal.core.internal.preferences.PreferenceStores
import com.onesignal.core.internal.startup.IBootstrapService
import com.onesignal.core.internal.startup.StartupService
import com.onesignal.debug.IDebugManager
import com.onesignal.debug.LogLevel
import com.onesignal.debug.internal.DebugManager
Expand Down Expand Up @@ -138,8 +137,6 @@ internal class OneSignalImp : IOneSignal, IServiceProvider {
get() = services.getService()
private var subscriptionModelStore: SubscriptionModelStore? = null
get() = services.getService()
private var startupService: StartupService? = null
get() = services.getService()
private var preferencesService: IPreferencesService? = null
get() = services.getService()

Expand Down

0 comments on commit e7353a2

Please sign in to comment.