Loading lib/src/main/java/foundation/e/lib/telemetry/Telemetry.kt +20 −4 Original line number Diff line number Diff line Loading @@ -11,6 +11,8 @@ object Telemetry { private var identifier: String = "" private lateinit var application: Application private var isTelemetryEnabled: Boolean = false /** * Call this function in `onCreate()` of custom Application class. * Telemetry will be enabled only if enabled from developer options. Loading @@ -22,7 +24,8 @@ object Telemetry { ) { this.identifier = identifier this.application = application if (isTelemetryEnabled()) { this.isTelemetryEnabled = checkTelemetryDeveloperOption() if (isTelemetryEnabled) { SentryAndroid.init(application) { options -> options.dsn = identifier } Loading @@ -45,8 +48,8 @@ object Telemetry { } @Deprecated( "Use isTelemetryEnabled() without parameters.", ReplaceWith("isTelemetryEnabled()"), "Use isReportingTelemetry()", ReplaceWith("isReportingTelemetry()"), ) fun isTelemetryEnabled(application: Application): Boolean { return try { Loading @@ -58,11 +61,24 @@ object Telemetry { } } /** * It is possible that the telemetry option in developer options is different from * the current state of the library. It is possible if the app is open and * e_telemetry system setting is (say) disabled via ADB command. * * This method reports the actual state of telemetry reporting, immaterial of the * developer options. This state is set when [init] has been called, usually * during app start up. */ fun isReportingTelemetry(): Boolean { return isTelemetryEnabled } /** * Read from OS developer options. * Pass false by default. */ fun isTelemetryEnabled(): Boolean { private fun checkTelemetryDeveloperOption(): Boolean { return try { Settings.System.getInt(application.contentResolver, SETTINGS_TELEMETRY_FIELD) == 1 } catch (e: Settings.SettingNotFoundException) { Loading Loading
lib/src/main/java/foundation/e/lib/telemetry/Telemetry.kt +20 −4 Original line number Diff line number Diff line Loading @@ -11,6 +11,8 @@ object Telemetry { private var identifier: String = "" private lateinit var application: Application private var isTelemetryEnabled: Boolean = false /** * Call this function in `onCreate()` of custom Application class. * Telemetry will be enabled only if enabled from developer options. Loading @@ -22,7 +24,8 @@ object Telemetry { ) { this.identifier = identifier this.application = application if (isTelemetryEnabled()) { this.isTelemetryEnabled = checkTelemetryDeveloperOption() if (isTelemetryEnabled) { SentryAndroid.init(application) { options -> options.dsn = identifier } Loading @@ -45,8 +48,8 @@ object Telemetry { } @Deprecated( "Use isTelemetryEnabled() without parameters.", ReplaceWith("isTelemetryEnabled()"), "Use isReportingTelemetry()", ReplaceWith("isReportingTelemetry()"), ) fun isTelemetryEnabled(application: Application): Boolean { return try { Loading @@ -58,11 +61,24 @@ object Telemetry { } } /** * It is possible that the telemetry option in developer options is different from * the current state of the library. It is possible if the app is open and * e_telemetry system setting is (say) disabled via ADB command. * * This method reports the actual state of telemetry reporting, immaterial of the * developer options. This state is set when [init] has been called, usually * during app start up. */ fun isReportingTelemetry(): Boolean { return isTelemetryEnabled } /** * Read from OS developer options. * Pass false by default. */ fun isTelemetryEnabled(): Boolean { private fun checkTelemetryDeveloperOption(): Boolean { return try { Settings.System.getInt(application.contentResolver, SETTINGS_TELEMETRY_FIELD) == 1 } catch (e: Settings.SettingNotFoundException) { Loading