-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce the direct use of the static logger so tests functional tests …
…work properly (#643) ## Goal Removed most of the direct use of the static logger, and instead rely on an instance that gets passed in that will be created in the InitModule. I also removed a lot of useless dev logging. The crux of he change involved using the instance that get passed down via the modules init chain, and in places where it's not convenient, rely on the static logger instead. Both are hooked into the same internal error service instance so internal exceptions are reported. The static logger will be slimmed down then completely removed, but I couldn't get away from having at least one massive change. There was no easy way of teasing these out without risking mistakes, and most of the changes are at least trivial. There are other refactors that I wanted to do and they were done in subsequent PRs. I'll will point to the right places to look but most of the other changes are just removing dev logging, adding the logger to a constructor, and passing it in when creating instances. ## Testing Tests were modified as needed. Relying on existing coverage to ensure functionality worked as before, except for adding a test that verifies the static and instance loggers are both hooked up to the same internal error service.
- Loading branch information
Showing
210 changed files
with
1,128 additions
and
1,502 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
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
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
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 |
---|---|---|
|
@@ -8,7 +8,8 @@ import android.net.Uri | |
import android.os.Handler | ||
import android.os.Looper | ||
import android.widget.Toast | ||
import io.embrace.android.embracesdk.logging.InternalStaticEmbraceLogger.Companion.logger | ||
import io.embrace.android.embracesdk.logging.InternalEmbraceLogger | ||
import io.embrace.android.embracesdk.logging.InternalStaticEmbraceLogger | ||
import io.embrace.android.embracesdk.samples.AutomaticVerificationChecker | ||
import io.embrace.android.embracesdk.samples.VerificationActions | ||
import io.embrace.android.embracesdk.samples.VerifyIntegrationException | ||
|
@@ -33,7 +34,8 @@ import kotlin.system.exitProcess | |
* | ||
*/ | ||
internal class EmbraceAutomaticVerification( | ||
private val scheduledExecutorService: ScheduledExecutorService = Executors.newSingleThreadScheduledExecutor() | ||
private val scheduledExecutorService: ScheduledExecutorService = Executors.newSingleThreadScheduledExecutor(), | ||
private val logger: InternalEmbraceLogger | ||
) : ActivityLifecycleListener, ProcessStateListener { | ||
private val handler = Handler(Looper.getMainLooper()) | ||
|
||
|
@@ -43,9 +45,9 @@ internal class EmbraceAutomaticVerification( | |
|
||
internal lateinit var processStateService: ProcessStateService | ||
|
||
var automaticVerificationChecker = AutomaticVerificationChecker() | ||
var automaticVerificationChecker = AutomaticVerificationChecker(logger) | ||
|
||
var verificationActions = VerificationActions(Embrace.getInstance(), automaticVerificationChecker) | ||
var verificationActions = VerificationActions(Embrace.getInstance(), logger, automaticVerificationChecker) | ||
|
||
/** | ||
* This flag track if the verification result popup was displayed or not, | ||
|
@@ -59,7 +61,7 @@ internal class EmbraceAutomaticVerification( | |
private const val EMBRACE_CONTACT_EMAIL = "[email protected]" | ||
private const val VERIFY_INTEGRATION_DELAY = 200L | ||
private const val ON_FOREGROUND_TIMEOUT = 5000L | ||
internal val instance = EmbraceAutomaticVerification() | ||
internal val instance = EmbraceAutomaticVerification(logger = InternalStaticEmbraceLogger.logger) | ||
} | ||
|
||
fun verifyIntegration() { | ||
|
@@ -154,10 +156,6 @@ internal class EmbraceAutomaticVerification( | |
try { | ||
appInitializerClass = Class.forName("androidx.startup.AppInitializer") | ||
} catch (cnfe: ClassNotFoundException) { | ||
logger.logDeveloper( | ||
"EmbraceAutomaticVerification", | ||
"AppInitializer not found. Assuming that appCompat < 1.4.1" | ||
) | ||
return false | ||
} | ||
|
||
|
@@ -172,10 +170,6 @@ internal class EmbraceAutomaticVerification( | |
val result = isEagerlyInitialized.invoke(appInitializer, lifecycleInitializerClass) as Boolean | ||
return result.not() | ||
} ?: run { | ||
logger.logDeveloper( | ||
"EmbraceAutomaticVerification", | ||
"Null application object, can not verify lifecycle annotations" | ||
) | ||
return false | ||
} | ||
} catch (e: Exception) { | ||
|
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
Oops, something went wrong.