Skip to content

Commit

Permalink
Merge pull request #947 from embrace-io/remove-orientation-service
Browse files Browse the repository at this point in the history
Remove unused orientation service
  • Loading branch information
fractalwrench authored Jun 12, 2024
2 parents 73412ca + 68c1852 commit 61a5f09
Show file tree
Hide file tree
Showing 13 changed files with 1 addition and 204 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ internal enum class InternalErrorType {
BG_SESSION_CACHE_FAIL,
FG_SESSION_CACHE_FAIL,
ACTIVITY_LISTENER_FAIL,
ORIENTATION_CAPTURE_FAIL,
PROCESS_STATE_CALLBACK_FAIL,
TIME_TRAVEL,
ANR_HEARTBEAT_CHECK_FAIL,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import io.embrace.android.embracesdk.capture.metadata.AppEnvironment
import io.embrace.android.embracesdk.capture.metadata.EmbraceMetadataService
import io.embrace.android.embracesdk.capture.metadata.HostedSdkVersionInfo
import io.embrace.android.embracesdk.capture.metadata.MetadataService
import io.embrace.android.embracesdk.capture.orientation.NoOpOrientationService
import io.embrace.android.embracesdk.capture.orientation.OrientationService
import io.embrace.android.embracesdk.capture.user.EmbraceUserService
import io.embrace.android.embracesdk.capture.user.UserService
import io.embrace.android.embracesdk.comms.api.ApiClient
Expand Down Expand Up @@ -53,7 +51,6 @@ import io.embrace.android.embracesdk.worker.WorkerThreadModule
*/
internal interface EssentialServiceModule {
val memoryCleanerService: MemoryCleanerService
val orientationService: OrientationService
val processStateService: ProcessStateService
val activityLifecycleTracker: ActivityTracker
val metadataService: MetadataService
Expand Down Expand Up @@ -145,19 +142,14 @@ internal class EssentialServiceModuleImpl(
EmbraceMemoryCleanerService(logger = initModule.logger)
}

override val orientationService: OrientationService by singleton {
// Embrace is not processing orientation changes on this moment, so return no-op service.
NoOpOrientationService()
}

override val processStateService: ProcessStateService by singleton {
Systrace.traceSynchronous("process-state-service-init") {
EmbraceProcessStateService(initModule.clock, initModule.logger)
}
}

override val activityLifecycleTracker: ActivityLifecycleTracker by singleton {
ActivityLifecycleTracker(coreModule.application, orientationService, initModule.logger)
ActivityLifecycleTracker(coreModule.application, initModule.logger)
}

override val configService: ConfigService by singleton {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.app.Application
import android.os.Bundle
import io.embrace.android.embracesdk.annotation.StartupActivity
import io.embrace.android.embracesdk.capture.internal.errors.InternalErrorType
import io.embrace.android.embracesdk.capture.orientation.OrientationService
import io.embrace.android.embracesdk.logging.EmbLogger
import io.embrace.android.embracesdk.utils.stream
import java.lang.ref.WeakReference
Expand All @@ -16,7 +15,6 @@ import java.util.concurrent.CopyOnWriteArrayList
*/
internal class ActivityLifecycleTracker(
private val application: Application,
private val orientationService: OrientationService,
private val logger: EmbLogger
) : ActivityTracker {

Expand Down Expand Up @@ -59,23 +57,8 @@ internal class ActivityLifecycleTracker(
return foregroundActivity
}

/**
* This method will update the current activity orientation.
*
* @param activity the activity involved in the tracking orientation process.
*/
private fun updateOrientationWithActivity(activity: Activity) {
try {
orientationService.onOrientationChanged(activity.resources.configuration.orientation)
} catch (ex: Exception) {
logger.logWarning("Failed to register an orientation change")
logger.trackInternalError(InternalErrorType.ORIENTATION_CAPTURE_FAIL, ex)
}
}

override fun onActivityCreated(activity: Activity, bundle: Bundle?) {
updateStateWithActivity(activity)
updateOrientationWithActivity(activity)
stream(listeners) { listener: ActivityLifecycleListener ->
try {
listener.onActivityCreated(activity, bundle)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import io.embrace.android.embracesdk.arch.destination.LogWriterImpl
import io.embrace.android.embracesdk.capture.connectivity.EmbraceNetworkConnectivityService
import io.embrace.android.embracesdk.capture.cpu.EmbraceCpuInfoDelegate
import io.embrace.android.embracesdk.capture.metadata.EmbraceMetadataService
import io.embrace.android.embracesdk.capture.orientation.NoOpOrientationService
import io.embrace.android.embracesdk.capture.user.EmbraceUserService
import io.embrace.android.embracesdk.comms.delivery.EmbracePendingApiCallsSender
import io.embrace.android.embracesdk.config.EmbraceConfigService
Expand Down Expand Up @@ -55,7 +54,6 @@ internal class EssentialServiceModuleImplTest {
) { null }

assertTrue(module.memoryCleanerService is EmbraceMemoryCleanerService)
assertTrue(module.orientationService is NoOpOrientationService)
assertTrue(module.processStateService is EmbraceProcessStateService)
assertTrue(module.metadataService is EmbraceMetadataService)
assertNotNull(module.urlBuilder)
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import io.embrace.android.embracesdk.capture.connectivity.NoOpNetworkConnectivit
import io.embrace.android.embracesdk.capture.cpu.CpuInfoDelegate
import io.embrace.android.embracesdk.capture.metadata.HostedSdkVersionInfo
import io.embrace.android.embracesdk.capture.metadata.MetadataService
import io.embrace.android.embracesdk.capture.orientation.NoOpOrientationService
import io.embrace.android.embracesdk.capture.orientation.OrientationService
import io.embrace.android.embracesdk.capture.user.UserService
import io.embrace.android.embracesdk.comms.api.ApiClient
import io.embrace.android.embracesdk.comms.api.ApiService
Expand Down Expand Up @@ -50,7 +48,6 @@ internal class FakeEssentialServiceModule(
override val configService: ConfigService = FakeConfigService(),
override val memoryCleanerService: MemoryCleanerService = FakeMemoryCleanerService(),
override val gatingService: GatingService = FakeGatingService(),
override val orientationService: OrientationService = NoOpOrientationService(),
override val apiClient: ApiClient = FakeApiClient(),
override val userService: UserService = FakeUserService(),
override val sharedObjectLoader: SharedObjectLoader = SharedObjectLoader(EmbLoggerImpl()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.content.res.Resources
import android.os.Bundle
import android.os.Looper
import io.embrace.android.embracesdk.fakes.FakeClock
import io.embrace.android.embracesdk.fakes.FakeOrientationService
import io.embrace.android.embracesdk.fakes.system.mockApplication
import io.embrace.android.embracesdk.fakes.system.mockLooper
import io.embrace.android.embracesdk.logging.EmbLoggerImpl
Expand All @@ -31,7 +30,6 @@ import org.junit.Test
internal class ActivityLifecycleTrackerTest {

private lateinit var activityLifecycleTracker: ActivityLifecycleTracker
private lateinit var orientationService: FakeOrientationService

companion object {
private lateinit var mockLooper: Looper
Expand Down Expand Up @@ -66,10 +64,8 @@ internal class ActivityLifecycleTrackerTest {
staticMocks = false
)

orientationService = FakeOrientationService()
activityLifecycleTracker = ActivityLifecycleTracker(
application,
orientationService,
EmbLoggerImpl()
)
}
Expand Down Expand Up @@ -99,7 +95,6 @@ internal class ActivityLifecycleTrackerTest {
activityLifecycleTracker.onActivityCreated(mockActivity, bundle)

assertEquals(mockActivity, activityLifecycleTracker.foregroundActivity)
assertEquals(orientation, orientationService.changes.single())
verify { mockActivityLifecycleListener.onActivityCreated(mockActivity, bundle) }
}

Expand Down

0 comments on commit 61a5f09

Please sign in to comment.