@@ -2,7 +2,6 @@ package com.bitwarden.authenticator
2
2
3
3
import android.content.Intent
4
4
import android.os.Bundle
5
- import android.util.Log
6
5
import android.view.WindowManager
7
6
import androidx.activity.compose.setContent
8
7
import androidx.activity.viewModels
@@ -11,6 +10,7 @@ import androidx.compose.runtime.getValue
11
10
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
12
11
import androidx.lifecycle.compose.collectAsStateWithLifecycle
13
12
import androidx.lifecycle.lifecycleScope
13
+ import com.bitwarden.authenticator.data.platform.util.isSuspicious
14
14
import com.bitwarden.authenticator.ui.platform.feature.rootnav.RootNavScreen
15
15
import com.bitwarden.authenticator.ui.platform.theme.AuthenticatorTheme
16
16
import dagger.hilt.android.AndroidEntryPoint
@@ -23,6 +23,7 @@ class MainActivity : AppCompatActivity() {
23
23
private val mainViewModel: MainViewModel by viewModels()
24
24
25
25
override fun onCreate (savedInstanceState : Bundle ? ) {
26
+ sanitizeIntent()
26
27
var shouldShowSplashScreen = true
27
28
installSplashScreen().setKeepOnScreenCondition { shouldShowSplashScreen }
28
29
super .onCreate(savedInstanceState)
@@ -53,18 +54,26 @@ class MainActivity : AppCompatActivity() {
53
54
54
55
override fun onNewIntent (intent : Intent ) {
55
56
super .onNewIntent(intent)
57
+ sanitizeIntent()
56
58
mainViewModel.trySendAction(
57
59
MainAction .ReceiveNewIntent (intent = intent)
58
60
)
59
61
}
60
62
63
+ private fun sanitizeIntent () {
64
+ if (intent.isSuspicious) {
65
+ intent = Intent (
66
+ /* packageContext = */ this ,
67
+ /* cls = */ MainActivity ::class .java,
68
+ )
69
+ }
70
+ }
71
+
61
72
private fun observeViewModelEvents () {
62
- Log .d(" TAG" , " observeViewModelEvents() called" )
63
73
mainViewModel
64
74
.eventFlow
65
75
.onEach { event ->
66
- Log .d(" TAG" , " observeViewModelEvents: onEach $event " )
67
- when (event) {
76
+ when (event) {
68
77
is MainEvent .ScreenCaptureSettingChange -> {
69
78
handleScreenCaptureSettingChange(event)
70
79
}
@@ -74,7 +83,6 @@ class MainActivity : AppCompatActivity() {
74
83
}
75
84
76
85
private fun handleScreenCaptureSettingChange (event : MainEvent .ScreenCaptureSettingChange ) {
77
- Log .d(" TAG" , " handleScreenCaptureSettingChange() called with: event = $event " )
78
86
if (event.isAllowed) {
79
87
window.clearFlags(WindowManager .LayoutParams .FLAG_SECURE )
80
88
} else {
0 commit comments