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") return config != null && config.components.contains("matter")
} }
override fun suppressDiscoveryBottomSheet(context: Context) {
if (!appSupportsCommissioning()) return
Matter.getCommissioningClient(context).suppressHalfSheetNotification()
}
override fun startNewCommissioningFlow( override fun startNewCommissioningFlow(
context: Context, context: Context,
onSuccess: (IntentSender) -> Unit, onSuccess: (IntentSender) -> Unit,

View file

@ -16,6 +16,11 @@ interface MatterManager {
*/ */
suspend fun coreSupportsCommissioning(serverId: Int): Boolean 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. * 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 * @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() { override fun onResume() {
super.onResume() super.onResume()
if (currentAutoplay != presenter.isAutoPlayVideoEnabled()) { if (currentAutoplay != presenter.isAutoPlayVideoEnabled()) {

View file

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

View file

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

View file

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