Adds an interface to the app to interact with the external bus outside the WebViewActivity. This should make it possible for the frontend to control more native UI of the app.
These changes are required for #4303 because of the flow established in home-assistant/frontend#19743 where the frontend controls some parts of the scanner activity.
In my testing this seems to work relatively well and survives simple configuration changes such as rotating the device. There is no direct reference to the webview to prevent leaks. It is possible that I make minor changes to the ExternalBusRepository in the barcode scanner PR, if I find something that hasn't been considered or doesn't work properly after merging this.
Example usage in this commit - note that this is only an example to test, the intended use of the PR is only the barcode scanner messages. You can see the external bus message being posted and a response from the frontend (about the ID not being known) + callback function, with other log lines related to the activity resuming 2s later:
2024-04-08 21:52:32.717 8567-8567 NfcSetupActivity io....stant.companion.android.debug D Wrote nfc tag with url: https://www.home-assistant.io/tag/e3b00f1c-40a1-4112-8b15-1c3bcef66112
2024-04-08 21:52:32.752 8567-8567 WebviewActivity io....stant.companion.android.debug D externalBus({"id":4,"type":"result","success":true,"result":{}});
2024-04-08 21:52:32.758 8567-8567 chromium io....stant.companion.android.debug I [INFO:CONSOLE(1)] "Received unknown msg ID 4", source: http://192.168.2.101:8123/frontend_latest/19311.JkgbKuCO63k.js (1)
2024-04-08 21:52:32.758 8567-8567 NfcSetupActivity io....stant.companion.android.debug D NFC Write Complete null
2024-04-08 21:52:34.798 8567-8567 WebviewActivity io....stant.companion.android.debug D Matter/Thread step changed to NOT_STARTED
2024-04-08 21:52:34.805 8567-8567 ServerConnectionInfo io....stant.companion.android.debug D localUrl is: true, usesInternalSsid is: true, usesWifi is: true
Summary
Adds an interface to the app to interact with the external bus outside the WebViewActivity. This should make it possible for the frontend to control more native UI of the app.
These changes are required for #4303 because of the flow established in home-assistant/frontend#19743 where the frontend controls some parts of the scanner activity.
In my testing this seems to work relatively well and survives simple configuration changes such as rotating the device. There is no direct reference to the webview to prevent leaks. It is possible that I make minor changes to the
ExternalBusRepository
in the barcode scanner PR, if I find something that hasn't been considered or doesn't work properly after merging this.Example usage in this commit - note that this is only an example to test, the intended use of the PR is only the barcode scanner messages. You can see the external bus message being posted and a response from the frontend (about the ID not being known) + callback function, with other log lines related to the activity resuming 2s later:
Screenshots
n/a
Link to pull request in Documentation repository
n/a, no visual changes
Any other notes