2021-11-04 16:56:54 +00:00
|
|
|
package org.thoughtcrime.securesms
|
|
|
|
|
2022-02-21 17:39:07 +00:00
|
|
|
import android.content.ContentValues
|
2022-02-14 19:18:03 +00:00
|
|
|
import android.os.Build
|
2021-11-04 16:56:54 +00:00
|
|
|
import leakcanary.LeakCanary
|
2022-02-14 19:18:03 +00:00
|
|
|
import org.signal.spinner.Spinner
|
2022-02-23 23:22:58 +00:00
|
|
|
import org.signal.spinner.Spinner.DatabaseConfig
|
2022-02-21 17:39:07 +00:00
|
|
|
import org.thoughtcrime.securesms.database.DatabaseMonitor
|
2022-02-14 19:18:03 +00:00
|
|
|
import org.thoughtcrime.securesms.database.JobDatabase
|
|
|
|
import org.thoughtcrime.securesms.database.KeyValueDatabase
|
|
|
|
import org.thoughtcrime.securesms.database.LocalMetricsDatabase
|
|
|
|
import org.thoughtcrime.securesms.database.LogDatabase
|
|
|
|
import org.thoughtcrime.securesms.database.MegaphoneDatabase
|
2022-02-23 23:22:58 +00:00
|
|
|
import org.thoughtcrime.securesms.database.MessageBitmaskColumnTransformer
|
2022-02-21 17:39:07 +00:00
|
|
|
import org.thoughtcrime.securesms.database.QueryMonitor
|
2022-02-14 19:18:03 +00:00
|
|
|
import org.thoughtcrime.securesms.database.SignalDatabase
|
|
|
|
import org.thoughtcrime.securesms.util.AppSignatureUtil
|
2021-11-04 16:56:54 +00:00
|
|
|
import shark.AndroidReferenceMatchers
|
|
|
|
|
2022-02-14 19:18:03 +00:00
|
|
|
class SpinnerApplicationContext : ApplicationContext() {
|
2021-11-04 16:56:54 +00:00
|
|
|
override fun onCreate() {
|
|
|
|
super.onCreate()
|
|
|
|
|
2022-02-14 19:18:03 +00:00
|
|
|
Spinner.init(
|
|
|
|
this,
|
|
|
|
Spinner.DeviceInfo(
|
|
|
|
name = "${Build.MODEL} (Android ${Build.VERSION.RELEASE}, API ${Build.VERSION.SDK_INT})",
|
|
|
|
packageName = "$packageName (${AppSignatureUtil.getAppSignature(this).or("Unknown")})",
|
|
|
|
appVersion = "${BuildConfig.VERSION_NAME} (${BuildConfig.CANONICAL_VERSION_CODE}, ${BuildConfig.GIT_HASH})"
|
|
|
|
),
|
|
|
|
linkedMapOf(
|
2022-02-23 23:22:58 +00:00
|
|
|
"signal" to DatabaseConfig(
|
|
|
|
db = SignalDatabase.rawDatabase,
|
|
|
|
columnTransformers = listOf(MessageBitmaskColumnTransformer)
|
|
|
|
),
|
|
|
|
"jobmanager" to DatabaseConfig(db = JobDatabase.getInstance(this).sqlCipherDatabase),
|
|
|
|
"keyvalue" to DatabaseConfig(db = KeyValueDatabase.getInstance(this).sqlCipherDatabase),
|
|
|
|
"megaphones" to DatabaseConfig(db = MegaphoneDatabase.getInstance(this).sqlCipherDatabase),
|
|
|
|
"localmetrics" to DatabaseConfig(db = LocalMetricsDatabase.getInstance(this).sqlCipherDatabase),
|
|
|
|
"logs" to DatabaseConfig(db = LogDatabase.getInstance(this).sqlCipherDatabase),
|
2022-02-14 19:18:03 +00:00
|
|
|
)
|
|
|
|
)
|
2021-11-04 16:56:54 +00:00
|
|
|
|
2022-02-21 17:39:07 +00:00
|
|
|
DatabaseMonitor.initialize(object : QueryMonitor {
|
|
|
|
override fun onSql(sql: String, args: Array<Any>?) {
|
|
|
|
Spinner.onSql("signal", sql, args)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onQuery(distinct: Boolean, table: String, projection: Array<String>?, selection: String?, args: Array<Any>?, groupBy: String?, having: String?, orderBy: String?, limit: String?) {
|
|
|
|
Spinner.onQuery("signal", distinct, table, projection, selection, args, groupBy, having, orderBy, limit)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onDelete(table: String, selection: String?, args: Array<Any>?) {
|
|
|
|
Spinner.onDelete("signal", table, selection, args)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onUpdate(table: String, values: ContentValues, selection: String?, args: Array<Any>?) {
|
|
|
|
Spinner.onUpdate("signal", table, values, selection, args)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-11-04 16:56:54 +00:00
|
|
|
LeakCanary.config = LeakCanary.config.copy(
|
|
|
|
referenceMatchers = AndroidReferenceMatchers.appDefaults +
|
2021-11-11 17:27:22 +00:00
|
|
|
AndroidReferenceMatchers.ignoredInstanceField(
|
2021-11-04 16:56:54 +00:00
|
|
|
className = "android.service.media.MediaBrowserService\$ServiceBinder",
|
2021-11-11 17:27:22 +00:00
|
|
|
fieldName = "this\$0"
|
2021-11-04 16:56:54 +00:00
|
|
|
) +
|
2021-11-11 17:27:22 +00:00
|
|
|
AndroidReferenceMatchers.ignoredInstanceField(
|
2021-11-04 16:56:54 +00:00
|
|
|
className = "androidx.media.MediaBrowserServiceCompat\$MediaBrowserServiceImplApi26\$MediaBrowserServiceApi26",
|
2021-11-11 17:27:22 +00:00
|
|
|
fieldName = "mBase"
|
2021-11-04 16:56:54 +00:00
|
|
|
) +
|
2021-11-11 17:27:22 +00:00
|
|
|
AndroidReferenceMatchers.ignoredInstanceField(
|
|
|
|
className = "android.support.v4.media.MediaBrowserCompat",
|
|
|
|
fieldName = "mImpl"
|
|
|
|
) +
|
|
|
|
AndroidReferenceMatchers.ignoredInstanceField(
|
|
|
|
className = "android.support.v4.media.session.MediaControllerCompat",
|
|
|
|
fieldName = "mToken"
|
|
|
|
) +
|
|
|
|
AndroidReferenceMatchers.ignoredInstanceField(
|
|
|
|
className = "android.support.v4.media.session.MediaControllerCompat",
|
|
|
|
fieldName = "mImpl"
|
|
|
|
) +
|
|
|
|
AndroidReferenceMatchers.ignoredInstanceField(
|
2021-11-04 16:56:54 +00:00
|
|
|
className = "org.thoughtcrime.securesms.components.voice.VoiceNotePlaybackService",
|
2021-11-11 17:27:22 +00:00
|
|
|
fieldName = "mApplication"
|
|
|
|
) +
|
|
|
|
AndroidReferenceMatchers.ignoredInstanceField(
|
|
|
|
className = "org.thoughtcrime.securesms.service.GenericForegroundService\$LocalBinder",
|
|
|
|
fieldName = "this\$0"
|
|
|
|
) +
|
|
|
|
AndroidReferenceMatchers.ignoredInstanceField(
|
|
|
|
className = "org.thoughtcrime.securesms.contacts.ContactsSyncAdapter",
|
|
|
|
fieldName = "mContext"
|
2021-11-04 16:56:54 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
2021-11-04 16:59:02 +00:00
|
|
|
}
|