Provide interface for external bus outside WebViewActivity #4338
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 web_view_ 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