Suppress system Matter device discovery bottom sheet (#4062)

- Prevents the system's Matter device discovery bottom sheet from showing up while the Home Assistant app is opened.
This commit is contained in:
Joris Pelgröm 2023-12-20 18:26:04 +01:00 committed by GitHub
parent 7cc545bfac
commit 1162a82c48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 0 deletions

View File

@ -30,6 +30,11 @@ class MatterManagerImpl @Inject constructor(
return config != null && config.components.contains("matter")
}
override fun suppressDiscoveryBottomSheet(context: Context) {
if (!appSupportsCommissioning()) return
Matter.getCommissioningClient(context).suppressHalfSheetNotification()
}
override fun startNewCommissioningFlow(
context: Context,
onSuccess: (IntentSender) -> Unit,

View File

@ -16,6 +16,11 @@ interface MatterManager {
*/
suspend fun coreSupportsCommissioning(serverId: Int): Boolean
/**
* Prevent the bottom sheet for discovered Matter devices from showing up while the app is open.
*/
fun suppressDiscoveryBottomSheet(context: Context)
/**
* Start a flow to commission a Matter device that is on the same network as this device.
* @param onSuccess Callback that receives an intent to launch the commissioning flow

View File

@ -800,6 +800,11 @@ class WebViewActivity : BaseActivity(), io.homeassistant.companion.android.webvi
}
}
override fun onStart() {
super.onStart()
presenter.onStart(this)
}
override fun onResume() {
super.onResume()
if (currentAutoplay != presenter.isAutoPlayVideoEnabled()) {

View File

@ -42,6 +42,8 @@ interface WebViewPresenter {
fun sessionTimeOut(): Int
fun onStart(context: Context)
fun onFinish()
fun isSsidUsed(): Boolean

View File

@ -287,6 +287,10 @@ class WebViewPresenterImpl @Inject constructor(
} ?: 0
}
override fun onStart(context: Context) {
matterUseCase.suppressDiscoveryBottomSheet(context)
}
override fun onFinish() {
mainScope.cancel()
}

View File

@ -14,6 +14,10 @@ class MatterManagerImpl @Inject constructor() : MatterManager {
override suspend fun coreSupportsCommissioning(serverId: Int): Boolean = false
override fun suppressDiscoveryBottomSheet(context: Context) {
// No support, so nothing to suppress
}
override fun startNewCommissioningFlow(
context: Context,
onSuccess: (IntentSender) -> Unit,