From 8109d2adc2b60b6619d20e7ddf81033444d452c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Tue, 13 Feb 2024 10:12:28 +0100 Subject: [PATCH 01/16] Add remember active state of sensor trigger --- .../data/models/memory/triggers/shared/SensorTrigger.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/data/models/memory/triggers/shared/SensorTrigger.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/data/models/memory/triggers/shared/SensorTrigger.kt index 1dfc2905..b2a10c8a 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/data/models/memory/triggers/shared/SensorTrigger.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/data/models/memory/triggers/shared/SensorTrigger.kt @@ -20,11 +20,16 @@ internal abstract class SensorTrigger( abstract fun processEvent(event: SensorEvent): Boolean + private var activeHolder: Boolean? = null + override fun start() { sensorManager = (context.getSystemService(Context.SENSOR_SERVICE) as? SensorManager) sensorManager?.let { registerSensor(it) - this.active = true + if (activeHolder == null) { + activeHolder = active + } + this.active = activeHolder ?: true // use remembered active state } ?: run { this.active = false } @@ -34,6 +39,7 @@ internal abstract class SensorTrigger( queue?.clear() unregisterSensor() sensorManager = null + activeHolder = active // remember active state this.active = false } From 247642a22ef2bb216022b6e11b66c8975298930f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Tue, 13 Feb 2024 10:12:49 +0100 Subject: [PATCH 02/16] Update cache when saving Trigger DAO --- .../com/infinum/sentinel/domain/triggers/TriggersRepository.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/domain/triggers/TriggersRepository.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/domain/triggers/TriggersRepository.kt index 63700e26..2f109aa8 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/domain/triggers/TriggersRepository.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/domain/triggers/TriggersRepository.kt @@ -19,6 +19,7 @@ internal class TriggersRepository( override suspend fun save(input: TriggerParameters) = input.entity?.let { dao.save(it) + updateCache(it) } ?: error("Cannot save null entity") override fun load(input: TriggerParameters): Flow> = From 8a5f74929aff8e2523ff35e7507532e5aea0528a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Tue, 13 Feb 2024 10:48:24 +0100 Subject: [PATCH 03/16] Fix lint --- .../kotlin/com/infinum/sentinel/ui/logger/LoggerActivity.kt | 1 + .../main/kotlin/com/infinum/sentinel/ui/logger/LoggerAdapter.kt | 2 +- .../kotlin/com/infinum/sentinel/ui/logger/LoggerViewHolder.kt | 2 +- .../src/main/kotlin/com/infinum/sentinel/ui/logs/LogsAdapter.kt | 2 +- .../main/kotlin/com/infinum/sentinel/ui/logs/LogsViewHolder.kt | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerActivity.kt b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerActivity.kt index d3267f05..fc6a2c9c 100644 --- a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerActivity.kt +++ b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerActivity.kt @@ -64,6 +64,7 @@ public class LoggerActivity : AppCompatActivity() { } ) + @Suppress("LongMethod", "CyclomaticComplexMethod") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerAdapter.kt b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerAdapter.kt index 2f49dc15..46d750f1 100644 --- a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerAdapter.kt +++ b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerAdapter.kt @@ -33,4 +33,4 @@ internal class LoggerAdapter( currentList: MutableList ) = onListChanged(currentList.isEmpty()) -} \ No newline at end of file +} diff --git a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerViewHolder.kt b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerViewHolder.kt index a938a003..5be29921 100644 --- a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerViewHolder.kt +++ b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerViewHolder.kt @@ -58,4 +58,4 @@ internal class LoggerViewHolder( stackTraceContainer.isVisible = false root.setOnClickListener(null) } -} \ No newline at end of file +} diff --git a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logs/LogsAdapter.kt b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logs/LogsAdapter.kt index ea5b4b9b..8913309e 100644 --- a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logs/LogsAdapter.kt +++ b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logs/LogsAdapter.kt @@ -36,4 +36,4 @@ internal class LogsAdapter( currentList: MutableList ) = onListChanged(currentList.isEmpty()) -} \ No newline at end of file +} diff --git a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logs/LogsViewHolder.kt b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logs/LogsViewHolder.kt index c9a7acf5..61c2d608 100644 --- a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logs/LogsViewHolder.kt +++ b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logs/LogsViewHolder.kt @@ -33,4 +33,4 @@ internal class LogsViewHolder( deleteButton.setOnClickListener(null) shareButton.setOnClickListener(null) } -} \ No newline at end of file +} From 09879ea93f8417f332a60147a60ebbacdcfa62c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Tue, 13 Feb 2024 10:56:27 +0100 Subject: [PATCH 04/16] Update code-analysis.yml --- .github/workflows/code-analysis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/code-analysis.yml b/.github/workflows/code-analysis.yml index 25cdd04b..f07455d9 100644 --- a/.github/workflows/code-analysis.yml +++ b/.github/workflows/code-analysis.yml @@ -15,6 +15,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + - name: Set up Java + uses: actions/setup-java@v2 + with: + distribution: "adopt" + java-version: 17 - name: Save Gradle Caches uses: actions/cache@v2 with: From f8b0119a7e96cfa109b23a2b9a605925d9c01249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Tue, 13 Feb 2024 12:35:13 +0100 Subject: [PATCH 05/16] Add Android 13 notification permission support --- README.md | 3 ++- sentinel/src/main/AndroidManifest.xml | 2 ++ .../shared/notification/SystemNotificationFactory.kt | 12 ++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 555af4f0..7049f6f9 100644 --- a/README.md +++ b/README.md @@ -258,7 +258,8 @@ _Plain_ formatter is selected by default, but selecting any other is persisted b ## Crash monitor _Sentinel_ has a built in default uncaught exception handler and ANR observer. If switched on in -settings, it will notify both in a form of a notification. +settings, it will notify both in a form of a notification. Note that from Android 13 you need to give permission +to the app to show notifications. Once tapped on this notification, a screen with details is shown. A complete list of crashes is persisted between sessions and available on demand. Methods to react on these crashes in a graceful way are provided in _Sentinel_. diff --git a/sentinel/src/main/AndroidManifest.xml b/sentinel/src/main/AndroidManifest.xml index 82190de3..5d3da567 100644 --- a/sentinel/src/main/AndroidManifest.xml +++ b/sentinel/src/main/AndroidManifest.xml @@ -1,6 +1,8 @@ + + = Build.VERSION_CODES.N) { + notificationManager.areNotificationsEnabled() + } else { + true + } + } + init { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val notificationChannel = NotificationChannel( @@ -117,6 +125,9 @@ internal class SystemNotificationFactory( content: String, intents: Array, ) { + if (!canShowNotifications()) { + return + } val builder = NotificationCompat.Builder(context, NOTIFICATIONS_CHANNEL_ID) .setContentIntent(buildPendingIntent(intents)) .setLocalOnly(true) @@ -139,6 +150,7 @@ internal class SystemNotificationFactory( when { Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> PendingIntent.FLAG_MUTABLE + else -> PendingIntent.FLAG_CANCEL_CURRENT } ) From 6ab47f3d34439929cd902de1360bb63f0088e9b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Tue, 13 Feb 2024 14:47:04 +0100 Subject: [PATCH 06/16] Add notification permission check --- .../sentinel/ui/settings/SettingsEvent.kt | 2 + .../sentinel/ui/settings/SettingsFragment.kt | 64 +++++++++++++++++++ .../sentinel/ui/settings/SettingsViewModel.kt | 1 + sentinel/src/main/res/values/themes.xml | 12 ++++ 4 files changed, 79 insertions(+) diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsEvent.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsEvent.kt index d54e73a6..b027b737 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsEvent.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsEvent.kt @@ -27,4 +27,6 @@ internal sealed class SettingsEvent { data class CertificateMonitorChanged( val value: CertificateMonitorEntity ) : SettingsEvent() + + object PermissionsCheck : SettingsEvent() } diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsFragment.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsFragment.kt index 14aad3ba..b324d965 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsFragment.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsFragment.kt @@ -1,8 +1,18 @@ package com.infinum.sentinel.ui.settings +import android.Manifest +import android.content.Intent +import android.content.pm.PackageManager +import android.net.Uri +import android.os.Build import android.os.Bundle +import android.provider.Settings import android.view.View +import android.widget.Toast +import androidx.activity.result.contract.ActivityResultContracts import androidx.annotation.RestrictTo +import androidx.core.content.ContextCompat +import com.google.android.material.snackbar.Snackbar import com.google.android.material.switchmaterial.SwitchMaterial import com.infinum.sentinel.R import com.infinum.sentinel.data.models.local.FormatEntity @@ -33,6 +43,18 @@ internal class SettingsFragment : BaseChildFragment(R.la override val viewModel: SettingsViewModel by viewModels() + private val permissionRequest = registerForActivityResult( + ActivityResultContracts.RequestPermission() + ) { isPermissionGranted: Boolean -> + if (!isPermissionGranted) { + Toast.makeText( + requireContext(), + "Notification permission denied. Can't show info", + Toast.LENGTH_LONG, + ).show() + } + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -107,10 +129,12 @@ internal class SettingsFragment : BaseChildFragment(R.la binding.airplaneModeTriggerView, trigger ) + else -> throw NotImplementedError() } } } + is SettingsEvent.FormatChanged -> { when (event.value.type) { FormatType.PLAIN -> R.id.plainChip @@ -123,6 +147,7 @@ internal class SettingsFragment : BaseChildFragment(R.la binding.formatGroup.check(it) } } + is SettingsEvent.BundleMonitorChanged -> { binding.bundleMonitorSwitch.setOnCheckedChangeListener(null) binding.bundleMonitorSwitch.isChecked = event.value.notify @@ -167,6 +192,7 @@ internal class SettingsFragment : BaseChildFragment(R.la } binding.limitValueView.text = String.format(FORMAT_BUNDLE_SIZE, event.value.limit) } + is SettingsEvent.CrashMonitorChanged -> { binding.uncaughtExceptionSwitch.setOnCheckedChangeListener(null) binding.uncaughtExceptionSwitch.isChecked = event.value.notifyExceptions @@ -184,6 +210,7 @@ internal class SettingsFragment : BaseChildFragment(R.la viewModel.updateCrashMonitor(event.value.copy(includeAllData = isChecked)) } } + is SettingsEvent.CertificateMonitorChanged -> { binding.runOnStartSwitch.setOnCheckedChangeListener(null) binding.runOnStartSwitch.isChecked = event.value.runOnStart @@ -240,8 +267,45 @@ internal class SettingsFragment : BaseChildFragment(R.la viewModel.updateCertificatesMonitor(event.value.copy(expireInUnit = ChronoUnit.YEARS)) } } + + SettingsEvent.PermissionsCheck -> { + handleNotificationsPermission() + } } + private fun handleNotificationsPermission() { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) { + return + } + when { + ContextCompat.checkSelfPermission( + requireContext(), Manifest.permission.POST_NOTIFICATIONS + ) == PackageManager.PERMISSION_GRANTED -> { + // We have permission, all good + } + + shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS) -> { + Snackbar.make( + binding.root, + "Notification permission denied. Can't show info", + Snackbar.LENGTH_LONG + ).setAction("Change") { + Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply { + addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + data = Uri.fromParts("package", requireContext().packageName, null) + }.also { intent -> + startActivity(intent) + } + }.show() + } + + else -> { + permissionRequest.launch(Manifest.permission.POST_NOTIFICATIONS) + } + } + + } + private fun setupSwitch(switchView: SwitchMaterial, trigger: TriggerEntity) = with(switchView) { setOnCheckedChangeListener(null) diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsViewModel.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsViewModel.kt index 1f2b9f65..dbdca198 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsViewModel.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsViewModel.kt @@ -124,6 +124,7 @@ internal class SettingsViewModel( anrObserver.stop() } } + emitEvent(SettingsEvent.PermissionsCheck) } fun updateCertificatesMonitor(entity: CertificateMonitorEntity) { diff --git a/sentinel/src/main/res/values/themes.xml b/sentinel/src/main/res/values/themes.xml index 7109386a..350ccb77 100644 --- a/sentinel/src/main/res/values/themes.xml +++ b/sentinel/src/main/res/values/themes.xml @@ -28,6 +28,8 @@ @color/sentinel_inverseOnSurface @color/sentinel_inverseSurface @color/sentinel_primaryInverse + @style/Sentinel.Snackbar + @style/Sentinel.Snackbar.TextButton + + + + + + \ No newline at end of file From e7a31aa3b641d83af541c861d6b4654a0fb9bcc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Tue, 13 Feb 2024 15:22:56 +0100 Subject: [PATCH 07/16] Extract string resources --- .../com/infinum/sentinel/ui/settings/SettingsFragment.kt | 8 ++++---- sentinel/src/main/res/values/strings.xml | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsFragment.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsFragment.kt index b324d965..c62a8566 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsFragment.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsFragment.kt @@ -49,7 +49,7 @@ internal class SettingsFragment : BaseChildFragment(R.la if (!isPermissionGranted) { Toast.makeText( requireContext(), - "Notification permission denied. Can't show info", + getString(R.string.sentinel_notification_permission_denied), Toast.LENGTH_LONG, ).show() } @@ -287,12 +287,12 @@ internal class SettingsFragment : BaseChildFragment(R.la shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS) -> { Snackbar.make( binding.root, - "Notification permission denied. Can't show info", + getString(R.string.sentinel_notification_permission_denied), Snackbar.LENGTH_LONG - ).setAction("Change") { + ).setAction(getString(R.string.sentinel_change)) { Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - data = Uri.fromParts("package", requireContext().packageName, null) + data = Uri.fromParts(getString(R.string.sentinel_package), requireContext().packageName, null) }.also { intent -> startActivity(intent) } diff --git a/sentinel/src/main/res/values/strings.xml b/sentinel/src/main/res/values/strings.xml index 166a0584..bbbf6999 100644 --- a/sentinel/src/main/res/values/strings.xml +++ b/sentinel/src/main/res/values/strings.xml @@ -18,6 +18,7 @@ Search Show Save + Change Network Memory @@ -151,5 +152,9 @@ Months Years + Notification permission denied. Can\'t show info + unknown + package + \ No newline at end of file From 995781dab8a54c513c5f7b33353845a8ae1e52bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Wed, 14 Feb 2024 12:54:49 +0100 Subject: [PATCH 08/16] Use package schema string in UI tool --- .../com/infinum/sentinel/ui/settings/SettingsFragment.kt | 2 +- .../kotlin/com/infinum/sentinel/ui/tools/AppInfoTool.kt | 6 +----- sentinel/src/main/res/values/strings.xml | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsFragment.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsFragment.kt index c62a8566..eeb02dc5 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsFragment.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsFragment.kt @@ -292,7 +292,7 @@ internal class SettingsFragment : BaseChildFragment(R.la ).setAction(getString(R.string.sentinel_change)) { Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - data = Uri.fromParts(getString(R.string.sentinel_package), requireContext().packageName, null) + data = Uri.fromParts(getString(R.string.sentinel_package_schema), requireContext().packageName, null) }.also { intent -> startActivity(intent) } diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/tools/AppInfoTool.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/tools/AppInfoTool.kt index a4542ae3..358a61a1 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/tools/AppInfoTool.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/tools/AppInfoTool.kt @@ -17,16 +17,12 @@ internal data class AppInfoTool( it.context.startActivity( Intent().apply { action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS - data = Uri.fromParts(SCHEME_PACKAGE, it.context.packageName, null) + data = Uri.fromParts(it.context.getString(R.string.sentinel_package_schema), it.context.packageName, null) } ) } ) : Sentinel.Tool { - companion object { - private const val SCHEME_PACKAGE = "package" - } - /** * A dedicated name for this tool * diff --git a/sentinel/src/main/res/values/strings.xml b/sentinel/src/main/res/values/strings.xml index bbbf6999..51a05cf2 100644 --- a/sentinel/src/main/res/values/strings.xml +++ b/sentinel/src/main/res/values/strings.xml @@ -155,6 +155,6 @@ Notification permission denied. Can\'t show info unknown - package + package \ No newline at end of file From 7d1113ebcd2b141ea61d7285883f4da864a0d8e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Wed, 14 Feb 2024 13:09:51 +0100 Subject: [PATCH 09/16] Add notifications permission check for certificates --- .../sentinel/ui/settings/SettingsViewModel.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsViewModel.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsViewModel.kt index dbdca198..e46eb1b8 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsViewModel.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsViewModel.kt @@ -124,9 +124,14 @@ internal class SettingsViewModel( anrObserver.stop() } } - emitEvent(SettingsEvent.PermissionsCheck) + if (isAtLeastSomeCrashOptionChecked(entity)) { + emitEvent(SettingsEvent.PermissionsCheck) + } } + private fun isAtLeastSomeCrashOptionChecked(entity: CrashMonitorEntity): Boolean = + entity.notifyAnrs || entity.notifyExceptions + fun updateCertificatesMonitor(entity: CertificateMonitorEntity) { launch { io { @@ -142,6 +147,12 @@ internal class SettingsViewModel( workManager.startCertificatesCheck(it) } ?: workManager.stopCertificatesCheck() } + if (isAtLeastSomeCertificateOptionChecked(entity)) { + emitEvent(SettingsEvent.PermissionsCheck) + } } } + + private fun isAtLeastSomeCertificateOptionChecked(entity: CertificateMonitorEntity): Boolean = + entity.runOnStart || entity.runInBackground || entity.notifyInvalidNow || entity.notifyToExpire } From 93513de27b37d3166bc8cc1deaabcfd0cb5ace48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Fri, 1 Mar 2024 14:53:24 +0100 Subject: [PATCH 10/16] Update code-analysis.yml --- .github/workflows/code-analysis.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/code-analysis.yml b/.github/workflows/code-analysis.yml index f07455d9..2f7f58fb 100644 --- a/.github/workflows/code-analysis.yml +++ b/.github/workflows/code-analysis.yml @@ -38,6 +38,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + - name: Set up Java + uses: actions/setup-java@v2 + with: + distribution: "adopt" + java-version: 17 - name: Save Gradle Caches uses: actions/cache@v2 with: @@ -56,6 +61,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + - name: Set up Java + uses: actions/setup-java@v2 + with: + distribution: "adopt" + java-version: 17 - name: Save Gradle Caches uses: actions/cache@v2 with: @@ -73,6 +83,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + - name: Set up Java + uses: actions/setup-java@v2 + with: + distribution: "adopt" + java-version: 17 - name: Save Gradle Caches uses: actions/cache@v2 with: From 347e0bcf25c19b0cabf4b26cf571dbd2004d2189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Fri, 1 Mar 2024 15:03:36 +0100 Subject: [PATCH 11/16] Fix detekt --- .../com/infinum/sentinel/ui/settings/SettingsFragment.kt | 7 +++++-- .../ui/shared/notification/SystemNotificationFactory.kt | 1 + .../kotlin/com/infinum/sentinel/ui/tools/AppInfoTool.kt | 6 +++++- .../com/infinum/sentinel/ui/logger/LoggerActivity.kt | 1 + .../com/infinum/sentinel/ui/logger/LoggerAdapter.kt | 2 +- .../com/infinum/sentinel/ui/logger/LoggerViewHolder.kt | 2 +- .../kotlin/com/infinum/sentinel/ui/logs/LogsAdapter.kt | 2 +- .../kotlin/com/infinum/sentinel/ui/logs/LogsViewHolder.kt | 2 +- .../com/infinum/sentinel/ui/shared/LogFileResolver.kt | 8 +++++--- 9 files changed, 21 insertions(+), 10 deletions(-) diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsFragment.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsFragment.kt index eeb02dc5..acbc0925 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsFragment.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/settings/SettingsFragment.kt @@ -292,7 +292,11 @@ internal class SettingsFragment : BaseChildFragment(R.la ).setAction(getString(R.string.sentinel_change)) { Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - data = Uri.fromParts(getString(R.string.sentinel_package_schema), requireContext().packageName, null) + data = Uri.fromParts( + getString(R.string.sentinel_package_schema), + requireContext().packageName, + null + ) }.also { intent -> startActivity(intent) } @@ -303,7 +307,6 @@ internal class SettingsFragment : BaseChildFragment(R.la permissionRequest.launch(Manifest.permission.POST_NOTIFICATIONS) } } - } private fun setupSwitch(switchView: SwitchMaterial, trigger: TriggerEntity) = diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/shared/notification/SystemNotificationFactory.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/shared/notification/SystemNotificationFactory.kt index d3019143..731296ac 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/shared/notification/SystemNotificationFactory.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/shared/notification/SystemNotificationFactory.kt @@ -14,6 +14,7 @@ import com.infinum.sentinel.data.models.local.CrashEntity import com.infinum.sentinel.ui.shared.Constants.NOTIFICATIONS_CHANNEL_ID import me.tatarka.inject.annotations.Inject +@Suppress("TooManyFunctions") @Inject internal class SystemNotificationFactory( private val context: Context, diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/tools/AppInfoTool.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/tools/AppInfoTool.kt index 358a61a1..103cf048 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/tools/AppInfoTool.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/tools/AppInfoTool.kt @@ -17,7 +17,11 @@ internal data class AppInfoTool( it.context.startActivity( Intent().apply { action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS - data = Uri.fromParts(it.context.getString(R.string.sentinel_package_schema), it.context.packageName, null) + data = Uri.fromParts( + it.context.getString(R.string.sentinel_package_schema), + it.context.packageName, + null + ) } ) } diff --git a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerActivity.kt b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerActivity.kt index d3267f05..fc6a2c9c 100644 --- a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerActivity.kt +++ b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerActivity.kt @@ -64,6 +64,7 @@ public class LoggerActivity : AppCompatActivity() { } ) + @Suppress("LongMethod", "CyclomaticComplexMethod") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerAdapter.kt b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerAdapter.kt index 2f49dc15..46d750f1 100644 --- a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerAdapter.kt +++ b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerAdapter.kt @@ -33,4 +33,4 @@ internal class LoggerAdapter( currentList: MutableList ) = onListChanged(currentList.isEmpty()) -} \ No newline at end of file +} diff --git a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerViewHolder.kt b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerViewHolder.kt index a938a003..5be29921 100644 --- a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerViewHolder.kt +++ b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logger/LoggerViewHolder.kt @@ -58,4 +58,4 @@ internal class LoggerViewHolder( stackTraceContainer.isVisible = false root.setOnClickListener(null) } -} \ No newline at end of file +} diff --git a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logs/LogsAdapter.kt b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logs/LogsAdapter.kt index ea5b4b9b..8913309e 100644 --- a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logs/LogsAdapter.kt +++ b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logs/LogsAdapter.kt @@ -36,4 +36,4 @@ internal class LogsAdapter( currentList: MutableList ) = onListChanged(currentList.isEmpty()) -} \ No newline at end of file +} diff --git a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logs/LogsViewHolder.kt b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logs/LogsViewHolder.kt index c9a7acf5..61c2d608 100644 --- a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logs/LogsViewHolder.kt +++ b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/logs/LogsViewHolder.kt @@ -33,4 +33,4 @@ internal class LogsViewHolder( deleteButton.setOnClickListener(null) shareButton.setOnClickListener(null) } -} \ No newline at end of file +} diff --git a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/shared/LogFileResolver.kt b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/shared/LogFileResolver.kt index 4f3964eb..80144b5d 100644 --- a/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/shared/LogFileResolver.kt +++ b/tool-timber/src/main/kotlin/com/infinum/sentinel/ui/shared/LogFileResolver.kt @@ -3,6 +3,7 @@ package com.infinum.sentinel.ui.shared import android.content.Context import java.io.File import java.util.Calendar +import java.util.Locale internal class LogFileResolver( private val context: Context @@ -27,11 +28,12 @@ internal class LogFileResolver( val year = Calendar.getInstance().get(Calendar.YEAR) val filename = buildString { - append(String.format("%02d", day)) + val locale = Locale.getDefault() + append(String.format(locale = locale, format = "%02d", day)) append("-") - append(String.format("%02d", month)) + append(String.format(locale = locale, format = "%02d", month)) append("-") - append(String.format("%04d", year)) + append(String.format(locale = locale, format = "%04d", year)) append(LOG_EXTENSION) } val nowFile = File("${parent.absolutePath}/$filename") From dd1d5ddb24a552a04ef78762a98d47011eb64de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Wed, 6 Mar 2024 09:19:05 +0100 Subject: [PATCH 12/16] Add don't obfuscate rule --- sentinel-no-op/proguard-rules.txt | 36 +------------------------- sentinel/proguard-rules.txt | 40 +---------------------------- tool-appgallery/proguard-rules.txt | 6 +---- tool-chucker/proguard-rules.txt | 6 +---- tool-collar/proguard-rules.txt | 6 +---- tool-dbinspector/proguard-rules.txt | 6 +---- tool-googleplay/proguard-rules.txt | 6 +---- tool-leakcanary/proguard-rules.txt | 6 +---- tool-thimble/proguard-rules.txt | 6 +---- tool-timber/proguard-rules.txt | 6 +---- 10 files changed, 10 insertions(+), 114 deletions(-) diff --git a/sentinel-no-op/proguard-rules.txt b/sentinel-no-op/proguard-rules.txt index 3ce9626f..0674e774 100644 --- a/sentinel-no-op/proguard-rules.txt +++ b/sentinel-no-op/proguard-rules.txt @@ -1,35 +1 @@ --keeppackagenames --keep public class com.infinum.sentinel.* { - public protected *; -} --keep public class com.infinum.sentinel.Sentinel { - public protected *; -} --keep public class com.infinum.sentinel.ui.tools.ChuckerTool { - public protected *; -} --keep public class com.infinum.sentinel.ui.tools.CollarTool { - public protected *; -} --keep public class com.infinum.sentinel.ui.tools.DbInspectorTool { - public protected *; -} --keep public class com.infinum.sentinel.ui.tools.LeakCanaryTool { - public protected *; -} --keep public class com.infinum.sentinel.ui.tools.AppGalleryTool { - public protected *; -} --keep public class com.infinum.sentinel.ui.tools.GooglePlayTool { - public protected *; -} --keep public class com.infinum.sentinel.ui.tools.ThimbleTool { - public protected *; -} --keep public class com.infinum.sentinel.ui.tools.TimberTool { - public protected *; -} --keep public class com.infinum.sentinel.ui.tools.CertificateTool { - public protected *; -} --keep public class com.infinum.sentinel.databinding.** \ No newline at end of file +-dontobfuscate \ No newline at end of file diff --git a/sentinel/proguard-rules.txt b/sentinel/proguard-rules.txt index 7bfc6c44..0674e774 100644 --- a/sentinel/proguard-rules.txt +++ b/sentinel/proguard-rules.txt @@ -1,39 +1 @@ --keeppackagenames --keep public class com.infinum.sentinel.* { - public protected *; -} --keep public class com.infinum.sentinel.Sentinel { - public protected *; -} --keep public class com.infinum.sentinel.ui.tools.CertificateTool { - public protected *; -} --keep public class com.infinum.sentinel.databinding.** - -# KotlinX Serialization --if @kotlinx.serialization.Serializable class ** --keepclassmembers class <1> { - static <1>$Companion Companion; -} --if @kotlinx.serialization.Serializable class ** { - static **$* *; -} --keepclassmembers class <1>$<3> { - kotlinx.serialization.KSerializer serializer(...); -} --if @kotlinx.serialization.Serializable class ** { - public static ** INSTANCE; -} --keepclassmembers class <1> { - public static <1> INSTANCE; - kotlinx.serialization.KSerializer serializer(...); -} --keepattributes RuntimeVisibleAnnotations,AnnotationDefault --keepattributes InnerClasses # Needed for `getDeclaredClasses`. --keepnames class <1>$$serializer { # -keepnames suffices; class is kept when serializer() is kept. - static <1>$$serializer INSTANCE; -} - --keep class * extends androidx.room.RoomDatabase --keep @androidx.room.Entity class * --keep @androidx.room.TypeConverters class * \ No newline at end of file +-dontobfuscate \ No newline at end of file diff --git a/tool-appgallery/proguard-rules.txt b/tool-appgallery/proguard-rules.txt index 8fedccd3..0674e774 100644 --- a/tool-appgallery/proguard-rules.txt +++ b/tool-appgallery/proguard-rules.txt @@ -1,5 +1 @@ --keeppackagenames --keep public class com.infinum.sentinel.ui.tools.AppGalleryTool { - public protected *; -} --keep public class com.infinum.sentinel.databinding.** +-dontobfuscate \ No newline at end of file diff --git a/tool-chucker/proguard-rules.txt b/tool-chucker/proguard-rules.txt index dff7c096..0674e774 100644 --- a/tool-chucker/proguard-rules.txt +++ b/tool-chucker/proguard-rules.txt @@ -1,5 +1 @@ --keeppackagenames --keep public class com.infinum.sentinel.ui.tools.ChuckerTool { - public protected *; -} --keep public class com.infinum.sentinel.databinding.** +-dontobfuscate \ No newline at end of file diff --git a/tool-collar/proguard-rules.txt b/tool-collar/proguard-rules.txt index eab87141..0674e774 100644 --- a/tool-collar/proguard-rules.txt +++ b/tool-collar/proguard-rules.txt @@ -1,5 +1 @@ --keeppackagenames --keep public class com.infinum.sentinel.ui.tools.CollarTool { - public protected *; -} --keep public class com.infinum.sentinel.databinding.** +-dontobfuscate \ No newline at end of file diff --git a/tool-dbinspector/proguard-rules.txt b/tool-dbinspector/proguard-rules.txt index b914121f..0674e774 100644 --- a/tool-dbinspector/proguard-rules.txt +++ b/tool-dbinspector/proguard-rules.txt @@ -1,5 +1 @@ --keeppackagenames --keep public class com.infinum.sentinel.ui.tools.DbInspectorTool { - public protected *; -} --keep public class com.infinum.sentinel.databinding.** \ No newline at end of file +-dontobfuscate \ No newline at end of file diff --git a/tool-googleplay/proguard-rules.txt b/tool-googleplay/proguard-rules.txt index ba10a085..0674e774 100644 --- a/tool-googleplay/proguard-rules.txt +++ b/tool-googleplay/proguard-rules.txt @@ -1,5 +1 @@ --keeppackagenames --keep public class com.infinum.sentinel.ui.tools.GooglePlayTool { - public protected *; -} --keep public class com.infinum.sentinel.databinding.** +-dontobfuscate \ No newline at end of file diff --git a/tool-leakcanary/proguard-rules.txt b/tool-leakcanary/proguard-rules.txt index d35cf0ff..0674e774 100644 --- a/tool-leakcanary/proguard-rules.txt +++ b/tool-leakcanary/proguard-rules.txt @@ -1,5 +1 @@ --keeppackagenames --keep public class com.infinum.sentinel.ui.tools.LeakCanaryTool { - public protected *; -} --keep public class com.infinum.sentinel.databinding.** +-dontobfuscate \ No newline at end of file diff --git a/tool-thimble/proguard-rules.txt b/tool-thimble/proguard-rules.txt index 81486b1d..0674e774 100644 --- a/tool-thimble/proguard-rules.txt +++ b/tool-thimble/proguard-rules.txt @@ -1,5 +1 @@ --keeppackagenames --keep public class com.infinum.sentinel.ui.tools.ThimbleTool { - public protected *; -} --keep public class com.infinum.sentinel.databinding.** +-dontobfuscate \ No newline at end of file diff --git a/tool-timber/proguard-rules.txt b/tool-timber/proguard-rules.txt index d6451db4..0674e774 100644 --- a/tool-timber/proguard-rules.txt +++ b/tool-timber/proguard-rules.txt @@ -1,5 +1 @@ --keeppackagenames --keep public class com.infinum.sentinel.ui.tools.TimberTool { - public protected *; -} --keep public class com.infinum.sentinel.databinding.** +-dontobfuscate \ No newline at end of file From 4dbbe12aa8b70eed28e1d668cbd0fc329e2b7c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Wed, 6 Mar 2024 10:02:57 +0100 Subject: [PATCH 13/16] Remove sensor trigger --- .../data/models/memory/triggers/shared/SensorTrigger.kt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/data/models/memory/triggers/shared/SensorTrigger.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/data/models/memory/triggers/shared/SensorTrigger.kt index b2a10c8a..b10a0e87 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/data/models/memory/triggers/shared/SensorTrigger.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/data/models/memory/triggers/shared/SensorTrigger.kt @@ -20,16 +20,10 @@ internal abstract class SensorTrigger( abstract fun processEvent(event: SensorEvent): Boolean - private var activeHolder: Boolean? = null - override fun start() { sensorManager = (context.getSystemService(Context.SENSOR_SERVICE) as? SensorManager) sensorManager?.let { registerSensor(it) - if (activeHolder == null) { - activeHolder = active - } - this.active = activeHolder ?: true // use remembered active state } ?: run { this.active = false } @@ -39,8 +33,6 @@ internal abstract class SensorTrigger( queue?.clear() unregisterSensor() sensorManager = null - activeHolder = active // remember active state - this.active = false } override fun onSensorChanged(event: SensorEvent) { From 42d34f6f4e72f5344198651eec9ad15600a5e2d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Wed, 6 Mar 2024 10:16:55 +0100 Subject: [PATCH 14/16] Bump version --- config.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.gradle b/config.gradle index 23b316c8..7a3c5bcb 100644 --- a/config.gradle +++ b/config.gradle @@ -1,7 +1,7 @@ ext { def major = 1 def minor = 3 - def patch = 1 + def patch = 2 buildConfig = [ "minSdk" : 21, From 16497183b8a08103873b42f9bb937469e1eeb4f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Wed, 6 Mar 2024 10:38:54 +0100 Subject: [PATCH 15/16] Bump sentinel version --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9e26b6d2..b1c95cbd 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -sentinel = "1.3.1" +sentinel = "1.3.2" gradle = "8.0.2" desugar = "2.0.3" kotlin = "1.8.21" From eec30b7b7b8ef7ec5b3cc78df19fe7f60721d278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Wed, 6 Mar 2024 11:19:08 +0100 Subject: [PATCH 16/16] Revert "Merge branch 'develop' into fix/trigger-init-not-working-properly-on-first-start" This reverts commit d4741a64da76fdfdbcffd0655045e9b45e6d978e, reversing changes made to c0eee7bd8440022605df32fa9cd5db104d495e93. --- sentinel-no-op/proguard-rules.txt | 36 +++++++++++++++++++++++++- sentinel/proguard-rules.txt | 40 ++++++++++++++++++++++++++++- tool-appgallery/proguard-rules.txt | 6 ++++- tool-chucker/proguard-rules.txt | 6 ++++- tool-collar/proguard-rules.txt | 6 ++++- tool-dbinspector/proguard-rules.txt | 6 ++++- tool-googleplay/proguard-rules.txt | 6 ++++- tool-leakcanary/proguard-rules.txt | 6 ++++- tool-thimble/proguard-rules.txt | 6 ++++- tool-timber/proguard-rules.txt | 6 ++++- 10 files changed, 114 insertions(+), 10 deletions(-) diff --git a/sentinel-no-op/proguard-rules.txt b/sentinel-no-op/proguard-rules.txt index 0674e774..3ce9626f 100644 --- a/sentinel-no-op/proguard-rules.txt +++ b/sentinel-no-op/proguard-rules.txt @@ -1 +1,35 @@ --dontobfuscate \ No newline at end of file +-keeppackagenames +-keep public class com.infinum.sentinel.* { + public protected *; +} +-keep public class com.infinum.sentinel.Sentinel { + public protected *; +} +-keep public class com.infinum.sentinel.ui.tools.ChuckerTool { + public protected *; +} +-keep public class com.infinum.sentinel.ui.tools.CollarTool { + public protected *; +} +-keep public class com.infinum.sentinel.ui.tools.DbInspectorTool { + public protected *; +} +-keep public class com.infinum.sentinel.ui.tools.LeakCanaryTool { + public protected *; +} +-keep public class com.infinum.sentinel.ui.tools.AppGalleryTool { + public protected *; +} +-keep public class com.infinum.sentinel.ui.tools.GooglePlayTool { + public protected *; +} +-keep public class com.infinum.sentinel.ui.tools.ThimbleTool { + public protected *; +} +-keep public class com.infinum.sentinel.ui.tools.TimberTool { + public protected *; +} +-keep public class com.infinum.sentinel.ui.tools.CertificateTool { + public protected *; +} +-keep public class com.infinum.sentinel.databinding.** \ No newline at end of file diff --git a/sentinel/proguard-rules.txt b/sentinel/proguard-rules.txt index 0674e774..7bfc6c44 100644 --- a/sentinel/proguard-rules.txt +++ b/sentinel/proguard-rules.txt @@ -1 +1,39 @@ --dontobfuscate \ No newline at end of file +-keeppackagenames +-keep public class com.infinum.sentinel.* { + public protected *; +} +-keep public class com.infinum.sentinel.Sentinel { + public protected *; +} +-keep public class com.infinum.sentinel.ui.tools.CertificateTool { + public protected *; +} +-keep public class com.infinum.sentinel.databinding.** + +# KotlinX Serialization +-if @kotlinx.serialization.Serializable class ** +-keepclassmembers class <1> { + static <1>$Companion Companion; +} +-if @kotlinx.serialization.Serializable class ** { + static **$* *; +} +-keepclassmembers class <1>$<3> { + kotlinx.serialization.KSerializer serializer(...); +} +-if @kotlinx.serialization.Serializable class ** { + public static ** INSTANCE; +} +-keepclassmembers class <1> { + public static <1> INSTANCE; + kotlinx.serialization.KSerializer serializer(...); +} +-keepattributes RuntimeVisibleAnnotations,AnnotationDefault +-keepattributes InnerClasses # Needed for `getDeclaredClasses`. +-keepnames class <1>$$serializer { # -keepnames suffices; class is kept when serializer() is kept. + static <1>$$serializer INSTANCE; +} + +-keep class * extends androidx.room.RoomDatabase +-keep @androidx.room.Entity class * +-keep @androidx.room.TypeConverters class * \ No newline at end of file diff --git a/tool-appgallery/proguard-rules.txt b/tool-appgallery/proguard-rules.txt index 0674e774..8fedccd3 100644 --- a/tool-appgallery/proguard-rules.txt +++ b/tool-appgallery/proguard-rules.txt @@ -1 +1,5 @@ --dontobfuscate \ No newline at end of file +-keeppackagenames +-keep public class com.infinum.sentinel.ui.tools.AppGalleryTool { + public protected *; +} +-keep public class com.infinum.sentinel.databinding.** diff --git a/tool-chucker/proguard-rules.txt b/tool-chucker/proguard-rules.txt index 0674e774..dff7c096 100644 --- a/tool-chucker/proguard-rules.txt +++ b/tool-chucker/proguard-rules.txt @@ -1 +1,5 @@ --dontobfuscate \ No newline at end of file +-keeppackagenames +-keep public class com.infinum.sentinel.ui.tools.ChuckerTool { + public protected *; +} +-keep public class com.infinum.sentinel.databinding.** diff --git a/tool-collar/proguard-rules.txt b/tool-collar/proguard-rules.txt index 0674e774..eab87141 100644 --- a/tool-collar/proguard-rules.txt +++ b/tool-collar/proguard-rules.txt @@ -1 +1,5 @@ --dontobfuscate \ No newline at end of file +-keeppackagenames +-keep public class com.infinum.sentinel.ui.tools.CollarTool { + public protected *; +} +-keep public class com.infinum.sentinel.databinding.** diff --git a/tool-dbinspector/proguard-rules.txt b/tool-dbinspector/proguard-rules.txt index 0674e774..b914121f 100644 --- a/tool-dbinspector/proguard-rules.txt +++ b/tool-dbinspector/proguard-rules.txt @@ -1 +1,5 @@ --dontobfuscate \ No newline at end of file +-keeppackagenames +-keep public class com.infinum.sentinel.ui.tools.DbInspectorTool { + public protected *; +} +-keep public class com.infinum.sentinel.databinding.** \ No newline at end of file diff --git a/tool-googleplay/proguard-rules.txt b/tool-googleplay/proguard-rules.txt index 0674e774..ba10a085 100644 --- a/tool-googleplay/proguard-rules.txt +++ b/tool-googleplay/proguard-rules.txt @@ -1 +1,5 @@ --dontobfuscate \ No newline at end of file +-keeppackagenames +-keep public class com.infinum.sentinel.ui.tools.GooglePlayTool { + public protected *; +} +-keep public class com.infinum.sentinel.databinding.** diff --git a/tool-leakcanary/proguard-rules.txt b/tool-leakcanary/proguard-rules.txt index 0674e774..d35cf0ff 100644 --- a/tool-leakcanary/proguard-rules.txt +++ b/tool-leakcanary/proguard-rules.txt @@ -1 +1,5 @@ --dontobfuscate \ No newline at end of file +-keeppackagenames +-keep public class com.infinum.sentinel.ui.tools.LeakCanaryTool { + public protected *; +} +-keep public class com.infinum.sentinel.databinding.** diff --git a/tool-thimble/proguard-rules.txt b/tool-thimble/proguard-rules.txt index 0674e774..81486b1d 100644 --- a/tool-thimble/proguard-rules.txt +++ b/tool-thimble/proguard-rules.txt @@ -1 +1,5 @@ --dontobfuscate \ No newline at end of file +-keeppackagenames +-keep public class com.infinum.sentinel.ui.tools.ThimbleTool { + public protected *; +} +-keep public class com.infinum.sentinel.databinding.** diff --git a/tool-timber/proguard-rules.txt b/tool-timber/proguard-rules.txt index 0674e774..d6451db4 100644 --- a/tool-timber/proguard-rules.txt +++ b/tool-timber/proguard-rules.txt @@ -1 +1,5 @@ --dontobfuscate \ No newline at end of file +-keeppackagenames +-keep public class com.infinum.sentinel.ui.tools.TimberTool { + public protected *; +} +-keep public class com.infinum.sentinel.databinding.**