Add a check on incoming intent.

This commit is contained in:
Benoit Marty 2024-02-16 11:49:30 +01:00
parent 355d091c94
commit 53734255ec
2 changed files with 20 additions and 0 deletions

View file

@ -0,0 +1 @@
Add a check on incoming intent.

View file

@ -39,6 +39,9 @@ import im.vector.app.features.analytics.VectorAnalytics
import im.vector.app.features.analytics.plan.ViewRoom
import im.vector.app.features.home.HomeActivity
import im.vector.app.features.home.ShortcutsHandler
import im.vector.app.features.home.room.detail.RoomDetailActivity
import im.vector.app.features.home.room.threads.ThreadsActivity
import im.vector.app.features.location.live.map.LiveLocationMapViewActivity
import im.vector.app.features.notifications.NotificationDrawerManager
import im.vector.app.features.pin.UnlockedActivity
import im.vector.app.features.pin.lockscreen.crypto.LockScreenKeyRepository
@ -115,6 +118,14 @@ class MainActivity : VectorBaseActivity<ActivityMainBinding>(), UnlockedActivity
putExtra(EXTRA_ROOM_ID, roomId)
}
}
val allowList = listOf(
HomeActivity::class.java.name,
MainActivity::class.java.name,
RoomDetailActivity::class.java.name,
ThreadsActivity::class.java.name,
LiveLocationMapViewActivity::class.java.name,
)
}
private val startAppViewModel: StartAppViewModel by viewModel()
@ -186,6 +197,7 @@ class MainActivity : VectorBaseActivity<ActivityMainBinding>(), UnlockedActivity
// Start the next Activity
startSyncing()
val nextIntent = intent.getParcelableExtraCompat<Intent>(EXTRA_NEXT_INTENT)
?.takeIf { it.isValid() }
startIntentAndFinish(nextIntent)
} else if (intent.hasExtra(EXTRA_INIT_SESSION)) {
startSyncing()
@ -380,4 +392,11 @@ class MainActivity : VectorBaseActivity<ActivityMainBinding>(), UnlockedActivity
intent?.let { startActivity(it) }
finish()
}
private fun Intent.isValid(): Boolean {
val componentName = resolveActivity(packageManager) ?: return false
val packageName = componentName.packageName
val className = componentName.className
return packageName == buildMeta.applicationId && className in allowList
}
}