Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide interface for external bus outside WebViewActivity #4338

Merged
merged 1 commit into from
Apr 20, 2024

Conversation

jpelgrom
Copy link
Member

@jpelgrom jpelgrom commented Apr 8, 2024

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:

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

Screenshots

n/a

Link to pull request in Documentation repository

n/a, no visual changes

Any other notes

 - 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.
Copy link
Member

@dshokouhi dshokouhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, tested APK locally

@dshokouhi dshokouhi merged commit f37e34e into home-assistant:master Apr 20, 2024
4 checks passed
@jpelgrom jpelgrom deleted the webview-externalbus-repo branch April 20, 2024 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants