lifting the low privacy build config to the config

This commit is contained in:
Adam Brown 2022-07-01 15:00:39 +01:00
parent 811b2e8c75
commit d42c27bfe0
10 changed files with 29 additions and 16 deletions

View File

@ -61,6 +61,8 @@ object Config {
*/
const val HANDLE_CALL_ASSERTED_IDENTITY_EVENTS = false
const val LOW_PRIVACY_LOG_ENABLE = false
/**
* The analytics configuration to use for the Debug build type.
* Can be disabled by providing Analytics.Disabled

View File

@ -237,7 +237,6 @@ android {
resValue "string", "app_name", "Element dbg"
resValue "color", "launcher_background", "#0DBD8B"
buildConfigField "boolean", "LOW_PRIVACY_LOG_ENABLE", "false"
// Set to true if you want to enable strict mode in debug
buildConfigField "boolean", "ENABLE_STRICT_MODE_LOGS", "false"
@ -252,7 +251,6 @@ android {
resValue "string", "app_name", "Element"
resValue "color", "launcher_background", "#0DBD8B"
buildConfigField "boolean", "LOW_PRIVACY_LOG_ENABLE", "false"
buildConfigField "boolean", "ENABLE_STRICT_MODE_LOGS", "false"
// When updating this block, please also update the same block in the `nightly` buildType below

View File

@ -32,7 +32,6 @@ import dagger.hilt.components.SingletonComponent
import im.vector.app.BuildConfig
import im.vector.app.EmojiCompatWrapper
import im.vector.app.EmojiSpanify
import im.vector.app.config.Analytics
import im.vector.app.config.Config
import im.vector.app.SpaceStateHandler
import im.vector.app.SpaceStateHandlerImpl
@ -44,11 +43,9 @@ import im.vector.app.core.time.Clock
import im.vector.app.core.time.DefaultClock
import im.vector.app.core.utils.AndroidSystemSettingsProvider
import im.vector.app.core.utils.SystemSettingsProvider
import im.vector.app.features.analytics.AnalyticsConfig
import im.vector.app.features.analytics.AnalyticsTracker
import im.vector.app.features.analytics.VectorAnalytics
import im.vector.app.features.analytics.impl.DefaultVectorAnalytics
import im.vector.app.features.home.room.detail.composer.voice.VoiceMessageConfig
import im.vector.app.features.invite.AutoAcceptInvites
import im.vector.app.features.invite.CompileTimeAutoAcceptInvites
import im.vector.app.features.navigation.DefaultNavigator
@ -217,6 +214,7 @@ object VectorStaticModule {
isDebug = BuildConfig.DEBUG,
sdkInt = Build.VERSION.SDK_INT,
applicationId = BuildConfig.APPLICATION_ID,
lowPrivacyLoggingEnabled = Config.LOW_PRIVACY_LOG_ENABLE,
)
@Provides

View File

@ -29,6 +29,7 @@ import im.vector.app.BuildConfig
import im.vector.app.core.di.ActiveSessionHolder
import im.vector.app.core.network.WifiDetector
import im.vector.app.core.pushers.model.PushData
import im.vector.app.core.resources.BuildMeta
import im.vector.app.core.services.GuardServiceStarter
import im.vector.app.features.notifications.NotifiableEventResolver
import im.vector.app.features.notifications.NotificationActionIds
@ -70,6 +71,7 @@ class VectorMessagingReceiver : MessagingReceiver() {
@Inject lateinit var unifiedPushStore: UnifiedPushStore
@Inject lateinit var pushParser: PushParser
@Inject lateinit var actionIds: NotificationActionIds
@Inject lateinit var buildMeta: BuildMeta
private val coroutineScope = CoroutineScope(SupervisorJob())
@ -89,7 +91,7 @@ class VectorMessagingReceiver : MessagingReceiver() {
Timber.tag(loggerTag.value).d("## onMessage() received")
val sMessage = String(message)
if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) {
if (buildMeta.lowPrivacyLoggingEnabled) {
Timber.tag(loggerTag.value).d("## onMessage() $sMessage")
}
@ -173,7 +175,7 @@ class VectorMessagingReceiver : MessagingReceiver() {
*/
private suspend fun onMessageReceivedInternal(pushData: PushData) {
try {
if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) {
if (buildMeta.lowPrivacyLoggingEnabled) {
Timber.tag(loggerTag.value).d("## onMessageReceivedInternal() : $pushData")
} else {
Timber.tag(loggerTag.value).d("## onMessageReceivedInternal()")

View File

@ -20,4 +20,5 @@ data class BuildMeta(
val isDebug: Boolean,
val sdkInt: Int,
val applicationId: String,
val lowPrivacyLoggingEnabled: Boolean,
)

View File

@ -26,6 +26,7 @@ import androidx.core.content.getSystemService
import androidx.core.location.LocationListenerCompat
import im.vector.app.BuildConfig
import im.vector.app.core.di.ActiveSessionHolder
import im.vector.app.core.resources.BuildMeta
import im.vector.app.features.session.coroutineScope
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.asSharedFlow
@ -40,7 +41,8 @@ import javax.inject.Singleton
@Singleton
class LocationTracker @Inject constructor(
context: Context,
private val activeSessionHolder: ActiveSessionHolder
private val activeSessionHolder: ActiveSessionHolder,
private val buildMeta: BuildMeta,
) : LocationListenerCompat {
private val locationManager = context.getSystemService<LocationManager>()
@ -104,7 +106,7 @@ class LocationTracker @Inject constructor(
}
.maxByOrNull { location -> location.time }
?.let { latestKnownLocation ->
if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) {
if (buildMeta.lowPrivacyLoggingEnabled) {
Timber.d("lastKnownLocation: $latestKnownLocation")
} else {
Timber.d("lastKnownLocation: ${latestKnownLocation.provider}")
@ -162,7 +164,7 @@ class LocationTracker @Inject constructor(
}
override fun onLocationChanged(location: Location) {
if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) {
if (buildMeta.lowPrivacyLoggingEnabled) {
Timber.d("onLocationChanged: $location")
} else {
Timber.d("onLocationChanged: ${location.provider}")
@ -196,7 +198,7 @@ class LocationTracker @Inject constructor(
private fun notifyLocation(location: Location) {
activeSessionHolder.getSafeActiveSession()?.coroutineScope?.launch {
if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) {
if (buildMeta.lowPrivacyLoggingEnabled) {
Timber.d("notify location: $location")
} else {
Timber.d("notify location: ${location.provider}")

View File

@ -19,6 +19,7 @@ import android.net.Uri
import im.vector.app.BuildConfig
import im.vector.app.R
import im.vector.app.core.extensions.takeAs
import im.vector.app.core.resources.BuildMeta
import im.vector.app.core.resources.StringProvider
import im.vector.app.core.time.Clock
import im.vector.app.features.displayname.getBestName
@ -62,6 +63,7 @@ class NotifiableEventResolver @Inject constructor(
private val noticeEventFormatter: NoticeEventFormatter,
private val displayableEventFormatter: DisplayableEventFormatter,
private val clock: Clock,
private val buildMeta: BuildMeta,
) {
// private val eventDisplay = RiotEventDisplay(context)
@ -264,7 +266,7 @@ class NotifiableEventResolver @Inject constructor(
)
} else {
Timber.e("## unsupported notifiable event for eventId [${event.eventId}]")
if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) {
if (buildMeta.lowPrivacyLoggingEnabled) {
Timber.e("## unsupported notifiable event for event [$event]")
}
// TODO generic handling?

View File

@ -22,6 +22,7 @@ import androidx.annotation.WorkerThread
import im.vector.app.ActiveSessionDataSource
import im.vector.app.BuildConfig
import im.vector.app.R
import im.vector.app.core.resources.BuildMeta
import im.vector.app.core.utils.FirstThrottler
import im.vector.app.features.displayname.getBestName
import im.vector.app.features.settings.VectorPreferences
@ -46,7 +47,8 @@ class NotificationDrawerManager @Inject constructor(
private val activeSessionDataSource: ActiveSessionDataSource,
private val notifiableEventProcessor: NotifiableEventProcessor,
private val notificationRenderer: NotificationRenderer,
private val notificationEventPersistence: NotificationEventPersistence
private val notificationEventPersistence: NotificationEventPersistence,
private val buildMeta: BuildMeta,
) {
private val handlerThread: HandlerThread = HandlerThread("NotificationDrawerManager", Thread.MIN_PRIORITY)
@ -92,7 +94,7 @@ class NotificationDrawerManager @Inject constructor(
}
// If we support multi session, event list should be per userId
// Currently only manage single session
if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) {
if (buildMeta.lowPrivacyLoggingEnabled) {
Timber.d("onNotifiableEventReceived(): $notifiableEvent")
} else {
Timber.d("onNotifiableEventReceived(): is push: ${notifiableEvent.canBeReplaced}")

View File

@ -23,6 +23,7 @@ import im.vector.app.features.session.coroutineScope
import im.vector.app.test.fakes.FakeActiveSessionHolder
import im.vector.app.test.fakes.FakeContext
import im.vector.app.test.fakes.FakeLocationManager
import im.vector.app.test.fixtures.aBuildMeta
import im.vector.app.test.test
import io.mockk.every
import io.mockk.just
@ -56,7 +57,7 @@ class LocationTrackerTest {
@Before
fun setUp() {
mockkStatic("im.vector.app.features.session.SessionCoroutineScopesKt")
locationTracker = LocationTracker(fakeContext.instance, fakeActiveSessionHolder.instance)
locationTracker = LocationTracker(fakeContext.instance, fakeActiveSessionHolder.instance, aBuildMeta())
fakeLocationManager.givenRemoveUpdates(locationTracker)
}

View File

@ -19,4 +19,9 @@ package im.vector.app.test.fixtures
import android.os.Build
import im.vector.app.core.resources.BuildMeta
fun aBuildMeta() = BuildMeta(Build.VERSION_CODES.O)
fun aBuildMeta() = BuildMeta(
isDebug = false,
sdkInt = Build.VERSION_CODES.O,
applicationId = "im.vector",
lowPrivacyLoggingEnabled = false,
)